git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/VREModeler@30284 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
04141a7e68
commit
1fb4562a45
|
@ -2,7 +2,7 @@
|
|||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/VREMODELERLIBS"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/GCORELIB"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/VreModelerDependecies"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -126,6 +126,9 @@
|
|||
|
||||
<xsd:element name="deployVREResponseMessage" type="coretypes:VOID"/>
|
||||
|
||||
<xsd:element name="undeployVRERequestMessage" type="coretypes:VOID"/>
|
||||
|
||||
<xsd:element name="undeployVREResponseMessage" type="coretypes:VOID"/>
|
||||
|
||||
<xsd:complexType name="CheckStatusResponse">
|
||||
<xsd:sequence>
|
||||
|
@ -137,6 +140,14 @@
|
|||
|
||||
<xsd:element name="checkStatusResponseMessage" type="tns:CheckStatusResponse"/>
|
||||
|
||||
<xsd:element name="setUseCloudResponseMessage" type="coretypes:VOID"/>
|
||||
|
||||
<xsd:element name="setUseCloudRequestMessage" type="xsd:boolean"/>
|
||||
|
||||
<xsd:element name="isUseCloudResponseMessage" type="xsd:boolean"/>
|
||||
|
||||
<xsd:element name="isUseCloudRequestMessage" type="coretypes:VOID"/>
|
||||
|
||||
<!--RESOURCE PROPERTIES -->
|
||||
|
||||
<xsd:element name="Id" type="xsd:string"/>
|
||||
|
@ -221,6 +232,19 @@
|
|||
<part name="response" element="tns:setQualityResponseMessage"/>
|
||||
</message>
|
||||
|
||||
<message name="SetUseCloudInputMessage">
|
||||
<part name="request" element="tns:setUseCloudRequestMessage"/>
|
||||
</message>
|
||||
<message name="SetUseCloudOutputMessage">
|
||||
<part name="response" element="tns:setUseCloudResponseMessage"/>
|
||||
</message>
|
||||
|
||||
<message name="IsUseCloudInputMessage">
|
||||
<part name="request" element="tns:isUseCloudRequestMessage"/>
|
||||
</message>
|
||||
<message name="IsUseCloudOutputMessage">
|
||||
<part name="response" element="tns:isUseCloudResponseMessage"/>
|
||||
</message>
|
||||
|
||||
<message name="GetFunctionalityInputMessage">
|
||||
<part name="request" element="tns:getFunctionalityRequestMessage"/>
|
||||
|
@ -264,6 +288,13 @@
|
|||
<part name="response" element="tns:deployVREResponseMessage"/>
|
||||
</message>
|
||||
|
||||
<message name="UndeployVREInputMessage">
|
||||
<part name="request" element="tns:undeployVRERequestMessage"/>
|
||||
</message>
|
||||
<message name="UndeployVREOutputMessage">
|
||||
<part name="response" element="tns:undeployVREResponseMessage"/>
|
||||
</message>
|
||||
|
||||
<message name="CheckStatusInputMessage">
|
||||
<part name="request" element="tns:checkStatusRequestMessage"/>
|
||||
</message>
|
||||
|
@ -312,9 +343,17 @@
|
|||
<input message="tns:SetMDCollectionInputMessage"/>
|
||||
<output message="tns:SetMDCollectionOutputMessage"/>
|
||||
</operation>
|
||||
|
||||
<operation name="setUseCloud">
|
||||
<input message="tns:SetUseCloudInputMessage"/>
|
||||
<output message="tns:SetUseCloudOutputMessage"/>
|
||||
</operation>
|
||||
|
||||
|
||||
|
||||
<operation name="isUseCloud">
|
||||
<input message="tns:IsUseCloudInputMessage"/>
|
||||
<output message="tns:IsUseCloudOutputMessage"/>
|
||||
</operation>
|
||||
|
||||
<operation name="getQuality">
|
||||
<input message="tns:GetQualityInputMessage"/>
|
||||
<output message="tns:GetQualityOutputMessage"/>
|
||||
|
@ -355,6 +394,11 @@
|
|||
<output message="tns:DeployVREOutputMessage"/>
|
||||
</operation>
|
||||
|
||||
<operation name="undeployVRE">
|
||||
<input message="tns:UndeployVREInputMessage"/>
|
||||
<output message="tns:UndeployVREOutputMessage"/>
|
||||
</operation>
|
||||
|
||||
<operation name="checkStatus">
|
||||
<input message="tns:CheckStatusInputMessage"/>
|
||||
<output message="tns:checkStatusOutputMessage"/>
|
||||
|
|
|
@ -26,14 +26,14 @@ public class CollectionConsumer extends BaseNotificationConsumer{
|
|||
|
||||
public void onNotificationReceived(NotificationEvent event){
|
||||
try{
|
||||
logger.trace("notificetion received");
|
||||
logger.trace("notification received");
|
||||
ServiceContext.getContext().setScope(this.scope);
|
||||
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
|
||||
String profile=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
|
||||
String operation=event.getPayload().getMessage()[0].getChildNodes().item(2).getChildNodes().item(0).getNodeValue();
|
||||
|
||||
|
||||
if (operation.compareTo("create")==0){
|
||||
logger.trace("adding a new GHN in DB");
|
||||
logger.trace("adding a new Collection in DB");
|
||||
GCUBECollection collection= GHNContext.getImplementation(GCUBECollection.class);
|
||||
collection.load(new StringReader(profile));
|
||||
new CollectionHandler().add(collection);
|
||||
|
|
|
@ -14,6 +14,7 @@ public class ModelerPersistenceDelegate extends GCUBEWSFilePersistenceDelegate<M
|
|||
resource.setId((String)ois.readObject());
|
||||
resource.setFirstReport((String)ois.readObject());
|
||||
resource.setSecondReport((String)ois.readObject());
|
||||
resource.setUseCloud(ois.readBoolean());
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,5 +23,6 @@ public class ModelerPersistenceDelegate extends GCUBEWSFilePersistenceDelegate<M
|
|||
oos.writeObject(resource.getId());
|
||||
oos.writeObject(resource.getFirstReport());
|
||||
oos.writeObject(resource.getSecondReport());
|
||||
oos.writeBoolean(resource.isUseCloud());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,16 +11,37 @@ public class ModelerResource extends GCUBEWSResource {
|
|||
|
||||
protected static String[] RPNames = { RP_ID, RP_FIRSTREPORT, RP_SECONDREPORT};
|
||||
|
||||
private boolean isUseCloud;
|
||||
|
||||
@Override
|
||||
protected void initialise(Object... args) throws ResourceException {
|
||||
if (args.length!=1) throw new ResourceException();
|
||||
this.setId((String) args[0]);
|
||||
this.setFirstReport("");
|
||||
this.setSecondReport("");
|
||||
this.isUseCloud=false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isUseCloud() {
|
||||
return isUseCloud;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param isUseClound
|
||||
*/
|
||||
public void setUseCloud(boolean isUseCloud) {
|
||||
this.isUseCloud = isUseCloud;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -84,7 +105,4 @@ public class ModelerResource extends GCUBEWSResource {
|
|||
this.getResourcePropertySet().get(RP_FIRSTREPORT).clear();
|
||||
this.getResourcePropertySet().get(RP_FIRSTREPORT).add(reportFirstStep);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.gcube.common.core.faults.GCUBEUnrecoverableFault;
|
|||
import org.gcube.common.core.types.VOID;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
||||
import org.gcube.vremanagement.vremodeler.impl.thread.DeployVRE;
|
||||
import org.gcube.vremanagement.vremodeler.impl.thread.DeployVREonGHNs;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.ModelerCollection;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.Util;
|
||||
import org.gcube.vremanagement.vremodeler.resources.MetadataFormat;
|
||||
|
@ -52,7 +52,6 @@ public class ModelerService {
|
|||
*
|
||||
*/
|
||||
public void setDescription(VREDescription request) throws GCUBEFault{
|
||||
|
||||
Date dateFrom=null, dateTo=null;
|
||||
ResultSet res=null;
|
||||
try {
|
||||
|
@ -96,11 +95,16 @@ public class ModelerService {
|
|||
* return an XML containing the GHN list
|
||||
*
|
||||
* @param request void
|
||||
* @return a XML String
|
||||
* @throws RemoteException -
|
||||
* @return List of GHNs on the system
|
||||
* @throws @throws GCUBEFault - if the clud is selected as Architecture or something fails on db
|
||||
*/
|
||||
public GHNList getGHNs(VOID var) throws GCUBEFault{
|
||||
logger.trace("getGHNs method");
|
||||
try {
|
||||
if (getResource().isUseCloud()) throw new GCUBEFault("deply on cloud is selected, the ghns cannot be returned");
|
||||
} catch (ResourceException e1) {
|
||||
throw new GCUBEFault(e1);
|
||||
}
|
||||
ResultSet res;
|
||||
ArrayList<String> relatedGHN=new ArrayList<String>();
|
||||
try{
|
||||
|
@ -123,13 +127,18 @@ public class ModelerService {
|
|||
|
||||
|
||||
/**
|
||||
* Set the selected DHN
|
||||
* Set the GHNs for deploying
|
||||
*
|
||||
* @param request array of GHN id
|
||||
* @param request array of GHNs ids
|
||||
* @return VoidType -
|
||||
* @throws RemoteException -
|
||||
* @throws GCUBEFault - if the clud is selected as Architecture or something fails on db
|
||||
*/
|
||||
public void setGHNs(GHNArray request) throws GCUBEFault{
|
||||
try {
|
||||
if (getResource().isUseCloud()) throw new GCUBEFault("deploy on cloud is selected, the ghns cannot be set");
|
||||
} catch (ResourceException e1) {
|
||||
throw new GCUBEFault(e1);
|
||||
}
|
||||
try{
|
||||
String instanceID=(String) getResource().getId();
|
||||
DBInterface.ExecuteUpdate("DELETE FROM VRERELATEDGHN WHERE VRERELATEDGHN.vreid='"+instanceID+"';");
|
||||
|
@ -161,7 +170,7 @@ public class ModelerService {
|
|||
*
|
||||
* @param request void
|
||||
* @return the collection retrieved from the database
|
||||
* @throws RemoteException -
|
||||
* @throws GCUBEFault -
|
||||
*/
|
||||
public CollectionList getCollection(VOID var) throws GCUBEFault{
|
||||
ResultSet res;
|
||||
|
@ -190,7 +199,7 @@ public class ModelerService {
|
|||
*
|
||||
* @param request An Array that contains the selected collections ids
|
||||
* @return void
|
||||
* @throws RemoteException -
|
||||
* @throws GCUBEFault -
|
||||
*/
|
||||
public void setCollection(CollectionArray request) throws GCUBEFault{
|
||||
try{
|
||||
|
@ -225,8 +234,8 @@ public class ModelerService {
|
|||
* Return the possibles metadata format for selected collection
|
||||
*
|
||||
* @param request void
|
||||
* @return a XML format string
|
||||
* @throws RemoteException -
|
||||
* @return a list of MetadataFormat
|
||||
* @throws GCUBEFault -
|
||||
*/
|
||||
public MetadataFormatResponse getMetadataRelatedToCollection(VOID var) throws GCUBEFault {
|
||||
|
||||
|
@ -285,7 +294,7 @@ public class ModelerService {
|
|||
*
|
||||
* @param request
|
||||
* @return void
|
||||
* @throws RemoteException -
|
||||
* @throws GCUBEFault -
|
||||
*/
|
||||
public void setMetadataRelatedToCollection(SetMDFormatArgs request) throws GCUBEFault {
|
||||
try{
|
||||
|
@ -323,7 +332,7 @@ public class ModelerService {
|
|||
*
|
||||
* @param request void
|
||||
* @return an xml String containing selectable functionalities
|
||||
* @throws RemoteException -
|
||||
* @throws GCUBEFault -
|
||||
*/
|
||||
public FunctionalityList getFunctionality(VOID var) throws GCUBEFault {
|
||||
|
||||
|
@ -356,7 +365,7 @@ public class ModelerService {
|
|||
*
|
||||
*
|
||||
* @return void
|
||||
* @throws RemoteException -
|
||||
* @throws GCUBEFault -
|
||||
*/
|
||||
public void setFunctionality(FunctionalityIDArray request) throws GCUBEFault {
|
||||
logger.trace("Set Functionality called");
|
||||
|
@ -409,7 +418,7 @@ public class ModelerService {
|
|||
*
|
||||
* @param request void
|
||||
* @return a XML format String
|
||||
* @throws RemoteException -
|
||||
* @throws GCUBEFault -
|
||||
*/
|
||||
public String getQuality(VOID var) throws GCUBEFault{
|
||||
return Util.prepareQualityXML();
|
||||
|
@ -420,10 +429,10 @@ public class ModelerService {
|
|||
* Sets Quality parameters
|
||||
*
|
||||
* @param request
|
||||
* @throws RemoteException -
|
||||
* @throws GCUBEFault -
|
||||
*/
|
||||
public void setQuality(String request) throws GCUBEFault{
|
||||
|
||||
//TODO
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -432,7 +441,7 @@ public class ModelerService {
|
|||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @throws RemoteException -
|
||||
* @throws GCUBEFault -
|
||||
*/
|
||||
public void setVREtoPendingState(VOID var) throws GCUBEFault{
|
||||
try{
|
||||
|
@ -445,12 +454,14 @@ public class ModelerService {
|
|||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @throws RemoteException -
|
||||
* @throws GCUBEFault -
|
||||
*/
|
||||
public void deployVRE(VOID var) throws GCUBEFault{
|
||||
String resourceID;
|
||||
ModelerResource resource;
|
||||
try {
|
||||
resourceID = getResource().getId();
|
||||
resource= getResource();
|
||||
resourceID = resource.getId();
|
||||
} catch (ResourceException e) {
|
||||
logger.error("Error retrieving the Resource Requested",e); throw new GCUBEUnrecoverableFault(e);
|
||||
}
|
||||
|
@ -462,20 +473,48 @@ public class ModelerService {
|
|||
throw new GCUBEUnrecoverableFault(e);
|
||||
}
|
||||
|
||||
|
||||
DeployVRE deployVREThread= new DeployVRE(resourceID, ServiceContext.getContext().getScope() );
|
||||
ServiceContext.getContext().setScope(deployVREThread, ServiceContext.getContext().getScope());
|
||||
logger.trace("Deploy VRE thread started");
|
||||
deployVREThread.start();
|
||||
|
||||
if (!resource.isUseCloud()){
|
||||
DeployVREonGHNs deployVREThread= new DeployVREonGHNs(resourceID, ServiceContext.getContext().getScope() );
|
||||
ServiceContext.getContext().setScope(deployVREThread, ServiceContext.getContext().getScope());
|
||||
logger.trace("Deploy VRE thread started");
|
||||
deployVREThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param var
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public CheckStatusResponse checkStatus(VOID var) throws Exception{
|
||||
CheckStatusResponse res= new CheckStatusResponse();
|
||||
res.setReports(new String[]{getResource().getFirstReport(), getResource().getSecondReport()});
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @throws RemoteException -
|
||||
*/
|
||||
public void undeployVRE(VOID var) throws GCUBEFault{
|
||||
//TODO: implement this method
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param val boolean
|
||||
*/
|
||||
public void setUseCloud(boolean val) throws Exception{
|
||||
getResource().setUseCloud(val);
|
||||
getResource().store();
|
||||
}
|
||||
|
||||
public boolean isUseCloud() throws Exception{
|
||||
return getResource().isUseCloud();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ import org.w3c.dom.Document;
|
|||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class DeployVRE extends Thread{
|
||||
public class DeployVREonGHNs extends Thread{
|
||||
|
||||
private static GCUBELog logger= new GCUBELog(ModelerService.class);
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class DeployVRE extends Thread{
|
|||
private String vreName=null;
|
||||
private CollectionResourceCreation collectionResourceCreation;
|
||||
|
||||
public DeployVRE(String resourceId, GCUBEScope scope){
|
||||
public DeployVREonGHNs(String resourceId, GCUBEScope scope){
|
||||
this.resourceId=resourceId;
|
||||
this.startingScope= scope;
|
||||
}
|
|
@ -89,8 +89,8 @@ public class Util {
|
|||
try{
|
||||
ResultSet riRes;
|
||||
while (res.next()){
|
||||
//controlling all the RIs on the GHN
|
||||
riRes= DBInterface.queryDB("select RI.id, RI.name, RI.class from RUNNINGINSTANCE as RI, GHNRELATEDRI as REL where REL.GHNID='"+res.getString("ID")+"' and REL.RIID=RI.ID");
|
||||
|
||||
int risNum=0;
|
||||
List<RunningInstance> riList= new ArrayList<RunningInstance>();
|
||||
while (riRes.next()){
|
||||
|
@ -98,9 +98,11 @@ public class Util {
|
|||
risNum++;
|
||||
riList.add(new RunningInstance(riRes.getString(3),riRes.getString(2)));
|
||||
}
|
||||
|
||||
GHNType ghn= new GHNType();
|
||||
ghn.setId(res.getString(1));
|
||||
ghn.setSelectable(!(risNum>0));
|
||||
ghn.setSelected(relatedGHNs.contains(res.getString(1)));
|
||||
ghn.setVreManagerUse(candidateGHN.compareTo(res.getString("ID"))==0);
|
||||
ghn.setHost(res.getString(2));
|
||||
ghn.setSecurity(res.getString(3));
|
||||
|
|
|
@ -32,15 +32,16 @@ public class CollectionHandler implements ResourceHandler<GCUBECollection> {
|
|||
ISClient client= GHNContext.getImplementation(ISClient.class);
|
||||
GCUBECollectionQuery query=client.getQuery(GCUBECollectionQuery.class);
|
||||
query.addAtomicConditions(new AtomicCondition("/Profile/IsUserCollection/@value","true"));
|
||||
List<GCUBECollection> collectionList= client.execute(client.getQuery(GCUBECollectionQuery.class), ServiceContext.getContext().getScope());
|
||||
List<GCUBECollection> collectionList= client.execute(query, ServiceContext.getContext().getScope());
|
||||
for (GCUBECollection collection:collectionList)
|
||||
try{
|
||||
insert(collection);
|
||||
}catch(Exception e){logger.error("error insertin values in "+tableName, e);}
|
||||
}catch(Exception e){logger.error("error inserting values in "+tableName, e);}
|
||||
}
|
||||
|
||||
|
||||
private void insert(GCUBECollection collection) throws Exception {
|
||||
if (!collection.isUserCollection()) return;
|
||||
ArrayList<String> row= new ArrayList<String>(6);
|
||||
row.add(collection.getID());
|
||||
row.add(collection.getName());
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.gcube.common.core.resources.GCUBEHostingNode;
|
|||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
||||
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
|
||||
import org.gcube.vremanagement.vremodeler.resources.GhnRiRelationObject;
|
||||
|
||||
public class GHNHandler implements ResourceHandler<GCUBEHostingNode> {
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@ public class RunningInstancesHandler implements ResourceHandler<GCUBERunningInst
|
|||
|
||||
|
||||
public void initialize() throws Exception{
|
||||
//DBInterface.connect();
|
||||
//DBInterface.ExecuteUpdate(creationQuery);
|
||||
ISClient client= GHNContext.getImplementation(ISClient.class);
|
||||
GCUBERIQuery queryRI= client.getQuery(GCUBERIQuery.class);
|
||||
queryRI.addGenericCondition("$result/Profile/GHN[string(@UniqueID) eq '"+this.relatedGhn+"']");
|
||||
|
|
Loading…
Reference in New Issue