Search in sources :

Example 6 with AcsJContainerEx

use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.

the class AcsManagerProxy method findManager.

/**
	 * Finds the Manger using the supplied <code>managerLoc</code>.
	 * 
	 * If the manager can't be found, this method enters a loop and tries again after every 3 seconds.
	 * The number of iterations of the loop is bounded by <code>attempts</code>.
	 * 
	 * @param managerLoc  the corbaloc string that uniquely identifies the manager 
	 * 						as a CORBA service.
	 * @param attempts	The number of attempts to contact the manager (0 means forever).
	 * 					If 0, this method will only return when it has successfully contacted the manager service;
	 * 					if greater then 0, this method will simply throw a <code>AcsJContainerServicesEx</code>
	 * 					if it fails to resolve the manager. 
	 * @throws AcsJContainerEx  if anything goes wrong.
	 */
private synchronized void findManager(String managerLoc, int attempts) throws AcsJContainerEx {
    if (attempts < 0) {
        throw new IllegalArgumentException("Invalid number of attempts to contact the manager: " + attempts);
    }
    int currentAttempt = attempts;
    do {
        if (m_shuttingDown) {
            // 
            AcsJContainerEx ex = new AcsJContainerEx();
            ex.setContextInfo("Abandoned because we are shutting down.");
            throw ex;
        }
        try {
            org.omg.CORBA.Object object = m_orb.string_to_object(m_managerLoc);
            m_logger.finest("manager corbaloc '" + managerLoc + "' resolved.");
            m_manager = ManagerHelper.narrow(object);
            if (m_manager == null) {
                AcsJContainerEx ex = new AcsJContainerEx();
                ex.setContextInfo("received null reference to ACS Manager.");
                throw ex;
            }
            m_logger.finest("manager narrow successful.");
            // Set attempts=1 and currentAttempt=0 to exit the loop
            attempts = 1;
            currentAttempt = 0;
        } catch (Throwable thr) {
            String msg = "Failed to obtain the manager reference from the corbaloc '" + m_managerLoc + "'. ";
            if (attempts == 0 || currentAttempt > 0) {
                m_logger.log(Level.INFO, msg + "Will keep trying.");
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e1) {
                // nada
                }
            } else {
                m_logger.log(Level.WARNING, msg + thr.getMessage());
                AcsJContainerEx ex = new AcsJContainerEx(thr);
                ex.setContextInfo(msg);
                throw ex;
            }
        }
        currentAttempt = (attempts == 0) ? 0 : currentAttempt - 1;
    } while (attempts == 0 || currentAttempt > 0);
}
Also used : AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) Object(org.omg.CORBA.Object)

Example 7 with AcsJContainerEx

use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.

the class AcsManagerProxy method loginToManager.

/**
	 * Logs in to the Manager.
	 * Only to be called from within this class (see connectorThread), when the  
	 * 
	 * @param attempts	The number of attempts to contact the manager (0 means forever)
	 * 					used for the call to {@link #findManager(String, int)}
	 * @throws AcsJContainerServicesEx
	 */
private synchronized void loginToManager(int attempts) throws AcsJContainerEx {
    if (m_shuttingDown) {
        String msg = "call to loginToManager(..) fails while shutting down.";
        m_logger.fine(msg);
        AcsJContainerEx ex = new AcsJContainerEx();
        ex.setContextInfo(msg);
        throw ex;
    }
    if (isLoggedIn(false)) {
        m_logger.info("login to Manager requested while being logged in - will first log out...");
        logoutFromManager();
    }
    if (m_manager == null) {
        m_logger.fine("manager reference not yet available in method loginToManager; " + "will try to find the manager first...");
        findManager(m_managerLoc, attempts);
    }
    try {
        // login
        ClientInfo ci = m_manager.login(m_managerClient);
        if (ci == null) {
            throw new NullPointerException("received null from manager.login()");
        }
        if (ci.h <= 0) {
            AcsJContainerEx ex = new AcsJContainerEx();
            ex.setContextInfo("Got invalid handle from manager login: " + ci.h);
            throw ex;
        }
        m_mgrHandle = ci.h;
    } catch (Throwable thr) {
        m_mgrHandle = 0;
        String msg = "Failed to login to manager.";
        m_logger.log(Level.WARNING, msg);
        AcsJContainerEx ex = new AcsJContainerEx(thr);
        ex.setContextInfo(msg);
        throw ex;
    }
    m_logger.fine("Manager login done, handle '" + m_mgrHandle + "' obtained.");
}
Also used : AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) ClientInfo(si.ijs.maci.ClientInfo)

