This commit is contained in:
Lucio Lelii 2009-01-18 18:08:53 +00:00
parent 1a953ec1da
commit fd13f312d2
2 changed files with 32 additions and 3 deletions

View File

@ -13,9 +13,16 @@ 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.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;
@ -69,7 +76,7 @@ public class DeployVRE extends Thread{
while (resRelatedGHN.next()) GHNList.add(resRelatedGHN.getString(1));
deployManagerOnVRE(firstGHNId);
createVRE(GHNList);
createVRE(GHNList, firstGHNId);
logger.info("Deploying of the VRE with id "+this.resourceId+" FINISHED");
}catch(Exception e){
logger.error("Error deploying the VRE with id "+this.resourceId+" "+e);
@ -147,9 +154,29 @@ public class DeployVRE extends Thread{
}
private void createVRE(List<String> ghnList) throws GCUBEFault{
private void createVRE(List<String> ghnList, String ghnId) throws GCUBEFault{
VREManagerServiceHandler<Boolean, Couple<List<String>, String>> vreManagerHandler= new VREManagerServiceHandler<Boolean,Couple<List<String>, String>>(){
@Override
protected List<EndpointReferenceType> findInstances() throws Exception {
System.out.println("findinstance called");
try{
ISClient client = GHNContext.getImplementation(ISClient.class);
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
query.addAtomicConditions(new AtomicCondition("//ServiceName", "VREManager"), new AtomicCondition("/Profile/GHN/@UniqueID", this.relatedGhnId));
List<EndpointReferenceType> eprs = new ArrayList<EndpointReferenceType>();
for (GCUBERunningInstance instance : client.execute(query, scope))
eprs.add(instance.getAccessPoint().getEndpoint("gcube/vremanagement/VREManager"));
System.out.println("EPRs: ");
for (EndpointReferenceType epr: eprs)
System.out.println(epr);
return eprs;
}catch(Exception e){e.printStackTrace(); throw e;}
}
//the parameter is resourceID
@SuppressWarnings("static-access")
@Override
@ -269,6 +296,7 @@ public class DeployVRE extends Thread{
};
vreManagerHandler.clearState();
vreManagerHandler.relatedGhnId=ghnId;
vreManagerHandler.setHandled(new GCUBEServiceClientImpl());
vreManagerHandler.setParameter(new Couple<List<String>, String>(ghnList,this.resourceId));
vreManagerHandler.scope=GCUBEScope.getScope(this.startingScope+"/"+this.vreName);

View File

@ -24,6 +24,7 @@ public abstract class VREManagerServiceHandler<T, P> extends GCUBEServiceHandler
private P parameter;
public GCUBEScope scope= ServiceContext.getContext().getScope();
public String relatedGhnId= null;
public T getReturnValue(){
return returnValue;
@ -48,7 +49,7 @@ public abstract class VREManagerServiceHandler<T, P> extends GCUBEServiceHandler
try{
ISClient client = GHNContext.getImplementation(ISClient.class);
GCUBERIQuery query = client.getQuery(GCUBERIQuery.class);
query.addAtomicConditions(new AtomicCondition("//ServiceName", "VREManager"));
query.apublic String relatedGhnId;ddAtomicConditions(new AtomicCondition("//ServiceName", "VREManager"));
List<EndpointReferenceType> eprs = new ArrayList<EndpointReferenceType>();
for (GCUBERunningInstance instance : client.execute(query, scope))
eprs.add(instance.getAccessPoint().getEndpoint("gcube/vremanagement/VREManager"));