git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/VREModeler@8579 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e988ae42e8
commit
c201d1094f
|
@ -27,6 +27,7 @@ import org.globus.wsrf.encoding.SerializationException;
|
||||||
|
|
||||||
public class ModelerService {
|
public class ModelerService {
|
||||||
|
|
||||||
|
public static final String INPROGRESS="In Progress";
|
||||||
public static final String DEPLOYED="Deployed";
|
public static final String DEPLOYED="Deployed";
|
||||||
public static final String FAILED="Failed";
|
public static final String FAILED="Failed";
|
||||||
public static final String PENDING="Pending";
|
public static final String PENDING="Pending";
|
||||||
|
@ -73,7 +74,7 @@ public class ModelerService {
|
||||||
throw new GCUBEFault(e);
|
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{
|
public void setVREtoPendingState(VOID var) throws GCUBEFault{
|
||||||
try{
|
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);}
|
}catch(Exception e){throw new GCUBEFault(e);}
|
||||||
}
|
}
|
||||||
|
@ -483,7 +484,7 @@ public class ModelerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
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) {
|
} catch (GCUBEFault e) {
|
||||||
logger.error("HSQLDB Error "+e);
|
logger.error("HSQLDB Error "+e);
|
||||||
throw new GCUBEUnrecoverableFault(e);
|
throw new GCUBEUnrecoverableFault(e);
|
||||||
|
|
|
@ -69,23 +69,34 @@ public class DeployVRE extends Thread{
|
||||||
try {
|
try {
|
||||||
ResultSet resRelatedGHN=DBInterface.queryDB("select VRERELATEDGHN.ghnid from VRERELATEDGHN where VRERELATEDGHN.vreid='"+this.resourceId+"'; ");
|
ResultSet resRelatedGHN=DBInterface.queryDB("select VRERELATEDGHN.ghnid from VRERELATEDGHN where VRERELATEDGHN.vreid='"+this.resourceId+"'; ");
|
||||||
if (!resRelatedGHN.next()){
|
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);
|
String firstGHNId= resRelatedGHN.getString(1);
|
||||||
List<String> GHNList= new ArrayList<String>();
|
List<String> GHNList= new ArrayList<String>();
|
||||||
while (resRelatedGHN.next()) GHNList.add(resRelatedGHN.getString(1));
|
while (resRelatedGHN.next()) GHNList.add(resRelatedGHN.getString(1));
|
||||||
|
|
||||||
deployManagerOnVRE(firstGHNId);
|
|
||||||
createVRE(GHNList, firstGHNId);
|
if (deployManagerOnVRE(firstGHNId) && createVRE(GHNList, firstGHNId)){
|
||||||
logger.info("Deploying of the VRE with id "+this.resourceId+" FINISHED");
|
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){
|
}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);
|
logger.error("Error deploying the VRE with id "+this.resourceId+" "+e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void deployManagerOnVRE(String firstGHNId) throws GCUBEFault{
|
private boolean deployManagerOnVRE(String firstGHNId) throws GCUBEFault{
|
||||||
String vreName= null;
|
String vreName= null;
|
||||||
try {
|
try {
|
||||||
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='Deploying' WHERE VRE.id='"+this.resourceId+"';");
|
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
|
// 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")
|
@SuppressWarnings("static-access")
|
||||||
@Override
|
@Override
|
||||||
protected String makeCall(VREManagerPortType mbportType)
|
protected Boolean makeCall(VREManagerPortType mbportType)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
//System.out.println("makeCall called");
|
//System.out.println("makeCall called");
|
||||||
|
String report;
|
||||||
try{
|
try{
|
||||||
AddResourcesParameters arp= new AddResourcesParameters();
|
AddResourcesParameters arp= new AddResourcesParameters();
|
||||||
ServiceList services= new ServiceList();
|
ServiceList services= new ServiceList();
|
||||||
|
@ -122,7 +134,6 @@ public class DeployVRE extends Thread{
|
||||||
arp.setTargetScope(this.scope+"/"+this.getParameter().first);
|
arp.setTargetScope(this.scope+"/"+this.getParameter().first);
|
||||||
String reportId=mbportType.addResources(arp);
|
String reportId=mbportType.addResources(arp);
|
||||||
|
|
||||||
String report;
|
|
||||||
int attempt=0;
|
int attempt=0;
|
||||||
do{
|
do{
|
||||||
Thread.currentThread().sleep(20000);
|
Thread.currentThread().sleep(20000);
|
||||||
|
@ -134,7 +145,7 @@ public class DeployVRE extends Thread{
|
||||||
System.out.println("---------");
|
System.out.println("---------");
|
||||||
}while (!isDeploymentStatusFinished(report) && attempt<10);
|
}while (!isDeploymentStatusFinished(report) && attempt<10);
|
||||||
}catch(Exception e){e.printStackTrace(); throw e;}
|
}catch(Exception e){e.printStackTrace(); throw e;}
|
||||||
return "";
|
return isSomethingFailed(report);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -148,13 +159,14 @@ public class DeployVRE extends Thread{
|
||||||
vreManagerHandler.run();
|
vreManagerHandler.run();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("DeployingVRE step 1 -- failed "+e);
|
logger.error("DeployingVRE step 1 -- failed "+e);
|
||||||
throw new GCUBEFault(e);
|
return false;
|
||||||
}
|
}
|
||||||
this.vreName= vreName;
|
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>>(){
|
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);
|
logger.error("DeployingVRE step 2 -- failed "+e);
|
||||||
throw new GCUBEFault(e);
|
throw new GCUBEFault(e);
|
||||||
}
|
}
|
||||||
|
return vreManagerHandler.getReturnValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class ModelerTest {
|
||||||
msptp.setFunctionality(fida);
|
msptp.setFunctionality(fida);
|
||||||
|
|
||||||
GHNArray ghnArray= new GHNArray();
|
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);
|
msptp.setGHNs(ghnArray);
|
||||||
|
|
||||||
System.out.println("-"+msptp.checkStatus(new VOID()).getReports(0)+"-");
|
System.out.println("-"+msptp.checkStatus(new VOID()).getReports(0)+"-");
|
||||||
|
|
Loading…
Reference in New Issue