Search in sources :

Example 1 with AcsManagerProxy

use of alma.acs.container.AcsManagerProxy in project ACS by ACS-Community.

the class ComponentClientTestCase method connectToManager.

/**
	 * Connects to the ACS Manager using {@link AcsManagerProxy}.
	 * @throws Exception
	 */
protected void connectToManager() throws Exception {
    if (System.getProperty("ACS.manager") != null) {
        m_managerLoc = System.getProperty("ACS.manager").trim();
    } else {
        // default = localhost
        String host = ACSPorts.getIP();
        m_managerLoc = "corbaloc::" + host + ":" + ACSPorts.getManagerPort() + "/Manager";
    }
    managerClientImpl = new ManagerClient(getFullName(), m_logger) {

        public void disconnect() {
            m_logger.info("disconnected from manager");
            m_acsManagerProxy.logoutFromManager();
            m_acsManagerProxy = null;
            throw new RuntimeException("disconnected from the manager");
        }
    };
    ORB orb = acsCorba.getORB();
    m_managerClient = managerClientImpl._this(orb);
    m_acsManagerProxy = new AcsManagerProxy(m_managerLoc, orb, m_logger);
    m_acsManagerProxy.loginToManager(m_managerClient, 1);
}
Also used : ORB(org.omg.CORBA.ORB) AcsManagerProxy(alma.acs.container.AcsManagerProxy)

Example 2 with AcsManagerProxy

use of alma.acs.container.AcsManagerProxy in project ACS by ACS-Community.

the class AdvancedComponentClient method createContainerServices.

/**
	 * Factory method for additional container service instances. This method should only be used by specialized clients
	 * such as the OMC GUI which needs independent ContainerServices instances for the plug-ins it runs.
	 * <p>
	 * Make sure to call {@link #destroyContainerServices(ContainerServices)} when done with the new CS.
	 * 
	 * @param clientName
	 *            name for {@link ContainerServices#getName()}
	 * @param csLogger
	 *            logger to be used internally by the new ContainerServices instance (which is different from the Logger
	 *            returned in {@link ContainerServices#getLogger()}). 
	 *            Since ACS 8.0 it is recommended to supply an {@link AcsLogger} instead of a plain JDK Logger because a 
	 *            plain Logger will have to be wrapped inside this method.
	 */
public ContainerServices createContainerServices(String clientName, Logger csLogger) throws AcsJContainerServicesEx {
    if (clientName == null) {
        throw new IllegalArgumentException("clientName must not be null");
    }
    if (csLogger == null) {
        throw new IllegalArgumentException("csLogger must not be null");
    }
    try {
        // wrap csLogger if necessary
        AcsLogger acsLogger = AcsLogger.fromJdkLogger(csLogger, null);
        ThreadFactory threadFactory = new CleaningDaemonThreadFactory(clientName, csLogger);
        // separately log in to the manager to get a new client handle.
        // TODO: if this does not work, then we need a way to get a new handle from manager without logging in separately.
        // Note that when activating components, the container receives the new handle directly from the manager.
        AcsManagerProxy acsManagerProxy = m_acsManagerProxy.createInstance();
        ManagerClient clImpl = new ManagerClient(clientName, acsLogger);
        Client managerClient = clImpl._this(acsCorba.getORB());
        acsManagerProxy.loginToManager(managerClient, 0);
        int clientHandle = acsManagerProxy.getManagerHandle();
        DAL cdb = DALHelper.narrow(m_acsManagerProxy.get_service("CDB", false));
        ContainerServicesImpl cs = new ContainerServicesImpl(acsManagerProxy, cdb, acsCorba.getRootPOA(), acsCorba, acsLogger, clientHandle, clientName, null, threadFactory);
        additionalContainerServices.put(cs, acsManagerProxy);
        return cs;
    } catch (Throwable thr) {
        throw new AcsJContainerServicesEx(thr);
    }
}
Also used : CleaningDaemonThreadFactory(alma.acs.container.CleaningDaemonThreadFactory) ThreadFactory(java.util.concurrent.ThreadFactory) ContainerServicesImpl(alma.acs.container.ContainerServicesImpl) CleaningDaemonThreadFactory(alma.acs.container.CleaningDaemonThreadFactory) Client(si.ijs.maci.Client) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) DAL(com.cosylab.CDB.DAL) AcsLogger(alma.acs.logging.AcsLogger) AcsManagerProxy(alma.acs.container.AcsManagerProxy)

