Fixings on Session management and reporting

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/ResourceManager@58906 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2012-09-23 19:38:14 +00:00
parent c24f1216f6
commit 6df430158c
5 changed files with 48 additions and 22 deletions

View File

@ -149,6 +149,9 @@ public class DeploySoftwareOperator extends Operator {
return (ScopedDeployedSoftware)software;
}
}
return (ScopedDeployedSoftware) ScopedResourceFactory.newResource(scopeState.getScope(), id, GCUBEService.TYPE);
//need to create a new one
ScopedDeployedSoftware sw = (ScopedDeployedSoftware) ScopedResourceFactory.newResource(scopeState.getScope(), id, GCUBEService.TYPE);
sw.setSourcePackage(sourcePackage);
return sw;
}
}

View File

@ -238,6 +238,8 @@ public class ScopedDeployedSoftware extends ScopedResource {
this.targetVirtualNode = node;
this.virtualNodeName = node.getName();
this.lastActivityOnGHN = node.getID();
sourcePackage.setGHNName(this.getTargetNodeName());
this.id = sourcePackage.getID(); //this way the ID depends also on the target node
this.addPackagesToTargetNode();
}
@ -325,5 +327,4 @@ public class ScopedDeployedSoftware extends ScopedResource {
}
this.targetVirtualNode.setPackagesToRemove(packages);
}
}

View File

@ -97,14 +97,14 @@ public abstract class ScopedResource {
this.success = true;
break;
} catch (Exception e) {
logger.warn("Can't find resource "+ this + " on the IS");
logger.warn("Can't find the resource "+ this.getId() + " on the IS");
if (i++ <= max_attempts) {
logger.warn("try again in 5 secs");
try {Thread.sleep(5000);} catch (InterruptedException e1) {}
continue;
}
else {
this.noHopeForMe("Can't find resource "+ this + " on the IS", new ResourceNotFound(e));
this.noHopeForMe("Can't find resource "+ this.getId() + " on the IS", new ResourceNotFound(e));
break;
}
}
@ -303,12 +303,20 @@ public abstract class ScopedResource {
*/
@Override
public String toString() {
return "Resource [id=" + id
+ ", type=" + type
+ ", timestamp=" + lastModificationTime
+ ", scope=" + scope
+ ", status=" + status
+ " hostedOn=" + hostedOn + "]";
return new StringBuilder().append("Resource [id=")
.append(id)
.append(", type=")
.append(type)
.append(", timestamp=")
.append(lastModificationTime)
.append(", scope=")
.append(scope)
.append(", status=")
.append(status)
.append(", hostedOn=")
.append(hostedOn)
.append("]")
.toString();
}

View File

@ -212,7 +212,7 @@ public class GCUBEPackage {
public String getID() {
StringBuilder builder = new StringBuilder();
builder.append(this.getClass());
builder.append(this.getClazz());
builder.append('-');
builder.append(this.getName());
builder.append('-');

View File

@ -10,6 +10,7 @@ import java.io.InputStreamReader;
import org.gcube.common.core.resources.GCUBEService;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.scope.ServiceMap;
import org.gcube.vremanagement.resourcemanager.impl.ServiceStartupTest;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource.STATUS;
import org.gcube.vremanagement.resourcemanager.impl.resources.software.GCUBEPackage;
import org.gcube.vremanagement.resourcemanager.impl.state.VirtualNode;
@ -23,7 +24,7 @@ import org.junit.Test;
* @author Manuele Simi (CNR)
*
*/
public class ScopedDeployedSoftwareTest {
public class ScopedDeployedSoftwareTest extends ServiceStartupTest {
static GCUBEScope scope;
static ScopedDeployedSoftware sw;
@ -47,7 +48,8 @@ public class ScopedDeployedSoftwareTest {
sourcePackage.setName("EnvironmentLibrariesSet");
sourcePackage.setClazz("Execution");
sourcePackage.setVersion("1.0.0");
sourcePackage.setPackageVersion("1.0.0-SNAPSHOT");
sourcePackage.setPackageVersion("1.0.0-SNAPSHOT");
sourcePackage.setPackageName("ReportingFrameworkLibrary");
sw = (ScopedDeployedSoftware) ScopedResourceFactory.newResource(scope, sourcePackage.getID(), GCUBEService.TYPE);
targetNode = new VirtualNodeList(scope).getNode(targetNodeName);
}
@ -161,6 +163,22 @@ public class ScopedDeployedSoftwareTest {
public final void testSetMissingDependencies() {
fail("Not yet implemented");
}
/**
* Test method for {@link org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedSoftware#scheduleDeploy(org.gcube.vremanagement.resourcemanager.impl.state.VirtualNode)}.
*/
@Test
public final void testScheduleDeploy() {
sw.setStatus(STATUS.ADDREQUESTED);
sw.scheduleDeploy(targetNode);
try {
//targetNode.deploy();
} catch (Exception e) {
e.printStackTrace();
fail("fails to depoy");
}
}
/**
* Test method for {@link org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedSoftware#scheduleUndeploy(org.gcube.vremanagement.resourcemanager.impl.state.VirtualNode)}.
@ -170,20 +188,16 @@ public class ScopedDeployedSoftwareTest {
try {
sw.setStatus(STATUS.REMOVEREQUESTED);
sw.scheduleUndeploy(targetNode);
//targetNode.undeploy();
} catch (NoGHNFoundException e) {
e.printStackTrace();
fail();
fail("no ghn found");
} catch (Exception e) {
e.printStackTrace();
fail("fails to undeploy");
}
}
/**
* Test method for {@link org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedSoftware#scheduleDeploy(org.gcube.vremanagement.resourcemanager.impl.state.VirtualNode)}.
*/
@Test
public final void testScheduleDeploy() {
sw.setStatus(STATUS.ADDREQUESTED);
sw.scheduleDeploy(targetNode);
}
/**
* Test method for {@link org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedSoftware#getTargetNodeID()}.