Search in sources :

Example 1 with CannotActivateComponentEx

use of alma.maciErrType.CannotActivateComponentEx in project ACS by ACS-Community.

the class ContainerProxy method activate_component.

/**
	 * @see com.cosylab.acs.maci.Container#activate_component(int, long, String, String, String)
	 */
public ComponentInfo activate_component(int handle, long executionId, String name, String exe, String type) throws AcsJCannotActivateComponentEx {
    try {
        ComponentInfo retVal = null;
        si.ijs.maci.ComponentInfo info;
        try {
            info = container.activate_component(handle, executionId, name, exe, type);
        } catch (CannotActivateComponentEx cannotActivateEx) {
            // and thus have to convert it to its JDK-style peer exception
            throw AcsJCannotActivateComponentEx.fromCannotActivateComponentEx(cannotActivateEx);
        }
        if (info != null) {
            retVal = new ComponentInfo(info.h, info.name, info.type, info.code, info.reference != null ? new ComponentProxy(info.name, info.reference) : null);
            retVal.setContainer(info.container);
            retVal.setContainerName(info.container_name);
            retVal.setAccessRights(inverseMapAccessRights(info.access));
            retVal.setClients(new IntArray(info.clients));
            retVal.setInterfaces(info.interfaces);
        }
        return retVal;
    } catch (TIMEOUT tex) {
        TimeoutRemoteException re = new TimeoutRemoteException("Timout occured while invoking 'activate_component()' method.", tex);
        throw re;
    } catch (org.omg.CORBA.MARSHAL marshalEx) {
        // see http://jira.alma.cl/browse/COMP-4371. Unclear if a parameter was null, or the returned struct was invalid.
        RemoteException re = new RemoteException("Failed to transform the paramters or return value of the container's 'activate_component' method " + "to/from the corba call, using parameters name=" + name + ", exe=" + exe + ", type=" + type, marshalEx);
        throw re;
    } catch (Exception ex) {
        RemoteException re = new RemoteException("Failed to invoke 'activate_component()' method.", ex);
        throw re;
    }
}
Also used : RemoteException(com.cosylab.acs.maci.RemoteException) IOException(java.io.IOException) TimeoutRemoteException(com.cosylab.acs.maci.TimeoutRemoteException) AcsJException(alma.acs.exceptions.AcsJException) AcsJCannotActivateComponentEx(alma.maciErrType.wrappers.AcsJCannotActivateComponentEx) CannotActivateComponentEx(alma.maciErrType.CannotActivateComponentEx) IntArray(com.cosylab.acs.maci.IntArray) TimeoutRemoteException(com.cosylab.acs.maci.TimeoutRemoteException) ComponentInfo(com.cosylab.acs.maci.ComponentInfo) CBComponentInfo(si.ijs.maci.CBComponentInfo) TIMEOUT(org.omg.CORBA.TIMEOUT) RemoteException(com.cosylab.acs.maci.RemoteException) TimeoutRemoteException(com.cosylab.acs.maci.TimeoutRemoteException)

Example 2 with CannotActivateComponentEx

use of alma.maciErrType.CannotActivateComponentEx in project ACS by ACS-Community.

the class AcsContainer method activate_component_async.

/* (non-Javadoc)
	 * @see si.ijs.maci.ContainerOperations#activate_component_async(int, long, java.lang.String, java.lang.String, java.lang.String, si.ijs.maci.CBComponentInfo, alma.ACS.CBDescIn)
	 */
