use of com.cosylab.acs.maci.ClientInfo in project ACS by ACS-Community.
the class ManagerImplTest method testContainerToManagerStateTransferComponents.
public void testContainerToManagerStateTransferComponents() {
TestComponent mount1COB = new TestComponent("MOUNT1");
TestComponent mount2COB = new TestComponent("MOUNT2");
Map supportedComponents = new HashMap();
supportedComponents.put("MOUNT1", mount1COB);
supportedComponents.put("MOUNT2", mount2COB);
try {
// dummy container
TestContainer dummyContainer = new TestContainer("Container", ClientType.CONTAINER, true);
ClientInfo dummyContainerInfo = manager.login(dummyContainer);
dummyContainer.setSupportedComponents(supportedComponents);
try {
Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
TestAdministrator client = new TestAdministrator(administratorName);
ClientInfo info = manager.login(client);
// activate MOUNT2
//
URI mount2URI;
try {
mount2URI = new URI("MOUNT2");
StatusHolder status = new StatusHolder();
Component ref = manager.getComponent(info.getHandle(), mount2URI, true, status);
assertEquals(mount2COB, ref);
assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
} catch (Exception ex) {
fail();
}
manager.logout(dummyContainerInfo.getHandle());
// try to confuse with recovery mode
TestContainer container = new TestContainer("Container", ClientType.CONTAINER, true);
container.setSupportedComponents(supportedComponents);
// add Components to container
ComponentInfo mount1COBInfo = new ComponentInfo(HandleConstants.COMPONENT_MASK + 1, "MOUNT1", "IDL:alma/MOUNT_ACS/Mount:1.0", "acsexmplMount", mount1COB);
mount1COBInfo.setInterfaces(mount1COB.implementedInterfaces());
mount1COBInfo.setContainer(dummyContainerInfo.getHandle());
mount1COBInfo.setContainerName(dummyContainerInfo.getName());
container.getActivatedComponents().put(new Integer(mount1COBInfo.getHandle()), mount1COBInfo);
ComponentInfo mount2COBInfo = new ComponentInfo(HandleConstants.COMPONENT_MASK + 2, "MOUNT2", "IDL:alma/MOUNT_ACS/Mount:1.0", "acsexmplMount", mount2COB);
mount2COBInfo.setInterfaces(mount2COB.implementedInterfaces());
mount2COBInfo.setContainer(dummyContainerInfo.getHandle());
mount2COBInfo.setContainerName(dummyContainerInfo.getName());
container.getActivatedComponents().put(new Integer(mount2COBInfo.getHandle()), mount2COBInfo);
// container login
ClientInfo containerInfo = manager.login(container);
try {
Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
// there should be 2 Components activated
ComponentInfo[] infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
Arrays.sort(infos);
assertEquals(2, infos.length);
assertEquals("MOUNT1", infos[0].getName());
assertEquals("MOUNT2", infos[1].getName());
// container2 took over
assertEquals(containerInfo.getHandle(), infos[0].getContainer());
assertEquals(containerInfo.getHandle(), infos[1].getContainer());
// manager
assertEquals(1, infos[0].getClients().size());
assertTrue(infos[0].getClients().contains(HandleConstants.MANAGER_MASK));
// client only
assertEquals(1, infos[1].getClients().size());
assertTrue(infos[1].getClients().contains(info.getHandle()));
} catch (AcsJNoPermissionEx e) {
fail("No permission");
}
}
use of com.cosylab.acs.maci.ClientInfo in project ACS by ACS-Community.
the class ManagerPrevaylerTest method dynamicComponentClientInstance.
private int dynamicComponentClientInstance(final String clientInstance) throws Throwable {
// simple trick to align all the threads
Thread.sleep(CLIENT_START_DELAY_MS);
TestClient client = new TestClient(clientInstance);
ClientInfo info = manager.login(client);
// all dynamic case
try {
for (int i = 0; i < COMPONENTS; i++) {
ComponentInfo componentInfo = manager.getDynamicComponent(info.getHandle(), new ComponentSpec(clientInstance + "-dynComponent-" + i, "java.lang.Object", "java.lang.Object", "DynContainer"), true);
assertTrue(componentInfo != null);
int nc = count.incrementAndGet();
if (nc % COUNT_REPORT_EVERY == 0)
System.out.println(nc + " components activated until now...");
}
} catch (Throwable ex) {
ex.printStackTrace();
fail();
}
return info.getHandle();
}
use of com.cosylab.acs.maci.ClientInfo in project ACS by ACS-Community.
the class TestDaemon method startContainer.
/* (non-Javadoc)
* @see com.cosylab.acs.maci.Daemon#startContainer(java.lang.String, java.lang.String, short, java.lang.String)
*/
public void startContainer(String containerType, final String containerName, short instanceNumber, String flags) throws RemoteException {
if (alwaysFail)
return;
new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
TestDynamicContainer tdc = new TestDynamicContainer(containerName, manager);
try {
ClientInfo info = manager.login(tdc);
tdc.setHandle(info.getHandle());
} catch (AcsJNoPermissionEx e) {
/// @todo Error handling when catching exceptions
e.printStackTrace();
}
}
}, "Conatiner starter").start();
}
use of com.cosylab.acs.maci.ClientInfo in project ACS by ACS-Community.
the class ManagerImplTest method testShutdown.
/**
*
* Test of ManagerImpl shutdown.
*
*/
public void testShutdown() {
try {
manager.shutdown(0, 0);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
Client client = new TestClient(clientName);
ClientInfo info = null;
try {
info = manager.login(client);
} catch (AcsJNoPermissionEx e) {
fail("No permission");
}
try {
manager.shutdown(info.getHandle(), 0);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
Administrator admin = new TestAdministrator("shutdownAdmin");
ClientInfo info2 = null;
try {
info2 = manager.login(admin);
manager.shutdown(info2.getHandle(), 0);
} catch (AcsJNoPermissionEx e) {
fail("No permission");
}
// already shutdown
try {
manager.shutdown(info2.getHandle(), 0);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
// already shutdown returns without exception
try {
manager.logout(info.getHandle());
System.out.println("This is OK");
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is NOT OK: " + npe.toString());
npe.printStackTrace();
}
// already shutdown
try {
manager.login(client);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
// tearDown should not shutdown
manager = null;
}
use of com.cosylab.acs.maci.ClientInfo in project ACS by ACS-Community.
the class ManagerImplTest method testStartupComponents.
public void testStartupComponents() {
try {
TestContainer container = new TestContainer("Container");
Map supportedComponents = new HashMap();
TestComponent mount1COB = new TestComponent("MOUNT1");
supportedComponents.put("MOUNT1", mount1COB);
container.setSupportedComponents(supportedComponents);
TestAdministrator client = new TestAdministrator(administratorName);
ClientInfo info = manager.login(client);
// test case when container is unable to activate startup Component - MOUNT1
ClientInfo containerInfo = manager.login(container);
try {
Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
// there should be only no Components activated
ComponentInfo[] infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
assertEquals(1, infos.length);
assertTrue("MOUNT1".equals(infos[0].getName()));
// manager and client
assertEquals(1, infos[0].getClients().size());
assertTrue(infos[0].getClients().contains(HandleConstants.MANAGER_MASK));
// container logout and login
manager.logout(containerInfo.getHandle());
try {
Thread.sleep(SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
assertEquals(0, infos.length);
manager.login(container);
try {
Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
// there should be only no Components activated
infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
assertEquals(1, infos.length);
assertTrue("MOUNT1".equals(infos[0].getName()));
// manager
assertEquals(1, infos[0].getClients().size());
assertTrue(infos[0].getClients().contains(HandleConstants.MANAGER_MASK));
manager.logout(info.getHandle());
try {
Thread.sleep(SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
} catch (AcsJNoPermissionEx e) {
fail("No permission");
}
}
Aggregations