Fixings on Session management and reporting

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/ResourceManager@58945 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2012-09-24 17:49:10 +00:00
parent 6df430158c
commit 90fa1613b5
4 changed files with 23 additions and 25 deletions

View File

@ -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;
}
}

View File

@ -90,7 +90,7 @@ public class ScopedDeployedSoftware extends ScopedResource {
* @return the resolved dependencies
*/
public List<Dependency> getLastResolvedDependencies() {
return this.resolved;
return Collections.unmodifiableList(this.resolved);
}
/**

View File

@ -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();
}

View File

@ -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);
}