Search in sources :

Example 11 with ClientInfo

use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.

the class BlockingPingClient method login.

/**
	 * Login to the manager.
	 * @param	manager	manager reference.
	 * @param	sleepTimeMs	ping sleep time in ms.
	 * @return	client info, <code>null</code> on failure.
	 */
private ClientInfo login(Manager manager, long sleepTimeMs) {
    if (orb == null || manager == null)
        return null;
    System.out.println("Logging to the manager...");
    try {
        ClientImpl clientImpl = new ClientImpl(sleepTimeMs);
        Client client = clientImpl._this(orb);
        ClientInfo info = manager.login(client);
        if (info == null)
            throw new Exception("Failed to login to the manager since returned ClientInfo is 'null'.");
        System.out.println("Logged in to the manager.");
        return info;
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("Failed to login to the manager.");
        return null;
    }
}
Also used : ClientInfo(si.ijs.maci.ClientInfo) Client(si.ijs.maci.Client)

Example 12 with ClientInfo

use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.

the class DumpManagerState method test.

/**
	 * Main test routine.
	 */
public void test() {
    initializeCORBA();
    Manager manager = resolveManager();
    if (manager != null) {
        ClientInfo clientInfo = login(manager);
        if (clientInfo != null) {
            System.out.println("All initialization done.");
            try {
                ComponentInfo[] componentInfo = manager.get_component_info(clientInfo.h, new int[0], "*", "*", true);
                if (componentInfo == null)
                    throw new Exception("null client info returned.");
                System.out.println(componentInfo.length + " component(s) returned:");
                for (int i = 0; i < componentInfo.length; i++) {
                    System.out.println("\tName            : " + componentInfo[i].name);
                    System.out.println("\tHandle          : " + componentInfo[i].h + ", " + HandleHelper.toString(componentInfo[i].h));
                    System.out.println("\tType            : " + componentInfo[i].type);
                    System.out.println("\tCode            : " + componentInfo[i].code);
                    System.out.println("\tContainer name  : " + componentInfo[i].container_name);
                    System.out.println("\tContainer handle: " + HandleHelper.toString(componentInfo[i].container));
                    System.out.println("\tClients         : count = " + componentInfo[i].clients.length);
                    for (int j = 0; j < componentInfo[i].clients.length; j++) System.out.println("\t             \t" + componentInfo[i].clients[j]);
                    System.out.println("\t-------------------------------");
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
            System.out.println();
            System.out.println();
            System.out.println();
            try {
                ContainerInfo[] containersInfo = manager.get_container_info(clientInfo.h, new int[0], "*");
                if (containersInfo == null)
                    throw new Exception("null container info returned.");
                System.out.println(containersInfo.length + " container(s) returned:");
                for (int i = 0; i < containersInfo.length; i++) {
                    System.out.println("\tName            : " + containersInfo[i].name);
                    System.out.println("\tHandle          : " + containersInfo[i].h + ", " + HandleHelper.toString(containersInfo[i].h));
                    System.out.println("\tComponents      : count = " + containersInfo[i].components.length);
                    for (int j = 0; j < containersInfo[i].components.length; j++) System.out.println("\t             \t" + containersInfo[i].components[j]);
                    System.out.println("\t-------------------------------");
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
            System.out.println();
            System.out.println();
            System.out.println();
            try {
                ClientInfo[] clientsInfo = manager.get_client_info(clientInfo.h, new int[0], "*");
                if (clientsInfo == null)
                    throw new Exception("null component info returned.");
                System.out.println(clientsInfo.length + " clients(s) returned:");
                for (int i = 0; i < clientsInfo.length; i++) {
                    System.out.println("\tName            : " + clientsInfo[i].name);
                    System.out.println("\tHandle          : " + clientsInfo[i].h + ", " + HandleHelper.toString(clientsInfo[i].h));
                    System.out.println("\tComponents      : count = " + clientsInfo[i].components.length);
                    for (int j = 0; j < clientsInfo[i].components.length; j++) System.out.println("\t             \t" + clientsInfo[i].components[j]);
                    System.out.println("\t-------------------------------");
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
            logout(manager, clientInfo);
        }
    }
    finalizeCORBA();
}
Also used : ContainerInfo(si.ijs.maci.ContainerInfo) ClientInfo(si.ijs.maci.ClientInfo) ComponentInfo(si.ijs.maci.ComponentInfo) POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager)

Example 13 with ClientInfo

use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.

the class BuildingTest method login.

/**
	 * Login to the manager.
	 * @param	manager	manager reference.
	 * @return	client info, <code>null</code> on failure.
	 */
private ClientInfo login(Manager manager) {
    if (orb == null || manager == null)
        return null;
    System.out.println("Logging to the manager...");
    try {
        ClientImpl clientImpl = new ClientImpl();
        Client client = clientImpl._this(orb);
        ClientInfo info = manager.login(client);
        if (info == null)
            throw new Exception("Failed to login to the manager since returned ClientInfo is 'null'.");
        System.out.println("Logged in to the manager.");
        return info;
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("Failed to login to the manager.");
        return null;
    }
}
Also used : ClientInfo(si.ijs.maci.ClientInfo) Client(si.ijs.maci.Client)

Example 14 with ClientInfo

use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.

the class BuildingTest method test.

/**
	 * Main test routine.
	 */
public void test() {
    initializeCORBA();
    Manager manager = resolveManager();
    if (manager != null) {
        ClientInfo clientInfo = login(manager);
        if (clientInfo != null) {
            System.out.println("All initialization done.");
            //
            // get component
            //
            final String COMPONENT_NAME = "BUILDING1";
            org.omg.CORBA.Object obj;
            try {
                obj = manager.get_component(clientInfo.h, COMPONENT_NAME, true);
                Building building = BuildingHelper.narrow(obj);
                ROstring version = building.version();
                // syncvalue retrival
                System.out.println("Version: " + version.get_sync(new CompletionHolder()));
                // create a monitor
                Monitor monitor = version.create_monitor(new CBstringImpl()._this(orb), new CBDescIn());
                // sleep for a while
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException ie) {
                }
                ;
                monitor.destroy();
            } catch (Exception e) {
                // CannotGetComponentEx, ComponentConfigurationNotFoundEx
                System.err.println("Failed to obtain component: " + COMPONENT_NAME);
            }
            // release now
            try {
                manager.release_component(clientInfo.h, COMPONENT_NAME);
            } catch (Exception ex) {
                ex.printStackTrace();
                System.out.println("Failed to release component.");
            }
            logout(manager, clientInfo);
        }
    }
    finalizeCORBA();
}
Also used : POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager) ROstring(alma.ACS.ROstring) CBDescIn(alma.ACS.CBDescIn) Monitor(alma.ACS.Monitor) CompletionHolder(alma.ACSErr.CompletionHolder) ClientInfo(si.ijs.maci.ClientInfo)

Example 15 with ClientInfo

use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.

the class SimpleMasterComponentTest method login.

/**
	 * Login to the manager.
	 * @param	manager	manager reference.
	 * @return	client info, <code>null</code> on failure.
	 */
private ClientInfo login(Manager manager) {
    if (orb == null || manager == null)
        return null;
    System.out.println("Logging to the manager...");
    try {
        ClientImpl clientImpl = new ClientImpl();
        Client client = clientImpl._this(orb);
        ClientInfo info = manager.login(client);
        if (info == null)
            throw new Exception("Failed to login to the manager since returned ClientInfo is 'null'.");
        System.out.println("Logged in to the manager.");
        return info;
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("Failed to login to the manager.");
        return null;
    }
}
Also used : ClientInfo(si.ijs.maci.ClientInfo) Client(si.ijs.maci.Client)

Aggregations

ClientInfo (si.ijs.maci.ClientInfo)24 ComponentInfo (si.ijs.maci.ComponentInfo)9 ContainerInfo (si.ijs.maci.ContainerInfo)8 Client (si.ijs.maci.Client)6 Manager (si.ijs.maci.Manager)6 POAManager (org.omg.PortableServer.POAManager)5 CBDescIn (alma.ACS.CBDescIn)2 CompletionHolder (alma.ACSErr.CompletionHolder)2 IMaciSupervisor (alma.acs.commandcenter.meta.IMaciSupervisor)2 NoPermissionEx (alma.maciErrType.NoPermissionEx)2 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)2 BadParametersException (com.cosylab.acs.maci.BadParametersException)2 CoreException (com.cosylab.acs.maci.CoreException)2 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)2 Monitor (alma.ACS.Monitor)1 MonitorstringSeq (alma.ACS.MonitorstringSeq)1 ROstring (alma.ACS.ROstring)1 ROstringSeq (alma.ACS.ROstringSeq)1 AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)1 OrbInitException (alma.acs.commandcenter.meta.Firestarter.OrbInitException)1