Example 3 with AcsManagerProxy

use of alma.acs.container.AcsManagerProxy in project ACS by ACS-Community.

the class AdvancedComponentClient method destroyContainerServices.

/**
     * "un-factory" method which inverts {@link #createContainerServices(String, Logger)}.
     * @param cs ContainerServices instance created by {@link #createContainerServices(String, Logger)}.
     */
public void destroyContainerServices(ContainerServices cs) throws AcsJContainerServicesEx {
    if (!additionalContainerServices.containsKey(cs)) {
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx();
        ex.setContextInfo("The given ContainerServices object was not created by this AdvancedComponentClient!");
        throw ex;
    }
    try {
        ContainerServicesImpl csImpl = (ContainerServicesImpl) cs;
        AcsManagerProxy acsManagerProxy = additionalContainerServices.get(cs);
        acsManagerProxy.shutdownNotify();
        csImpl.releaseAllComponents();
        ((CleaningDaemonThreadFactory) csImpl.getThreadFactory()).cleanUp();
        acsManagerProxy.logoutFromManager();
        additionalContainerServices.remove(cs);
        csImpl.cleanUp();
    } catch (Throwable thr) {
        AcsJContainerServicesEx ex = new AcsJContainerServicesEx();
        ex.setContextInfo("Failed to destroy additional container services instance");
        throw ex;
    }
}
Also used : ContainerServicesImpl(alma.acs.container.ContainerServicesImpl) CleaningDaemonThreadFactory(alma.acs.container.CleaningDaemonThreadFactory) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) AcsManagerProxy(alma.acs.container.AcsManagerProxy)

Example 4 with AcsManagerProxy

use of alma.acs.container.AcsManagerProxy in project ACS by ACS-Community.

the class ComponentClient method initAcs.

private void initAcs(String managerLoc, POA rootPOA) throws Exception {
    try {
        ManagerClient clImpl = new ManagerClient(m_clientName, m_logger) {

            public void disconnect() {
                m_logger.info("disconnected from manager");
                m_acsManagerProxy.logoutFromManager();
                m_acsManagerProxy = null;
                throw new RuntimeException("disconnected from the manager");
            }
        };
        m_managerClient = clImpl._this(acsCorba.getORB());
        m_acsManagerProxy = new AcsManagerProxy(managerLoc, acsCorba.getORB(), m_logger);
        m_acsManagerProxy.loginToManager(m_managerClient, 1);
        DAL cdb = DALHelper.narrow(m_acsManagerProxy.get_service("CDB", false));
        m_threadFactory = new CleaningDaemonThreadFactory(m_clientName, m_logger);
        m_containerServices = new ContainerServicesImpl(m_acsManagerProxy, cdb, rootPOA, acsCorba, m_logger, 0, m_clientName, null, m_threadFactory);
        clImpl.setContainerServices(m_containerServices);
        initAlarmSystem();
    } catch (Exception ex) {
        //										"or to set up the container services.", ex);
        if (acsCorba.getORB() != null) {
            acsCorba.getORB().destroy();
        }
        throw ex;
    }
}
Also used : ContainerServicesImpl(alma.acs.container.ContainerServicesImpl) CleaningDaemonThreadFactory(alma.acs.container.CleaningDaemonThreadFactory) DAL(com.cosylab.CDB.DAL) AcsManagerProxy(alma.acs.container.AcsManagerProxy)

Aggregations

AcsManagerProxy (alma.acs.container.AcsManagerProxy)4 CleaningDaemonThreadFactory (alma.acs.container.CleaningDaemonThreadFactory)3 ContainerServicesImpl (alma.acs.container.ContainerServicesImpl)3 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)2 DAL (com.cosylab.CDB.DAL)2 AcsLogger (alma.acs.logging.AcsLogger)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 ORB (org.omg.CORBA.ORB)1 Client (si.ijs.maci.Client)1