This commit is contained in:
Lucio Lelii 2010-11-15 19:06:13 +00:00
parent 40dcb73d4d
commit 2f32d663f3
10 changed files with 156 additions and 85 deletions

View File

@ -1,16 +1,19 @@
package org.gcube.vremanagement.vremodeler.consumers;
import java.io.StringReader;
import java.sql.ResultSet;
import javax.xml.namespace.QName;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.contexts.GHNContext.Status;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.BaseNotificationConsumer;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.GCUBENotificationTopic;
import org.gcube.common.core.informationsystem.notifier.ISNotifier.NotificationEvent;
import org.gcube.common.core.resources.GCUBEHostingNode;
import org.gcube.common.core.scope.GCUBEScope;
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.handlers.GHNHandler;
@ -21,7 +24,7 @@ public class GHNConsumer extends BaseNotificationConsumer{
static{
ghnTopic= new GCUBENotificationTopic(new QName("http://gcube-system.org/namespaces/informationsystem/registry","GHN"));
ghnTopic.setPrecondition("(//operationType[text()='destroy']) or (//operationType[text()='create'])");
ghnTopic.setPrecondition("(//operationType[text()='destroy']) or (//operationType[text()='update'])");
ghnTopic.setUseRenotifier(false);
}
@ -38,18 +41,26 @@ public class GHNConsumer extends BaseNotificationConsumer{
public void onNotificationReceived(NotificationEvent event){
try{
logger.trace("notification received");
//logger.trace("notification received");
ServiceContext.getContext().setScope(this.scope);
String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
String operation=event.getPayload().getMessage()[0].getChildNodes().item(2).getChildNodes().item(0).getNodeValue();
//logger.trace("received id: "+id+" op: "+operation+" profile: "+profile);
if (operation.compareTo("create")==0){
logger.trace("adding a new GHN in DB");
if (operation.compareTo("update")==0){
//logger.trace("adding a new GHN in DB");
GCUBEHostingNode ghn= GHNContext.getImplementation(GCUBEHostingNode.class);
String profile=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
ghn.load(new StringReader(profile));
new GHNHandler().add(ghn);
//if (ghn.getNodeDescription().getStatus()!=Status.CERTIFIED) return;
ResultSet queryRes= DBInterface.queryDB("select host from ghn where id='"+ghn.getID()+"'");
if (queryRes.next()){
if (ghn.getNodeDescription().getStatus()!=Status.CERTIFIED)
new GHNHandler().drop(ghn.getID());
} else {
if (ghn.getNodeDescription().getStatus()==Status.CERTIFIED)
new GHNHandler().add(ghn);
}
} else if (operation.compareTo("destroy")==0){
logger.trace("removing a GHN from DB");
new GHNHandler().drop(id);

View File

@ -19,6 +19,7 @@ public class RunningInstanceConsumer extends BaseNotificationConsumer{
public static final GCUBENotificationTopic riTopic= new GCUBENotificationTopic(new QName("http://gcube-system.org/namespaces/informationsystem/registry","RunningInstance"));
static{
riTopic.setPrecondition("//operationType[text()='create']");
riTopic.setUseRenotifier(false);
}

View File

@ -11,6 +11,7 @@ import org.gcube.common.core.faults.GCUBEFault;
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.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.deploy.DeployVRE;
import org.gcube.vremanagement.vremodeler.impl.util.ModelerCollection;
@ -493,7 +494,7 @@ public class ModelerService {
* @throws RemoteException -
*/
public void undeployVRE(VOID var) throws GCUBEFault{
//TODO: implement this method
//TODO
}

View File

@ -72,6 +72,7 @@ public class DeployGHNsOnCloud{
for (int i=1; i<hostnames.length; i++)
ghns.add(hostnames[i].getGhnId());
ghnToUse.setGhns(ghns);
report.setState(State.Finished);
return ghnToUse;
}

View File

@ -13,20 +13,12 @@ import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.faults.GCUBEFault;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
import org.gcube.common.core.resources.GCUBECollection;
import org.gcube.common.core.resources.GCUBEGenericResource;
import org.gcube.common.core.resources.GCUBEMCollection;
import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.scope.GCUBEScope.MalformedScopeExpressionException;
import org.gcube.common.core.utils.handlers.GCUBEServiceClientImpl;
import org.gcube.common.core.utils.handlers.GCUBEServiceHandler.NoQueryResultException;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.common.resources.kxml.KGCUBEResource;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.AddResourcesParameters;
@ -38,14 +30,12 @@ import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceMan
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ScopeOption;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceList;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.ModelerContext;
import org.gcube.vremanagement.vremodeler.impl.ModelerResource;
import org.gcube.vremanagement.vremodeler.impl.ModelerService;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
import org.gcube.vremanagement.vremodeler.impl.util.ReportFiller;
import org.gcube.vremanagement.vremodeler.impl.util.ResourceManagerServiceHandler;
import org.gcube.vremanagement.vremodeler.impl.util.Util;
import org.gcube.vremanagement.vremodeler.portallayout.CollectionResourceCreation;
import org.gcube.vremanagement.vremodeler.portallayout.GenericResourcePortlet;
import org.gcube.vremanagement.vremodeler.stubs.deployreport.DeployReport;
@ -121,22 +111,23 @@ public class DeployVRE extends Thread{
if (deployManagerOnVRE(ghnsToUse.candidateForRM)){
getResource().getDeployReport().getResourceManagerDeployingReport().setState(org.gcube.vremanagement.vremodeler.stubs.deployreport.State.Finished);
if (createVRE(ghnsToUse.getGhns())){
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+org.gcube.vremanagement.vremodeler.stubs.deployreport.State.Finished+"' WHERE VRE.id='"+this.resourceId+"';");
getResource().getDeployReport().getFunctionalityDeployingReport().setState(org.gcube.vremanagement.vremodeler.stubs.deployreport.State.Finished);
getResource().getDeployReport().getResourceDeployingReport().setState(org.gcube.vremanagement.vremodeler.stubs.deployreport.State.Finished);
getResource().getDeployReport().setState(org.gcube.vremanagement.vremodeler.stubs.deployreport.State.Finished);
getResource().store();
logger.info("Deploying of the VRE with id "+this.resourceId+" FINISHED");
}
else{
logger.info("Deploying of the VRE with id "+this.resourceId+" FAILED on second step");
getResource().getDeployReport().getResourceDeployingReport().setState(org.gcube.vremanagement.vremodeler.stubs.deployreport.State.Failed);
getResource().getDeployReport().setState(org.gcube.vremanagement.vremodeler.stubs.deployreport.State.Failed);
getResource().store();
throw new Exception("Error Deployng the VRE failed on second step");
}
}else{
getResource().getDeployReport().setState(org.gcube.vremanagement.vremodeler.stubs.deployreport.State.Failed);
getResource().getDeployReport().getResourceManagerDeployingReport().setState(org.gcube.vremanagement.vremodeler.stubs.deployreport.State.Failed);
getResource().store();
logger.info("Deploying of the VRE with id "+this.resourceId+" FAILED on first step");
throw new Exception("Error Deployng the VRE filed on first step");
}
@ -165,7 +156,7 @@ public class DeployVRE extends Thread{
getResource().getDeployReport().getResourceManagerDeployingReport().setState(org.gcube.vremanagement.vremodeler.stubs.deployreport.State.Running);
getResource().store();
ResourceManagerPortType rmPortType=getResourceMangerPT(this.startingScope);
ResourceManagerPortType rmPortType=Util.getResourceMangerPT(this.startingScope);
String report;
@ -185,7 +176,7 @@ public class DeployVRE extends Thread{
String reportId=rmPortType.addResources(arp);
logger.trace("the report id for Rm is "+reportId);
//waiting few seconds
Thread.sleep(60000);
Thread.sleep(30000);
int attempt=0;
do{
Thread.sleep(20000);
@ -193,15 +184,13 @@ public class DeployVRE extends Thread{
attempt++;
getResource().getDeployReport().getResourceManagerDeployingReport().setResourceManagerReport(report);
getResource().store();
}while (!isDeploymentStatusFinished(report) && attempt<10);
}while (!isDeploymentStatusFinished(report) && attempt<20);
}catch(Exception e){logger.error("error deploying RM on VRE",e); throw e;}
logger.trace("report step 1: "+report);
logger.info("is something failed in the first step?"+isSomethingFailed(report));
collectionResourceCreation= new CollectionResourceCreation(this.resourceId, this.vreName);
getResource().getDeployReport().getResourceManagerDeployingReport().setState(org.gcube.vremanagement.vremodeler.stubs.deployreport.State.Finished);
getResource().store();
return !isSomethingFailed(report);
}
@ -214,7 +203,7 @@ public class DeployVRE extends Thread{
ReportFiller.initizlizeFunctionalityForReport(getResource().getDeployReport().getFunctionalityDeployingReport(),this.resourceId);
ReportFiller.initializeResourcesForReport(getResource().getDeployReport().getResourceDeployingReport(), this.resourceId);
ResourceManagerPortType rmPortType=getResourceMangerPT(GCUBEScope.getScope(this.startingScope+"/"+this.vreName));
ResourceManagerPortType rmPortType=Util.getResourceMangerPT(GCUBEScope.getScope(this.startingScope+"/"+this.vreName));
CreateScopeParameters scopeParameter=getScopeParameters();
@ -305,6 +294,8 @@ public class DeployVRE extends Thread{
String deploymentXpath = "/ResourceReport/DeploymentPlanCreation/Status";
String dependenciesResolutionXpath ="/ResourceReport/Services/Service/DependenciesResolutionStatus";
String serviceXpath="/ResourceReport/Services/Service/DeploymentActivity/GHN/LastReportReceived/Packages/Package/Status";
String resourceXpath="/ResourceReport/Resources/Resource[/Type/text()!='GHN']/Status";
String relatedRIXpath="/ResourceReport/Services/Service/DeploymentActivity/RelatedRunningInstance/Status";
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
@ -332,6 +323,21 @@ public class DeployVRE extends Thread{
return true;
}
}
NodeList resResoulution = (NodeList) engine.evaluate(resourceXpath,document, XPathConstants.NODESET);
for (int i = 0; i < resResoulution.getLength(); i++) {
if(resResoulution.item(i).getFirstChild().getNodeValue().compareTo("FAILED")==0){
return true;
}
}
NodeList relResoulution = (NodeList) engine.evaluate(relatedRIXpath,document, XPathConstants.NODESET);
for (int i = 0; i < relResoulution.getLength(); i++) {
if(relResoulution.item(i).getFirstChild().getNodeValue().compareTo("FAILED")==0){
return true;
}
}
} catch (ParserConfigurationException e) {
return true;
} catch (SAXException e) {
@ -346,7 +352,7 @@ public class DeployVRE extends Thread{
private static boolean isDeploymentStatusFinished(String report) {
boolean ret = false;
String xpath = "/ResourceReport/Services/Service/DeploymentActivity/GHN/LastReportReceived/Status";
String xpath = "/ResourceReport/Status";
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
try {
@ -374,46 +380,7 @@ public class DeployVRE extends Thread{
}
return ret;
}
private ResourceManagerPortType getResourceMangerPT(GCUBEScope scope) throws Exception{
ResourceManagerPortType rmPortType = null;
int attempt=0;
do{
try{
try{
Thread.sleep(30000);
}catch (Exception et){}
ISClient client = GHNContext.getImplementation(ISClient.class);
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
query.setExpression("declare namespace is = 'http://gcube-system.org/namespaces/informationsystem/registry';" +
" for $outer in collection(\"/db/Profiles/RunningInstance\")//Document/Data/is:Profile/Resource " +
" let $scope:= $outer/Scopes/Scope[string() eq '"+scope.toString()+"'] " +
" where count($scope)>0 " +
" and $outer/Profile/ServiceName/string() eq 'ResourceManager' " +
" and $outer/Profile/DeploymentData/Status/string() eq 'ready'"+
" return $outer");
List<EndpointReferenceType> eprs = new ArrayList<EndpointReferenceType>();
for (GCUBERunningInstance instance : client.execute(query, scope))
eprs.add(instance.getAccessPoint().getEndpoint("gcube/vremanagement/ResourceManager"));
if(eprs.size()==0) throw new NoQueryResultException();
ResourceManagerServiceAddressingLocator vmsal= new ResourceManagerServiceAddressingLocator();
logger.trace("trying to contact instance at "+eprs.get(0).getAddress());
rmPortType= vmsal.getResourceManagerPortTypePort(eprs.get(0));
rmPortType = GCUBERemotePortTypeContext.getProxy(rmPortType,scope, Integer.parseInt((String)ServiceContext.getContext().getProperty("resourceManagerTimeout", true)));
}catch(Exception e){
logger.warn(e);
logger.warn("the query for resourceManager returned no result, re-trying in 30 secs ("+attempt+")");
}finally {attempt++;}
}while(rmPortType==null && attempt<10);
if (attempt>=10) throw new Exception("no ResourceMaanger can be retrieved for scope "+scope);
return rmPortType;
}
private CreateScopeParameters getScopeParameters() throws Exception{
ResultSet resGenericInfo = DBInterface.queryDB("select VRE.name, VRE.vredesigner, VRE.vremanager, VRE.IntervalTo, VRE.IntervalFrom, VRE.description from VRE where VRE.id='"+this.resourceId+"'; ");
if (!resGenericInfo.next()) throw new GCUBEFault("The VRE with ID "+this.resourceId+" cannot be retrieved");

View File

@ -4,6 +4,8 @@ import java.io.ByteArrayInputStream;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
@ -50,12 +52,12 @@ public class ReportFiller {
servReport.setState(org.gcube.vremanagement.vremodeler.stubs.deployreport.State.Running);
List<ServiceReport> listService;
if ((listService=report.getFunctionalityTable().get(funcReport))==null){
if (!report.getFunctionalityTable().contains(funcReport)){
listService= new ArrayList<ServiceReport>();
listService.add(servReport);
report.getFunctionalityTable().put(funcReport, listService);
}else
listService.add(servReport);
report.getFunctionalityTable().get(funcReport).add(servReport);
}
}
@ -85,6 +87,7 @@ public class ReportFiller {
* @param report
*/
public static void reportElaboration(DeployReport report){
logger.trace("Elaborationg report");
String rmReport = report.getFunctionalityDeployingReport().getResourceManagerReport();
if (rmReport==null) return;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
@ -94,13 +97,17 @@ public class ReportFiller {
Document document = db.parse(new ByteArrayInputStream(rmReport.getBytes()));
XPath xpath= XPathFactory.newInstance().newXPath();
//first step: services retrieving
for (List<ServiceReport> serviceReportsList:report.getFunctionalityDeployingReport().getFunctionalityTable().values()){
for (ServiceReport serviceReport: serviceReportsList){
for (Entry<FunctionalityReport,List<ServiceReport>> entry: report.getFunctionalityDeployingReport().getFunctionalityTable().entrySet()){
State generalFunctState=State.Finished;
for (ServiceReport serviceReport: entry.getValue()){
if (serviceReport.getState()==State.Finished || serviceReport.getState()==State.Failed) continue;
NodeList nResoulution = (NodeList)xpath.evaluate("/ResourceReport/Services/Service/DeploymentActivity/GHN/LastReportReceived/Packages/Package[/ServiceClass/text()='"+serviceReport.getServiceClass()+"' and /ServiceName/text()='"+serviceReport.getServiceName()+"' and /ServiceVersion/text()='"+serviceReport.getServiceVersion()+"']/Status",document,XPathConstants.NODESET);
boolean isServiceDeployed=true;
boolean isServiceFailed=false;
for (int i = 0; i < nResoulution.getLength(); i++) {
logger.trace("retrieved package for service "+serviceReport.getServiceName());
if(nResoulution.item(i).getFirstChild().getNodeValue().compareTo("FAILED")==0){
isServiceFailed=true;
break;
@ -109,16 +116,27 @@ public class ReportFiller {
}
}
if (isServiceFailed) serviceReport.setState(State.Failed);
if (isServiceFailed){
serviceReport.setState(State.Failed);
generalFunctState= State.Failed;
}
if (isServiceDeployed) serviceReport.setState(State.Finished);
else generalFunctState= State.Running;
}
entry.getKey().setState(generalFunctState);
}
logger.trace("second step : resources retrieving");
//second step: resources retrieving
//State generalResourceState=State.Finished;
for (Resource resource:report.getResourceDeployingReport().getResources()){
if (resource.getState()==State.Finished || resource.getState()==State.Failed) continue;
logger.trace("checking resource with id "+resource.getResourceId());
NodeList nResoulution = (NodeList)xpath.evaluate("/ResourceReport/Resources/Resource[/ID/text()='"+resource.getResourceId()+"']/Status",document,XPathConstants.NODESET);
logger.trace("found "+nResoulution.getLength());
if (nResoulution.getLength()>0){
logger.trace("found "+nResoulution.item(0).getFirstChild().getNodeValue());
if(nResoulution.item(0).getFirstChild().getNodeValue().compareTo("FAILED")==0)
resource.setState(State.Failed);
else resource.setState(State.Finished);

View File

@ -15,7 +15,17 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.handlers.GCUBEServiceHandler.NoQueryResultException;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.ModelerService;
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
@ -344,4 +354,43 @@ public class Util {
return returnEl;
}
public static ResourceManagerPortType getResourceMangerPT(GCUBEScope scope) throws Exception{
ResourceManagerPortType rmPortType = null;
int attempt=0;
do{
try{
try{
Thread.sleep(30000);
}catch (Exception et){}
ISClient client = GHNContext.getImplementation(ISClient.class);
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
query.setExpression("declare namespace is = 'http://gcube-system.org/namespaces/informationsystem/registry';" +
" for $outer in collection(\"/db/Profiles/RunningInstance\")//Document/Data/is:Profile/Resource " +
" let $scope:= $outer/Scopes/Scope[string() eq '"+scope.toString()+"'] " +
" where count($scope)>0 " +
" and $outer/Profile/ServiceName/string() eq 'ResourceManager' " +
" and $outer/Profile/DeploymentData/Status/string() eq 'ready'"+
" return $outer");
List<EndpointReferenceType> eprs = new ArrayList<EndpointReferenceType>();
for (GCUBERunningInstance instance : client.execute(query, scope))
eprs.add(instance.getAccessPoint().getEndpoint("gcube/vremanagement/ResourceManager"));
if(eprs.size()==0) throw new NoQueryResultException();
ResourceManagerServiceAddressingLocator vmsal= new ResourceManagerServiceAddressingLocator();
logger.trace("trying to contact instance at "+eprs.get(0).getAddress());
rmPortType= vmsal.getResourceManagerPortTypePort(eprs.get(0));
rmPortType = GCUBERemotePortTypeContext.getProxy(rmPortType,scope, Integer.parseInt((String)ServiceContext.getContext().getProperty("resourceManagerTimeout", true)));
}catch(Exception e){
logger.warn(e);
logger.warn("the query for resourceManager returned no result, re-trying in 30 secs ("+attempt+")");
}finally {attempt++;}
}while(rmPortType==null && attempt<10);
if (attempt>=10) throw new Exception("no ResourceMaanger can be retrieved for scope "+scope);
return rmPortType;
}
}

View File

@ -1,9 +1,11 @@
package org.gcube.vremanagement.vremodeler.resources.handlers;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.contexts.GHNContext.Status;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGHNQuery;
@ -34,7 +36,7 @@ public class GHNHandler implements ResourceHandler<GCUBEHostingNode> {
}
private void insert(GCUBEHostingNode ghn) throws Exception {
logger.trace("adding a GHN with id "+ghn.getID());
//GHN(ID VARCHAR NOT NULL PRIMARY KEY,HOST VARCHAR,SECURITY VARCHAR,UPTIME VARCHAR,MAINMEMORYVA VARCHAR,MAINMEMORYVS VARCHAR,LOCALAS VARCHAR,LOCATION VARCHAR,COUNTRY VARCHAR,DOMAIN VARCHAR, ISONCLOUD BOOLEAN)
ArrayList<String> row= new ArrayList<String>(10);
String id= ghn.getID();
@ -57,9 +59,11 @@ public class GHNHandler implements ResourceHandler<GCUBEHostingNode> {
public void add(GCUBEHostingNode resource) throws Exception {
this.insert(resource);
}
public void drop(String ghnId) throws Exception {
logger.trace("removing a GHN with id "+ghnId);
DBInterface.connect();
DBInterface.deleteElement(tableName, "ID='"+ghnId+"'");
}

View File

@ -55,6 +55,6 @@ public class FunctionalityReport implements Serializable{
public int hashCode(){
return functionalityId.hashCode();
return this.functionalityId.hashCode();
}
}

View File

@ -4,14 +4,21 @@ import java.util.Calendar;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.apache.axis.types.URI;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.resources.GCUBEHostingNode.Site;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.types.VOID;
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
import org.gcube.vremanagement.vremodeler.stubs.CollectionList;
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityItem;
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityList;
import org.gcube.vremanagement.vremodeler.stubs.GHNArray;
import org.gcube.vremanagement.vremodeler.stubs.ModelerFactoryPortType;
import org.gcube.vremanagement.vremodeler.stubs.ModelerServicePortType;
import org.gcube.vremanagement.vremodeler.stubs.Utils;
import org.gcube.vremanagement.vremodeler.stubs.VREDescription;
import org.gcube.vremanagement.vremodeler.stubs.deployreport.DeployReport;
import org.gcube.vremanagement.vremodeler.stubs.deployreport.State;
import org.gcube.vremanagement.vremodeler.stubs.service.ModelerFactoryServiceAddressingLocator;
import org.gcube.vremanagement.vremodeler.stubs.service.ModelerServiceAddressingLocator;
@ -54,7 +61,7 @@ public class ModelerTest {
vreReq.setDescription("desc");
vreReq.setDesigner("Lucio");
vreReq.setManager("Lucio");
vreReq.setName("lucioCloud");
vreReq.setName("ManzosCloudVRE");
msptp.setDescription(vreReq);
System.out.println("description set");
@ -66,11 +73,21 @@ public class ModelerTest {
System.out.println(i+" - "+cl.getList(i));
msptp.setCollection(new CollectionArray(new String[]{cl.getList(0).getId()}));
/*
FunctionalityList flist=msptp.getFunctionality(new VOID());
for (FunctionalityItem fitem: flist.getList()){
for (FunctionalityItem fchild:fitem.getChilds())
System.out.println(fchild.getName()+" "+fchild.getId());
}
*/
System.out.println("collection set");
FunctionalityIDArray fida= new FunctionalityIDArray();
fida.setFunctionalityIDElement(new String[]{"0"});
fida.setFunctionalityIDElement(new String[]{"4"});
msptp.setFunctionality(fida);
System.out.println("functionality set");
@ -78,18 +95,20 @@ public class ModelerTest {
msptp.setUseCloud(true);
msptp.setCloudVMs(2);
//msptp.setUseCloud(false);
//msptp.setGHNs(new GHNArray(new String[]{"af63ccc0-d6a7-11df-b524-ba33a5c87470","73ceb130-e844-11df-a7f0-e529e2191760"},"af63ccc0-d6a7-11df-b524-ba33a5c87470"));
/*
msptp.setUseCloud(false);
msptp.setGHNs(new GHNArray(new String[]{"038bab20-eccd-11df-890f-bfe609d68cc0","046da6b0-eccd-11df-90ca-ecd7051b065f"},"038bab20-eccd-11df-890f-bfe609d68cc0"));
*/
msptp.deployVRE(new VOID());
for (int i=0; i<200; i++){
Thread.sleep(30000);
DeployReport deployReport;
do{
String report=msptp.checkStatus(new VOID());
System.out.println("report is:");
System.out.println(msptp.checkStatus(new VOID()));
}
System.out.println(report);
deployReport= Utils.fromXML(report);
Thread.sleep(15000);
}while (deployReport.getState()==State.Running);
}catch(Exception e){e.printStackTrace();}
}