Bunch of fixings on resource publication

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/ResourceManager@58854 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2012-09-20 16:37:59 +00:00
parent e39a30e22c
commit 51e7ff4f2d
8 changed files with 92 additions and 48 deletions

View File

@ -87,9 +87,10 @@ public class DeploySoftwareOperator extends Operator {
new Thread() {
@Override
public void run() {
Session tsession = DeploySoftwareOperator.this.configuration.session;;
Session tsession = DeploySoftwareOperator.this.configuration.session;
while (true) {
try { Thread.sleep(5000);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {}
//checking if the session is closed and we need to send feedback
if ((tsession.isReportClosed()

View File

@ -28,8 +28,7 @@ import org.globus.wsrf.NoSuchResourceException;
*/
public final class InstanceState extends GCUBEWSResource {
static ScopeStateList resources = new ScopeStateList();
static final ScopeStateList resources = new ScopeStateList();
/** session id -> session map*/
static Map<String, Session> id2session = Collections.synchronizedMap(new HashMap<String, Session>());;
@ -39,16 +38,16 @@ public final class InstanceState extends GCUBEWSResource {
this.reuseState(this.getScope());
}
protected void reuseState(GCUBEScope scope) throws Exception {
protected void reuseState(final GCUBEScope scope) throws Exception {
//initialize the scope states
resources.initializeScope(scope);
ScopeState state = resources.getState(scope);
final ScopeState state = resources.getState(scope);
this.registerObservers(state);
//notify the observers about the initialization
new Thread("ReuseStateThread"+InstanceState.this.getScope().getName()) {
new Thread("ReuseStateThread"+scope.getName()) {
@Override
public void run() {
resources.getState(InstanceState.this.getScope()).notifyObservers();
state.notifyObservers();
}
}.start();
}

View File

@ -159,12 +159,13 @@ public class PublishedScopeResource {
throws Exception {
if (value == null)
return;
logger.debug("setting option " + name);
try {
if (name.compareToIgnoreCase("DESIGNER") == 0) {
// the manager DN
this.designer = value;
} else if (name.compareToIgnoreCase("MANAGER") == 0) {
} else if ((name.compareToIgnoreCase("MANAGER") == 0)
|| ((name.compareToIgnoreCase("CREATOR") == 0))){
// the creator's DN
this.manager = value;
} else if (name.compareToIgnoreCase("ENDTIME") == 0) {
@ -182,8 +183,8 @@ public class PublishedScopeResource {
} else if (name.compareToIgnoreCase("SECURITYENABLED") == 0) {
// the name to display (the unique name is the qualified scope)
this.securityEnabled = Boolean.valueOf(value);
} else
throw new UnknownScopeOptionException();
} /*else
throw new UnknownScopeOptionException();*/
} catch (ParseException e) {
throw new Exception ("Unable to parse option " + name);
}

View File

@ -12,7 +12,7 @@ import org.gcube.vremanagement.resourcemanager.impl.state.VirtualNode.NoGHNFound
* @author manuele simi (CNR)
*
*/
class VirtualNodeList {
public class VirtualNodeList {
Map<String, VirtualNode> listByName;
Map<String, VirtualNode> listByID;
@ -20,7 +20,7 @@ class VirtualNodeList {
GCUBEScope scope;
private final String stateTag = "NODES";
VirtualNodeList(GCUBEScope scope) {
public VirtualNodeList(GCUBEScope scope) {
this.scope = scope;
this.listByName = new HashMap<String, VirtualNode>();
this.listByID = new HashMap<String, VirtualNode>();
@ -56,7 +56,7 @@ class VirtualNodeList {
* @return the node
* @throws NoGHNFoundException
*/
VirtualNode getNode(String name) throws NoGHNFoundException {
public VirtualNode getNode(String name) throws NoGHNFoundException {
if (!this.listByName.containsKey(name)) {
VirtualNode node = VirtualNode.fromName(name, this.scope);
if (GHNContext.getContext().getName().equalsIgnoreCase(node.getName()))

View File

@ -5,6 +5,7 @@ package org.gcube.vremanagement.resourcemanager.porttypes;
import java.util.Collection;
import org.gcube.common.core.contexts.GCUBEServiceContext.Status;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.scope.GCUBEScopeManager.IllegalScopeException;
import org.gcube.vremanagement.resourcemanager.impl.contexts.ServiceContext;
@ -74,6 +75,8 @@ class ScopeUtils {
static void removeFromInstance(GCUBEScope scope, ResourceManagerPortType pt) {
//this will also trigger the transparent removal of the instance state
ServiceContext.getContext().removeScope(scope);
//TODO: to remove when the removal from VRE on the IS-Registry is fixed
ServiceContext.getContext().setStatus(Status.UPDATED);
}
}

View File

@ -5,21 +5,51 @@ package org.gcube.vremanagement.resourcemanager.impl.resources;
import static org.junit.Assert.*;
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.resources.ScopedResource.STATUS;
import org.gcube.vremanagement.resourcemanager.impl.resources.software.GCUBEPackage;
import org.gcube.vremanagement.resourcemanager.impl.state.VirtualNode;
import org.gcube.vremanagement.resourcemanager.impl.state.VirtualNode.NoGHNFoundException;
import org.gcube.vremanagement.resourcemanager.impl.state.VirtualNodeList;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* @author manuele
* @author Manuele Simi (CNR)
*
*/
public class ScopedDeployedSoftwareTest {
static GCUBEScope scope;
static ScopedDeployedSoftware sw;
static GCUBEPackage sourcePackage;
static VirtualNode targetNode;
static final String targetNodeName= "node2.d.d4science.research-infrastructures.eu:8080";
/**
* @throws java.lang.Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
//static initialisations
scope = GCUBEScope.getScope("/gcube/devsec");
ServiceMap map = new ServiceMap();
map.load(new InputStreamReader(ScopedDeployedSoftwareTest.class.getResourceAsStream("/ServiceMap_devsec.xml")));
scope.setServiceMap(map);
sourcePackage = new GCUBEPackage();
sourcePackage.setName("EnvironmentLibrariesSet");
sourcePackage.setClazz("Execution");
sourcePackage.setVersion("1.0.0");
sourcePackage.setPackageVersion("1.0.0-SNAPSHOT");
sw = (ScopedDeployedSoftware) ScopedResourceFactory.newResource(scope, sourcePackage.getID(), GCUBEService.TYPE);
targetNode = new VirtualNodeList(scope).getNode(targetNodeName);
}
/**
@ -29,12 +59,34 @@ public class ScopedDeployedSoftwareTest {
public static void tearDownAfterClass() throws Exception {
}
/**
* Test method for {@link org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedSoftware#setSourcePackage(org.gcube.vremanagement.resourcemanager.impl.resources.software.GCUBEPackage)}.
*/
@Test
public final void testSetSourcePackage() {
sw.setSourcePackage(sourcePackage);
}
/**
* Test method for {@link org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedSoftware#getSourcePackage()}.
*/
@Test
public final void testGetSourcePackage() {
assertNotNull(sw.getSourcePackage());
}
/**
* Test method for {@link org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedSoftware#find()}.
*/
@Test
public final void testFind() {
fail("Not yet implemented");
try {
sw.find();
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
/**
@ -58,32 +110,9 @@ public class ScopedDeployedSoftwareTest {
*/
@Test
public final void testGetMaxFindAttempts() {
fail("Not yet implemented");
System.out.println("Max attempts: " + sw.getMaxFindAttempts());
}
/**
* Test method for {@link org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedSoftware#ScopedDeployedSoftware(java.lang.String, org.gcube.common.core.scope.GCUBEScope)}.
*/
@Test
public final void testScopedDeployedSoftware() {
fail("Not yet implemented");
}
/**
* Test method for {@link org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedSoftware#setSourcePackage(org.gcube.vremanagement.resourcemanager.impl.resources.software.GCUBEPackage)}.
*/
@Test
public final void testSetSourcePackage() {
fail("Not yet implemented");
}
/**
* Test method for {@link org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedSoftware#getSourcePackage()}.
*/
@Test
public final void testGetSourcePackage() {
fail("Not yet implemented");
}
/**
* Test method for {@link org.gcube.vremanagement.resourcemanager.impl.resources.ScopedDeployedSoftware#getResolvedDependencies(java.lang.String)}.
@ -138,7 +167,13 @@ public class ScopedDeployedSoftwareTest {
*/
@Test
public final void testScheduleUndeploy() {
fail("Not yet implemented");
try {
sw.setStatus(STATUS.REMOVEREQUESTED);
sw.scheduleUndeploy(targetNode);
} catch (NoGHNFoundException e) {
e.printStackTrace();
fail();
}
}
/**
@ -146,7 +181,8 @@ public class ScopedDeployedSoftwareTest {
*/
@Test
public final void testScheduleDeploy() {
fail("Not yet implemented");
sw.setStatus(STATUS.ADDREQUESTED);
sw.scheduleDeploy(targetNode);
}
/**

View File

@ -22,6 +22,9 @@ public class VirtualNodeListTest {
static VirtualNodeList list;
static GCUBEScope scope;
static String name = "node2.d.d4science.research-infrastructures.eu:8080";
@BeforeClass
public static void setUpBeforeClass() throws Exception {
@ -53,9 +56,9 @@ public class VirtualNodeListTest {
try {
GCUBEScope scope = GCUBEScope.getScope("/gcube/devsec");
ServiceMap map = new ServiceMap();
map.load(new InputStreamReader(VirtualNodeTest.class.getResourceAsStream("/ServiceMap_devsec.xml")));
map.load(new InputStreamReader(VirtualNodeListTest.class.getResourceAsStream("/ServiceMap_devsec.xml")));
scope.setServiceMap(map);
VirtualNode node = VirtualNode.fromID("39837060-c9e3-11e1-9956-d67b5fce5acc", scope);
VirtualNode node = VirtualNode.fromName("node2.d.d4science.research-infrastructures.eu:8080", scope);
list.addNode(node);
} catch (MalformedScopeExpressionException e) {
fail("invalid scope");
@ -71,7 +74,8 @@ public class VirtualNodeListTest {
@Test
public final void testGetNode() {
try {
assertNotNull(list.getNode("node2.d.d4science.research-infrastructures.eu:8080"));
assertNotNull(list.getNode(name));
System.out.println("Node in the list: " + list.getNode("node2.d.d4science.research-infrastructures.eu:8080").getID());
} catch (NoGHNFoundException e) {
e.printStackTrace();
fail("can't find the node");

View File

@ -48,8 +48,8 @@ public class VirtualNodeTest extends ServiceStartupTest{
p.setServiceName("EnvironmentLibrariesSet");
p.setServiceClass("Execution");
p.setServiceVersion("1.0.0");
p.setVersion("1.2.0-SNAPSHOT");
p.setName("EnvironmentProviderLibrary"); //packageName
p.setVersion("1.0.0-SNAPSHOT");
p.setName("ReportingFrameworkLibrary"); //packageName
packages.add(p);
} catch (MalformedScopeExpressionException e) {