This commit is contained in:
Lucio Lelii 2009-01-14 11:11:12 +00:00
parent 78412724f5
commit 9ce0000972
8 changed files with 133 additions and 189 deletions

View File

@ -18,6 +18,8 @@
<!-- the polling time: how often the IS synchronizes its content with the RPD values -->
<agg:PollIntervalMillis>60000</agg:PollIntervalMillis>
<agg:ResourcePropertyNames>modeler:Id</agg:ResourcePropertyNames>
<agg:ResourcePropertyNames>modeler:firstStep</agg:ResourcePropertyNames>
<agg:ResourcePropertyNames>modeler:fecondStep</agg:ResourcePropertyNames>
</agg:GetMultipleResourcePropertiesPollType>
</agg:AggregatorConfig>

View File

@ -133,16 +133,29 @@
<xsd:element name="deployVREResponseMessage" type="coretypes:VOID"/>
<xsd:complexType name="CheckStatusResponse">
<xsd:sequence>
<xsd:element name="Reports" type="xsd:string" minOccurs="2" maxOccurs="2" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="checkStatusRequestMessage" type="coretypes:VOID"/>
<xsd:element name="checkStatusResponseMessage" type="tns:CheckStatusResponse"/>
<!--RESOURCE PROPERTIES -->
<xsd:element name="Id" type="xsd:string"/>
<xsd:element name="firstReport" type="xsd:string"/>
<xsd:element name="secondReport" type="xsd:string"/>
<xsd:element name="ModelerProperties">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="tns:Id" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="tns:firstReport" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="tns:secondReport" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
@ -258,7 +271,12 @@
<part name="response" element="tns:deployVREResponseMessage"/>
</message>
<message name="CheckStatusInputMessage">
<part name="request" element="tns:checkStatusRequestMessage"/>
</message>
<message name="checkStatusOutputMessage">
<part name="response" element="tns:checkStatusResponseMessage"/>
</message>
<!--============================================================
@ -344,7 +362,10 @@
<output message="tns:DeployVREOutputMessage"/>
</operation>
<operation name="checkStatus">
<input message="tns:CheckStatusInputMessage"/>
<output message="tns:checkStatusOutputMessage"/>
</operation>
</portType>

View File

