Search in sources :

Example 1 with ComponentDeactivationUncleanEx

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

the class BACIRemoteAccess method internalManagerConnect.

/**
	 * Insert the method's description here.
	 * Creation date: (2.11.2000 0:34:52)
	 * @param node si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode
	 */
private void internalManagerConnect(BACIRemoteNode baciNode) throws AcsJObjectExplorerConnectEx {
    /* we are connecting directly to the Manager to obtain the object reference */
    //System.out.println("DEBUG: imc "+baciNode);
    String curl = (String) baciNode.getUserObject();
    notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "Requesting component: '" + curl + "', activate = true");
    notifier.reportMessage("Connecting to '" + curl + "'.");
    baciNode.setNonSticky(connectNonSticky);
    org.omg.CORBA.Object obj = null;
    if (connectNonSticky) {
        try {
            obj = manager.get_component_non_sticky(handle, curl);
        } catch (Throwable e) {
            String message = "Connection to component '" + curl + "' failed. \n" + "'Connect as non-sticky' mode is enabled: in this mode component will not be activated by ObjectExplorer,\n" + "only already activated components can be accessed.";
            int ans = choiceForNonStickyComponentConnection(message);
            switch(ans) {
                case 0:
                    baciNode.setNonSticky(false);
                    System.out.println("BACIRemoteAccess.internalManagerConnect setNonSticky to " + baciNode.isNonSticky() + " @ " + baciNode.hashCode());
                    break;
                case 1:
                    baciEngineMenu.setNonSticky(false);
                    baciNode.setNonSticky(false);
                    break;
                case 2:
                    {
                        AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
                        acsjex.setCurl(curl);
                        throw acsjex;
                    }
                default:
                    {
                        // should not happen.
                        notifier.reportError("Unexpected choice.");
                        AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
                        acsjex.setCurl(curl);
                        throw acsjex;
                    }
            }
        }
    }
    try {
        if (obj == null) {
            obj = manager.get_component(handle, curl, true);
        }
        notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "Manager returns OK");
    }/* 
         * We wrap into a specific exception and report up
         */
     catch (CannotGetComponentEx e) {
        notifier.reportError("Connection to component '" + curl + "' failed.");
        AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
        acsjex.setCurl(curl);
        throw acsjex;
    } catch (org.omg.CORBA.TRANSIENT e) {
        notifier.reportError("Connection to component '" + curl + "' failed.\nCouldn't connect to the manager.");
        AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
        acsjex.setCurl(curl);
        throw acsjex;
    } catch (Throwable e) {
        notifier.reportError("Connection to component '" + curl + "' failed.\nUnknown Reason.");
        AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
        acsjex.setCurl(curl);
        throw acsjex;
    }
    String irfid = null;
    try {
        notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "Querying component '" + curl + "' for CORBA type id.");
        ComponentInfo[] cobInfos = manager.get_component_info(handle, new int[0], curl, "*", true);
        if (cobInfos.length != 1) {
            AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx();
            acsjex.setReason("Manager did not return valid ComponentInfo for '" + curl + "'.");
            throw acsjex;
        }
        irfid = cobInfos[0].type;
        notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "component '" + curl + "' has id: " + irfid);
    } catch (Exception e) {
        notifier.reportError("Cannot retrieve Interface Repository ID for component '" + curl + "'", e);
        AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
        acsjex.setCurl(curl);
        throw acsjex;
    }
    //		baciNode.setNonSticky(connectNonSticky);
    baciNode.setCORBARef(obj);
    try {
        baciNode.setIFDesc(getIFDesc(irfid));
        if (baciNode.getIFDesc() != null)
            notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "IR Query OK.");
        else {
            AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx();
            acsjex.setCurl(curl);
            acsjex.setReason("Cannot retrieve Interface Repository description for component for '" + curl + "'.");
            throw acsjex;
        }
    } catch (Exception e) {
        baciNode.setCORBARef(null);
        notifier.reportError("Failed to retrieve interface description from IR, releasing component on Manager, if needed.", e);
        AcsJException releaseCompEx = null;
        try {
            if (manager != null && obj != null && !baciNode.isNonSticky()) {
                manager.release_component(handle, curl);
            }
        } catch (NoPermissionEx npe) {
            releaseCompEx = AcsJNoPermissionEx.fromNoPermissionEx(npe);
        } catch (CannotDeactivateComponentEx ex) {
            // @TODO remove this catch once we remove this ex from maci.idl
            releaseCompEx = AcsJCannotDeactivateComponentEx.fromCannotDeactivateComponentEx(ex);
        } catch (ComponentDeactivationUncleanEx ex) {
            releaseCompEx = AcsJComponentDeactivationUncleanEx.fromComponentDeactivationUncleanEx(ex);
        } catch (ComponentDeactivationFailedEx ex) {
            releaseCompEx = AcsJComponentDeactivationFailedEx.fromComponentDeactivationFailedEx(ex);
        }
        if (releaseCompEx != null) {
            notifier.reportError("Failed to release component", releaseCompEx);
            logACSException(releaseCompEx);
        }
        AcsJObjectExplorerInterfaceRepositoryAccessEx acsjex = new AcsJObjectExplorerInterfaceRepositoryAccessEx(e);
        acsjex.setCurl(curl);
        acsjex.setIRid(irfid);
        AcsJObjectExplorerConnectEx acsjex2 = new AcsJObjectExplorerConnectEx(acsjex);
        acsjex2.setCurl(curl);
        throw acsjex2;
    }
    notifier.reportMessage("Connected to '" + curl + "'.");
}
Also used : AcsJComponentDeactivationFailedEx(alma.maciErrType.wrappers.AcsJComponentDeactivationFailedEx) ComponentDeactivationFailedEx(alma.maciErrType.ComponentDeactivationFailedEx) AcsJObjectExplorerInterfaceRepositoryAccessEx(alma.objexpErrType.wrappers.AcsJObjectExplorerInterfaceRepositoryAccessEx) AcsJException(alma.acs.exceptions.AcsJException) CannotGetComponentEx(alma.maciErrType.CannotGetComponentEx) CannotDeactivateComponentEx(alma.maciErrType.CannotDeactivateComponentEx) AcsJCannotDeactivateComponentEx(alma.maciErrType.wrappers.AcsJCannotDeactivateComponentEx) IntrospectionInconsistentException(si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException) AcsJException(alma.acs.exceptions.AcsJException) DataException(si.ijs.acs.objectexplorer.engine.DataException) NonStickyConnectFailedRemoteException(si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException) RemoteException(si.ijs.acs.objectexplorer.engine.RemoteException) AcsJObjectExplorerConnectEx(alma.objexpErrType.wrappers.AcsJObjectExplorerConnectEx) ComponentDeactivationUncleanEx(alma.maciErrType.ComponentDeactivationUncleanEx) AcsJComponentDeactivationUncleanEx(alma.maciErrType.wrappers.AcsJComponentDeactivationUncleanEx) NoPermissionEx(alma.maciErrType.NoPermissionEx) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) ComponentInfo(si.ijs.maci.ComponentInfo)

