From 1fb4562a4554852c23bcd3a9043fb30963888744 Mon Sep 17 00:00:00 2001 From: Lucio Lelii Date: Fri, 29 Oct 2010 17:36:10 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/VREModeler@30284 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 2 +- schema/ModelerService.wsdl | 48 +++++++++- .../consumers/CollectionConsumer.java | 6 +- .../impl/ModelerPersistenceDelegate.java | 2 + .../vremodeler/impl/ModelerResource.java | 26 +++++- .../vremodeler/impl/ModelerService.java | 93 +++++++++++++------ .../{DeployVRE.java => DeployVREonGHNs.java} | 4 +- .../vremodeler/impl/util/Util.java | 4 +- .../resources/handlers/CollectionHandler.java | 5 +- .../resources/handlers/GHNHandler.java | 1 - .../handlers/RunningInstancesHandler.java | 2 - 11 files changed, 148 insertions(+), 45 deletions(-) rename src/org/gcube/vremanagement/vremodeler/impl/thread/{DeployVRE.java => DeployVREonGHNs.java} (99%) diff --git a/.classpath b/.classpath index 7fae30d..d29d7d9 100644 --- a/.classpath +++ b/.classpath @@ -2,7 +2,7 @@ - + diff --git a/schema/ModelerService.wsdl b/schema/ModelerService.wsdl index f37f2b4..ac4fd60 100644 --- a/schema/ModelerService.wsdl +++ b/schema/ModelerService.wsdl @@ -126,6 +126,9 @@ + + + @@ -137,6 +140,14 @@ + + + + + + + + @@ -221,6 +232,19 @@ + + + + + + + + + + + + + @@ -264,6 +288,13 @@ + + + + + + + @@ -312,9 +343,17 @@ + + + + + - - + + + + + @@ -355,6 +394,11 @@ + + + + + diff --git a/src/org/gcube/vremanagement/vremodeler/consumers/CollectionConsumer.java b/src/org/gcube/vremanagement/vremodeler/consumers/CollectionConsumer.java index 9b2baae..b5397e8 100644 --- a/src/org/gcube/vremanagement/vremodeler/consumers/CollectionConsumer.java +++ b/src/org/gcube/vremanagement/vremodeler/consumers/CollectionConsumer.java @@ -26,14 +26,14 @@ public class CollectionConsumer extends BaseNotificationConsumer{ public void onNotificationReceived(NotificationEvent event){ try{ - logger.trace("notificetion received"); + logger.trace("notification received"); ServiceContext.getContext().setScope(this.scope); String id= event.getPayload().getMessage()[0].getChildNodes().item(0).getChildNodes().item(0).getNodeValue(); String profile=event.getPayload().getMessage()[0].getChildNodes().item(1).getChildNodes().item(0).getNodeValue(); String operation=event.getPayload().getMessage()[0].getChildNodes().item(2).getChildNodes().item(0).getNodeValue(); - + if (operation.compareTo("create")==0){ - logger.trace("adding a new GHN in DB"); + logger.trace("adding a new Collection in DB"); GCUBECollection collection= GHNContext.getImplementation(GCUBECollection.class); collection.load(new StringReader(profile)); new CollectionHandler().add(collection); diff --git a/src/org/gcube/vremanagement/vremodeler/impl/ModelerPersistenceDelegate.java b/src/org/gcube/vremanagement/vremodeler/impl/ModelerPersistenceDelegate.java index 7c8e011..7d74d8f 100644 --- a/src/org/gcube/vremanagement/vremodeler/impl/ModelerPersistenceDelegate.java +++ b/src/org/gcube/vremanagement/vremodeler/impl/ModelerPersistenceDelegate.java @@ -14,6 +14,7 @@ public class ModelerPersistenceDelegate extends GCUBEWSFilePersistenceDelegate relatedGHN=new ArrayList(); try{ @@ -123,13 +127,18 @@ public class ModelerService { /** - * Set the selected DHN + * Set the GHNs for deploying * - * @param request array of GHN id + * @param request array of GHNs ids * @return VoidType - - * @throws RemoteException - + * @throws GCUBEFault - if the clud is selected as Architecture or something fails on db */ public void setGHNs(GHNArray request) throws GCUBEFault{ + try { + if (getResource().isUseCloud()) throw new GCUBEFault("deploy on cloud is selected, the ghns cannot be set"); + } catch (ResourceException e1) { + throw new GCUBEFault(e1); + } try{ String instanceID=(String) getResource().getId(); DBInterface.ExecuteUpdate("DELETE FROM VRERELATEDGHN WHERE VRERELATEDGHN.vreid='"+instanceID+"';"); @@ -161,7 +170,7 @@ public class ModelerService { * * @param request void * @return the collection retrieved from the database - * @throws RemoteException - + * @throws GCUBEFault - */ public CollectionList getCollection(VOID var) throws GCUBEFault{ ResultSet res; @@ -190,7 +199,7 @@ public class ModelerService { * * @param request An Array that contains the selected collections ids * @return void - * @throws RemoteException - + * @throws GCUBEFault - */ public void setCollection(CollectionArray request) throws GCUBEFault{ try{ @@ -225,8 +234,8 @@ public class ModelerService { * Return the possibles metadata format for selected collection * * @param request void - * @return a XML format string - * @throws RemoteException - + * @return a list of MetadataFormat + * @throws GCUBEFault - */ public MetadataFormatResponse getMetadataRelatedToCollection(VOID var) throws GCUBEFault { @@ -285,7 +294,7 @@ public class ModelerService { * * @param request * @return void - * @throws RemoteException - + * @throws GCUBEFault - */ public void setMetadataRelatedToCollection(SetMDFormatArgs request) throws GCUBEFault { try{ @@ -323,7 +332,7 @@ public class ModelerService { * * @param request void * @return an xml String containing selectable functionalities - * @throws RemoteException - + * @throws GCUBEFault - */ public FunctionalityList getFunctionality(VOID var) throws GCUBEFault { @@ -356,7 +365,7 @@ public class ModelerService { * * * @return void - * @throws RemoteException - + * @throws GCUBEFault - */ public void setFunctionality(FunctionalityIDArray request) throws GCUBEFault { logger.trace("Set Functionality called"); @@ -409,7 +418,7 @@ public class ModelerService { * * @param request void * @return a XML format String - * @throws RemoteException - + * @throws GCUBEFault - */ public String getQuality(VOID var) throws GCUBEFault{ return Util.prepareQualityXML(); @@ -420,10 +429,10 @@ public class ModelerService { * Sets Quality parameters * * @param request - * @throws RemoteException - + * @throws GCUBEFault - */ public void setQuality(String request) throws GCUBEFault{ - + //TODO } /** @@ -432,7 +441,7 @@ public class ModelerService { * * @param request * @return - * @throws RemoteException - + * @throws GCUBEFault - */ public void setVREtoPendingState(VOID var) throws GCUBEFault{ try{ @@ -445,12 +454,14 @@ public class ModelerService { * * @param request * @return - * @throws RemoteException - + * @throws GCUBEFault - */ public void deployVRE(VOID var) throws GCUBEFault{ String resourceID; + ModelerResource resource; try { - resourceID = getResource().getId(); + resource= getResource(); + resourceID = resource.getId(); } catch (ResourceException e) { logger.error("Error retrieving the Resource Requested",e); throw new GCUBEUnrecoverableFault(e); } @@ -462,20 +473,48 @@ public class ModelerService { throw new GCUBEUnrecoverableFault(e); } - - DeployVRE deployVREThread= new DeployVRE(resourceID, ServiceContext.getContext().getScope() ); - ServiceContext.getContext().setScope(deployVREThread, ServiceContext.getContext().getScope()); - logger.trace("Deploy VRE thread started"); - deployVREThread.start(); - + if (!resource.isUseCloud()){ + DeployVREonGHNs deployVREThread= new DeployVREonGHNs(resourceID, ServiceContext.getContext().getScope() ); + ServiceContext.getContext().setScope(deployVREThread, ServiceContext.getContext().getScope()); + logger.trace("Deploy VRE thread started"); + deployVREThread.start(); + } } - + /** + * + * @param var + * @return + * @throws Exception + */ public CheckStatusResponse checkStatus(VOID var) throws Exception{ CheckStatusResponse res= new CheckStatusResponse(); res.setReports(new String[]{getResource().getFirstReport(), getResource().getSecondReport()}); return res; } + /** + * + * @param request + * @return + * @throws RemoteException - + */ + public void undeployVRE(VOID var) throws GCUBEFault{ + //TODO: implement this method + } + + + /** + * + * @param val boolean + */ + public void setUseCloud(boolean val) throws Exception{ + getResource().setUseCloud(val); + getResource().store(); + } + public boolean isUseCloud() throws Exception{ + return getResource().isUseCloud(); + } + } diff --git a/src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVRE.java b/src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVREonGHNs.java similarity index 99% rename from src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVRE.java rename to src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVREonGHNs.java index f80ab08..76a9d7b 100644 --- a/src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVRE.java +++ b/src/org/gcube/vremanagement/vremodeler/impl/thread/DeployVREonGHNs.java @@ -55,7 +55,7 @@ import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -public class DeployVRE extends Thread{ +public class DeployVREonGHNs extends Thread{ private static GCUBELog logger= new GCUBELog(ModelerService.class); @@ -65,7 +65,7 @@ public class DeployVRE extends Thread{ private String vreName=null; private CollectionResourceCreation collectionResourceCreation; - public DeployVRE(String resourceId, GCUBEScope scope){ + public DeployVREonGHNs(String resourceId, GCUBEScope scope){ this.resourceId=resourceId; this.startingScope= scope; } diff --git a/src/org/gcube/vremanagement/vremodeler/impl/util/Util.java b/src/org/gcube/vremanagement/vremodeler/impl/util/Util.java index 8e4f924..4a551c0 100644 --- a/src/org/gcube/vremanagement/vremodeler/impl/util/Util.java +++ b/src/org/gcube/vremanagement/vremodeler/impl/util/Util.java @@ -89,8 +89,8 @@ public class Util { try{ ResultSet riRes; while (res.next()){ + //controlling all the RIs on the GHN riRes= DBInterface.queryDB("select RI.id, RI.name, RI.class from RUNNINGINSTANCE as RI, GHNRELATEDRI as REL where REL.GHNID='"+res.getString("ID")+"' and REL.RIID=RI.ID"); - int risNum=0; List riList= new ArrayList(); while (riRes.next()){ @@ -98,9 +98,11 @@ public class Util { risNum++; riList.add(new RunningInstance(riRes.getString(3),riRes.getString(2))); } + GHNType ghn= new GHNType(); ghn.setId(res.getString(1)); ghn.setSelectable(!(risNum>0)); + ghn.setSelected(relatedGHNs.contains(res.getString(1))); ghn.setVreManagerUse(candidateGHN.compareTo(res.getString("ID"))==0); ghn.setHost(res.getString(2)); ghn.setSecurity(res.getString(3)); diff --git a/src/org/gcube/vremanagement/vremodeler/resources/handlers/CollectionHandler.java b/src/org/gcube/vremanagement/vremodeler/resources/handlers/CollectionHandler.java index 836c3fc..560f9dc 100644 --- a/src/org/gcube/vremanagement/vremodeler/resources/handlers/CollectionHandler.java +++ b/src/org/gcube/vremanagement/vremodeler/resources/handlers/CollectionHandler.java @@ -32,15 +32,16 @@ public class CollectionHandler implements ResourceHandler { ISClient client= GHNContext.getImplementation(ISClient.class); GCUBECollectionQuery query=client.getQuery(GCUBECollectionQuery.class); query.addAtomicConditions(new AtomicCondition("/Profile/IsUserCollection/@value","true")); - List collectionList= client.execute(client.getQuery(GCUBECollectionQuery.class), ServiceContext.getContext().getScope()); + List collectionList= client.execute(query, ServiceContext.getContext().getScope()); for (GCUBECollection collection:collectionList) try{ insert(collection); - }catch(Exception e){logger.error("error insertin values in "+tableName, e);} + }catch(Exception e){logger.error("error inserting values in "+tableName, e);} } private void insert(GCUBECollection collection) throws Exception { + if (!collection.isUserCollection()) return; ArrayList row= new ArrayList(6); row.add(collection.getID()); row.add(collection.getName()); diff --git a/src/org/gcube/vremanagement/vremodeler/resources/handlers/GHNHandler.java b/src/org/gcube/vremanagement/vremodeler/resources/handlers/GHNHandler.java index ff7213f..6a54f58 100644 --- a/src/org/gcube/vremanagement/vremodeler/resources/handlers/GHNHandler.java +++ b/src/org/gcube/vremanagement/vremodeler/resources/handlers/GHNHandler.java @@ -11,7 +11,6 @@ import org.gcube.common.core.resources.GCUBEHostingNode; import org.gcube.common.core.utils.logging.GCUBELog; import org.gcube.vremanagement.vremodeler.db.DBInterface; import org.gcube.vremanagement.vremodeler.impl.ServiceContext; -import org.gcube.vremanagement.vremodeler.resources.GhnRiRelationObject; public class GHNHandler implements ResourceHandler { diff --git a/src/org/gcube/vremanagement/vremodeler/resources/handlers/RunningInstancesHandler.java b/src/org/gcube/vremanagement/vremodeler/resources/handlers/RunningInstancesHandler.java index aebe676..3dc4e67 100644 --- a/src/org/gcube/vremanagement/vremodeler/resources/handlers/RunningInstancesHandler.java +++ b/src/org/gcube/vremanagement/vremodeler/resources/handlers/RunningInstancesHandler.java @@ -30,8 +30,6 @@ public class RunningInstancesHandler implements ResourceHandler