Search in sources :

Example 1 with Administrator

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

the class MaciSupervisor method connectToManager.

// ==================================================================
// Internal
// ==================================================================
// ============= Connecting / Disconnecting ===============
/**
	 * 
	 */
protected void connectToManager() throws CannotRetrieveManagerException, NoPermissionEx, SystemException {
    log.fine(connect + "connecting to manager");
    try {
        org.omg.CORBA.Object object = orb.string_to_object(managerLoc);
        managerRef = ManagerHelper.narrow(object);
    } catch (Exception exc) {
        log.fine(connect + "failed to connect to manager: " + exc);
        throw new CannotRetrieveManagerException("could not retrieve manager reference", exc);
    }
    if (managerRef == null) {
        log.fine(connect + "failed to connect to manager: got null manager reference");
        throw new CannotRetrieveManagerException("orb delivered null-reference for manager-location " + managerLoc);
    }
    // <-- may throw "port occupied"
    Administrator admin = acImpl.asCorbaObject(orb);
    administratorClientInfo = managerRef.login(admin);
    log.info(connect + "connected to manager (" + getManagerLocation() + ") as " + administratorClientInfo.h + " (= 0x" + Integer.toHexString(administratorClientInfo.h) + ")");
}
Also used : Administrator(si.ijs.maci.Administrator) SystemException(org.omg.CORBA.SystemException)

Example 2 with Administrator

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

the class AdministratorClient method connectToManager.

/**
	 * Connect to the manager 
	 */
public void connectToManager() throws Exception {
    managerLoc = System.getProperty("ACS.manager");
    if (managerLoc == null || managerLoc.length() == 0) {
        throw new Exception("Error getting the manager loc: " + managerLoc);
    }
    managerLoc = managerLoc.trim();
    org.omg.CORBA.Object object = orb.string_to_object(managerLoc);
    if (object == null) {
        throw new Exception("Error getting the manager " + managerLoc);
    }
    managerRef = ManagerHelper.narrow(object);
    if (managerRef == null) {
        throw new Exception("Error narrowing the " + managerLoc);
    }
    // <-- throws "port occupied"
    Administrator adminIF = _this(orb);
    administratorInfo = managerRef.login(adminIF);
    logger.info("Connected to manager (name=" + administratorInfo.name + ", handle=" + administratorInfo.h + ")");
}
Also used : Administrator(si.ijs.maci.Administrator) SystemException(org.omg.CORBA.SystemException)

Example 3 with Administrator

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

the class ContainerTestUtil method loginToManager.

public void loginToManager() throws AcsJContainerEx {
    if (adminProxy == null) {
        AdministratorPOATie adminpoa = new AdministratorPOATie(new ManagerAdminClient(containerServices.getName(), logger));
        Administrator adminCorbaObj = adminpoa._this(containerServices.getAdvancedContainerServices().getORB());
        adminProxy = managerProxy.createInstance();
        adminProxy.loginToManager(adminCorbaObj, 1);
        int adminManagerHandle = adminProxy.getManagerHandle();
        Assert.assertTrue(adminManagerHandle > 0);
    }
}
Also used : Administrator(si.ijs.maci.Administrator) AdministratorPOATie(si.ijs.maci.AdministratorPOATie)

Example 4 with Administrator

use of si.ijs.maci.Administrator 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 5 with Administrator

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

the class AdministratorClient method connectToManager.

/**
	 * Connect to the manager 
	 */
public void connectToManager() throws Exception {
    managerLoc = System.getProperty("ACS.manager");
    if (managerLoc == null || managerLoc.length() == 0) {
        throw new Exception("Error getting the manager loc: " + managerLoc);
    }
    managerLoc = managerLoc.trim();
    org.omg.CORBA.Object object = orb.string_to_object(managerLoc);
    if (object == null) {
        throw new Exception("Error getting the manager " + managerLoc);
    }
    managerRef = ManagerHelper.narrow(object);
    if (managerRef == null) {
        throw new Exception("Error narrowing the " + managerLoc);
    }
    // <-- throws "port occupied"
    Administrator adminIF = _this(orb);
    administratorInfo = managerRef.login(adminIF);
    logger.info("Connected to manager (name=" + administratorInfo.name + ", handle=" + administratorInfo.h + ")");
}
Also used : Administrator(si.ijs.maci.Administrator) SystemException(org.omg.CORBA.SystemException) NotConnectedToManagerException(alma.acs.commandcenter.meta.IMaciSupervisor.NotConnectedToManagerException)

Aggregations

Administrator (si.ijs.maci.Administrator)8 AdministratorPOATie (si.ijs.maci.AdministratorPOATie)4 SystemException (org.omg.CORBA.SystemException)3 NotConnectedToManagerException (alma.acs.commandcenter.meta.IMaciSupervisor.NotConnectedToManagerException)1 LogRecord (java.util.logging.LogRecord)1 Logger (java.util.logging.Logger)1 ORB (org.omg.CORBA.ORB)1 ClientInfo (si.ijs.maci.ClientInfo)1 ComponentInfo (si.ijs.maci.ComponentInfo)1 ContainerInfo (si.ijs.maci.ContainerInfo)1 Manager (si.ijs.maci.Manager)1 SynchronousAdministratorOperations (si.ijs.maci.SynchronousAdministratorOperations)1 SynchronousAdministratorPOATie (si.ijs.maci.SynchronousAdministratorPOATie)1