This commit is contained in:
Lucio Lelii 2009-02-16 18:31:32 +00:00
parent 3c8b1cbb47
commit 8721e2beaf
1 changed files with 26 additions and 19 deletions

View File

@ -13,16 +13,10 @@ 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.GHNContext;
import org.gcube.common.core.faults.GCUBEFault;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
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.resources.impl.kxml.KGCUBEResource;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.handlers.GCUBEServiceClientImpl;
@ -43,7 +37,6 @@ import org.gcube.vremanagement.vremodeler.impl.util.Couple;
import org.gcube.vremanagement.vremodeler.impl.util.VREManagerServiceHandler;
import org.gcube.vremanagement.vremodeler.portallayout.CollectionResourceCreation;
import org.gcube.vremanagement.vremodeler.portallayout.GenericResourcePortlet;
import org.gcube.vremanagement.vremodeler.portallayout.LayoutCreation;
import org.globus.wsrf.ResourceException;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@ -72,17 +65,20 @@ public class DeployVRE extends Thread{
public void run() {
try {
ResultSet resRelatedGHN=DBInterface.queryDB("select VRERELATEDGHN.ghnid, GHN.domain from VRERELATEDGHN, GHN where GHN.id=VRERELATEDGHN.ghnid and VRERELATEDGHN.vreid='"+this.resourceId+"'; ");
if (!resRelatedGHN.next()){
throw new Exception("No ghn Selected");
}
String firstGHNId= resRelatedGHN.getString(1);
List<String> GHNList= new ArrayList<String>();
while (resRelatedGHN.next()) GHNList.add(resRelatedGHN.getString(1));
List<Couple<String, String>> GHNList= new ArrayList<Couple<String, String>>();
while (resRelatedGHN.next()) GHNList.add(new Couple<String, String>(resRelatedGHN.getString(1),resRelatedGHN.getString(2)));
if (GHNList.size()<2){
throw new Exception("No ghn Selected (at least 2 GHNs have to be selcted)");
}
if (!deployManagerOnVRE(firstGHNId)){
if (!createVRE(GHNList)){
if (!deployManagerOnVRE(GHNList)){
//transforming the Couple<String, String> to a ghnid List<String>
List<String> ghnEpuredList = new ArrayList<String>();
for (Couple<String, String> cpl: GHNList) ghnEpuredList.add(cpl.first);
if (!createVRE(ghnEpuredList)){
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+ModelerService.DEPLOYED+"' WHERE VRE.id='"+this.resourceId+"';");
logger.info("Deploying of the VRE with id "+this.resourceId+" FINISHED");
}
@ -108,7 +104,7 @@ public class DeployVRE extends Thread{
}
private boolean deployManagerOnVRE(String firstGHNId) throws GCUBEFault{
private boolean deployManagerOnVRE(List<Couple<String, String>> GHNList) throws GCUBEFault{
String vreName= null;
try {
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='Deploying' WHERE VRE.id='"+this.resourceId+"';");
@ -124,7 +120,7 @@ public class DeployVRE extends Thread{
}
// Couple<GCUBEScope,Couple<String, String>>> is a triple with first GCUBEScope, second couple: first String is the VREName, second string is the GHNId
VREManagerServiceHandler<Boolean, Couple<String, String>> vreManagerHandler= new VREManagerServiceHandler<Boolean,Couple<String, String>>(){
VREManagerServiceHandler<Boolean, Couple<String, List<Couple<String, String>>>> vreManagerHandler= new VREManagerServiceHandler<Boolean,Couple<String, List<Couple<String, String>>>>(){
@SuppressWarnings("static-access")
@Override
@ -140,10 +136,21 @@ public class DeployVRE extends Thread{
service[0].setServiceName("VREManager");
service[0].setServiceVersion("1.00.00");
services.setService(service);
services.setGHN(new String[]{this.getParameter().second});
Couple<String, String> ghnId=null;
for (Couple<String, String> cpl: getParameter().second){
if (this.getCachedEPR().getAddress().getHost().contains(cpl.second)){
ghnId=cpl;
break;
}
}
if (ghnId==null) ghnId=getParameter().second.get(0);
services.setGHN(new String[]{ghnId.first});
arp.setServices(services);
arp.setTargetScope(this.scope+"/"+this.getParameter().first);
String reportId=mbportType.addResources(arp);
getParameter().second.remove(ghnId);
int attempt=0;
do{
@ -162,7 +169,7 @@ public class DeployVRE extends Thread{
vreManagerHandler.clearState();
vreManagerHandler.setHandled(new GCUBEServiceClientImpl());
Couple<String, String> coupleParams= new Couple<String, String>(vreName, firstGHNId);
Couple<String, List<Couple<String, String>>> coupleParams= new Couple<String, List<Couple<String, String>>>(vreName, GHNList);
vreManagerHandler.setParameter(coupleParams);
vreManagerHandler.scope=this.startingScope;