Search in sources :

Example 1 with Manager

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

the class MaciSupervisorTest method setUp.

@Override
public void setUp() throws Exception {
    System.out.println("\n--- " + getName() + " ----------------");
    // make the manager
    // -----------------------------------------------------------------
    orb = Mockito.mock(ORB.class);
    manager = Mockito.mock(Manager.class);
    administrator = Mockito.mock(Administrator.class);
    final int hhhhh = 0;
    final int[] empty = new int[] {};
    ComponentInfo comp100 = new ComponentInfo("type", "code", null, "comp100", empty, 10, "cont10", 100, 0, new String[] {});
    ComponentInfo comp200 = new ComponentInfo("type", "code", null, "comp200", empty, 20, "cont20", 200, 0, new String[] {});
    ComponentInfo comp300 = new ComponentInfo("type", "code", null, "comp300", empty, 30, "cont30", 300, 0, new String[] {});
    ComponentInfo[] one_comp = { comp100 };
    ComponentInfo[] two_comps = { comp100, comp200 };
    ComponentInfo[] three_comps = { comp100, comp200, comp300 };
    ContainerInfo cont10 = new ContainerInfo("cont10", 10, null, empty);
    ContainerInfo cont20 = new ContainerInfo("cont20", 20, null, empty);
    ContainerInfo cont30 = new ContainerInfo("cont30", 30, null, empty);
    ContainerInfo[] one_cont = { cont10 };
    ContainerInfo[] two_conts = { cont10, cont20 };
    ContainerInfo[] three_conts = { cont10, cont20, cont30 };
    ClientInfo clientA = new ClientInfo(0, null, empty, "clientA", 0);
    ClientInfo client1 = new ClientInfo(1, null, empty, "client1", 0);
    ClientInfo client2 = new ClientInfo(2, null, empty, "client2", 0);
    ClientInfo client3 = new ClientInfo(3, null, empty, "client3", 0);
    ClientInfo[] one_client = { client1 };
    ClientInfo[] two_clients = { client1, client2 };
    ClientInfo[] three_clients = { client1, client2, client3 };
    Mockito.when(orb.string_to_object("dummy")).thenReturn(manager);
    Mockito.when(manager.login(administrator)).thenReturn(clientA);
    Mockito.when(manager.get_component_info(hhhhh, empty, "*", "*", false)).thenReturn(one_comp, two_comps, three_comps);
    Mockito.when(manager.get_container_info(hhhhh, empty, "*")).thenReturn(one_cont, one_cont, two_conts, three_conts);
    Mockito.when(manager.get_client_info(hhhhh, empty, "*")).thenReturn(one_client, two_clients, three_clients, two_clients, three_clients);
    // make the supervisor
    // -----------------------------------------------------------------
    log = new Logger("Test", null) {

        final long start = System.nanoTime();

        @Override
        public void log(LogRecord r) {
            long sinceStart = (System.nanoTime() - start) / 1000 / 1000 / 1000;
            System.out.println(String.format("%2d", sinceStart) + "  " + r.getLevel() + "  " + r.getMessage());
        }
    };
    log.setLevel(Level.FINE);
    testee = new MaciSupervisor("Test", "dummy", orb, log);
    testee.acImpl = testee.new AdministratorImplementation() {

        @Override
        protected Administrator asCorbaObject(ORB orb) {
            return administrator;
        }
    };
    testee.start();
    // assertions
    // ----------------------------------------------------------------
    maciListener = new MaciInfoListener();
    MaciInfo maciInformation = testee.getMaciInformation();
    maciInformation.addTreeModelListener(maciListener);
}
Also used : Manager(si.ijs.maci.Manager) Logger(java.util.logging.Logger) Administrator(si.ijs.maci.Administrator) LogRecord(java.util.logging.LogRecord) ContainerInfo(si.ijs.maci.ContainerInfo) ComponentInfo(si.ijs.maci.ComponentInfo) ClientInfo(si.ijs.maci.ClientInfo) ORB(org.omg.CORBA.ORB)

Example 2 with Manager

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

the class SimpleMasterComponentTest method resolveManager.

/**
	 * Resolves manager reference.
	 * @return manager reference, <code>null</code> on failure.
	 */
private Manager resolveManager() {
    if (orb == null)
        return null;
    String managerReference = System.getProperty("ACS.manager");
    if (managerReference == null)
        managerReference = "corbaloc::" + ACSPorts.getIP() + ":3000/Manager";
    System.out.println("Resolving manager reference '" + managerReference + "'.");
    try {
        org.omg.CORBA.Object obj = orb.string_to_object(managerReference);
        if (obj == null)
            throw new NullPointerException("'null' reference returned.");
        Manager manager = ManagerHelper.narrow(obj);
        if (manager == null)
            throw new NullPointerException("'null' narrowed reference returned.");
        System.out.println("Manager reference successfully resolved.");
        return manager;
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("Failed to resolve manager reference.");
        return null;
    }
}
Also used : POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager)

Example 3 with Manager

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

