git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/ResourceManager@18897 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ad7dfe054e
commit
f4856b8fe8
Binary file not shown.
|
@ -107,12 +107,24 @@ public class ResourceManager extends GCUBEPortType {
|
|||
}
|
||||
}
|
||||
|
||||
public void disposeScope(DisposeScopeParameters params) {
|
||||
public void disposeScope(DisposeScopeParameters params) throws GCUBEFault {
|
||||
logger.info("Dispose Scope invoked... the entire scope is going to be thrown away!!");
|
||||
try {
|
||||
ResourceReport report = new ResourceReport(UUIDGenFactory.getUUIDGen().nextUUID(), this.getResource().getManagedScope());
|
||||
this.getResource().addReport(report);
|
||||
//new RemoveResourcesOperator(new OperatorConfig(report, this.getResource().getResourceList(), this.getResource().getManagedScope()),resourceList).run();
|
||||
} catch (NoSuchResourceException e) {
|
||||
logger.error("No resource found for this scope", e);
|
||||
throw ServiceContext.getContext().getDefaultException("No resource found for this scope", e).toFault();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void createScope(CreateScopeParameters params) {
|
||||
public void createScope(CreateScopeParameters params) throws GCUBEFault {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
package org.gcube.vremanagement.resourcemanager.impl.deployment;
|
||||
|
||||
import java.util.List;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceItem;
|
||||
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceList;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.ResolvedService;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.Service;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.VirtualNodeManager;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.VirtualNodeManager.NoGHNFoundException;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.operators.OperatorConfig;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.operators.Operator;
|
||||
|
||||
/**
|
||||
* A Deployer Operator that contacts the Deployer Services on the target nodes asking for the package deployment
|
||||
*
|
||||
* @author Manuele Simi (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class DeployServiceOperator extends Operator {
|
||||
|
||||
/** Object logger */
|
||||
protected final GCUBELog logger=new GCUBELog(this);
|
||||
|
||||
private ServiceList services;
|
||||
|
||||
private OperatorConfig configuration;
|
||||
|
||||
public DeployServiceOperator(OperatorConfig configuration, ServiceList services) {
|
||||
this.services = services;
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public void exec() throws Exception {
|
||||
|
||||
SoftwareRepositoryRequest request = new SoftwareRepositoryRequest();
|
||||
|
||||
//resolving the list of packages for each service
|
||||
for (ServiceItem serviceitem : services.getService())
|
||||
request.addService(Service.fromServiceItem(serviceitem));
|
||||
List<ResolvedService> resolved = request.send();
|
||||
this.configuration.report.save();
|
||||
//sanity check: do we get the same list passed as input?
|
||||
if ( (resolved == null) || (resolved.size() != services.getService().length)) {
|
||||
logger.error("Unable to understand the list of deps for the given service(s): input services #" +services.getService().length + ", resolved services #" + resolved.size());
|
||||
logger.trace("RESOLVED: " + resolved);
|
||||
logger.trace("REQUESTED " + services.getService());
|
||||
throw new Exception("invalid list of deps retrieved: input services #" +services.getService().length + ", resolved services #" + resolved.size());
|
||||
}
|
||||
|
||||
//deploy the packages
|
||||
VirtualNodeManager drequest = new VirtualNodeManager(this.configuration.report.getId(), this.configuration.scope);
|
||||
drequest.setTargetGHNs(services.getGHN());
|
||||
for (ResolvedService resolvedService : resolved) {
|
||||
|
||||
if (resolvedService.getMissingDependencies().size() > 0) {//ops, some deps are missing!
|
||||
logger.debug("Missing dependencies for service " + resolvedService.toString());
|
||||
resolvedService.setErrorMessage("The service cannot be deployed due to one or more missing dependencies");
|
||||
} else {
|
||||
try {
|
||||
drequest.addService(resolvedService);
|
||||
} catch (NoGHNFoundException e) {
|
||||
logger.error("Unable to find a valid GHN to target for the deployment of this service: " + resolvedService.getName());
|
||||
resolvedService.setErrorMessage("Unable to find a valid GHN to target for the deployment of this service");
|
||||
}
|
||||
}
|
||||
this.configuration.report.addService(resolvedService);
|
||||
}
|
||||
drequest.send();
|
||||
this.configuration.report.save();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -20,8 +20,8 @@ import org.gcube.common.core.scope.GCUBEScope;
|
|||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.contexts.ServiceContext;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.Dependency;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.ResolvedService;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.Service;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedService;
|
||||
import org.gcube.vremanagement.softwarerepository.stubs.ListScopedPackagesByServiceDataMessage;
|
||||
import org.gcube.vremanagement.softwarerepository.stubs.ListScopedPackagesByServiceDataMessageScope;
|
||||
import org.gcube.vremanagement.softwarerepository.stubs.SoftwareRepositoryPortType;
|
||||
|
@ -35,9 +35,9 @@ import org.kxml2.io.KXmlParser;
|
|||
* @author Manuele Simi (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
class SoftwareRepositoryRequest {
|
||||
public final class SoftwareRepositoryRequest {
|
||||
|
||||
Map<Service, ListScopedPackagesByServiceDataMessage> requests = new HashMap<Service, ListScopedPackagesByServiceDataMessage>();
|
||||
private Map<ScopedDeployedService, ListScopedPackagesByServiceDataMessage> requests = new HashMap<ScopedDeployedService, ListScopedPackagesByServiceDataMessage>();
|
||||
|
||||
protected static final String RESOLVED_DEPS_KEY = "listResolvedDeps";
|
||||
|
||||
|
@ -60,11 +60,11 @@ class SoftwareRepositoryRequest {
|
|||
*
|
||||
* @param service
|
||||
*/
|
||||
protected void addService(Service service) {
|
||||
public void addService(ScopedDeployedService service) {
|
||||
ListScopedPackagesByServiceDataMessage message = new ListScopedPackagesByServiceDataMessage();
|
||||
message.setServiceClass(service.getClazz());
|
||||
message.setServiceName(service.getName());
|
||||
message.setServiceVersion(service.getVersion());
|
||||
message.setServiceClass(service.getSourceService().getClazz());
|
||||
message.setServiceName(service.getSourceService().getName());
|
||||
message.setServiceVersion(service.getSourceService().getVersion());
|
||||
message.setScope(ListScopedPackagesByServiceDataMessageScope.GHN);// look for packages to co-deploy
|
||||
requests.put(service, message);
|
||||
}
|
||||
|
@ -74,10 +74,10 @@ class SoftwareRepositoryRequest {
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected List<ResolvedService> send() throws Exception {
|
||||
List<ResolvedService> service2package = new ArrayList<ResolvedService>();
|
||||
public List<ScopedDeployedService> send() throws Exception {
|
||||
List<ScopedDeployedService> service2package = new ArrayList<ScopedDeployedService>();
|
||||
Map<GCUBEScope, Set<EndpointReferenceType>> eprs = this.findInstances();
|
||||
for (Service service : requests.keySet()) {
|
||||
for (ScopedDeployedService service : requests.keySet()) {
|
||||
ListScopedPackagesByServiceDataMessage message = requests.get(service);
|
||||
logger.trace("Checking deps for " + message.getServiceName());
|
||||
//look for service deps in one of the instances found
|
||||
|
@ -94,9 +94,9 @@ class SoftwareRepositoryRequest {
|
|||
}
|
||||
}
|
||||
// if we are here, no SR instance was able to resolve the dependencies
|
||||
ResolvedService s = new ResolvedService(service);
|
||||
s.setErrorMessage("Unable to check deps for this service in any of the Service Repository instance in scope");
|
||||
service2package.add(s);
|
||||
//ResolvedService s = new ResolvedService(service);
|
||||
service.setErrorMessage("Unable to check deps for this service in any of the Service Repository instance in scope");
|
||||
service2package.add(service);
|
||||
}
|
||||
}
|
||||
return service2package;
|
||||
|
@ -107,8 +107,8 @@ class SoftwareRepositoryRequest {
|
|||
* @param report
|
||||
* @return
|
||||
*/
|
||||
private ResolvedService parseDependenciesReport(Service service, String report) throws Exception {
|
||||
ResolvedService depsMap = new ResolvedService(service);
|
||||
private ScopedDeployedService parseDependenciesReport(ScopedDeployedService service, String report) throws Exception {
|
||||
//ResolvedService depsMap = new ResolvedService(service);
|
||||
KXmlParser parser = new KXmlParser();
|
||||
parser.setInput(new BufferedReader(new StringReader(report)));
|
||||
logger.trace("Parsing: " + report);
|
||||
|
@ -116,8 +116,8 @@ class SoftwareRepositoryRequest {
|
|||
loop: while (true) {
|
||||
switch (parser.next()) {
|
||||
case KXmlParser.START_TAG:
|
||||
if (parser.getName().equals("ResolvedDependencies")) this.parseResolvedDependencies(parser, depsMap.getResolvedDependencies());
|
||||
if (parser.getName().equals("MissingDependencies")) this.parseMissingDependencies(parser, depsMap.getMissingDependencies());
|
||||
if (parser.getName().equals("ResolvedDependencies")) this.parseResolvedDependencies(parser, service.getResolvedDependencies());
|
||||
if (parser.getName().equals("MissingDependencies")) this.parseMissingDependencies(parser, service.getMissingDependencies());
|
||||
break;
|
||||
case KXmlParser.END_DOCUMENT:
|
||||
break loop;
|
||||
|
@ -126,7 +126,7 @@ class SoftwareRepositoryRequest {
|
|||
} catch (Exception e) {
|
||||
logger.error("Unable to parse the deployment report returned by the Software Repository", e);
|
||||
}
|
||||
return depsMap;
|
||||
return service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package org.gcube.vremanagement.resourcemanager.impl.deployment;
|
||||
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.operators.Operator;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.operators.OperatorConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* TODO: manuele, don't forget to comment this class
|
||||
*
|
||||
* @author Manuele Simi (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class UndeployServiceOperator extends Operator {
|
||||
|
||||
protected final GCUBELog logger=new GCUBELog(this);
|
||||
|
||||
private OperatorConfig configuration;
|
||||
|
||||
public UndeployServiceOperator(OperatorConfig configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public void exec() throws Exception {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,11 @@
|
|||
package org.gcube.vremanagement.resourcemanager.impl.deployment.resources;
|
||||
package org.gcube.vremanagement.resourcemanager.impl.deployment;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.axis.message.addressing.Address;
|
||||
import org.apache.axis.message.addressing.EndpointReferenceType;
|
||||
import org.apache.axis.types.URI.MalformedURIException;
|
||||
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.informationsystem.client.AtomicCondition;
|
||||
|
@ -13,9 +16,10 @@ import org.gcube.common.core.utils.logging.GCUBELog;
|
|||
import org.gcube.common.vremanagement.deployer.stubs.common.PackageInfo;
|
||||
import org.gcube.common.vremanagement.deployer.stubs.deployer.DeployParameters;
|
||||
import org.gcube.common.vremanagement.deployer.stubs.deployer.DeployerPortType;
|
||||
import org.gcube.common.vremanagement.deployer.stubs.deployer.UndeployParameters;
|
||||
import org.gcube.common.vremanagement.deployer.stubs.deployer.service.DeployerServiceAddressingLocator;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.contexts.ServiceContext;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.VirtualNodeManager.NoGHNFoundException;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.contexts.StatefulPortTypeContext;
|
||||
|
||||
/**
|
||||
* Models a node with its the packages
|
||||
|
@ -23,38 +27,62 @@ import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.Virtual
|
|||
* @author Manuele Simi (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
class VirtualNode {
|
||||
public class VirtualNode {
|
||||
|
||||
/** Object logger */
|
||||
protected final GCUBELog logger=new GCUBELog(this);
|
||||
|
||||
/**the callback identifier to send to the Deployer*/
|
||||
private String callbackID;
|
||||
|
||||
private String ID = "";
|
||||
private String ghnID = "";
|
||||
|
||||
private String name = "";
|
||||
|
||||
private GCUBEScope scope = null;
|
||||
|
||||
private static Map<String, VirtualNode> nodes = new HashMap<String, VirtualNode>();
|
||||
|
||||
private boolean isWorking = false;
|
||||
|
||||
Set<PackageInfo> packages = new java.util.HashSet<PackageInfo>();
|
||||
|
||||
protected VirtualNode(String ID, GCUBEScope scope, String ... name) throws NoGHNFoundException {
|
||||
this.ID = ID;
|
||||
private VirtualNode(String callbackID, String ID, GCUBEScope scope, String ... name) throws NoGHNFoundException, MalformedURIException {
|
||||
this.ghnID = ID;
|
||||
this.scope = scope;
|
||||
this.name = (name != null && name.length > 0)? name[0] : this.detectName();
|
||||
this.name = (name != null && name.length > 0)? name[0] : this.detectName();
|
||||
this.callbackID = callbackID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets or builds the VirtualNode
|
||||
* @param callback ID the callback identifier to send to the Deployer
|
||||
* @param ID the node identifier
|
||||
* @param scope the deployment scope
|
||||
* @param name
|
||||
* @return the Virtual Node
|
||||
* @throws MalformedURIException
|
||||
* @throws NoGHNFoundException
|
||||
*/
|
||||
public static VirtualNode getNode(String callbackID, String ID, GCUBEScope scope, String ... name) throws MalformedURIException, NoGHNFoundException {
|
||||
if (!nodes.containsKey(ID)) {
|
||||
nodes.put(ID,new VirtualNode(callbackID, ID, scope, name));
|
||||
}
|
||||
return nodes.get(ID);
|
||||
}
|
||||
|
||||
private String detectName() throws NoGHNFoundException {
|
||||
|
||||
if (GHNContext.getContext().getGHNID().compareToIgnoreCase(this.ID) == 0)
|
||||
throw new NoGHNFoundException ("cannot deploy on the same GHN (ID=" + this.ID + ") where the ResourceManager is deployed");
|
||||
if (GHNContext.getContext().getGHNID().compareToIgnoreCase(this.ghnID) == 0)
|
||||
throw new NoGHNFoundException ("cannot deploy on the same GHN (ghnID=" + this.ghnID + ") where the ResourceManager is deployed");
|
||||
try {
|
||||
ISClient client = GHNContext.getImplementation(ISClient.class);
|
||||
GCUBEGHNQuery query = client.getQuery(GCUBEGHNQuery.class);
|
||||
query.addAtomicConditions(new AtomicCondition("/ID/text()", this.ID));
|
||||
query.addAtomicConditions(new AtomicCondition("/ghnID/text()", this.ghnID));
|
||||
return client.execute(query, this.scope).get(0).getNodeDescription().getName();
|
||||
} catch (Exception e) {
|
||||
logger.error("unable to find the target GHN (ID=" + this.ID + ")");
|
||||
throw new NoGHNFoundException ("unable to find the target GHN (ID=" + this.ID + ")");
|
||||
logger.error("unable to find the target GHN (ghnID=" + this.ghnID + ")");
|
||||
throw new NoGHNFoundException ("unable to find the target GHN (ghnID=" + this.ghnID + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +92,11 @@ class VirtualNode {
|
|||
*
|
||||
* @param packages the list of packages to add
|
||||
*/
|
||||
protected void addPackages(Set<PackageInfo> packages) {
|
||||
public void addPackages(Set<PackageInfo> packages) {
|
||||
//check if there is a node with all the packages already scheduled to be deployed
|
||||
//if so, the service will be already activated there, therefore there is nothing to do
|
||||
if (this.hasPackages(packages))
|
||||
return;
|
||||
for (PackageInfo p : packages)
|
||||
this.packages.add(p);
|
||||
}
|
||||
|
@ -107,22 +139,24 @@ class VirtualNode {
|
|||
|
||||
|
||||
/**
|
||||
* Gets the node ID
|
||||
* Gets the node ghnID
|
||||
*
|
||||
* @return the node ID
|
||||
* @return the node ghnID
|
||||
*/
|
||||
protected String getID() {
|
||||
return this.ID;
|
||||
public String getID() {
|
||||
return this.ghnID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a request to the physical node to deploy the packages
|
||||
*
|
||||
* @param callbackID the callback identifier
|
||||
* @param callbackEPR the callback {@link EndpointReferenceType}
|
||||
* @throws Exception if the deployment fails
|
||||
*/
|
||||
protected void materialize(String callbackID, EndpointReferenceType callbackEPR) throws Exception {
|
||||
public synchronized void deploy() throws Exception {
|
||||
if (isWorking)
|
||||
return;
|
||||
EndpointReferenceType callbackEPR = new EndpointReferenceType();
|
||||
callbackEPR.setAddress(new Address("http://"+ GHNContext.getContext().getHostnameAndPort() +"/wsrf/services/" + StatefulPortTypeContext.getContext().getJNDIName()));
|
||||
DeployParameters param = new DeployParameters();
|
||||
param.set_package(this.packages.toArray(new PackageInfo[0]));
|
||||
param.setTargetScope(new String[] {this.scope.toString()});
|
||||
|
@ -134,9 +168,33 @@ class VirtualNode {
|
|||
DeployerPortType pt = GCUBERemotePortTypeContext.getProxy(new DeployerServiceAddressingLocator().getDeployerPortTypePort(nodeEPR),
|
||||
this.scope, ServiceContext.getContext());
|
||||
pt.deploy(param);
|
||||
|
||||
isWorking = true;//this will prevent further requests to the ghn until the deployment report is received back
|
||||
|
||||
}
|
||||
|
||||
public synchronized void undeploy() throws Exception {
|
||||
if (isWorking)
|
||||
return;
|
||||
EndpointReferenceType callbackEPR = new EndpointReferenceType();
|
||||
callbackEPR.setAddress(new Address("http://"+ GHNContext.getContext().getHostnameAndPort() +"/wsrf/services/" + StatefulPortTypeContext.getContext().getJNDIName()));
|
||||
UndeployParameters params = new UndeployParameters();
|
||||
params.set_package(this.packages.toArray(new PackageInfo[0]));
|
||||
params.setTargetScope(new String[] {this.scope.toString()});
|
||||
params.setCallbackID(callbackID);
|
||||
params.setEndpointReference(callbackEPR);
|
||||
EndpointReferenceType nodeEPR = new EndpointReferenceType();
|
||||
nodeEPR.setAddress(new Address("http://" + this.name+"/wsrf/services/gcube/common/vremanagement/Deployer"));
|
||||
logger.trace("Deploying on " + nodeEPR.toString());
|
||||
DeployerPortType pt = GCUBERemotePortTypeContext.getProxy(new DeployerServiceAddressingLocator().getDeployerPortTypePort(nodeEPR),
|
||||
this.scope, ServiceContext.getContext());
|
||||
pt.undeploy(params);
|
||||
isWorking = true;//this will prevent further requests to the ghn until the deployment report is received back
|
||||
}
|
||||
|
||||
/** NoGHNFoundException exception */
|
||||
public static class NoGHNFoundException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public NoGHNFoundException(String message) {super(message);}
|
||||
}
|
||||
|
||||
}
|
|
@ -93,8 +93,15 @@ public class Dependency {
|
|||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return this.getName() + "," + this.getVersion() + " of service (" + this.getService() + ")";
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Dependency [name=" + name
|
||||
+ ", version=" + version
|
||||
+ ", service=" + service + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class Service {
|
|||
protected String version;
|
||||
|
||||
/** the gHN on which the servie is expected to be deployed */
|
||||
protected String GHN;
|
||||
protected String GHN = null;
|
||||
|
||||
public static Service fromServiceItem(ServiceItem item) {
|
||||
Service s = new Service();
|
||||
|
@ -128,7 +128,15 @@ public class Service {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return this.getName() + "," + this.getClazz() + "," + this.getVersion() ;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Service [class=" + clazz
|
||||
+ ", name=" + name
|
||||
+ ", version=" + version + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.gcube.common.core.scope.GCUBEScope;
|
|||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.common.vremanagement.deployer.stubs.common.PackageInfo;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.contexts.StatefulPortTypeContext;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.VirtualNode;
|
||||
|
||||
|
||||
|
||||
|
@ -53,125 +54,125 @@ public class VirtualNodeManager {
|
|||
|
||||
Map<String, VirtualNode> virtualNodes = new HashMap<String, VirtualNode>();
|
||||
|
||||
public void addService(ResolvedService service, String ... GHN) throws NoGHNFoundException {
|
||||
|
||||
|
||||
try {
|
||||
//select the target GHN
|
||||
/*
|
||||
String nodeID = this.getTargetGHN(service);
|
||||
String nodename = findNodeName(node);
|
||||
if (! requests.containsKey(nodename))
|
||||
requests.put(nodename, new HashSet<PackageInfo>());
|
||||
Set<PackageInfo> packages = new HashSet<PackageInfo>();
|
||||
service.setDeployedOn(node);
|
||||
*/
|
||||
|
||||
Set<PackageInfo> packages = new HashSet<PackageInfo>();
|
||||
//prepare the input list of packages for that GHN
|
||||
List<Dependency> deps = service.getResolvedDependencies();
|
||||
for (int i = 0; i < deps.size(); i++) {
|
||||
PackageInfo p = new PackageInfo();
|
||||
p.setServiceName(deps.get(i).getService().getName());
|
||||
p.setServiceClass(deps.get(i).getService().getClazz());
|
||||
p.setServiceVersion(deps.get(i).getService().getVersion());
|
||||
p.setVersion(deps.get(i).getVersion());
|
||||
p.setName(deps.get(i).getName()); //packageName
|
||||
logger.trace("Adding Package to deployment request: " + deps.get(i));
|
||||
packages.add(p);
|
||||
}
|
||||
|
||||
//check if there is a node with all the packages already scheduled to be deployed
|
||||
//if so, the service will be already activated there, therefore there is nothing to do
|
||||
for (VirtualNode virtualNode : this.virtualNodes.values())
|
||||
if (virtualNode.hasPackages(packages)) return;
|
||||
|
||||
VirtualNode node = this.getTargetGHN(service);
|
||||
|
||||
if (this.virtualNodes.containsKey(node.getID())) {
|
||||
this.virtualNodes.get(node.getID()).addPackages(packages);
|
||||
|
||||
} else {
|
||||
node.addPackages(packages);
|
||||
this.virtualNodes.put(node.getID(), node);
|
||||
}
|
||||
service.setDeployedOn(node.getID());
|
||||
|
||||
} catch (NoGHNFoundException e) {
|
||||
service.setDeployedOn("");
|
||||
service.setErrorMessage("unable to deploy: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the request to the appropriate target Deployers
|
||||
*/
|
||||
public void send() {
|
||||
|
||||
for (VirtualNode virtualNode : this.virtualNodes.values())
|
||||
try {
|
||||
virtualNode.materialize(this.callbackID, this.callbackEPR);
|
||||
} catch (Exception e) {
|
||||
logger.error("Deployment failed at " + virtualNode.getID());
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Looks for a GHN hostname given its ID
|
||||
* @param id the GHN ID
|
||||
* @return the GHN hostname, if found
|
||||
*
|
||||
* @throws Exception if the GHN does not exist
|
||||
*/
|
||||
/*private String findNodeName(String id) throws NoGHNFoundException {
|
||||
try {
|
||||
ISClient client = GHNContext.getImplementation(ISClient.class);
|
||||
GCUBEGHNQuery query = client.getQuery(GCUBEGHNQuery.class);
|
||||
query.addAtomicConditions(new AtomicCondition("/ID/text()", id));
|
||||
return client.execute(query, this.target).get(0).getNodeDescription().getName();
|
||||
} catch (Exception e) {
|
||||
logger.error("unable to find the target GHN (ID=" + id + ")");
|
||||
throw new NoGHNFoundException ("unable to find the target GHN (ID=" + id + ")");
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Selects a target node for the deployment
|
||||
*
|
||||
* @param service the service to deploy
|
||||
* @return the GHN ID
|
||||
*/
|
||||
private VirtualNode getTargetGHN(ResolvedService service) throws NoGHNFoundException {
|
||||
|
||||
if ( (service.getGHN() != null) && (service.getGHN().compareToIgnoreCase("") != 0)) {
|
||||
//a specific GHN has been requested
|
||||
return new VirtualNode(service.getGHN(),this.target);
|
||||
} else if (this.GHNs.size() > 0) {
|
||||
//a set of target GHNs has been requested, assign one of them with a round robin
|
||||
return new VirtualNode(this.GHNs.get(nodewalker++ % GHNs.size()),this.target);
|
||||
} else {
|
||||
//no GHN has been specified as explicit target
|
||||
return new VirtualNode(DEFAULTNODE,this.target);
|
||||
}
|
||||
|
||||
// TODO: integration with the BMM here?
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the GHNs to use as target nodes
|
||||
*
|
||||
* @param ghns the list of GHN ID
|
||||
*/
|
||||
public void setTargetGHNs(String[] ghns) {
|
||||
if (ghns == null)
|
||||
return;
|
||||
for (String ghn : ghns)
|
||||
this.GHNs.add(ghn);
|
||||
}
|
||||
|
||||
/** NoGHNFoundException exception */
|
||||
public static class NoGHNFoundException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public NoGHNFoundException(String message) {super(message);}
|
||||
}
|
||||
// public void addService(ResolvedService service, String ... GHN) throws NoGHNFoundException {
|
||||
//
|
||||
//
|
||||
// try {
|
||||
// //select the target GHN
|
||||
// /*
|
||||
// String nodeID = this.getTargetGHN(service);
|
||||
// String nodename = findNodeName(node);
|
||||
// if (! requests.containsKey(nodename))
|
||||
// requests.put(nodename, new HashSet<PackageInfo>());
|
||||
// Set<PackageInfo> packages = new HashSet<PackageInfo>();
|
||||
// service.setDeployedOn(node);
|
||||
// */
|
||||
//
|
||||
// Set<PackageInfo> packages = new HashSet<PackageInfo>();
|
||||
// //prepare the input list of packages for that GHN
|
||||
// List<Dependency> deps = service.getResolvedDependencies();
|
||||
// for (int i = 0; i < deps.size(); i++) {
|
||||
// PackageInfo p = new PackageInfo();
|
||||
// p.setServiceName(deps.get(i).getService().getName());
|
||||
// p.setServiceClass(deps.get(i).getService().getClazz());
|
||||
// p.setServiceVersion(deps.get(i).getService().getVersion());
|
||||
// p.setVersion(deps.get(i).getVersion());
|
||||
// p.setName(deps.get(i).getName()); //packageName
|
||||
// logger.trace("Adding Package to deployment request: " + deps.get(i));
|
||||
// packages.add(p);
|
||||
// }
|
||||
//
|
||||
// //check if there is a node with all the packages already scheduled to be deployed
|
||||
// //if so, the service will be already activated there, therefore there is nothing to do
|
||||
// for (VirtualNode virtualNode : this.virtualNodes.values())
|
||||
// if (virtualNode.hasPackages(packages)) return;
|
||||
//
|
||||
// VirtualNode node = this.getTargetGHN(service);
|
||||
//
|
||||
// if (this.virtualNodes.containsKey(node.getID())) {
|
||||
// this.virtualNodes.get(node.getID()).addPackages(packages);
|
||||
//
|
||||
// } else {
|
||||
// node.addPackages(packages);
|
||||
// this.virtualNodes.put(node.getID(), node);
|
||||
// }
|
||||
// service.setDeployedOn(node.getID());
|
||||
//
|
||||
// } catch (NoGHNFoundException e) {
|
||||
// service.setDeployedOn("");
|
||||
// service.setErrorMessage("unable to deploy: " + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Sends the request to the appropriate target Deployers
|
||||
// */
|
||||
// public void send() {
|
||||
//
|
||||
// for (VirtualNode virtualNode : this.virtualNodes.values())
|
||||
// try {
|
||||
// virtualNode.materialize(this.callbackID, this.callbackEPR);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("Deployment failed at " + virtualNode.getID());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// /**
|
||||
// * Looks for a GHN hostname given its ID
|
||||
// * @param id the GHN ID
|
||||
// * @return the GHN hostname, if found
|
||||
// *
|
||||
// * @throws Exception if the GHN does not exist
|
||||
// */
|
||||
// /*private String findNodeName(String id) throws NoGHNFoundException {
|
||||
// try {
|
||||
// ISClient client = GHNContext.getImplementation(ISClient.class);
|
||||
// GCUBEGHNQuery query = client.getQuery(GCUBEGHNQuery.class);
|
||||
// query.addAtomicConditions(new AtomicCondition("/ID/text()", id));
|
||||
// return client.execute(query, this.target).get(0).getNodeDescription().getName();
|
||||
// } catch (Exception e) {
|
||||
// logger.error("unable to find the target GHN (ID=" + id + ")");
|
||||
// throw new NoGHNFoundException ("unable to find the target GHN (ID=" + id + ")");
|
||||
// }
|
||||
// }*/
|
||||
//
|
||||
// /**
|
||||
// * Selects a target node for the deployment
|
||||
// *
|
||||
// * @param service the service to deploy
|
||||
// * @return the GHN ID
|
||||
// */
|
||||
// private VirtualNode getTargetGHN(ResolvedService service) throws NoGHNFoundException {
|
||||
//
|
||||
// if ( (service.getGHN() != null) && (service.getGHN().compareToIgnoreCase("") != 0)) {
|
||||
// //a specific GHN has been requested
|
||||
// return new VirtualNode(service.getGHN(),this.target);
|
||||
// } else if (this.GHNs.size() > 0) {
|
||||
// //a set of target GHNs has been requested, assign one of them with a round robin
|
||||
// return new VirtualNode(this.GHNs.get(nodewalker++ % GHNs.size()),this.target);
|
||||
// } else {
|
||||
// //no GHN has been specified as explicit target
|
||||
// return new VirtualNode(DEFAULTNODE,this.target);
|
||||
// }
|
||||
//
|
||||
// // TODO: integration with the BMM here?
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Sets the GHNs to use as target nodes
|
||||
// *
|
||||
// * @param ghns the list of GHN ID
|
||||
// */
|
||||
// public void setTargetGHNs(String[] ghns) {
|
||||
// if (ghns == null)
|
||||
// return;
|
||||
// for (String ghn : ghns)
|
||||
// this.GHNs.add(ghn);
|
||||
// }
|
||||
//
|
||||
// /** NoGHNFoundException exception */
|
||||
// public static class NoGHNFoundException extends Exception {
|
||||
// private static final long serialVersionUID = 1L;
|
||||
// public NoGHNFoundException(String message) {super(message);}
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -2,12 +2,9 @@ package org.gcube.vremanagement.resourcemanager.impl.operators;
|
|||
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.contexts.ServiceContext;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.DeployServiceOperator;
|
||||
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.AddResourcesParameters;
|
||||
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceList;
|
||||
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceList;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.scopemanagement.ScopedResourceManagerOperator;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.scopemanagement.ScopedResourceManagerOperator.ACTION;
|
||||
|
||||
/**
|
||||
* A Resources Operator that coordinates the adding of resources to the scope
|
||||
|
@ -45,7 +42,7 @@ public class AddResourcesOperator extends Operator {
|
|||
logger.warn("The list of services to deploy is empty");
|
||||
} else {
|
||||
try {
|
||||
new DeployServiceOperator(configuration, services).run();
|
||||
new DeployServiceOperator(configuration, services, ACTION.ADD).run();
|
||||
} catch (Exception e) {
|
||||
logger.error("Unable to activate the deployment of the given service(s)", e);
|
||||
throw new Exception("Unable to activate the deployment of the given service(s)", e);
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
package org.gcube.vremanagement.resourcemanager.impl.operators;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.axis.types.URI.MalformedURIException;
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.informationsystem.client.AtomicCondition;
|
||||
import org.gcube.common.core.informationsystem.client.ISClient;
|
||||
import org.gcube.common.core.informationsystem.client.queries.GCUBEServiceQuery;
|
||||
import org.gcube.common.core.resources.GCUBEService;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceItem;
|
||||
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceList;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.VirtualNode;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.Service;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.VirtualNode.NoGHNFoundException;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedService;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResourceFactory;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource.STATUS;
|
||||
|
||||
/**
|
||||
* A Deployer Operator that contacts the Deployer Services on the target nodes asking for the package deployment
|
||||
*
|
||||
* @author Manuele Simi (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class DeployServiceOperator extends Operator {
|
||||
|
||||
/** Object logger */
|
||||
protected final GCUBELog logger=new GCUBELog(this);
|
||||
|
||||
private ServiceList services;
|
||||
|
||||
private OperatorConfig configuration;
|
||||
|
||||
//used to apply a round robin assignment of the input GHNs (if any)
|
||||
private int nodewalker = 0;
|
||||
|
||||
public DeployServiceOperator(OperatorConfig configuration, ServiceList services, ACTION action) {
|
||||
this.services = services;
|
||||
this.configuration = configuration;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public void exec() throws Exception {
|
||||
|
||||
this.configuration.report.save();
|
||||
|
||||
Set<ScopedResource> servicesToDeploy = new HashSet<ScopedResource>();
|
||||
Set<ScopedResource> servicesToUndeploy = new HashSet<ScopedResource>();
|
||||
ISClient client = GHNContext.getImplementation(ISClient.class);
|
||||
|
||||
for (ServiceItem serviceitem : services.getService()) {
|
||||
//retrieve the service ID from the IS
|
||||
GCUBEServiceQuery query = client.getQuery(GCUBEServiceQuery.class);
|
||||
query.addAtomicConditions(new AtomicCondition("//Name",serviceitem.getServiceName()));
|
||||
query.addAtomicConditions(new AtomicCondition("//Class",serviceitem.getServiceClass()));
|
||||
List<GCUBEService> profiles = client.execute(query, this.configuration.scope);
|
||||
if ((profiles == null) || (profiles.size() == 0)) {
|
||||
logger.error("Failed to find the service");
|
||||
continue;
|
||||
|
||||
}
|
||||
logger.debug("Retrieved service ID " + profiles.get(0).getID() );
|
||||
//build the related scoped resource
|
||||
ScopedDeployedService service = (ScopedDeployedService) ScopedResourceFactory.newResource(profiles.get(0).getID(), GCUBEService.TYPE, this.configuration.scope);
|
||||
service.setSourceServiceName(Service.fromServiceItem(serviceitem));
|
||||
try {
|
||||
if (this.action == ACTION.ADD) {
|
||||
service.find();//resolve the service deps
|
||||
try {
|
||||
this.assignTargetGHN(service);//FIXME: to remove when integrating the ResourceBroker
|
||||
servicesToDeploy.add(service);
|
||||
} catch (NoGHNFoundException e1) {
|
||||
logger.error(service.getSourceService() + "Unable to find a suitable target gHN");
|
||||
service.setStatus(STATUS.LOST);
|
||||
service.setErrorMessage("Unable to find a suitable target gHN");
|
||||
}
|
||||
}
|
||||
else {
|
||||
servicesToUndeploy.add(service);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("Failed to find the service",e);
|
||||
}
|
||||
this.configuration.report.addResource(service);
|
||||
this.configuration.report.addService(service); //for the specific service section
|
||||
|
||||
|
||||
}
|
||||
|
||||
//TODO: create the Deployment Plan here with the Resource Broker
|
||||
//by using services.getGHN() and service.getSourceService().getGHN() per each service
|
||||
|
||||
//TODO: assign to each service the target gHN (as for the outcoming Plan
|
||||
//for (ScopedDeployedService service : servicesToDeploy) {
|
||||
//
|
||||
//}
|
||||
|
||||
|
||||
//add/remove the services to/from the ScopeState
|
||||
if(servicesToDeploy.size() > 0)
|
||||
configuration.scopeState.addResources(servicesToDeploy);
|
||||
if(servicesToUndeploy.size() > 0)
|
||||
configuration.scopeState.removeResources(servicesToUndeploy);
|
||||
|
||||
this.configuration.report.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects a target node for the deployment
|
||||
*
|
||||
* @param service the service to deploy
|
||||
* @return the GHN ID
|
||||
* @throws MalformedURIException
|
||||
*/
|
||||
private void assignTargetGHN(ScopedDeployedService service) throws org.gcube.vremanagement.resourcemanager.impl.deployment.VirtualNode.NoGHNFoundException, MalformedURIException {
|
||||
|
||||
if ( (service.getSourceService().getGHN() != null) && (service.getSourceService().getGHN().compareToIgnoreCase("") != 0)) {
|
||||
//a specific GHN has been requested
|
||||
service.setTargetGHN(VirtualNode.getNode(this.configuration.report.getId(),service.getSourceService().getGHN(),this.configuration.scope));
|
||||
} else if (this.services.getGHN().length > 0) {
|
||||
//a set of target GHNs has been requested, assign one of them with a round robin
|
||||
service.setTargetGHN(VirtualNode.getNode(this.configuration.report.getId(), this.services.getGHN()[nodewalker++ % this.services.getGHN().length],this.configuration.scope));
|
||||
} else {
|
||||
//no GHN has been specified as explicit target
|
||||
throw new NoGHNFoundException("No GHN was assigned to the service from the caller");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -16,6 +16,12 @@ public abstract class Operator {
|
|||
|
||||
protected final GCUBELog logger=new GCUBELog(this.getClass());
|
||||
|
||||
protected ACTION action;
|
||||
|
||||
protected OperatorConfig configuration;
|
||||
|
||||
public enum ACTION {ADD,REMOVE}
|
||||
|
||||
public final void run() {
|
||||
//new Thread() {
|
||||
// public void run() {
|
||||
|
|
|
@ -4,8 +4,6 @@ import org.gcube.common.core.utils.logging.GCUBELog;
|
|||
import org.gcube.vremanagement.resourcemanager.impl.contexts.ServiceContext;
|
||||
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.RemoveResourcesParameters;
|
||||
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceList;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.scopemanagement.ScopedResourceManagerOperator;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.scopemanagement.ScopedResourceManagerOperator.ACTION;
|
||||
|
||||
/**
|
||||
* A Resources Operator that coordinates the removal of resources from the scope
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package org.gcube.vremanagement.resourcemanager.impl.operators;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceItem;
|
||||
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceList;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResourceFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Add and remove list of {@link ScopedResource}s to/from a given scope
|
||||
*
|
||||
* @author Manuele Simi (ISTI-CNR)
|
||||
*
|
||||
*/
|
||||
public class ScopedResourceManagerOperator extends Operator {
|
||||
|
||||
|
||||
private ResourceList resources;
|
||||
|
||||
public ScopedResourceManagerOperator(OperatorConfig configuration, ResourceList resources, ACTION action) {
|
||||
this.configuration = configuration;
|
||||
this.resources = resources;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public void exec() throws Exception {
|
||||
|
||||
Set<ScopedResource> toadd = new HashSet<ScopedResource>();
|
||||
Set<ScopedResource> toremove = new HashSet<ScopedResource>();
|
||||
ScopedResource sresource = null;
|
||||
for (ResourceItem resource : this.resources.getResource()) {
|
||||
sresource = ScopedResourceFactory.newResource(resource.getID(), resource.getType(), this.configuration.scope);
|
||||
if (this.action == ACTION.ADD) {
|
||||
logger.info("Adding resource " + sresource.getId() + " (" + sresource.getType() + ") to scope " + this.configuration.scope.getName());
|
||||
toadd.add(sresource);
|
||||
} else if (this.action == ACTION.REMOVE) {
|
||||
logger.info("Removing resource " + sresource.getId() + " (" + sresource.getType() + ") from scope " + this.configuration.scope.getName());
|
||||
toremove.add(sresource);
|
||||
}
|
||||
|
||||
//add the resource item to the report
|
||||
this.configuration.report.addResource(sresource);
|
||||
}
|
||||
if(toadd.size() > 0)
|
||||
configuration.scopeState.addResources(toadd);
|
||||
if(toremove.size() > 0)
|
||||
configuration.scopeState.removeResources(toremove);
|
||||
|
||||
this.configuration.report.save();
|
||||
}
|
||||
|
||||
}
|
|
@ -72,6 +72,8 @@ public final class ScopedAnyResource extends ScopedResource {
|
|||
this.profile = (GCUBEResource) client.execute(realquery, this.scope.getEnclosingScope()).get(0);
|
||||
} catch (Exception e) {
|
||||
logger.error("unable to find the target resource (ID=" + id + ")", e);
|
||||
this.success = false;
|
||||
this.setErrorMessage("unable to find the target resource (ID=" + id + ")");
|
||||
throw new Exception("unable to find target resource (ID=" + id + "). Possible cause: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
package org.gcube.vremanagement.resourcemanager.impl.resources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.common.core.resources.GCUBEService;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.vremanagement.deployer.stubs.common.PackageInfo;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.SoftwareRepositoryRequest;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.VirtualNode;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.Dependency;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.DeployedDependency;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.Service;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -17,30 +24,149 @@ import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.Deploye
|
|||
public final class ScopedDeployedService extends ScopedResource {
|
||||
|
||||
public static final String TYPE = GCUBEService.TYPE;
|
||||
|
||||
Set<DeployedDependency> deployedUnits = new HashSet<DeployedDependency>();
|
||||
|
||||
private List<Dependency> resolved = new ArrayList<Dependency>();
|
||||
|
||||
private List<Dependency> missing = new ArrayList<Dependency>();
|
||||
|
||||
/** Target port-type name. */
|
||||
protected static final String REPOSITORY_ENDPOINT = "gcube/vremanagement/softwarerepository/SoftwareRepository";
|
||||
/** Target service name. */
|
||||
protected static final String REPOSITORY_NAME = "SoftwareRepository";
|
||||
/** Target service class. */
|
||||
protected static final String REPOSITORY_CLASS = "VREManagement";
|
||||
/** Target service class. */
|
||||
protected static final int TIMEOUT = 600000; //in milliseconds
|
||||
|
||||
private Service service;
|
||||
|
||||
private String ghnID;
|
||||
|
||||
//the target ghn
|
||||
private VirtualNode virtualNode;
|
||||
|
||||
protected ScopedDeployedService(String id, GCUBEScope scope) {
|
||||
super(id, TYPE, scope);
|
||||
}
|
||||
|
||||
public void setSourceServiceName(Service service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public Service getSourceService() {
|
||||
return this.service;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the resolved dependencies
|
||||
*/
|
||||
public List<Dependency> getResolvedDependencies() {
|
||||
return resolved;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the missing dependencies
|
||||
*/
|
||||
public List<Dependency> getMissingDependencies() {
|
||||
return missing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void find() throws Exception {}
|
||||
public void find() throws Exception {
|
||||
//looks for the service and its deps in the Software Repository
|
||||
SoftwareRepositoryRequest request = new SoftwareRepositoryRequest();
|
||||
request.addService(this);
|
||||
try {
|
||||
request.send();
|
||||
if (this.getResolvedDependencies().size() == 0) {
|
||||
this.success = false;
|
||||
this.setErrorMessage("Invalid list of dependecies retrieved from the Software Repository");
|
||||
}
|
||||
if (this.getMissingDependencies().size() > 0) {//ops, some deps are missing!
|
||||
this.success = false;
|
||||
this.setErrorMessage("The service cannot be deployed due to one or more missing dependencies: " + this.getMissingDependencies());
|
||||
}
|
||||
this.success = true;
|
||||
} catch (Exception e) {
|
||||
logger.error("Unable to resolve the list of deps for " + this.service, e);
|
||||
this.noHopeForThisService("Unable to resolve the list of dependencies");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void addToScope() throws Exception {
|
||||
|
||||
//this.find();
|
||||
if (!this.isSuccess()) {
|
||||
this.noHopeForThisService(this.getErrorMessage());
|
||||
}
|
||||
|
||||
if ((this.ghnID == null) || (this.ghnID.compareTo("")==0)) {
|
||||
this.noHopeForThisService("Unable to find a suitable target gHN where to deploy the service");
|
||||
}
|
||||
//deploy the service
|
||||
try {
|
||||
this.virtualNode.deploy();
|
||||
} catch (Exception e) {
|
||||
this.noHopeForThisService("Unable to contact the target gHN ("+ this.ghnID +") where to deploy the service");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void removeFromScope() throws Exception {
|
||||
|
||||
if (!this.isSuccess()) {
|
||||
this.noHopeForThisService(this.getErrorMessage());
|
||||
}
|
||||
|
||||
if ((this.ghnID == null) || (this.ghnID.compareTo("")==0)) {
|
||||
this.noHopeForThisService("Unable to find a suitable target gHN where to deploy the service");
|
||||
}
|
||||
//undeploy the service
|
||||
try {
|
||||
this.virtualNode.undeploy();
|
||||
} catch (Exception e) {
|
||||
this.noHopeForThisService("Unable to contact the target gHN ("+ this.ghnID +") where to deploy the service");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the GHN where the service will be deployed
|
||||
*
|
||||
* @param node the target GHN
|
||||
*/
|
||||
public void setTargetGHN(VirtualNode node) {
|
||||
this.ghnID = node.getID();
|
||||
this.virtualNode = node;
|
||||
Set<PackageInfo> packages = new HashSet<PackageInfo>();
|
||||
//prepare the input list of packages for that GHN
|
||||
List<Dependency> deps = this.getResolvedDependencies();
|
||||
for (int i = 0; i < deps.size(); i++) {
|
||||
PackageInfo p = new PackageInfo();
|
||||
p.setServiceName(deps.get(i).getService().getName());
|
||||
p.setServiceClass(deps.get(i).getService().getClazz());
|
||||
p.setServiceVersion(deps.get(i).getService().getVersion());
|
||||
p.setVersion(deps.get(i).getVersion());
|
||||
p.setName(deps.get(i).getName()); //packageName
|
||||
logger.trace("Adding Package to deployment request: " + deps.get(i));
|
||||
packages.add(p);
|
||||
}
|
||||
this.virtualNode.addPackages(packages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives up the operation on the service
|
||||
* @param message the error message to return
|
||||
* @throws Exception the exception returned to the operation caller
|
||||
*/
|
||||
private void noHopeForThisService(String message) throws Exception {
|
||||
logger.error(this.service + ": " + message);
|
||||
this.setStatus(STATUS.LOST);
|
||||
this.success = false;
|
||||
this.setErrorMessage(this.service + ": " + message);
|
||||
throw new Exception(this.getErrorMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.List;
|
|||
import org.gcube.common.core.resources.GCUBEResource;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
import org.gcube.common.core.utils.logging.GCUBELog;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.scopemanagement.ScopedResourceManagerOperator.ACTION;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.operators.Operator.ACTION;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ public final class ScopedRunningInstance extends ScopedResource {
|
|||
}
|
||||
this.ri = ris.get(0);
|
||||
} catch (Exception e) {
|
||||
this.success = false;
|
||||
this.setStatus(STATUS.LOST);
|
||||
this.setErrorMessage("unable to find the target RI (ID=" + id + ")");
|
||||
logger.error("unable to find the target RI (ID=" + id + ")", e);
|
||||
throw new Exception("unable to find target RI (ID=" + id + ")");
|
||||
}
|
||||
|
@ -65,8 +68,11 @@ public final class ScopedRunningInstance extends ScopedResource {
|
|||
this.hostingNode = client.execute(query, ServiceContext.getContext().getScope()).get(0).getNodeDescription().getName();
|
||||
this.hostedOn = hostingNode;
|
||||
} catch (Exception e) {
|
||||
logger.error("unable to find the target GHN (ID=" + ri.getGHNID() + ")", e);
|
||||
throw new Exception("unable to find target GHN (ID=" + ri.getGHNID() + ")");
|
||||
this.success = false;
|
||||
this.setStatus(STATUS.LOST);
|
||||
this.setErrorMessage("unable to find the hosting GHN (ID=" + ri.getGHNID() + ")");
|
||||
logger.error("unable to find the hosting GHN (ID=" + ri.getGHNID() + ")", e);
|
||||
throw new Exception("unable to find hosting GHN (ID=" + ri.getGHNID() + ")");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -92,6 +98,9 @@ public final class ScopedRunningInstance extends ScopedResource {
|
|||
params.setScope(this.scope.toString());
|
||||
pt.addRIToScope(params);
|
||||
} catch (Exception e) {
|
||||
this.setStatus(STATUS.LOST);
|
||||
this.success = false;
|
||||
this.setErrorMessage("Failed to add RunningInstance to scope " + scope.toString());
|
||||
logger.error("Failed to add RunningInstance to scope " + scope.toString(), e);
|
||||
throw new Exception("Failed to add RunningInstance to scope " + scope.toString());
|
||||
}
|
||||
|
@ -124,6 +133,9 @@ public final class ScopedRunningInstance extends ScopedResource {
|
|||
params.setScope(this.scope.toString());
|
||||
pt.removeRIFromScope(params);
|
||||
} catch (Exception e) {
|
||||
this.setStatus(STATUS.LOST);
|
||||
this.success = false;
|
||||
this.setErrorMessage("Failed to remove RunningInstance from scope " + scope.toString());
|
||||
logger.error("Failed to remove RunningInstance from scope " + scope.toString(), e);
|
||||
throw new Exception("Failed to remove RunningInstance from scope " + scope.toString());
|
||||
}
|
||||
|
|
|
@ -3,7 +3,9 @@ package org.gcube.vremanagement.resourcemanager.impl.state;
|
|||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.common.core.contexts.GHNContext;
|
||||
import org.gcube.common.core.scope.GCUBEScope;
|
||||
|
@ -24,10 +26,6 @@ import org.globus.wsrf.NoSuchResourceException;
|
|||
*/
|
||||
public final class InstanceState extends GCUBEWSResource {
|
||||
|
||||
protected static final String ManagedScopeRP="ManagedScope";
|
||||
|
||||
final static String[] RPNames = {ManagedScopeRP};
|
||||
|
||||
final protected GCUBEScope scope = ServiceContext.getContext().getInstance().getScopes().values().iterator().next();
|
||||
|
||||
protected ScopeState scopeState;
|
||||
|
@ -37,7 +35,6 @@ public final class InstanceState extends GCUBEWSResource {
|
|||
|
||||
@Override
|
||||
protected void initialise(Object... params) throws Exception {
|
||||
this.setManagedScope(scope.toString());
|
||||
scopeState = new ScopeState();
|
||||
try {
|
||||
logger.info("Initializing the instance state from the local file system...");
|
||||
|
@ -73,30 +70,16 @@ public final class InstanceState extends GCUBEWSResource {
|
|||
scopeState.addObserver(new Serializer());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getPropertyNames() {
|
||||
return RPNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the RP <em>ManagedScope</em>
|
||||
*
|
||||
* @return the scope managed by this instance
|
||||
*/
|
||||
synchronized public int getManagedScope () {
|
||||
return (Integer) this.getResourcePropertySet().get(ManagedScopeRP).get(0);
|
||||
synchronized public GCUBEScope getManagedScope () {
|
||||
return this.scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets for the RP <em>ManagedScope</em>
|
||||
|
||||
* @param scope the scope managed by this instace
|
||||
*
|
||||
*/
|
||||
synchronized public void setManagedScope (String scope) {
|
||||
this.getResourcePropertySet().get(ManagedScopeRP).clear();
|
||||
this.getResourcePropertySet().get(ManagedScopeRP).add(scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link ResourceReport}
|
||||
|
@ -154,4 +137,21 @@ public final class InstanceState extends GCUBEWSResource {
|
|||
public ScopeState getResourceList() {
|
||||
return scopeState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes the current scope
|
||||
*/
|
||||
public void dispose() {
|
||||
Set<ScopedResource> allResources = new HashSet<ScopedResource>();
|
||||
for (ScopedResource resource : this.scopeState.getAllResources()) {
|
||||
allResources.add(resource);
|
||||
}
|
||||
//remove all resources
|
||||
this.scopeState.removeResources(allResources);
|
||||
|
||||
//TODO: unpublish the published scope resource
|
||||
|
||||
//TODO: undeploy myself?
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.gcube.vremanagement.resourcemanager.impl.contexts.ServiceContext;
|
|||
import org.gcube.vremanagement.resourcemanager.impl.deployment.DeployerReport;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.Dependency;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.DeployedDependency;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.deployment.resources.ResolvedService;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.scopemanagement.ScopedResourceManagerOperator.ACTION;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.operators.Operator.ACTION;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedService;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource;
|
||||
import org.kxml2.io.KXmlSerializer;
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class ResourceReport implements Serializable, Observer {
|
|||
/** Status of a dependency resolver request */
|
||||
public enum DEPSTATUS {SUCCESS, FAILED};
|
||||
|
||||
private Set<ResolvedService> services = Collections.synchronizedSet(new HashSet<ResolvedService>());
|
||||
private Set<ScopedDeployedService> services = Collections.synchronizedSet(new HashSet<ScopedDeployedService>());
|
||||
|
||||
private Set<ScopedResource> resources = Collections.synchronizedSet(new HashSet<ScopedResource>());
|
||||
|
||||
|
@ -92,10 +92,10 @@ public class ResourceReport implements Serializable, Observer {
|
|||
this.lastUpdate = new GregorianCalendar();
|
||||
}
|
||||
|
||||
synchronized public void addService(ResolvedService service) {
|
||||
synchronized public void addService(ScopedDeployedService service) {
|
||||
this.services.add(service);
|
||||
this.lastUpdate = new GregorianCalendar();
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -110,21 +110,43 @@ public class ResourceReport implements Serializable, Observer {
|
|||
serializer.startTag(NS,"ID").text(this.id).endTag(NS, "ID");
|
||||
serializer.startTag(NS,"LastUpdate").text(ProfileDate.toXMLDateAndTime(this.lastUpdate.getTime())).endTag(NS,"LastUpdate");
|
||||
serializer.startTag(NS,"TargetScope").text(this.scope.toString()).endTag(NS,"TargetScope");
|
||||
|
||||
//resources section
|
||||
serializer.startTag(NS,"Resources");
|
||||
for (ScopedResource resource : resources) {
|
||||
serializer.startTag(NS,"Resource");
|
||||
serializer.startTag(NS,"ID").text(resource.getId()).endTag(NS,"ID");
|
||||
serializer.startTag(NS,"Type").text(resource.getType()).endTag(NS,"Type");
|
||||
if (resource.isSuccess()) {
|
||||
if (resource.getAction().compareTo(ACTION.ADD) == 0)
|
||||
serializer.startTag(NS,"Status").text("ADDED").endTag(NS,"Status");
|
||||
else if (resource.getAction().compareTo(ACTION.REMOVE) == 0)
|
||||
serializer.startTag(NS,"Status").text("REMOVED").endTag(NS,"Status");
|
||||
serializer.startTag(NS,"ErrorDescription").text("-").endTag(NS,"ErrorDescription");
|
||||
} else {
|
||||
serializer.startTag(NS,"Status").text("FAILED").endTag(NS,"Status");
|
||||
serializer.startTag(NS,"ErrorDescription").text(resource.getErrorMessage()).endTag(NS,"ErrorDescription");
|
||||
}
|
||||
serializer.endTag(NS,"Resource");
|
||||
}
|
||||
|
||||
serializer.endTag(NS,"Resources");
|
||||
//services section
|
||||
|
||||
serializer.startTag(NS,"Services");
|
||||
for (ResolvedService service : this.services) {
|
||||
for (ScopedDeployedService service : this.services) {
|
||||
serializer.startTag(NS,"Service");
|
||||
serializer.startTag(NS,"Class").text(service.getClazz()).endTag(NS, "Class");
|
||||
serializer.startTag(NS,"Name").text(service.getName()).endTag(NS, "Name");
|
||||
serializer.startTag(NS,"Version").text(service.getVersion()).endTag(NS, "Version");
|
||||
serializer.startTag(NS,"ID").text(service.getId()).endTag(NS, "ID");
|
||||
serializer.startTag(NS,"Class").text(service.getSourceService().getClazz()).endTag(NS, "Class");
|
||||
serializer.startTag(NS,"Name").text(service.getSourceService().getName()).endTag(NS, "Name");
|
||||
serializer.startTag(NS,"Version").text(service.getSourceService().getVersion()).endTag(NS, "Version");
|
||||
if ( (service.getMissingDependencies().size() > 0) || (service.getErrorMessage().length() > 0) ) {
|
||||
serializer.startTag(NS,"DependenciesResolutionStatus").text(DEPSTATUS.FAILED.name()).endTag(NS, "DependenciesResolutionStatus");
|
||||
serializer.startTag(NS,"DeployedOn").text("not deployed").endTag(NS, "DeployedOn");
|
||||
serializer.startTag(NS,"ErrorDescription").text(service.getErrorMessage()).endTag(NS, "ErrorDescription");
|
||||
}else {
|
||||
serializer.startTag(NS,"DependenciesResolutionStatus").text(DEPSTATUS.SUCCESS.name()).endTag(NS, "DependenciesResolutionStatus");
|
||||
serializer.startTag(NS,"DeployedOn").text(service.getDeployedOn()).endTag(NS, "DeployedOn");
|
||||
serializer.startTag(NS,"DeployedOn").text(service.getHostedOn()).endTag(NS, "DeployedOn");
|
||||
serializer.startTag(NS,"ErrorDescription").text("-").endTag(NS, "ErrorDescription");
|
||||
}
|
||||
serializer.startTag(NS,"DependenciesResolution");
|
||||
|
@ -153,44 +175,45 @@ public class ResourceReport implements Serializable, Observer {
|
|||
}
|
||||
serializer.endTag(NS,"MissingDependencies");
|
||||
serializer.endTag(NS,"DependenciesResolution");
|
||||
//add the deployment report if it is available
|
||||
String reportID = /*service.getId() + "-" +*/ service.getHostedOn();
|
||||
serializer.startTag(NS,"DeploymentActivity");
|
||||
if (node2report.keySet().contains(reportID)) {
|
||||
serializer.startTag(NS,"GHN");
|
||||
serializer.startTag(NS,"ID").text(service.getHostedOn()).endTag(NS, "ID");
|
||||
serializer.startTag(NS,"Host").text(node2report.get(reportID).getHost()).endTag(NS,"Host");
|
||||
serializer.startTag(NS,"LastReportReceivedOn").text(ProfileDate.toXMLDateAndTime(node2report.get(reportID).getLastUpdate())).endTag(NS,"LastReportReceivedOn");
|
||||
serializer.startTag(NS,"LastReportReceived");
|
||||
serializer.startTag(NS,"Status").text(node2report.get(reportID).getStatus()).endTag(NS, "Status");
|
||||
this.addGHNReport(serializer, node2report.get(reportID));
|
||||
serializer.endTag(NS, "LastReportReceived");
|
||||
serializer.endTag(NS,"GHN");
|
||||
} else {
|
||||
if (service.isSuccess())
|
||||
serializer.text("Deployment report is still not available for this service");
|
||||
else
|
||||
serializer.text("No report");
|
||||
}
|
||||
|
||||
serializer.endTag(NS,"DeploymentActivity");
|
||||
|
||||
serializer.endTag(NS,"Service");
|
||||
}
|
||||
serializer.endTag(NS,"Services");
|
||||
serializer.startTag(NS,"DeploymentActivity");
|
||||
for (String ghnID : node2report.keySet()) {
|
||||
serializer.startTag(NS,"GHN");
|
||||
serializer.startTag(NS,"ID").text(ghnID).endTag(NS, "ID");
|
||||
serializer.startTag(NS,"Host").text(node2report.get(ghnID).getHost()).endTag(NS,"Host");
|
||||
serializer.startTag(NS,"LastReportReceivedOn").text(ProfileDate.toXMLDateAndTime(node2report.get(ghnID).getLastUpdate())).endTag(NS,"LastReportReceivedOn");
|
||||
serializer.startTag(NS,"LastReportReceived");
|
||||
serializer.startTag(NS,"Status").text(node2report.get(ghnID).getStatus()).endTag(NS, "Status");
|
||||
this.addGHNReport(serializer, node2report.get(ghnID));
|
||||
serializer.endTag(NS, "LastReportReceived");
|
||||
serializer.endTag(NS,"GHN");
|
||||
}
|
||||
|
||||
serializer.endTag(NS,"DeploymentActivity");
|
||||
|
||||
//resources section
|
||||
serializer.startTag(NS,"Resources");
|
||||
for (ScopedResource resource : resources) {
|
||||
serializer.startTag(NS,"Resource");
|
||||
serializer.startTag(NS,"ID").text(resource.getId()).endTag(NS,"ID");
|
||||
serializer.startTag(NS,"Type").text(resource.getType()).endTag(NS,"Type");
|
||||
if (resource.isSuccess()) {
|
||||
if (resource.getAction().compareTo(ACTION.ADD) == 0)
|
||||
serializer.startTag(NS,"Status").text("ADDED").endTag(NS,"Status");
|
||||
else if (resource.getAction().compareTo(ACTION.REMOVE) == 0)
|
||||
serializer.startTag(NS,"Status").text("REMOVED").endTag(NS,"Status");
|
||||
serializer.startTag(NS,"ErrorDescription").text("-").endTag(NS,"ErrorDescription");
|
||||
} else {
|
||||
serializer.startTag(NS,"Status").text("FAILED").endTag(NS,"Status");
|
||||
serializer.startTag(NS,"ErrorDescription").text(resource.getErrorMessage()).endTag(NS,"ErrorDescription");
|
||||
}
|
||||
serializer.endTag(NS,"Resource");
|
||||
}
|
||||
|
||||
serializer.endTag(NS,"Resources");
|
||||
// serializer.startTag(NS,"DeploymentActivity");
|
||||
// for (String ghnID : node2report.keySet()) {
|
||||
// serializer.startTag(NS,"GHN");
|
||||
// serializer.startTag(NS,"ID").text(ghnID).endTag(NS, "ID");
|
||||
// serializer.startTag(NS,"Host").text(node2report.get(ghnID).getHost()).endTag(NS,"Host");
|
||||
// serializer.startTag(NS,"LastReportReceivedOn").text(ProfileDate.toXMLDateAndTime(node2report.get(ghnID).getLastUpdate())).endTag(NS,"LastReportReceivedOn");
|
||||
// serializer.startTag(NS,"LastReportReceived");
|
||||
// serializer.startTag(NS,"Status").text(node2report.get(ghnID).getStatus()).endTag(NS, "Status");
|
||||
// this.addGHNReport(serializer, node2report.get(ghnID));
|
||||
// serializer.endTag(NS, "LastReportReceived");
|
||||
// serializer.endTag(NS,"GHN");
|
||||
// }
|
||||
//
|
||||
// serializer.endTag(NS,"DeploymentActivity");
|
||||
serializer.endTag(NS,"ResourceReport");
|
||||
serializer.endDocument();
|
||||
}
|
||||
|
@ -212,14 +235,14 @@ public class ResourceReport implements Serializable, Observer {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
* @return the resource report identifier
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scope
|
||||
* @return the scope this report belongs to
|
||||
*/
|
||||
public GCUBEScope getScope() {
|
||||
return scope;
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.vremanagement.resourcemanager.impl.state;
|
|||
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Observable;
|
||||
import java.util.Set;
|
||||
|
@ -195,7 +196,7 @@ public class ScopeState extends Observable {
|
|||
* @return all the {@link ScopedResource}s
|
||||
*/
|
||||
public Collection<ScopedResource> getAllResources() {
|
||||
return rawState.resources.values();
|
||||
return Collections.unmodifiableCollection(rawState.resources.values());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package org.gcube.vremanagement.resourcemanager.impl.state.observers;
|
||||
|
||||
import org.gcube.vremanagement.resourcemanager.impl.operators.Operator.ACTION;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource.STATUS;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.scopemanagement.ScopedResourceManagerOperator.ACTION;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.state.ScopeState;
|
||||
import org.gcube.vremanagement.resourcemanager.impl.state.ScopeState.OPERATION;
|
||||
|
||||
|
|
Loading…
Reference in New Issue