Search in sources :

Example 21 with ContainerInfo

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();
    }
}
Also used : AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) ContainerInfo(com.cosylab.acs.maci.ContainerInfo) ClientInfo(com.cosylab.acs.maci.ClientInfo) Component(com.cosylab.acs.maci.Component) URI(java.net.URI) AcsJCannotGetComponentEx(alma.maciErrType.wrappers.AcsJCannotGetComponentEx) StatusHolder(com.cosylab.acs.maci.StatusHolder)

Example 22 with ContainerInfo

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;
}
Also used : ManagerImpl(com.cosylab.acs.maci.manager.ManagerImpl) ContainerInfo(com.cosylab.acs.maci.ContainerInfo)

Example 23 with ContainerInfo

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);
    }
}
Also used : RemoteTimeoutException(com.cosylab.acs.maci.RemoteTimeoutException) ContainerInfo(com.cosylab.acs.maci.ContainerInfo) TIMEOUT(org.omg.CORBA.TIMEOUT) RemoteException(com.cosylab.acs.maci.RemoteException) TRANSIENT(org.omg.CORBA.TRANSIENT) RemoteTransientException(com.cosylab.acs.maci.RemoteTransientException)

Example 24 with ContainerInfo

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");
    }
}
Also used : AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) ContainerInfo(com.cosylab.acs.maci.ContainerInfo) ClientInfo(com.cosylab.acs.maci.ClientInfo) BadParametersException(com.cosylab.acs.maci.BadParametersException)

Aggregations

ContainerInfo (com.cosylab.acs.maci.ContainerInfo)24 ComponentInfo (com.cosylab.acs.maci.ComponentInfo)9 ClientInfo (com.cosylab.acs.maci.ClientInfo)7 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)5 Container (com.cosylab.acs.maci.Container)5 DAOProxy (com.cosylab.cdb.client.DAOProxy)5 BadParametersException (com.cosylab.acs.maci.BadParametersException)4 RemoteException (com.cosylab.acs.maci.RemoteException)4 TimeoutRemoteException (com.cosylab.acs.maci.TimeoutRemoteException)4 URI (java.net.URI)4 ArrayList (java.util.ArrayList)4 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)3 Component (com.cosylab.acs.maci.Component)3 CoreException (com.cosylab.acs.maci.CoreException)3 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)3 StatusHolder (com.cosylab.acs.maci.StatusHolder)3 ManagerImpl (com.cosylab.acs.maci.manager.ManagerImpl)3 ImplLang (com.cosylab.acs.maci.ImplLang)2 IntArray (com.cosylab.acs.maci.IntArray)2 Manager (com.cosylab.acs.maci.Manager)2