diff --git a/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/reporting/Session.java b/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/reporting/Session.java index 046439b..16ee6b9 100644 --- a/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/reporting/Session.java +++ b/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/reporting/Session.java @@ -170,19 +170,19 @@ public class Session implements Serializable { if (((this.operation == OPERATION.AddResources) ||(this.operation == OPERATION.Create)) && (service.getStatus() != STATUS.LOST) && (this.brokerWasSuccessful)) { - if ( (service.getMissingDependencies(service.getTargetNodeID()).size() > 0) || (service.getErrorMessage().length() > 0) ) { + if ( (service.getMissingDependencies(service.getTargetNodeName()).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.getTargetNodeID()).endTag(NS, "DeployedOn"); + serializer.startTag(NS,"DeployedOn").text(service.getTargetNodeName()).endTag(NS, "DeployedOn"); serializer.startTag(NS,"ErrorDescription").text("-").endTag(NS, "ErrorDescription"); } serializer.startTag(NS,"DependenciesResolution"); //resolved dependencies serializer.startTag(NS,"ResolvedDependencies"); - for (Dependency dep : service.getResolvedDependencies(service.getTargetNodeID())) { + for (Dependency dep : service.getLastResolvedDependencies()) { serializer.startTag(NS,"Dependency"); serializer.startTag(NS,"ServiceClass").text(dep.getService().getClazz()).endTag(NS, "ServiceClass"); serializer.startTag(NS,"ServiceName").text(dep.getService().getName()).endTag(NS, "ServiceName"); @@ -194,7 +194,7 @@ public class Session implements Serializable { serializer.endTag(NS,"ResolvedDependencies"); //missing dependencies serializer.startTag(NS,"MissingDependencies"); - for (Dependency dep : service.getMissingDependencies(service.getTargetNodeID())) { + for (Dependency dep : service.getLastMissingDependencies()) { serializer.startTag(NS,"Dependency"); serializer.startTag(NS,"ServiceClass").text(dep.getService().getClazz()).endTag(NS, "ServiceClass"); serializer.startTag(NS,"ServiceName").text(dep.getService().getName()).endTag(NS, "ServiceName"); @@ -207,19 +207,19 @@ public class Session implements Serializable { serializer.endTag(NS,"DependenciesResolution"); } //add the deployment report if it is available - String reportID = service.getTargetNodeID(); + String targetNodeName = service.getTargetNodeName(); if (this.operation == OPERATION.AddResources) serializer.startTag(NS,"DeploymentActivity"); else serializer.startTag(NS,"UndeploymentActivity"); - if (node2report.keySet().contains(reportID)) { + if (node2report.keySet().contains(targetNodeName)) { serializer.startTag(NS,"GHN"); - serializer.startTag(NS,"ID").text(service.getTargetNodeID()).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,"LogicalName").text(service.getTargetNodeName()).endTag(NS, "LogicalName"); + serializer.startTag(NS,"Host").text(node2report.get(targetNodeName).getHost()).endTag(NS,"Host"); + serializer.startTag(NS,"LastReportReceivedOn").text(ProfileDate.toXMLDateAndTime(node2report.get(targetNodeName).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), service); + serializer.startTag(NS,"Status").text(node2report.get(targetNodeName).getStatus()).endTag(NS, "Status"); + this.addGHNReport(serializer, node2report.get(targetNodeName), service); serializer.endTag(NS, "LastReportReceived"); serializer.endTag(NS,"GHN"); DeployedRunningInstance instance = this.getInstanceForService(service); @@ -233,7 +233,7 @@ public class Session implements Serializable { serializer.startTag(NS,"Message").text(instance.getMessage()).endTag(NS,"Message"); serializer.endTag(NS,"RelatedRunningInstance"); - } else if (node2report.get(reportID).getStatus().compareToIgnoreCase("CLOSED") == 0 ) { + } else if (node2report.get(targetNodeName).getStatus().compareToIgnoreCase("CLOSED") == 0 ) { serializer.startTag(NS,"RelatedRunningInstance"); serializer.startTag(NS,"Status").text("FAILED").endTag(NS,"Status"); serializer.startTag(NS,"Message").text("The Deployer service did not detect any new instance of this service on the target gHN").endTag(NS,"Message"); @@ -363,7 +363,7 @@ public class Session implements Serializable { private void addGHNReport(KXmlSerializer serializer, DeployerReport report, ScopedDeployedSoftware service) throws Exception { serializer.startTag(NS, "Packages"); for (DeployedDependency dep: report.getDependencies()) { - if (this.isDepOfService(dep, service, report.getGHNName())) { + if (this.isDepOfService(dep, service)) { serializer.startTag(NS,"Package"); serializer.startTag(NS,"ServiceClass").text(dep.getService().getClazz()).endTag(NS, "ServiceClass"); serializer.startTag(NS,"ServiceName").text(dep.getService().getName()).endTag(NS, "ServiceName"); @@ -404,8 +404,8 @@ public class Session implements Serializable { * @param service the potential owner service * @return true if the dependency belongs the service */ - private boolean isDepOfService(DeployedDependency dep, ScopedDeployedSoftware service,String targetGHNName) { - for (Dependency resolvedDependency : service.getResolvedDependencies(targetGHNName)) { + private boolean isDepOfService(DeployedDependency dep, ScopedDeployedSoftware service) { + for (Dependency resolvedDependency : service.getLastResolvedDependencies()) { if (dep.equals((Dependency)resolvedDependency)) return true; } return false; @@ -423,12 +423,12 @@ public class Session implements Serializable { } for (ScopedDeployedSoftware service : this.services) { - String reportID = service.getTargetNodeID(); + String reportHostName = service.getTargetNodeName(); if (service.isSuccess() && (this.brokerWasSuccessful)) { //check the availability of the report and its status - if (! node2report.keySet().contains(reportID)) { + if (! node2report.keySet().contains(reportHostName)) { return false; - } else if (node2report.get(reportID).getStatus().compareToIgnoreCase("CLOSED") != 0){ + } else if (node2report.get(reportHostName).getStatus().compareToIgnoreCase("CLOSED") != 0){ return false; } } diff --git a/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedDeployedSoftware.java b/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedDeployedSoftware.java index a44347d..f685307 100644 --- a/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedDeployedSoftware.java +++ b/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedDeployedSoftware.java @@ -90,7 +90,7 @@ public class ScopedDeployedSoftware extends ScopedResource { * @return the resolved dependencies */ public List getLastResolvedDependencies() { - return this.resolved; + return Collections.unmodifiableList(this.resolved); } /** diff --git a/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/resources/software/GCUBEPackage.java b/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/resources/software/GCUBEPackage.java index dec174e..b719580 100644 --- a/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/resources/software/GCUBEPackage.java +++ b/resource-manager-service/src/main/java/org/gcube/vremanagement/resourcemanager/impl/resources/software/GCUBEPackage.java @@ -221,8 +221,6 @@ public class GCUBEPackage { builder.append(this.getPackageName()); builder.append('-'); builder.append(this.getPackageVersion()); - builder.append('-'); - builder.append(this.getGHNName()); return builder.toString(); } diff --git a/resource-manager-service/src/test/java/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedDeployedSoftwareTest.java b/resource-manager-service/src/test/java/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedDeployedSoftwareTest.java index f58d6e9..3110249 100644 --- a/resource-manager-service/src/test/java/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedDeployedSoftwareTest.java +++ b/resource-manager-service/src/test/java/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedDeployedSoftwareTest.java @@ -45,11 +45,11 @@ public class ScopedDeployedSoftwareTest extends ServiceStartupTest { map.load(new InputStreamReader(ScopedDeployedSoftwareTest.class.getResourceAsStream("/ServiceMap_devsec.xml"))); scope.setServiceMap(map); sourcePackage = new GCUBEPackage(); - sourcePackage.setName("EnvironmentLibrariesSet"); - sourcePackage.setClazz("Execution"); + sourcePackage.setName("UserProfileAccess"); + sourcePackage.setClazz("Personalisation"); sourcePackage.setVersion("1.0.0"); - sourcePackage.setPackageVersion("1.0.0-SNAPSHOT"); - sourcePackage.setPackageName("ReportingFrameworkLibrary"); + sourcePackage.setPackageVersion("2.1.0-SNAPSHOT"); + sourcePackage.setPackageName("UserProfileAccess-service"); sw = (ScopedDeployedSoftware) ScopedResourceFactory.newResource(scope, sourcePackage.getID(), GCUBEService.TYPE); targetNode = new VirtualNodeList(scope).getNode(targetNodeName); }