Example 8 with AcsJContainerEx

use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.

the class ManagerContainerServices method checkOffShootPOA.

/**
	 * Creates the shared offshoot poa on demand 
	 */
public void checkOffShootPOA() throws AcsJContainerEx, AcsJUnexpectedExceptionEx {
    final String offshootPoaName = "offshootPoa";
    synchronized (clientPOA) {
        try {
            // can we reuse it?
            offshootPoa = clientPOA.find_POA(offshootPoaName, false);
        } catch (AdapterNonExistent e) {
            logger.finest("will have to create offshoot POA");
            if (offshootPolicies == null) {
                offshootPolicies = new Policy[4];
                offshootPolicies[0] = clientPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
                offshootPolicies[1] = clientPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
                offshootPolicies[2] = clientPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY);
                offshootPolicies[3] = clientPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
            }
            try {
                offshootPoa = clientPOA.create_POA(offshootPoaName, clientPOA.the_POAManager(), offshootPolicies);
                logger.finest("successfully created offshoot POA");
            } catch (InvalidPolicy ex) {
                AcsJContainerEx ex2 = new AcsJContainerEx(ex);
                ex2.setContextInfo("Attempted to create offshoot POA with invalid policies.");
                throw ex2;
            } catch (AdapterAlreadyExists ex) {
                // we sync on componentPOA, so this should never happen
                throw new AcsJUnexpectedExceptionEx(ex);
            }
        }
    }
}
Also used : Policy(org.omg.CORBA.Policy) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) AdapterAlreadyExists(org.omg.PortableServer.POAPackage.AdapterAlreadyExists) AcsJUnexpectedExceptionEx(alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx) AdapterNonExistent(org.omg.PortableServer.POAPackage.AdapterNonExistent)

Example 9 with AcsJContainerEx

use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.

the class AlarmSystemContainerServices method getPOAForOffshoots.

public POA getPOAForOffshoots(POA componentPOA) throws AcsJContainerEx, AcsJUnexpectedExceptionEx {
    final String offshootPoaName = "offshootPoa";
    POA offshootPoa = null;
    synchronized (componentPOA) {
        try {
            // can we reuse it?
            offshootPoa = componentPOA.find_POA(offshootPoaName, false);
        } catch (AdapterNonExistent e) {
            logger.finest("will have to create offshoot POA");
            if (m_offshootPolicies == null) {
                m_offshootPolicies = new Policy[4];
                m_offshootPolicies[0] = componentPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
                m_offshootPolicies[1] = componentPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
                m_offshootPolicies[2] = componentPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY);
                m_offshootPolicies[3] = componentPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
            }
            try {
                offshootPoa = componentPOA.create_POA(offshootPoaName, alSysCorbaServer.getRootPOA().the_POAManager(), m_offshootPolicies);
                logger.finest("successfully created offshoot POA");
            } catch (InvalidPolicy ex) {
                AcsJContainerEx ex2 = new AcsJContainerEx(ex);
                ex2.setContextInfo("Attempted to create offshoot POA with invalid policies.");
                throw ex2;
            } catch (AdapterAlreadyExists ex) {
                // we sync on componentPOA, so this should never happen
                throw new AcsJUnexpectedExceptionEx(ex);
            }
        }
    }
    return offshootPoa;
}
Also used : Policy(org.omg.CORBA.Policy) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) POA(org.omg.PortableServer.POA) InvalidPolicy(org.omg.PortableServer.POAPackage.InvalidPolicy) AdapterAlreadyExists(org.omg.PortableServer.POAPackage.AdapterAlreadyExists) AcsJUnexpectedExceptionEx(alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx) AdapterNonExistent(org.omg.PortableServer.POAPackage.AdapterNonExistent)

