git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/VREModeler@8059 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
19078ff416
commit
5ffa9dbefe
|
@ -9,40 +9,18 @@ import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.namespace.QName;
|
import javax.xml.namespace.QName;
|
||||||
import javax.xml.rpc.ServiceException;
|
|
||||||
|
|
||||||
import org.gcube.common.core.contexts.GHNContext;
|
|
||||||
import org.gcube.common.core.faults.GCUBEFault;
|
import org.gcube.common.core.faults.GCUBEFault;
|
||||||
import org.gcube.common.core.informationsystem.client.AtomicCondition;
|
import org.gcube.common.core.faults.GCUBEUnrecoverableFault;
|
||||||
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.GCUBEMCollection;
|
|
||||||
import org.gcube.common.core.resources.GCUBERunningInstance;
|
|
||||||
import org.gcube.common.core.resources.impl.kxml.KGCUBEResource;
|
|
||||||
import org.gcube.common.core.types.VOID;
|
import org.gcube.common.core.types.VOID;
|
||||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||||
import org.gcube.metadatamanagement.metadatabroker.stubs.FindPossibleTransformationPrograms;
|
|
||||||
import org.gcube.metadatamanagement.metadatabroker.stubs.MetadataBrokerPortType;
|
|
||||||
import org.gcube.metadatamanagement.metadatabroker.stubs.Transform;
|
|
||||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.AddResourcesParameters;
|
|
||||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.ResourceItem;
|
|
||||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.ResourceList;
|
|
||||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.ScopeOption;
|
|
||||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.ServiceItem;
|
|
||||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.ServiceList;
|
|
||||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.VREManagerPortType;
|
|
||||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.service.VREManagerServiceAddressingLocator;
|
|
||||||
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
||||||
import org.gcube.vremanagement.vremodeler.impl.util.MBrokerServiceHandler;
|
import org.gcube.vremanagement.vremodeler.impl.thread.DeployVRE;
|
||||||
import org.gcube.vremanagement.vremodeler.impl.util.VREManagerServiceHandler;
|
|
||||||
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil;
|
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil;
|
||||||
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
|
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
|
||||||
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
|
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
|
||||||
import org.gcube.vremanagement.vremodeler.stubs.GHNArray;
|
import org.gcube.vremanagement.vremodeler.stubs.GHNArray;
|
||||||
import org.gcube.vremanagement.vremodeler.stubs.SetMDFormatArgs;
|
import org.gcube.vremanagement.vremodeler.stubs.SetMDFormatArgs;
|
||||||
import org.gcube.vremanagement.vremodeler.stubs.VRERequest;
|
import org.gcube.vremanagement.vremodeler.stubs.VRERequest;
|
||||||
import org.gcube.vremanagement.vremanager.stubs.vremanager.OptionsParameters;
|
|
||||||
import org.globus.wsrf.ResourceException;
|
import org.globus.wsrf.ResourceException;
|
||||||
import org.globus.wsrf.encoding.ObjectSerializer;
|
import org.globus.wsrf.encoding.ObjectSerializer;
|
||||||
import org.globus.wsrf.encoding.SerializationException;
|
import org.globus.wsrf.encoding.SerializationException;
|
||||||
|
@ -50,12 +28,20 @@ import org.globus.wsrf.encoding.SerializationException;
|
||||||
|
|
||||||
public class ModelerService {
|
public class ModelerService {
|
||||||
|
|
||||||
|
public static final String DEPLOYED="Deployed";
|
||||||
|
public static final String FAILED="Failed";
|
||||||
|
public static final String PENDING="Pending";
|
||||||
|
public static final String DEPLOYING="Deploying";
|
||||||
|
|
||||||
|
|
||||||
private static final GCUBELog logger = new GCUBELog(ModelerService.class.getName());
|
private static final GCUBELog logger = new GCUBELog(ModelerService.class.getName());
|
||||||
|
|
||||||
protected ModelerResource getResource() throws ResourceException{
|
protected ModelerResource getResource() throws ResourceException{
|
||||||
return (ModelerResource) ModelerContext.getPortTypeContext().getWSHome().find();
|
return (ModelerResource) ModelerContext.getPortTypeContext().getWSHome().find();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param request void
|
* @param request void
|
||||||
|
@ -372,14 +358,14 @@ public class ModelerService {
|
||||||
try {
|
try {
|
||||||
DBInterface.connect();
|
DBInterface.connect();
|
||||||
resFunct= DBInterface.queryDB("select * from functionality where father is null;");
|
resFunct= DBInterface.queryDB("select * from functionality where father is null;");
|
||||||
selectedFuncRes= DBInterface.queryDB("select funcid from VRERELATEDFUNCT where vreid='"+getResource().getID()+"';");
|
selectedFuncRes= DBInterface.queryDB("select funcid from VRERELATEDFUNCT where vreid='"+getResource().getId()+"';");
|
||||||
while (selectedFuncRes.next())
|
while (selectedFuncRes.next())
|
||||||
selectedFunctionality.add(selectedFuncRes.getInt(1));
|
selectedFunctionality.add(selectedFuncRes.getInt(1));
|
||||||
selectedCSRes= DBInterface.queryDB("select csid from VRERELATEDCS where vreid='"+getResource().getID()+"';");
|
selectedCSRes= DBInterface.queryDB("select csid from VRERELATEDCS where vreid='"+getResource().getId()+"';");
|
||||||
while (selectedCSRes.next())
|
while (selectedCSRes.next())
|
||||||
selectedCS.add(selectedCSRes.getString(1));
|
selectedCS.add(selectedCSRes.getString(1));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//logger.error("VDLModel Service: error retreiving functionality");
|
//logger.error("VDLModel Service: error retrieving functionality");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new GCUBEFault(e);
|
throw new GCUBEFault(e);
|
||||||
}
|
}
|
||||||
|
@ -396,44 +382,48 @@ public class ModelerService {
|
||||||
* @throws RemoteException -
|
* @throws RemoteException -
|
||||||
*/
|
*/
|
||||||
public void setFunctionality(FunctionalityIDArray request) throws GCUBEFault {
|
public void setFunctionality(FunctionalityIDArray request) throws GCUBEFault {
|
||||||
|
System.out.println("Set Functionality called");
|
||||||
|
|
||||||
try{
|
try{
|
||||||
DBInterface.ExecuteUpdate("DELETE FROM VRERELATEDFUNCT WHERE VRERELATEDFUNCT.vreid='"+getResource().getId()+"';");
|
DBInterface.ExecuteUpdate("DELETE FROM VRERELATEDFUNCT WHERE VRERELATEDFUNCT.vreid='"+getResource().getId()+"';");
|
||||||
DBInterface.ExecuteUpdate("DELETE FROM VRERELATEDCS WHERE VRERELATEDCS.vreid='"+getResource().getId()+"';");
|
DBInterface.ExecuteUpdate("DELETE FROM VRERELATEDCS WHERE VRERELATEDCS.vreid='"+getResource().getId()+"';");
|
||||||
|
|
||||||
|
|
||||||
String dlKey=(String) getResource().getId();
|
String vreKey=(String) getResource().getId();
|
||||||
//logger.debug("KEY: "+dlKey);
|
//logger.debug("KEY: "+dlKey);
|
||||||
|
|
||||||
if (request.getFunctionalityIDElement()!=null){
|
if (request.getFunctionalityIDElement()!=null){
|
||||||
ArrayList<List<String>> values= new ArrayList<List<String>>(request.getFunctionalityIDElement().length);
|
ArrayList<List<String>> values= new ArrayList<List<String>>(request.getFunctionalityIDElement().length);
|
||||||
ArrayList<String> row=null;
|
ArrayList<String> row=null;
|
||||||
for (int i=0; i<request.getFunctionalityIDElement().length; i++)
|
for (String funct: request.getFunctionalityIDElement())
|
||||||
{
|
{
|
||||||
row= new ArrayList<String>(2);
|
row= new ArrayList<String>(2);
|
||||||
row.add(dlKey);
|
row.add(vreKey);
|
||||||
row.add(request.getFunctionalityIDElement()[i]);
|
row.add(funct);
|
||||||
values.add(row);
|
values.add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBInterface.InsertInto("VRERELATEDFUNCT", values);
|
DBInterface.InsertInto("VRERELATEDFUNCT", values);
|
||||||
}
|
}else System.out.println("requestFunciotnality is null");
|
||||||
|
|
||||||
if (request.getCsIDElement()!=null)
|
if (request.getCsIDElement()!=null)
|
||||||
{
|
{
|
||||||
ArrayList<List<String>> values= new ArrayList<List<String>>(request.getCsIDElement().length);
|
ArrayList<List<String>> values= new ArrayList<List<String>>(request.getCsIDElement().length);
|
||||||
ArrayList<String> row=null;
|
ArrayList<String> row=null;
|
||||||
|
|
||||||
for (int i=0; i<request.getCsIDElement().length; i++)
|
for (String css:request.getCsIDElement())
|
||||||
{
|
{
|
||||||
row= new ArrayList<String>(2);
|
row= new ArrayList<String>(2);
|
||||||
row.add(dlKey);
|
row.add(vreKey);
|
||||||
row.add(request.getCsIDElement()[i]);
|
row.add(css);
|
||||||
values.add(row);
|
values.add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBInterface.InsertInto("VRERELATEDCS", values);
|
DBInterface.InsertInto("VRERELATEDCS", values);
|
||||||
}
|
}
|
||||||
}catch(Exception e){throw new GCUBEFault(e);}
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new GCUBEFault(e);}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,38 +471,34 @@ public class ModelerService {
|
||||||
* @throws RemoteException -
|
* @throws RemoteException -
|
||||||
*/
|
*/
|
||||||
public void deployVRE(VOID var) throws GCUBEFault{
|
public void deployVRE(VOID var) throws GCUBEFault{
|
||||||
|
String resourceID;
|
||||||
|
try {
|
||||||
|
resourceID = getResource().getId();
|
||||||
|
} catch (ResourceException e) {
|
||||||
|
logger.error("Error retrieving the Resource Requested"); throw new GCUBEUnrecoverableFault(e);
|
||||||
|
}
|
||||||
|
|
||||||
// couple: first String is the VREName, second string is the GHNId
|
try{
|
||||||
VREManagerServiceHandler<String, Couple<String, String>> vreManagerHandler= new VREManagerServiceHandler<String,Couple<String, String>>(){
|
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='Deploying' WHERE VRE.id='"+resourceID+"';");
|
||||||
|
} catch (GCUBEFault e) {
|
||||||
|
logger.error("HSQLDB Error "+e);
|
||||||
|
throw new GCUBEUnrecoverableFault(e);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
Thread deployVREThread= new Thread(new DeployVRE(resourceID));
|
||||||
protected String makeCall(VREManagerPortType mbportType)
|
ServiceContext.getContext().setScope(deployVREThread, ServiceContext.getContext().getScope());
|
||||||
throws Exception {
|
deployVREThread.start();
|
||||||
AddResourcesParameters arp= new AddResourcesParameters();
|
|
||||||
ServiceList services= new ServiceList();
|
|
||||||
ServiceItem[] service= new ServiceItem[1];
|
|
||||||
service[0].setServiceClass("VREManagement");
|
|
||||||
service[0].setServiceName("VREManager");
|
|
||||||
service[0].setServiceVersion("1.00.00");
|
|
||||||
services.setService(service);
|
|
||||||
services.setGHN(new String[]{this.getParameter().second});
|
|
||||||
arp.setServices(services);
|
|
||||||
arp.setTargetScope(ServiceContext.getContext().getScope().toString()+"/"+this.getParameter().first);
|
|
||||||
return mbportType.addResources(arp);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
boolean contactedVRE= false;
|
boolean contactedVRE= false;
|
||||||
try {
|
|
||||||
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='Deploying' WHERE VRE.id='"+getResource().getId()+"';");
|
|
||||||
} catch (ResourceException e1) {
|
|
||||||
throw new GCUBEFault(e1);
|
|
||||||
}
|
|
||||||
|
|
||||||
VREManagerServiceAddressingLocator vreManAL= new VREManagerServiceAddressingLocator();
|
VREManagerServiceAddressingLocator vreManAL= new VREManagerServiceAddressingLocator();
|
||||||
VREManagerPortType vreManagerPT= null;
|
VREManagerPortType vreManagerPT= null;
|
||||||
|
@ -526,7 +512,7 @@ public class ModelerService {
|
||||||
ris = client.execute(query, ServiceContext.getContext().getScope());
|
ris = client.execute(query, ServiceContext.getContext().getScope());
|
||||||
}catch (Exception e) { logger.error("Error Excecuting Query"); throw new GCUBEFault(e);}
|
}catch (Exception e) { logger.error("Error Excecuting Query"); throw new GCUBEFault(e);}
|
||||||
|
|
||||||
String resourceID;
|
|
||||||
try {
|
try {
|
||||||
resourceID = getResource().getId();
|
resourceID = getResource().getId();
|
||||||
} catch (ResourceException e) {
|
} catch (ResourceException e) {
|
||||||
|
@ -540,7 +526,7 @@ public class ModelerService {
|
||||||
|
|
||||||
OptionsParameters ops;
|
OptionsParameters ops;
|
||||||
try{
|
try{
|
||||||
ResultSet resGenericInfo=DBInterface.queryDB("select * from VRE where VRE.id='"+resourceID+"'; ");
|
|
||||||
|
|
||||||
if (!resGenericInfo.next()) throw new GCUBEFault("The VRE with ID "+resourceID+" cannot be retrieved");
|
if (!resGenericInfo.next()) throw new GCUBEFault("The VRE with ID "+resourceID+" cannot be retrieved");
|
||||||
|
|
||||||
|
@ -646,7 +632,7 @@ public class ModelerService {
|
||||||
resItem.setID(resRelatedCol.getString(1));
|
resItem.setID(resRelatedCol.getString(1));
|
||||||
resItem.setType(GCUBEMCollection.TYPE);
|
resItem.setType(GCUBEMCollection.TYPE);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
contactedVRE= true;
|
contactedVRE= true;
|
||||||
}catch(RemoteException re){logger.warn("Error Contacting VREManager, trying next RI"); contactedVRE= false;}
|
}catch(RemoteException re){logger.warn("Error Contacting VREManager, trying next RI"); contactedVRE= false;}
|
||||||
|
@ -656,27 +642,12 @@ public class ModelerService {
|
||||||
if (!contactedVRE) {
|
if (!contactedVRE) {
|
||||||
logger.error("Error Contacting VREManager");
|
logger.error("Error Contacting VREManager");
|
||||||
throw new GCUBEFault("Error Contacting VREManager");
|
throw new GCUBEFault("Error Contacting VREManager");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inner class for couple
|
|
||||||
* @author lucio
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class Couple<F,S>{
|
|
||||||
|
|
||||||
public F first;
|
|
||||||
public S second;
|
|
||||||
|
|
||||||
public Couple(F first, S second){
|
|
||||||
this.first=first;
|
|
||||||
this.second= second;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package org.gcube.vremanagement.vremodeler.impl.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* couple
|
||||||
|
* @author lucio
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Couple<F,S>{
|
||||||
|
|
||||||
|
public F first;
|
||||||
|
public S second;
|
||||||
|
|
||||||
|
public Couple(F first, S second){
|
||||||
|
this.first=first;
|
||||||
|
this.second= second;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -55,7 +55,6 @@ public abstract class VREManagerServiceHandler<T, P> extends GCUBEServiceHandler
|
||||||
protected abstract T makeCall(VREManagerPortType mbportType) throws Exception;
|
protected abstract T makeCall(VREManagerPortType mbportType) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected void interact(EndpointReferenceType arg0) throws Exception{
|
protected void interact(EndpointReferenceType arg0) throws Exception{
|
||||||
VREManagerPortType mbpt= null;
|
VREManagerPortType mbpt= null;
|
||||||
try{
|
try{
|
||||||
|
@ -65,4 +64,5 @@ public abstract class VREManagerServiceHandler<T, P> extends GCUBEServiceHandler
|
||||||
this.setReturnValue(this.makeCall(mbpt));
|
this.setReturnValue(this.makeCall(mbpt));
|
||||||
}catch(Exception e){throw e;}
|
}catch(Exception e){throw e;}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -371,7 +371,7 @@ public class XMLUtil {
|
||||||
toReturn.append(res.getString(3));
|
toReturn.append(res.getString(3));
|
||||||
toReturn.append("</Description><VREDesigner>");
|
toReturn.append("</Description><VREDesigner>");
|
||||||
toReturn.append(res.getString(4));
|
toReturn.append(res.getString(4));
|
||||||
toReturn.append("</DLDesigner><VREManager>");
|
toReturn.append("</VREDesigner><VREManager>");
|
||||||
toReturn.append(res.getString(5));
|
toReturn.append(res.getString(5));
|
||||||
toReturn.append("</VREManager><StartTime>");
|
toReturn.append("</VREManager><StartTime>");
|
||||||
toReturn.append(res.getDate(6).getTime());
|
toReturn.append(res.getDate(6).getTime());
|
||||||
|
|
Loading…
Reference in New Issue