use of com.cosylab.acs.maci.ContainerInfo in project ACS by ACS-Community.
the class ManagerImplTest method testOnDemandContainer.
public void testOnDemandContainer() throws Throwable {
TestDaemon daemon = new TestDaemon(manager, false);
transport.registerDeamon("test", daemon);
TestAdministrator client = new TestAdministrator(administratorName);
ClientInfo info = manager.login(client);
assertTrue(info.getHandle() != 0);
URI curl = null;
// test on-demand activation
curl = new URI("DEMANDER");
StatusHolder status = new StatusHolder();
Component ref = manager.getComponent(info.getHandle(), curl, true, status);
assertNotNull(ref);
assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
// check if container is logged in
ContainerInfo[] infos = manager.getContainerInfo(info.getHandle(), new int[0], "OnDemandContainer");
assertNotNull(infos);
assertEquals(1, infos.length);
// release component
manager.releaseComponent(info.getHandle(), curl);
Thread.sleep(SLEEP_TIME_MS);
// there should be no container
infos = manager.getContainerInfo(info.getHandle(), new int[0], "OnDemandContainer");
assertNotNull(infos);
assertEquals(0, infos.length);
// now fail to start container
daemon = new TestDaemon(manager, true);
transport.registerDeamon("test", daemon);
try {
status = new StatusHolder();
ref = manager.getComponent(info.getHandle(), curl, true, status);
fail();
} catch (AcsJCannotGetComponentEx e) {
System.out.println("This is OK: " + e.toString());
}
// no daemon case
transport.registerDeamon("test", null);
try {
status = new StatusHolder();
ref = manager.getComponent(info.getHandle(), curl, true, status);
fail("Expected AcsJCannotGetComponentEx");
} catch (AcsJCannotGetComponentEx e) {
System.out.println("This is OK: " + e.toString());
} catch (AcsJNoPermissionEx e) {
fail();
}
}
use of com.cosylab.acs.maci.ContainerInfo in project ACS by ACS-Community.
the class ContainerInfoCommandComponentRemove method execute.
/**
* @see Command#execute(PrevalentSystem)
*/
public Serializable execute(PrevalentSystem system) throws Exception {
ContainerInfo containerInfo = (ContainerInfo) ((ManagerImpl) system).getContainers().get(handle);
containerInfo.getComponents().remove(cobHandle);
return null;
}
use of com.cosylab.acs.maci.ContainerInfo in project ACS by ACS-Community.
the class AdministratorProxy method containerLoggedIn.
/**
* @see com.cosylab.acs.maci.Administrator#containerLoggedIn(ContainerInfo, long, long)
*/
public void containerLoggedIn(ContainerInfo info, long timeStamp, long executionId) throws RemoteException {
try {
si.ijs.maci.ContainerInfo containerInfo = null;
if (info != null)
containerInfo = new si.ijs.maci.ContainerInfo(info.getName(), info.getHandle(), (Container) ((ClientProxy) info.getContainer()).getClient(), info.getComponents().toArray());
administrator.container_logged_in(containerInfo, UTCUtility.utcJavaToOmg(timeStamp), executionId);
} catch (TIMEOUT te) {
throw new RemoteTimeoutException("Failed to invoke 'container_logged_in()' method due to timeout.", te);
} catch (TRANSIENT tre) {
throw new RemoteTransientException("Failed to invoke 'container_logged_in()' method due to transient exception.", tre);
} catch (Throwable ex) {
throw new RemoteException("Failed to invoke 'container_logged_in()' method.", ex);
}
}
use of com.cosylab.acs.maci.ContainerInfo in project ACS by ACS-Community.
the class ManagerImplTest method testContainerInfo.
public void testContainerInfo() {
try {
//test invalid
try {
manager.getContainerInfo(0, null, null);
fail();
} catch (BadParametersException bpe) {
System.out.println("This is OK: " + bpe.getMessage());
}
//test invalid
try {
manager.getContainerInfo(Integer.MAX_VALUE, null, null);
fail();
} catch (BadParametersException bpe) {
System.out.println("This is OK: " + bpe.getMessage());
}
//test invalid
try {
manager.getContainerInfo(dummyHandle, null, null);
fail();
} catch (BadParametersException bpe) {
System.out.println("This is OK: " + bpe.getMessage());
}
//test invalid
try {
manager.getContainerInfo(dummyHandle, new int[0], null);
fail();
} catch (BadParametersException bpe) {
System.out.println("This is OK: " + bpe.getMessage());
}
//test invalid
try {
manager.getContainerInfo(dummyHandle, new int[0], "non-null");
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
/*
//test invalid regular expression
try {
manager.getContainerInfo(dummyHandle, new int[0], ")");
fail();
}
catch (BadParametersException bpe)
{
System.out.println("This is OK: "+bpe.getMessage());
}
*/
//test valid
ClientInfo info = manager.login(new TestContainer(containerName));
int[] handles = { info.getHandle() };
ContainerInfo[] infos = manager.getContainerInfo(info.getHandle(), handles, null);
assertNotNull(infos);
assertEquals(infos.length, 1);
assertEquals(infos[0].getHandle(), info.getHandle());
manager.logout(info.getHandle());
//test inaccessible
info = manager.login(new TestContainer(containerName));
ClientInfo anotherInfo = manager.login(new TestContainer(anotherName));
handles[0] = anotherInfo.getHandle();
try {
infos = manager.getContainerInfo(info.getHandle(), handles, null);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
try {
manager.getClientInfo(info.getHandle(), new int[0], anotherName);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
manager.logout(info.getHandle());
manager.logout(anotherInfo.getHandle());
//test with INTROSPECTION_MANAGER rights
info = manager.login(new TestContainer(containerName));
ClientInfo adminInfo = manager.login(new TestAdministrator(administratorName));
handles = new int[3];
handles[0] = adminInfo.getHandle();
handles[1] = info.getHandle();
handles[2] = dummyHandle;
infos = manager.getContainerInfo(adminInfo.getHandle(), handles, null);
assertNotNull(infos);
assertNull(infos[0]);
assertEquals(infos[1].getHandle(), info.getHandle());
assertNull(infos[2]);
manager.logout(info.getHandle());
manager.logout(adminInfo.getHandle());
// test wildcard search
info = manager.login(new TestContainer("container1"));
assertNotNull(info);
ClientInfo info2 = manager.login(new TestContainer("container2a"));
assertNotNull(info2);
ClientInfo info3 = manager.login(new TestContainer("container3aa"));
assertNotNull(info3);
ClientInfo info4 = manager.login(new TestContainer("other4"));
assertNotNull(info4);
adminInfo = manager.login(new TestAdministrator("admin"));
assertNotNull(adminInfo);
//infos = manager.getContainerInfo(adminInfo.getHandle(), new int[0], "container.*");
infos = manager.getContainerInfo(adminInfo.getHandle(), new int[0], "container*");
assertNotNull(infos);
assertEquals(3, infos.length);
assertEquals(info.getHandle(), infos[0].getHandle());
assertEquals(info2.getHandle(), infos[1].getHandle());
assertEquals(info3.getHandle(), infos[2].getHandle());
manager.logout(info.getHandle());
manager.logout(info2.getHandle());
manager.logout(info3.getHandle());
manager.logout(info4.getHandle());
manager.logout(adminInfo.getHandle());
} catch (AcsJNoPermissionEx e) {
fail("No permission");
}
}
Aggregations