the class SimpleMasterComponentTest 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 = "SIMPLEMASTERCOMPONENT1";
            org.omg.CORBA.Object obj;
            try {
                obj = manager.get_component(clientInfo.h, COMPONENT_NAME, true);
                SimpleMasterComponent simpleMasterComponent = SimpleMasterComponentHelper.narrow(obj);
                ROstringSeq currentStateHierarchy = simpleMasterComponent.currentStateHierarchy();
                // syncvalue retrival
                System.out.println("Current state hierarchy: " + getStringArray(currentStateHierarchy.get_sync(new CompletionHolder())));
                System.out.println("Monitoring - 1s interval...");
                // create a monitor
                MonitorstringSeq monitor = currentStateHierarchy.create_monitor(new CBstringSeqImpl()._this(orb), new CBDescIn());
                // sleep for a while
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException ie) {
                }
                ;
                monitor.set_timer_trigger(0);
                monitor.set_value_trigger(new String[0], true);
                System.out.println("On-change monitoring...");
                // 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 (NoPermissionEx ex) {
                ex.printStackTrace();
            }
            logout(manager, clientInfo);
        }
    }
    finalizeCORBA();
}
Also used : SimpleMasterComponent(test.jbaci.SimpleMasterComponent) POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager) CBDescIn(alma.ACS.CBDescIn) ROstringSeq(alma.ACS.ROstringSeq) MonitorstringSeq(alma.ACS.MonitorstringSeq) NoPermissionEx(alma.maciErrType.NoPermissionEx) CompletionHolder(alma.ACSErr.CompletionHolder) ClientInfo(si.ijs.maci.ClientInfo)

Example 4 with Manager

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

the class RemoteLoggingTest method initRemoteLogging.

///////////////////////////////////////////////////////////
//////////////////    Helper methods    ///////////////////
///////////////////////////////////////////////////////////
/**
	 * Calls {@linkplain ClientLogManagerStandalone#initRemoteLogging(ORB, Manager, int, boolean)}
	 * with appropriate dummy parameters.
	 * @param clm The instance to call initRemoteLogging on.
	 * @return true if simulated remote logging was initialized successfully
	 */
private boolean initRemoteLogging(ClientLogManagerStandalone clm) {
    // An unconfigured ORB will do, just needed to produce Any objects for sending remote logs.
    // There is however the ugly side effect that the constructor org.jacorb.orb.ORBSingleton
    // will use slf4j and thus call ClientLogManager#getAcsLogManager, so that we have another
    // instance of ClientLogManager in addition to our ClientLogManagerStandalone instance.
    ORB orb = ORB.init();
    // will only be used for != null check.
    Manager managerDummy = new _ManagerStub();
    return clm.initRemoteLogging(orb, managerDummy, 1, true);
}
Also used : si.ijs.maci._ManagerStub(si.ijs.maci._ManagerStub) Manager(si.ijs.maci.Manager) ORB(org.omg.CORBA.ORB)

Example 5 with Manager

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

the class ManagerDynComponentTest method resolveManager.

/**
	 * Resolves manager reference.
	 * @return manager reference, <code>null</code> on failure.
	 */
private Manager resolveManager() {
    if (orb == null)
        return null;
    String managerReference = System.getProperty("ACS.manager");
    if (managerReference == null)
        managerReference = "corbaloc:" + ACSPorts.getIP() + ":" + ACSPorts.getManagerPort() + "/Manager";
    System.out.println("Resolving manager reference '" + managerReference + "'.");
    try {
        org.omg.CORBA.Object obj = orb.string_to_object(managerReference);
        if (obj == null)
            throw new NullPointerException("'null' reference returned.");
        Manager manager = ManagerHelper.narrow(obj);
        if (manager == null)
            throw new NullPointerException("'null' narrowed reference returned.");
        System.out.println("Manager reference successfully resolved.");
        return manager;
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("Failed to resolve manager reference.");
        return null;
    }
}
Also used : POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager)

Aggregations

Manager (si.ijs.maci.Manager)17 POAManager (org.omg.PortableServer.POAManager)11 ClientInfo (si.ijs.maci.ClientInfo)6 ComponentInfo (si.ijs.maci.ComponentInfo)3 ContainerInfo (si.ijs.maci.ContainerInfo)3 CBDescIn (alma.ACS.CBDescIn)2 CompletionHolder (alma.ACSErr.CompletionHolder)2 LoggingConfigurableOperations (alma.Logging.LoggingConfigurableOperations)2 LogPaneNotFoundException (alma.acs.gui.loglevel.LogPaneNotFoundException)2 SwingWorker (javax.swing.SwingWorker)2 ORB (org.omg.CORBA.ORB)2 Monitor (alma.ACS.Monitor)1 MonitorstringSeq (alma.ACS.MonitorstringSeq)1 ROstring (alma.ACS.ROstring)1 ROstringSeq (alma.ACS.ROstringSeq)1 ClientLogManager (alma.acs.logging.ClientLogManager)1 AcsORBProfilerImplBase (alma.acs.profiling.orb.AcsORBProfilerImplBase)1 InvalidComponentSpecEx (alma.maciErrType.InvalidComponentSpecEx)1 NoDefaultComponentEx (alma.maciErrType.NoDefaultComponentEx)1 NoPermissionEx (alma.maciErrType.NoPermissionEx)1