public void activate_component_async(final int h, final long execution_id, final String name, final String exe, final String type, final CBComponentInfo callback, final CBDescIn desc) {
    m_logger.finer("activate_component_async request received for '" + name + "', enqueueing (taskCount: " + threadPoolExecutor.getTaskCount() + ", active threads: " + threadPoolExecutor.getActiveCount() + ", maxPoolSize: " + threadPoolExecutor.getMaximumPoolSize() + ").");
    threadPoolExecutor.execute(new Runnable() {

        @Override
        public void run() {
            m_logger.finer("activate_component_async request for '" + name + "' is being processed now.");
            CBDescOut descOut = new CBDescOut(0, desc.id_tag);
            ComponentInfo componentInfo = null;
            try {
                componentInfo = activate_component(h, execution_id, name, exe, type);
            } catch (CannotActivateComponentEx ae) {
                AcsJCannotActivateComponentEx aae = AcsJCannotActivateComponentEx.fromCannotActivateComponentEx(ae);
                ComponentInfo dummyComponentInfo = new ComponentInfo(type, exe, null, name, new int[0], 0, m_containerName, h, 0, new String[0]);
                callback.done(dummyComponentInfo, aae.toAcsJCompletion().toCorbaCompletion(), descOut);
            } catch (Throwable th) {
                AcsJException ae = new AcsJUnknownEx(th);
                ComponentInfo dummyComponentInfo = new ComponentInfo(type, exe, null, name, new int[0], 0, m_containerName, h, 0, new String[0]);
                callback.done(dummyComponentInfo, ae.toAcsJCompletion().toCorbaCompletion(), descOut);
            }
            // Try to invoke the callback several times before giving up
            int retry = 0;
            boolean notified = false;
            while (retry < 3 && !notified) {
                try {
                    m_logger.log(AcsLogLevel.DELOUSE, "Calling maci::CBComponentInfo::done with descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "'");
                    callback.done(componentInfo, new alma.ACSErrTypeOK.wrappers.ACSErrOKAcsJCompletion().toCorbaCompletion(), descOut);
                    notified = true;
                    m_logger.log(AcsLogLevel.DELOUSE, "Call to maci::CBComponentInfo::done with descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "' completed");
                } catch (Throwable t) {
                    retry++;
                    m_logger.log(AcsLogLevel.DELOUSE, "Call to maci::CBComponentInfo::done with descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "' failed, retrying...", t);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException ie) {
                    }
                }
            }
            if (!notified) {
                m_logger.log(AcsLogLevel.ERROR, "Call to maci::CBComponentInfo::done with descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "' failed, deactivating the component.");
                try {
                    deactivate_component(h);
                } catch (ComponentDeactivationUncleanEx e) {
                    m_logger.log(AcsLogLevel.WARNING, "UNclean deactivation of component descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "'", e);
                } catch (ComponentDeactivationFailedEx e) {
                    m_logger.log(AcsLogLevel.WARNING, "Deactivation of component failed descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "'", e);
                } catch (Throwable t) {
                    m_logger.log(AcsLogLevel.WARNING, "Deactivation of component failed descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "'", t);
                }
            }
        }
    });
}
Also used : AcsJComponentDeactivationFailedEx(alma.maciErrType.wrappers.AcsJComponentDeactivationFailedEx) ComponentDeactivationFailedEx(alma.maciErrType.ComponentDeactivationFailedEx) CBDescOut(alma.ACS.CBDescOut) AcsJCannotActivateComponentEx(alma.maciErrType.wrappers.AcsJCannotActivateComponentEx) AcsJException(alma.acs.exceptions.AcsJException) AcsJUnknownEx(alma.ACSErrTypeCommon.wrappers.AcsJUnknownEx) CannotActivateComponentEx(alma.maciErrType.CannotActivateComponentEx) AcsJCannotActivateComponentEx(alma.maciErrType.wrappers.AcsJCannotActivateComponentEx) ComponentDeactivationUncleanEx(alma.maciErrType.ComponentDeactivationUncleanEx) AcsJComponentDeactivationUncleanEx(alma.maciErrType.wrappers.AcsJComponentDeactivationUncleanEx) ComponentInfo(si.ijs.maci.ComponentInfo) CBComponentInfo(si.ijs.maci.CBComponentInfo)

Aggregations

AcsJException (alma.acs.exceptions.AcsJException)2 CannotActivateComponentEx (alma.maciErrType.CannotActivateComponentEx)2 AcsJCannotActivateComponentEx (alma.maciErrType.wrappers.AcsJCannotActivateComponentEx)2 CBComponentInfo (si.ijs.maci.CBComponentInfo)2 CBDescOut (alma.ACS.CBDescOut)1 AcsJUnknownEx (alma.ACSErrTypeCommon.wrappers.AcsJUnknownEx)1 ComponentDeactivationFailedEx (alma.maciErrType.ComponentDeactivationFailedEx)1 ComponentDeactivationUncleanEx (alma.maciErrType.ComponentDeactivationUncleanEx)1 AcsJComponentDeactivationFailedEx (alma.maciErrType.wrappers.AcsJComponentDeactivationFailedEx)1 AcsJComponentDeactivationUncleanEx (alma.maciErrType.wrappers.AcsJComponentDeactivationUncleanEx)1 ComponentInfo (com.cosylab.acs.maci.ComponentInfo)1 IntArray (com.cosylab.acs.maci.IntArray)1 RemoteException (com.cosylab.acs.maci.RemoteException)1 TimeoutRemoteException (com.cosylab.acs.maci.TimeoutRemoteException)1 IOException (java.io.IOException)1 TIMEOUT (org.omg.CORBA.TIMEOUT)1 ComponentInfo (si.ijs.maci.ComponentInfo)1