This commit is contained in:
Lucio Lelii 2009-01-19 15:20:22 +00:00
parent e988ae42e8
commit c201d1094f
3 changed files with 30 additions and 17 deletions

View File

@ -27,6 +27,7 @@ import org.globus.wsrf.encoding.SerializationException;
public class ModelerService {
public static final String INPROGRESS="In Progress";
public static final String DEPLOYED="Deployed";
public static final String FAILED="Failed";
public static final String PENDING="Pending";
@ -73,7 +74,7 @@ public class ModelerService {
throw new GCUBEFault(e);
}
DBInterface.ExecuteUpdate("insert into VRE values('"+getResource().getId()+"','"+request.getVREName()+"','"+request.getVREDescription()+"','"+request.getVREDesigner()+"','"+request.getVREManager()+"','"+dateFrom+"','"+dateTo+"','"+eprToString+"','In Progress'); ");
DBInterface.ExecuteUpdate("insert into VRE values('"+getResource().getId()+"','"+request.getVREName()+"','"+request.getVREDescription()+"','"+request.getVREDesigner()+"','"+request.getVREManager()+"','"+dateFrom+"','"+dateTo+"','"+eprToString+"','"+INPROGRESS+"'); ");
}
@ -463,7 +464,7 @@ public class ModelerService {
*/
public void setVREtoPendingState(VOID var) throws GCUBEFault{
try{
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='Pending' WHERE VRE.id='"+getResource().getId()+"';");
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+PENDING+"' WHERE VRE.id='"+getResource().getId()+"';");
}catch(Exception e){throw new GCUBEFault(e);}
}
@ -483,7 +484,7 @@ public class ModelerService {
}
try{
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='Deploying' WHERE VRE.id='"+resourceID+"';");
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+DEPLOYING+"' WHERE VRE.id='"+resourceID+"';");
} catch (GCUBEFault e) {
logger.error("HSQLDB Error "+e);
throw new GCUBEUnrecoverableFault(e);

View File

@ -69,23 +69,34 @@ public class DeployVRE extends Thread{
try {
ResultSet resRelatedGHN=DBInterface.queryDB("select VRERELATEDGHN.ghnid from VRERELATEDGHN where VRERELATEDGHN.vreid='"+this.resourceId+"'; ");
if (!resRelatedGHN.next()){
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='Failed' WHERE VRE.id='"+this.resourceId+"';");
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));
deployManagerOnVRE(firstGHNId);
createVRE(GHNList, firstGHNId);
logger.info("Deploying of the VRE with id "+this.resourceId+" FINISHED");
if (deployManagerOnVRE(firstGHNId) && createVRE(GHNList, firstGHNId)){
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+ModelerService.DEPLOYED+"' WHERE VRE.id='"+this.resourceId+"';");
logger.info("Deploying of the VRE with id "+this.resourceId+" FINISHED");
}else{
logger.info("Deploying of the VRE with id "+this.resourceId+" FAILED");
throw new Exception("Error Deployng the VRE");
}
}catch(Exception e){
try {
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+ModelerService.FAILED+"' WHERE VRE.id='"+this.resourceId+"';");
} catch (GCUBEFault e1) {
logger.error("impossible to update the VRE Status");
e1.printStackTrace();
}
logger.error("Error deploying the VRE with id "+this.resourceId+" "+e);
e.printStackTrace();
}
}
private void deployManagerOnVRE(String firstGHNId) throws GCUBEFault{
private boolean deployManagerOnVRE(String firstGHNId) throws GCUBEFault{
String vreName= null;
try {
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='Deploying' WHERE VRE.id='"+this.resourceId+"';");
@ -101,13 +112,14 @@ 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<String, Couple<String, String>> vreManagerHandler= new VREManagerServiceHandler<String,Couple<String, String>>(){
VREManagerServiceHandler<Boolean, Couple<String, String>> vreManagerHandler= new VREManagerServiceHandler<Boolean,Couple<String, String>>(){
@SuppressWarnings("static-access")
@Override
protected String makeCall(VREManagerPortType mbportType)
protected Boolean makeCall(VREManagerPortType mbportType)
throws Exception {
//System.out.println("makeCall called");
String report;
try{
AddResourcesParameters arp= new AddResourcesParameters();
ServiceList services= new ServiceList();
@ -122,7 +134,6 @@ public class DeployVRE extends Thread{
arp.setTargetScope(this.scope+"/"+this.getParameter().first);
String reportId=mbportType.addResources(arp);
String report;
int attempt=0;
do{
Thread.currentThread().sleep(20000);
@ -134,7 +145,7 @@ public class DeployVRE extends Thread{
System.out.println("---------");
}while (!isDeploymentStatusFinished(report) && attempt<10);
}catch(Exception e){e.printStackTrace(); throw e;}
return "";
return isSomethingFailed(report);
}
};
@ -148,13 +159,14 @@ public class DeployVRE extends Thread{
vreManagerHandler.run();
} catch (Exception e) {
logger.error("DeployingVRE step 1 -- failed "+e);
throw new GCUBEFault(e);
return false;
}
this.vreName= vreName;
return vreManagerHandler.getReturnValue();
}
private void createVRE(List<String> ghnList, String ghnId) throws GCUBEFault{
private boolean createVRE(List<String> ghnList, String ghnId) throws GCUBEFault{
VREManagerServiceHandler<Boolean, Couple<List<String>, String>> vreManagerHandler= new VREManagerServiceHandler<Boolean,Couple<List<String>, String>>(){
@ -306,7 +318,7 @@ public class DeployVRE extends Thread{
logger.error("DeployingVRE step 2 -- failed "+e);
throw new GCUBEFault(e);
}
return vreManagerHandler.getReturnValue();
}

View File

@ -65,7 +65,7 @@ public class ModelerTest {
msptp.setFunctionality(fida);
GHNArray ghnArray= new GHNArray();
ghnArray.setGHNElement(new String[]{"fbd4db10-e268-11dd-bf95-b9ea85be7470","fe602770-e3f5-11dd-a0e9-fe3a60cbc58d"});
ghnArray.setGHNElement(new String[]{"e0ca7650-e58c-11dd-88eb-b3e5d13cd008","8579e2d0-e58d-11dd-b8e3-9f571c6c1426"});
msptp.setGHNs(ghnArray);
System.out.println("-"+msptp.checkStatus(new VOID()).getReports(0)+"-");