Example 2 with ComponentDeactivationUncleanEx

use of alma.maciErrType.ComponentDeactivationUncleanEx 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 ComponentDeactivationFailedEx (alma.maciErrType.ComponentDeactivationFailedEx)2 ComponentDeactivationUncleanEx (alma.maciErrType.ComponentDeactivationUncleanEx)2 AcsJComponentDeactivationFailedEx (alma.maciErrType.wrappers.AcsJComponentDeactivationFailedEx)2 AcsJComponentDeactivationUncleanEx (alma.maciErrType.wrappers.AcsJComponentDeactivationUncleanEx)2 ComponentInfo (si.ijs.maci.ComponentInfo)2 CBDescOut (alma.ACS.CBDescOut)1 AcsJUnknownEx (alma.ACSErrTypeCommon.wrappers.AcsJUnknownEx)1 CannotActivateComponentEx (alma.maciErrType.CannotActivateComponentEx)1 CannotDeactivateComponentEx (alma.maciErrType.CannotDeactivateComponentEx)1 CannotGetComponentEx (alma.maciErrType.CannotGetComponentEx)1 NoPermissionEx (alma.maciErrType.NoPermissionEx)1 AcsJCannotActivateComponentEx (alma.maciErrType.wrappers.AcsJCannotActivateComponentEx)1 AcsJCannotDeactivateComponentEx (alma.maciErrType.wrappers.AcsJCannotDeactivateComponentEx)1 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)1 AcsJObjectExplorerConnectEx (alma.objexpErrType.wrappers.AcsJObjectExplorerConnectEx)1 AcsJObjectExplorerInterfaceRepositoryAccessEx (alma.objexpErrType.wrappers.AcsJObjectExplorerInterfaceRepositoryAccessEx)1 DataException (si.ijs.acs.objectexplorer.engine.DataException)1 IntrospectionInconsistentException (si.ijs.acs.objectexplorer.engine.IntrospectionInconsistentException)1 NonStickyConnectFailedRemoteException (si.ijs.acs.objectexplorer.engine.NonStickyConnectFailedRemoteException)1