Example 10 with AcsJContainerEx

use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.

the class DataPrinter method startSample.

/**
	 * Starts the sampling, connecting to ACS Manager and the Sampling Manager.
	 * @throws CouldntAccessComponentEx Component wasn't available at the time.
	 * @throws TypeNotSupportedEx Sampling Manager specific exception. Some types are currently not supported in acssamp.
	 * @throws CouldntAccessPropertyEx
	 */
public void startSample() throws CouldntAccessComponentEx, TypeNotSupportedEx, CouldntAccessPropertyEx, SamplingManagerException {
    samp = new Sampler();
    synchronized (this) {
        System.out.println("Initialization:" + initializations);
        if (initializations == 0) {
            try {
                spinUp(SampTool.NAME, ssg.MAN_NAME);
            } catch (AcsInformationException e) {
                System.out.print(e.getMessage());
                System.exit(-1);
            } catch (SamplingManagerException e) {
                System.out.print(e.getMessage());
                System.exit(-1);
            } catch (AcsJContainerEx e) {
                System.out.println(e.getMessage());
                System.exit(-1);
            }
        }
        initializations++;
    }
    try {
        SamplingManagerUITool.startSample(new SampDetail(component, property, (long) this.frequency, reportRate));
    } catch (alma.ACSErrTypeCommon.CouldntAccessComponentEx e) {
        setComponentAvailable(false, "Cannot access component implementation");
        throw e;
    } catch (alma.ACSErrTypeCommon.TypeNotSupportedEx e) {
        setComponentAvailable(false, "Type not supported");
        throw e;
    } catch (CouldntAccessPropertyEx e) {
        setComponentAvailable(false, "Cannot access the property");
        throw e;
    } catch (SamplingManagerException e) {
        setComponentAvailable(false, e.getMessage());
        throw e;
    }
    samp.start();
}
Also used : AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) CouldntAccessComponentEx(alma.ACSErrTypeCommon.CouldntAccessComponentEx) SampDetail(cl.utfsm.samplingSystemUI.core.SampDetail) TypeNotSupportedEx(alma.ACSErrTypeCommon.TypeNotSupportedEx) AcsInformationException(cl.utfsm.samplingSystemUI.core.AcsInformationException) CouldntAccessPropertyEx(alma.ACSErrTypeCommon.CouldntAccessPropertyEx) SamplingManagerException(cl.utfsm.samplingSystemUI.core.SamplingManagerException)

Aggregations

AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)27 POA (org.omg.PortableServer.POA)6 Object (org.omg.CORBA.Object)4 Policy (org.omg.CORBA.Policy)4 AdapterAlreadyExists (org.omg.PortableServer.POAPackage.AdapterAlreadyExists)4 InvalidPolicy (org.omg.PortableServer.POAPackage.InvalidPolicy)4 AcsJUnexpectedExceptionEx (alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx)3 AdapterNonExistent (org.omg.PortableServer.POAPackage.AdapterNonExistent)3 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)2 AcsJException (alma.acs.exceptions.AcsJException)2 AcsLogger (alma.acs.logging.AcsLogger)2 LogConfigException (alma.acs.logging.config.LogConfigException)2 StopWatch (alma.acs.util.StopWatch)2 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2 Servant (org.omg.PortableServer.Servant)2 CouldntAccessComponentEx (alma.ACSErrTypeCommon.CouldntAccessComponentEx)1 CouldntAccessPropertyEx (alma.ACSErrTypeCommon.CouldntAccessPropertyEx)1 TypeNotSupportedEx (alma.ACSErrTypeCommon.TypeNotSupportedEx)1 AcsComponentClassLoader (alma.acs.classloading.AcsComponentClassLoader)1 ComponentLifecycle (alma.acs.component.ComponentLifecycle)1