@ -1,6 +1,5 @@
package org.gcube.vremanagement.vremodeler.impl;
import java.io.StringReader;
import java.sql.ResultSet;
import java.util.ArrayList;
import org.apache.axis.components.uuid.UUIDGen;
@ -13,9 +12,8 @@ import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil;
import org.gcube.vremanagement.vremodeler.stubs.GetExistingNamesResponseMessage;
import org.globus.wsrf.encoding.ObjectDeserializer;
import org.globus.wsrf.tests.basic.CreateResource;
import org.xml.sax.InputSource;
@ -29,9 +27,15 @@ public class ModelFactoryService extends GCUBEStartupPortType{
return ServiceContext.getContext();
}
/* Implementation of createResource Operation */
/**
* implementation of createResource method
* @param request creation request
* @return the EndpointReference pointing to the resource
* @throws GCUBEFault if something fails
*/
public EndpointReferenceType createResource(CreateResource request) throws GCUBEFault {
String id=uuidGen.nextUUID();
logger.trace("resource "+id+" created");
ModelerResource mr;
try{
ModelerContext pctx= ModelerContext.getPortTypeContext();
@ -46,7 +50,7 @@ public class ModelFactoryService extends GCUBEStartupPortType{
* return the existing DL Name
*
* @param request void
* @return array of string qith exististin dl names
* @return array of string with existing VRE names
* @throws RemoteException -
*/
public GetExistingNamesResponseMessage getExistingNamesVREs(VOID arg) throws GCUBEFault {
@ -119,20 +123,27 @@ public class ModelFactoryService extends GCUBEStartupPortType{
*/
public void removeVRE(String request) throws GCUBEFault{
try{
ResultSet res=DBInterface.queryDB("Select VRE.epr from VRE where VRE.id='"+request+"';");
EndpointReferenceType dlEpr;
ResultSet res=DBInterface.queryDB("Select VRE.id from VRE where VRE.epr='"+request+"';");
String id;
if (res.next()){
StringReader stringReader = new StringReader(res.getString(1));
InputSource inputSource = new InputSource(stringReader);
dlEpr = (EndpointReferenceType) ObjectDeserializer.deserialize(inputSource, EndpointReferenceType.class);
try{
id= res.getString(1);
}catch(Exception e){logger.error("Error retrieving the VRE on DB "+e); throw e;}
}else throw new Exception("VRE not retreived in DB");
ModelerContext pctx= ModelerContext.getPortTypeContext();
ModelerResource mr= (ModelerResource) pctx.getWSHome().find(pctx.makeKey(id));
logger.trace("Deleting resource with id "+id);
System.out.println("Deleting resource "+id);
//destroy the resource;
DBInterface.ExecuteUpdate("DELETE FROM VRE where VRE.id='"+request+"';");
DBInterface.ExecuteUpdate("DELETE FROM VRE where VRE.id='"+id+"';");
mr.remove();
}catch(Exception e){
logger.error("VDLModel: "+e.getMessage());
throw new GCUBEFault( e);
}

View File

@ -6,12 +6,17 @@ import org.globus.wsrf.ResourceException;
public class ModelerResource extends GCUBEWSResource {
protected static final String RP_ID = "Id";
protected static String[] RPNames = { RP_ID};
protected static final String RP_FIRSTSTEP = "reportFirstStep";
protected static final String RP_SECONDSTEP = "reportSecondStep";
protected static String[] RPNames = { RP_ID, RP_FIRSTSTEP, RP_SECONDSTEP};
@Override
protected void initialise(Object... args) throws ResourceException {
if (args.length!=1) throw new ResourceException();
this.setId((String) args[0]);
this.setReportFirstStep("");
this.setReportSecondStep("");
}
@ -30,11 +35,55 @@ public class ModelerResource extends GCUBEWSResource {
* @return the id.
*/
public String getId() throws ResourceException {
return (String) this.getResourcePropertySet().get(RP_ID).get(0);
return (String) this.getResourcePropertySet().get(RP_ID).get(0);
}
protected synchronized void setId(String id) throws ResourceException {
/**
*
* @param id
* @throws ResourceException
*/
public synchronized void setId(String id) throws ResourceException {
this.getResourcePropertySet().get(RP_ID).clear();
this.getResourcePropertySet().get(RP_ID).add(id);
}
/**
*
* @return
* @throws ResourceException
*/
public String getReportSecondStep() throws ResourceException {
return (String) this.getResourcePropertySet().get(RP_SECONDSTEP).get(0);
}
/**
*
* @param reportSecondStep
* @throws ResourceException
*/
public synchronized void setReportSecondStep(String reportSecondStep) throws ResourceException {
this.getResourcePropertySet().get(RP_SECONDSTEP).clear();
this.getResourcePropertySet().get(RP_SECONDSTEP).add(reportSecondStep);
}
/**
*
* @return
* @throws ResourceException
*/
public String getReportFirstStep() throws ResourceException {
return (String) this.getResourcePropertySet().get(RP_FIRSTSTEP).get(0);
}
/**
*
* @param reportFirstStep
* @throws ResourceException
*/
public synchronized void setReportFirstStep(String reportFirstStep) throws ResourceException {
this.getResourcePropertySet().get(RP_FIRSTSTEP).clear();
this.getResourcePropertySet().get(RP_FIRSTSTEP).add(reportFirstStep);
}
}

View File

@ -3,19 +3,19 @@ package org.gcube.vremanagement.vremodeler.impl;
import java.rmi.RemoteException;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import javax.xml.namespace.QName;
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.vremanager.stubs.testsuite.GetReportTest;
import org.gcube.vremanagement.vremodeler.db.DBInterface;
import org.gcube.vremanagement.vremodeler.impl.thread.DeployVRE;
import org.gcube.vremanagement.vremodeler.impl.util.XMLUtil;
import org.gcube.vremanagement.vremodeler.stubs.CheckStatusResponse;
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
import org.gcube.vremanagement.vremodeler.stubs.GHNArray;
@ -490,171 +490,19 @@ public class ModelerService {
throw new GCUBEUnrecoverableFault(e);
}
System.out.println("the scope is"+ServiceContext.getContext().getScope());
DeployVRE deployVREThread= new DeployVRE(resourceID);
ServiceContext.getContext().setScope(deployVREThread, ServiceContext.getContext().getScope());
DeployVRE deployVREThread= new DeployVRE(resourceID, ServiceContext.getContext().getScope() );
logger.trace("Deploy VRE thread started");
deployVREThread.start();
/*
boolean contactedVRE= false;
VREManagerServiceAddressingLocator vreManAL= new VREManagerServiceAddressingLocator();
VREManagerPortType vreManagerPT= null;
List<GCUBERunningInstance> ris= null;
try{
ISClient client= GHNContext.getImplementation(ISClient.class);
GCUBERIQuery query=client.getQuery(GCUBERIQuery.class);
query.addAtomicConditions(new AtomicCondition("//ServiceName", "VREManager"));
query.addAtomicConditions(new AtomicCondition("//ServiceClass", "VREManagement"));
ris = client.execute(query, ServiceContext.getContext().getScope());
}catch (Exception e) { logger.error("Error Excecuting Query"); throw new GCUBEFault(e);}
try {
resourceID = getResource().getId();
} catch (ResourceException e) {
logger.error("Error retrieving the Resource Query"); throw new GCUBEFault(e);
}
for (GCUBERunningInstance ri: ris){
try{
vreManagerPT=vreManAL.getVREManagerPortTypePort(ri.getAccessPoint().getEndpoint("gcube/vremanagement/VREManager"));
OptionsParameters ops;
try{
if (!resGenericInfo.next()) throw new GCUBEFault("The VRE with ID "+resourceID+" cannot be retrieved");
ops=new OptionsParameters();
ScopeOption[] scopeOptionList= new ScopeOption[6];
ScopeOption soDesigner= new ScopeOption();
soDesigner.setName("DESIGNER");
soDesigner.setValue(resGenericInfo.getString("vredesigner"));
scopeOptionList[0]= soDesigner;
ScopeOption soCreator= new ScopeOption();
soCreator.setName("CREATOR");
soCreator.setValue(resGenericInfo.getString("vremanager"));
scopeOptionList[1]= soCreator;
ScopeOption soEndtime= new ScopeOption();
soEndtime.setName("ENDTIME");
soEndtime.setValue(KGCUBEResource.toXMLDateAndTime(resGenericInfo.getDate("IntervalTo")));
scopeOptionList[2]= soEndtime;
ScopeOption soStarttime= new ScopeOption();
soStarttime.setName("STARTTIME");
soStarttime.setValue(KGCUBEResource.toXMLDateAndTime(resGenericInfo.getDate("IntervalFrom")));
scopeOptionList[3]= soStarttime;
ScopeOption soDescription= new ScopeOption();
soDescription.setName("DESCRIPTION");
soDescription.setValue(resGenericInfo.getString("description"));
scopeOptionList[4]= soDescription;
ScopeOption soDisplayname= new ScopeOption();
soDisplayname.setName("DISPLAYNAME");
soDisplayname.setValue(resGenericInfo.getString("name"));
scopeOptionList[5]= soDisplayname;
ops.setScopeOptionList(scopeOptionList);
}catch(SQLException e) {logger.error("cannot retreive the VRE"); throw new GCUBEFault(e);}
//sending scope options
vreManagerPT.setScopeOptions(ops);
AddResourcesParameters arp= new AddResourcesParameters();
ResourceList rl= new ResourceList();
List<ResourceItem> resItemList= new ArrayList<ResourceItem>();
ResourceItem resItem= null;
//retrieving Collection
try{
ResultSet resRelatedCol =DBInterface.queryDB("select VRERELATEDCOLLECTION.collid from VRERELATEDCOLLECTION where VRERELATEDCOLLECTION.vreid='"+resourceID+"';");
while (resRelatedCol.next()){
resItem= new ResourceItem();
resItem.setID(resRelatedCol.getString(1));
resItem.setType(GCUBECollection.TYPE);
resItemList.add(resItem);
}
}catch(SQLException sqle){logger.error("Error contacting HSQLDB");}
//retrieving MDCollection with native MDFormat
try{
ResultSet resMdColNative =DBInterface.queryDB("select mdcollid from SELECTEDNATIVEMDFROMAT AS s where s.vreid='"+resourceID+"';");
while (resMdColNative.next()){
resItem= new ResourceItem();
resItem.setID(resMdColNative.getString(1));
System.out.println(resItem.getID());
resItem.setType(GCUBEMCollection.TYPE);
resItemList.add(resItem);
}
}catch(SQLException sqle){logger.error("Error contacting HSQLDB");}
//retrieve and create MDCollection with Broker
try{
ResultSet resMdColDerivate =DBInterface.queryDB("select mdcollid, tpid from SELECTEDDERIVATEMDFROMAT AS s where s.vreid='"+resourceID+"';");
MBrokerServiceHandler<String, Couple<String, String>> sHandler= new MBrokerServiceHandler<String,Couple<String, String>>(){
@Override
protected String makeCall(MetadataBrokerPortType mbportType) throws Exception {
FindPossibleTransformationPrograms fptp= new FindPossibleTransformationPrograms();
Transform t= new Transform();
t.setTransformationProgramID(this.getParameter().second);
String toReturn= mbportType.transform(t);
return toReturn;
}
};
while (resMdColDerivate.next()){
}
}catch(SQLException sqle){logger.error("Error contacting HSQLDB");}
//adding Services
ServiceList sl = new ServiceList();
/*
ResultSet resRelatedMetadataCol =DBInterface.queryDB("select VRERELATEDCOLLECTION.collid from DLRELATEDCOLLECTION where VRERELATEDCOLLECTION.dlid='"+getResource().getId()+"';");
while (resRelatedCol.next()){
resItem= new ResourceItem();
resItem.setID(resRelatedCol.getString(1));
resItem.setType(GCUBEMCollection.TYPE);
}
contactedVRE= true;
}catch(RemoteException re){logger.warn("Error Contacting VREManager, trying next RI"); contactedVRE= false;}
catch(ServiceException se1){logger.warn("Error Contacting VREManager, trying next RI"); contactedVRE= false;}
}
if (!contactedVRE) {
logger.error("Error Contacting VREManager");
throw new GCUBEFault("Error Contacting VREManager");
}*/
}
public CheckStatusResponse checkStatus(VOID var) throws Exception{
CheckStatusResponse res= new CheckStatusResponse();
res.setReports(new String[]{getResource().getReportFirstStep(), getResource().getReportSecondStep()});
return res;
}
}

View File

@ -46,16 +46,18 @@ public class DeployVRE extends Thread{
private String resourceId;
private GCUBEScope startingScope;
private String vreName=null;
public DeployVRE(String resourceId){
public DeployVRE(String resourceId, GCUBEScope scope){
this.resourceId=resourceId;
this.startingScope= scope;
}
public void run() {
try {
deployManagerOnVRE();
ServiceContext.getContext().setScope(GCUBEScope.getScope(ServiceContext.getContext().getScope()+"/"+this.vreName));
ServiceContext.getContext().setScope(GCUBEScope.getScope(this.startingScope+"/"+this.vreName));
createVRE();
logger.info("FINISHED");
}catch(Exception e){
@ -85,9 +87,10 @@ public class DeployVRE extends Thread{
throw new GCUBEFault(e);
}
// 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>>(){
@SuppressWarnings("static-access")
@Override
protected String makeCall(VREManagerPortType mbportType)
throws Exception {
@ -105,14 +108,15 @@ public class DeployVRE extends Thread{
System.out.println("fin qui ci sono 2");
services.setGHN(new String[]{this.getParameter().second});
arp.setServices(services);
System.out.println(ServiceContext.getContext().getScope());
arp.setTargetScope(ServiceContext.getContext().getScope().toString()+"/"+this.getParameter().first);
System.out.println(this.scope);
arp.setTargetScope(this.scope+"/"+this.getParameter().first);
String reportId=mbportType.addResources(arp);
System.out.println("fin qui ci sono 3");
String report;
int attempt=0;
do{
this.wait(30000);
Thread.currentThread().sleep(30000);
report=mbportType.getReport(reportId);
attempt++;
System.out.println("report:");
@ -127,6 +131,8 @@ public class DeployVRE extends Thread{
vreManagerHandler.setHandled(new GCUBEServiceClientImpl());
Couple<String, String> coupleParams= new Couple<String, String>(vreName, firstGHNId);
vreManagerHandler.setParameter(coupleParams);
vreManagerHandler.scope=this.startingScope;
try {
vreManagerHandler.run();
} catch (Exception e) {
@ -276,6 +282,7 @@ public class DeployVRE extends Thread{
vreManagerHandler.setHandled(new GCUBEServiceClientImpl());
vreManagerHandler.setParameter(this.resourceId);
vreManagerHandler.scope=this.startingScope;
try {
vreManagerHandler.run();
} catch (Exception e) {

View File

@ -10,6 +10,7 @@ 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.GCUBERunningInstance;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.handlers.GCUBEServiceClient;
import org.gcube.common.core.utils.handlers.GCUBEServiceHandler;
import org.gcube.vremanagement.vremanager.stubs.vremanager.VREManagerPortType;
@ -22,6 +23,8 @@ public abstract class VREManagerServiceHandler<T, P> extends GCUBEServiceHandler
private P parameter;
public GCUBEScope scope= ServiceContext.getContext().getScope();
public T getReturnValue(){
return returnValue;
}
@ -47,7 +50,7 @@ public abstract class VREManagerServiceHandler<T, P> extends GCUBEServiceHandler
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
query.addAtomicConditions(new AtomicCondition("//ServiceName", "VREManager"));
List<EndpointReferenceType> eprs = new ArrayList<EndpointReferenceType>();
for (GCUBERunningInstance instance : client.execute(query, ServiceContext.getContext().getScope()))
for (GCUBERunningInstance instance : client.execute(query, scope))
eprs.add(instance.getAccessPoint().getEndpoint("gcube/vremanagement/VREManager"));
System.out.println(eprs.size());
return eprs;
@ -63,7 +66,7 @@ public abstract class VREManagerServiceHandler<T, P> extends GCUBEServiceHandler
try{
VREManagerServiceAddressingLocator mbsal= new VREManagerServiceAddressingLocator();
mbpt= mbsal.getVREManagerPortTypePort(arg0);
mbpt = GCUBERemotePortTypeContext.getProxy(mbpt,ServiceContext.getContext().getScope());
mbpt = GCUBERemotePortTypeContext.getProxy(mbpt,scope);
this.setReturnValue(this.makeCall(mbpt));
}catch(Exception e){e.printStackTrace();throw e; }
}

View File

@ -15,7 +15,6 @@ import org.gcube.common.core.types.VOID;
import org.gcube.vremanagement.vremodeler.stubs.CollectionArray;
import org.gcube.vremanagement.vremodeler.stubs.FunctionalityIDArray;
import org.gcube.vremanagement.vremodeler.stubs.GHNArray;
import org.gcube.vremanagement.vremodeler.stubs.GetExistingNamesResponseMessage;
import org.gcube.vremanagement.vremodeler.stubs.ModelerFactoryPortType;
import org.gcube.vremanagement.vremodeler.stubs.ModelerServicePortType;
import org.gcube.vremanagement.vremodeler.stubs.VRERequest;
@ -44,6 +43,8 @@ public class ModelerTest {
ModelerServiceAddressingLocator msal= new ModelerServiceAddressingLocator();
ModelerServicePortType msptp=msal.getModelerServicePortTypePort(eprModelerRes);
msptp = GCUBERemotePortTypeContext.getProxy(msptp, GCUBEScope.getScope("/gcube/devsec"));
VRERequest vreReq= new VRERequest();
@ -67,8 +68,10 @@ public class ModelerTest {
ghnArray.setGHNElement(new String[]{"13e6a280-e0b4-11dd-aafb-8e705a88c80f","a9673990-c792-11dd-aa98-9dfda17b7a75"});
msptp.setGHNs(ghnArray);
System.out.println("-"+msptp.checkStatus(new VOID()).getReports(0)+"-");
msptp.deployVRE(new VOID());
//msptp.deployVRE(new VOID());