git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/VREModeler@20236 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8082125adb
commit
e3741bceea
7
README
7
README
|
@ -21,8 +21,6 @@ v. 1.0.0 (17-10-2008)
|
|||
* First release
|
||||
|
||||
v. 1.2.0 (14-05-2010)
|
||||
* ticket #211: ResourceManager integration
|
||||
* stubs modified
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
@ -34,15 +32,12 @@ The VREModeler allows the user to create a new VRE
|
|||
Source code is available from SVN:
|
||||
http://svn.d4science.research-infrastructures.eu/gcube/trunk/vremanager/VREModeler
|
||||
|
||||
Binaries can be downloaded from:
|
||||
http://diligent.di.uoa.gr/distributionSite/index.html
|
||||
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
Documentation is available on-line from the Projects Documentation Wiki:
|
||||
|
||||
https://technical.wiki.d4science.research-infrastructures.eu/documentation/index.php
|
||||
https://gcube.wiki.gcube-system.org/gcube/index.php/VRE_Modeler
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -47,23 +47,6 @@
|
|||
type="java.lang.String"
|
||||
override="false"/>
|
||||
|
||||
<resource name="publicationProfile" type="org.gcube.common.core.state.GCUBEPublicationProfile">
|
||||
<resourceParams>
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>org.globus.wsrf.jndi.BeanFactory</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>mode</name>
|
||||
<value>pull</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>fileName</name>
|
||||
<value>registration.xml</value>
|
||||
</parameter>
|
||||
</resourceParams>
|
||||
</resource>
|
||||
|
||||
<resource name="home" type="org.gcube.vremanagement.vremodeler.impl.ModelerHome">
|
||||
<resourceParams>
|
||||
<parameter>
|
||||
|
|
|
@ -24,17 +24,6 @@
|
|||
<Scope level="GHN"/>
|
||||
<Optional>false</Optional>
|
||||
</Dependency>
|
||||
<Dependency>
|
||||
<Service>
|
||||
<Class>VREManagement</Class>
|
||||
<Name>VREManager</Name>
|
||||
<Version>1.0.0</Version>
|
||||
</Service>
|
||||
<Package>VREManager-stubs</Package>
|
||||
<Version>[1.02.00,1.03.00)</Version>
|
||||
<Scope level="GHN"/>
|
||||
<Optional>false</Optional>
|
||||
</Dependency>
|
||||
<Dependency>
|
||||
<Service>
|
||||
<Class>ExternalSoftware</Class>
|
||||
|
|
|
@ -45,9 +45,13 @@
|
|||
|
||||
<xsd:element name="removeVRERequestMessage" type="xsd:string"/>
|
||||
|
||||
|
||||
<xsd:element name="removeVREResponseMessage" type="coretypes:VOID"/>
|
||||
|
||||
<xsd:element name="getEPRbyIdRequestMessage" type="xsd:string"/>
|
||||
|
||||
<xsd:element name="getEPRbyIdResponseMessage" type="wsa:EndpointReferenceType"/>
|
||||
|
||||
|
||||
<xsd:element name="getExistingNamesResponseMessage">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
|
@ -98,6 +102,12 @@
|
|||
<message name="GetExistingNamesOutputMessage">
|
||||
<part name="response" element="tns:getExistingNamesResponseMessage"/>
|
||||
</message>
|
||||
<message name="GetEPRbyIdInputMessage">
|
||||
<part name="request" element="tns:getEPRbyIdRequestMessage"/>
|
||||
</message>
|
||||
<message name="GetEPRbyIdOutputMessage">
|
||||
<part name="response" element="tns:getEPRbyIdResponseMessage"/>
|
||||
</message>
|
||||
|
||||
<!--============================================================
|
||||
|
||||
|
@ -129,6 +139,12 @@
|
|||
<input message="tns:RemoveVREInputMessage"/>
|
||||
<output message="tns:RemoveVREOutputMessage"/>
|
||||
</operation>
|
||||
|
||||
<operation name="getEPRbyId">
|
||||
<input message="tns:GetEPRbyIdInputMessage"/>
|
||||
<output message="tns:GetEPRbyIdOutputMessage"/>
|
||||
</operation>
|
||||
|
||||
</portType>
|
||||
|
||||
|
||||
|
|
|
@ -15,9 +15,6 @@ import org.gcube.vremanagement.vremodeler.stubs.Report;
|
|||
import org.gcube.vremanagement.vremodeler.stubs.ReportList;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class ModelFactoryService{
|
||||
|
||||
private GCUBELog logger = new GCUBELog(ModelFactoryService.class);
|
||||
|
@ -141,6 +138,22 @@ public class ModelFactoryService{
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws GCUBEFault
|
||||
*/
|
||||
public EndpointReferenceType getEPRbyId(String id) throws GCUBEFault{
|
||||
ModelerContext pctx= ModelerContext.getPortTypeContext();
|
||||
try {
|
||||
return pctx.getWSHome().find(pctx.makeKey(id)).getEPR();
|
||||
} catch (Exception e) {
|
||||
logger.error("resource with id "+id+" not found",e);
|
||||
throw new GCUBEFault(e,"resource with id "+id+" not found");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@ package org.gcube.vremanagement.vremodeler.impl;
|
|||
|
||||
import java.net.URI;
|
||||
import java.rmi.RemoteException;
|
||||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import org.gcube.common.core.faults.GCUBEFault;
|
||||
|
@ -53,23 +53,20 @@ public class ModelerService {
|
|||
*/
|
||||
public void setDescription(VREDescription request) throws GCUBEFault{
|
||||
|
||||
Calendar dateFrom=null, dateTo=null;
|
||||
Date dateFrom=null, dateTo=null;
|
||||
ResultSet res=null;
|
||||
try {
|
||||
res=DBInterface.queryDB("select * from VRE where VRE.id='"+getResource().getId()+"'; ");
|
||||
|
||||
dateFrom=new Date(request.getStartTime().getTimeInMillis());
|
||||
dateTo=new Date(request.getEndTime().getTimeInMillis());
|
||||
if(res.next())
|
||||
{
|
||||
dateFrom=request.getStartTime();
|
||||
dateTo=request.getEndTime();
|
||||
DBInterface.queryDB("update VRE set name='"+request.getName()+"', description='"+request.getDescription()+"', vredesigner='"+request.getDesigner()+"', vremanager= '"+request.getManager()+"', intervalfrom='"+dateFrom.getTime()+"', intervalto='"+dateTo.getTime()+"' where VRE.id='"+getResource().getId()+"'; ");
|
||||
}else{
|
||||
dateFrom=request.getStartTime();
|
||||
dateTo=request.getEndTime();
|
||||
DBInterface.ExecuteUpdate("insert into VRE values('"+getResource().getId()+"','"+request.getName()+"','"+request.getDescription()+"','"+request.getDesigner()+"','"+request.getManager()+"','"+dateFrom+"','"+dateTo+"','"+VREState.IN_PROGRESS+"'); ");
|
||||
DBInterface.queryDB("update VRE set name='"+request.getName()+"', description='"+request.getDescription()+"', vredesigner='"+request.getDesigner()+"', vremanager= '"+request.getManager()+"', intervalfrom='"+dateFrom+"', intervalto='"+dateTo+"' where VRE.id='"+getResource().getId()+"'; ");
|
||||
else{
|
||||
logger.debug("insert into VRE values('"+getResource().getId()+"','"+request.getName()+"','"+request.getDescription()+"','"+request.getDesigner()+"','"+request.getManager()+"','"+dateFrom+"','"+dateTo+"','"+VREState.IN_PROGRESS.getValue()+"'); ");
|
||||
DBInterface.ExecuteUpdate("insert into VRE values('"+getResource().getId()+"','"+request.getName()+"','"+request.getDescription()+"','"+request.getDesigner()+"','"+request.getManager()+"','"+dateFrom+"','"+dateTo+"','"+VREState.IN_PROGRESS.getValue()+"'); ");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
logger.error("an error occurs setting the VRE Description",e);
|
||||
throw new GCUBEFault(e);
|
||||
}
|
||||
|
||||
|
@ -146,7 +143,7 @@ public class ModelerService {
|
|||
row= new ArrayList<String>(3);
|
||||
row.add(dlKey);
|
||||
row.add(ghnId);
|
||||
if (request.getCandidateGHN().compareTo(ghnId)==0) row.add("true");
|
||||
if (request.getCandidateGHN()!=null && request.getCandidateGHN().compareTo(ghnId)==0) row.add("true");
|
||||
else row.add("false");
|
||||
values.add(row.toArray(new String[3]));
|
||||
}
|
||||
|
@ -155,7 +152,6 @@ public class ModelerService {
|
|||
}catch(Exception e){
|
||||
logger.error("error setting GHNs ",e);
|
||||
throw new GCUBEFault(e);}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ import org.gcube.vremanagement.vremodeler.db.DBInterface;
|
|||
import org.gcube.vremanagement.vremodeler.impl.ModelerContext;
|
||||
import org.gcube.vremanagement.vremodeler.impl.ModelerResource;
|
||||
import org.gcube.vremanagement.vremodeler.impl.ModelerService;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.Couple;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.VREManagerServiceHandler;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.Pair;
|
||||
import org.gcube.vremanagement.vremodeler.impl.util.ResourceManagerServiceHandler;
|
||||
import org.gcube.vremanagement.vremodeler.portallayout.CollectionResourceCreation;
|
||||
import org.gcube.vremanagement.vremodeler.portallayout.GenericResourcePortlet;
|
||||
import org.gcube.vremanagement.vremodeler.portallayout.LayoutCreation;
|
||||
|
@ -65,19 +65,27 @@ public class DeployVRE extends Thread{
|
|||
return wsResource;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void run() {
|
||||
try {
|
||||
ResultSet resRelatedGHN=DBInterface.queryDB("select VRERELATEDGHN.ghnid, GHN.domain, VRERELATEDGHN.ISCANDIDATE from VRERELATEDGHN, GHN where GHN.id=VRERELATEDGHN.ghnid and VRERELATEDGHN.vreid='"+this.resourceId+"' ORDER BY GHN.host; ");
|
||||
|
||||
List<Couple<String, String>> GHNList= new ArrayList<Couple<String, String>>();
|
||||
List<Pair<String, String>> GHNList= new ArrayList<Pair<String, String>>();
|
||||
String candidateGHN=null;
|
||||
boolean isCandidatePresent=false;
|
||||
while (resRelatedGHN.next()) {
|
||||
if(resRelatedGHN.getBoolean(3))
|
||||
if(resRelatedGHN.getBoolean(3)){
|
||||
candidateGHN=resRelatedGHN.getString(1);
|
||||
else GHNList.add(new Couple<String, String>(resRelatedGHN.getString(1),resRelatedGHN.getString(2)));
|
||||
|
||||
isCandidatePresent= true;
|
||||
}else GHNList.add(new Pair<String, String>(resRelatedGHN.getString(1),resRelatedGHN.getString(2)));
|
||||
}
|
||||
if (GHNList.size()<2){
|
||||
|
||||
if (!(GHNList.size()>=2 || (GHNList.size()==1 && isCandidatePresent))){
|
||||
getResource().setFirstReport(VREState.FAILED.getValue()+": wrong ghn definition");
|
||||
getResource().store();
|
||||
logger.info("Deploying of the VRE with id "+this.resourceId+" FAILED for wrong ghn definition");
|
||||
throw new Exception("No ghn Selected (at least 2 GHNs have to be selected)");
|
||||
}
|
||||
|
||||
|
@ -85,7 +93,7 @@ public class DeployVRE extends Thread{
|
|||
if (!deployManagerOnVRE(GHNList, candidateGHN)){
|
||||
//transforming the Pair<String, String> to a ghnid List<String>
|
||||
List<String> ghnEpuredList = new ArrayList<String>();
|
||||
for (Couple<String, String> cpl: GHNList) ghnEpuredList.add(cpl.first);
|
||||
for (Pair<String, String> cpl: GHNList) ghnEpuredList.add(cpl.first);
|
||||
|
||||
if (!createVRE(ghnEpuredList)){
|
||||
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='"+VREState.DEPLOYED+"' WHERE VRE.id='"+this.resourceId+"';");
|
||||
|
@ -93,10 +101,11 @@ public class DeployVRE extends Thread{
|
|||
}
|
||||
else{
|
||||
logger.info("Deploying of the VRE with id "+this.resourceId+" FAILED on second step");
|
||||
getResource().setSecondReport(VREState.FAILED.getValue());
|
||||
throw new Exception("Error Deployng the VRE failed on second step");
|
||||
}
|
||||
}else{
|
||||
getResource().setSecondReport(VREState.FAILED.getValue());
|
||||
getResource().setFirstReport(VREState.FAILED.getValue());
|
||||
getResource().store();
|
||||
logger.info("Deploying of the VRE with id "+this.resourceId+" FAILED on first step");
|
||||
throw new Exception("Error Deployng the VRE filed on first step");
|
||||
|
@ -113,7 +122,7 @@ public class DeployVRE extends Thread{
|
|||
}
|
||||
|
||||
|
||||
private boolean deployManagerOnVRE(List<Couple<String, String>> ghnList, String candidateGHN) throws GCUBEFault{
|
||||
private boolean deployManagerOnVRE(List<Pair<String, String>> ghnList, String candidateGHN) throws GCUBEFault{
|
||||
String vreName= null;
|
||||
try {
|
||||
DBInterface.ExecuteUpdate("UPDATE VRE SET STATUS='Deploying' WHERE VRE.id='"+this.resourceId+"';");
|
||||
|
@ -122,13 +131,12 @@ public class DeployVRE extends Thread{
|
|||
throw new GCUBEFault("The VRE with ID "+this.resourceId+" cannot be retrieved on the DB");
|
||||
}
|
||||
vreName= resGenericInfo.getString(1);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("HSQLDB Error "+e);
|
||||
throw new GCUBEFault(e);
|
||||
}
|
||||
|
||||
VREManagerServiceHandler<Boolean, Object[]> vreManagerHandler= new VREManagerServiceHandler<Boolean,Object[]>(){
|
||||
ResourceManagerServiceHandler<Boolean, Object[]> resourceManagerHandler= new ResourceManagerServiceHandler<Boolean,Object[]>(){
|
||||
|
||||
@SuppressWarnings({ "static-access", "unchecked" })
|
||||
@Override
|
||||
|
@ -138,7 +146,7 @@ public class DeployVRE extends Thread{
|
|||
try{
|
||||
|
||||
String vreName=(String) this.getParameter()[0];
|
||||
List<Couple<String, String>> ghnList= (List<Couple<String, String>>) this.getParameter()[1];
|
||||
List<Pair<String, String>> ghnList= (List<Pair<String, String>>) this.getParameter()[1];
|
||||
String candidateGHN=(String) this.getParameter()[2];
|
||||
|
||||
AddResourcesParameters arp= new AddResourcesParameters();
|
||||
|
@ -146,21 +154,21 @@ public class DeployVRE extends Thread{
|
|||
ServiceItem[] service= new ServiceItem[1];
|
||||
service[0]=new ServiceItem();
|
||||
service[0].setServiceClass("VREManagement");
|
||||
service[0].setServiceName("VREManager");
|
||||
service[0].setServiceName("ResourceManager");
|
||||
service[0].setServiceVersion("1.00.00");
|
||||
services.setService(service);
|
||||
|
||||
//preparing the GHN where will be deployed the VREManager
|
||||
if (candidateGHN==null){
|
||||
Couple<String, String> ghnId=null;
|
||||
for (Couple<String, String> cpl: ghnList){
|
||||
Pair<String, String> ghnId=null;
|
||||
for (Pair<String, String> cpl: ghnList){
|
||||
if (this.usedhost.contains(cpl.second)){
|
||||
ghnId=cpl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ghnId==null) ghnId=ghnList.get(0);
|
||||
logger.debug("deploying the VREManager for the vre on "+ ghnId.second);
|
||||
logger.debug("deploying the ResourceManager for the vre on "+ ghnId.second);
|
||||
services.setGHN(new String[]{ghnId.first});
|
||||
ghnList.remove(ghnId);
|
||||
}else services.setGHN(new String[]{candidateGHN});
|
||||
|
@ -185,20 +193,20 @@ public class DeployVRE extends Thread{
|
|||
}
|
||||
};
|
||||
|
||||
vreManagerHandler.clearBlackboard();
|
||||
vreManagerHandler.setHandled(new GCUBEServiceClientImpl());
|
||||
vreManagerHandler.setParameter(new Object[]{vreName,ghnList,candidateGHN});
|
||||
vreManagerHandler.scope=this.startingScope;
|
||||
resourceManagerHandler.clearBlackboard();
|
||||
resourceManagerHandler.setHandled(new GCUBEServiceClientImpl());
|
||||
resourceManagerHandler.setParameter(new Object[]{vreName,ghnList,candidateGHN});
|
||||
resourceManagerHandler.scope=this.startingScope;
|
||||
|
||||
try {
|
||||
vreManagerHandler.run();
|
||||
resourceManagerHandler.run();
|
||||
} catch (Exception e) {
|
||||
logger.error("DeployingVRE step 1 -- failed "+e);
|
||||
return false;
|
||||
}
|
||||
this.vreName= vreName;
|
||||
collectionResourceCreation= new CollectionResourceCreation(this.resourceId, this.vreName);
|
||||
return vreManagerHandler.getReturnValue();
|
||||
return resourceManagerHandler.getReturnValue();
|
||||
}
|
||||
|
||||
|
||||
|
@ -207,7 +215,7 @@ public class DeployVRE extends Thread{
|
|||
|
||||
|
||||
private boolean createVRE(List<String> ghnList) throws GCUBEFault{
|
||||
VREManagerServiceHandler<Boolean, Couple<List<String>, String>> vreManagerHandler= new VREManagerServiceHandler<Boolean,Couple<List<String>, String>>(){
|
||||
ResourceManagerServiceHandler<Boolean, Pair<List<String>, String>> vreManagerHandler= new ResourceManagerServiceHandler<Boolean,Pair<List<String>, String>>(){
|
||||
|
||||
//the parameter is resourceID
|
||||
@SuppressWarnings("static-access")
|
||||
|
@ -351,7 +359,8 @@ public class DeployVRE extends Thread{
|
|||
arp.setServices(serviceList);
|
||||
|
||||
scopeParameter.setAddResourcesParameters(arp);
|
||||
scopeParameter.setName(this.scope+"/"+vreName);
|
||||
scopeParameter.setName(this.scope.toString());
|
||||
|
||||
String report= "ok";
|
||||
String reportId=rmPortType.createScope(scopeParameter);
|
||||
|
||||
|
@ -373,7 +382,7 @@ public class DeployVRE extends Thread{
|
|||
|
||||
vreManagerHandler.clearBlackboard();
|
||||
vreManagerHandler.setHandled(new GCUBEServiceClientImpl());
|
||||
vreManagerHandler.setParameter(new Couple<List<String>, String>(ghnList,this.resourceId));
|
||||
vreManagerHandler.setParameter(new Pair<List<String>, String>(ghnList,this.resourceId));
|
||||
vreManagerHandler.scope=GCUBEScope.getScope(this.startingScope+"/"+this.vreName);
|
||||
try {
|
||||
vreManagerHandler.run();
|
||||
|
|
|
@ -5,12 +5,12 @@ package org.gcube.vremanagement.vremodeler.impl.util;
|
|||
* @author lucio
|
||||
*
|
||||
*/
|
||||
public class Couple<F,S>{
|
||||
public class Pair<F,S>{
|
||||
|
||||
public F first;
|
||||
public S second;
|
||||
|
||||
public Couple(F first, S second){
|
||||
public Pair(F first, S second){
|
||||
this.first=first;
|
||||
this.second= second;
|
||||
}
|
|
@ -16,7 +16,7 @@ import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceMan
|
|||
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
|
||||
import org.gcube.vremanagement.vremodeler.impl.ServiceContext;
|
||||
|
||||
public abstract class VREManagerServiceHandler<T, P> extends GCUBEServiceHandler<GCUBEServiceClient> {
|
||||
public abstract class ResourceManagerServiceHandler<T, P> extends GCUBEServiceHandler<GCUBEServiceClient> {
|
||||
|
||||
private T returnValue;
|
||||
|
||||
|
@ -53,13 +53,13 @@ public abstract class VREManagerServiceHandler<T, P> extends GCUBEServiceHandler
|
|||
query.setExpression("declare namespace is = 'http://gcube-system.org/namespaces/informationsystem/registry';" +
|
||||
" for $outer in collection(\"/db/Profiles/RunningInstance\")//Document/Data/is:Profile/Resource " +
|
||||
" let $scope:= $outer/Scopes/Scope[string() eq '"+scope.toString()+"'] " +
|
||||
" where count($scope)>0 and $outer/Profile/ServiceName/string() eq 'VREManager'" +
|
||||
" and $outer/Profile/ServiceName/string() eq 'VREManager' " +
|
||||
" where count($scope)>0 " +
|
||||
" and $outer/Profile/ServiceName/string() eq 'ResourceManager' " +
|
||||
" return $outer");
|
||||
|
||||
List<EndpointReferenceType> eprs = new ArrayList<EndpointReferenceType>();
|
||||
for (GCUBERunningInstance instance : client.execute(query, scope))
|
||||
eprs.add(instance.getAccessPoint().getEndpoint("gcube/vremanagement/VREManager"));
|
||||
eprs.add(instance.getAccessPoint().getEndpoint("gcube/vremanagement/ResourceManager"));
|
||||
return eprs;
|
||||
}catch(Exception e){logger.error(e); throw e;}
|
||||
}
|
|
@ -335,10 +335,10 @@ public class Util {
|
|||
* @param text the text to add at the element
|
||||
* @return the result element
|
||||
*/
|
||||
public static Element createTextElement(Document doc, String tag, String text, Couple<String, String> ... attributes ){
|
||||
public static Element createTextElement(Document doc, String tag, String text, Pair<String, String> ... attributes ){
|
||||
Element returnEl= doc.createElement(tag);
|
||||
if (attributes!=null){
|
||||
for (Couple<String, String> attribute : attributes){
|
||||
for (Pair<String, String> attribute : attributes){
|
||||
returnEl.setAttribute(attribute.first, attribute.second);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ public class VREModelerInitializer {
|
|||
ModelerFactoryPortType mfptp= mfal.getModelerFactoryPortTypePort(epr);
|
||||
|
||||
mfptp = GCUBERemotePortTypeContext.getProxy(mfptp, GCUBEScope.getScope(args[0]));
|
||||
|
||||
mfptp.initDB(new VOID());
|
||||
}catch (Exception e){e.printStackTrace();}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue