Search in sources :

Example 6 with AcsJIllegalStateEventEx

use of alma.ACSErrTypeCommon.wrappers.AcsJIllegalStateEventEx in project ACS by ACS-Community.

the class NCSubscriber method createConnectionAction.

protected void createConnectionAction(EventDispatcher evtDispatcher, ErrorReporter errRep, SCInstance scInstance, Collection<TriggerEvent> derivedEvents) throws AcsJStateMachineActionEx {
    super.createConnectionAction(evtDispatcher, errRep, scInstance, derivedEvents);
    try {
        // Register callback for subscribed events
        if (corbaRef == null) {
            corbaObj = new OSPushConsumerPOATie(NCSubscriber.this);
            corbaRef = OSPushConsumerHelper.narrow(helper.getContainerServices().activateOffShoot(corbaObj));
        }
        // Register callback for reconnection requests
        channelReconnectionCallback = new AcsNcReconnectionCallback(NCSubscriber.this, logger);
        // if the factory is null, the reconnection callback is not registered
        channelReconnectionCallback.registerForReconnect(services, helper.getNotifyFactory());
        proxySupplier.connect_structured_push_consumer(org.omg.CosNotifyComm.StructuredPushConsumerHelper.narrow(corbaRef));
    } catch (AcsJContainerServicesEx e) {
        LOG_NC_SubscriptionConnect_FAIL.log(logger, channelName, getNotificationFactoryName());
        throw new AcsJStateMachineActionEx(e);
    } catch (org.omg.CosEventChannelAdmin.AlreadyConnected e) {
        throw new AcsJStateMachineActionEx(new AcsJIllegalStateEventEx(e));
    } catch (org.omg.CosEventChannelAdmin.TypeError ex) {
        LOG_NC_SubscriptionConnect_FAIL.log(logger, channelName, getNotificationFactoryName());
        throw new AcsJStateMachineActionEx(ex);
    } catch (AcsJIllegalArgumentEx ex) {
        throw new AcsJStateMachineActionEx(ex);
    }
    // Create the thread responsible for checking the connection and reconnect
    createConCheckerThread();
    LOG_NC_SubscriptionConnect_OK.log(logger, channelName, getNotificationFactoryName());
}
Also used : AcsJIllegalStateEventEx(alma.ACSErrTypeCommon.wrappers.AcsJIllegalStateEventEx) OSPushConsumerPOATie(alma.acsnc.OSPushConsumerPOATie) AcsJIllegalArgumentEx(alma.ACSErrTypeCommon.wrappers.AcsJIllegalArgumentEx) AcsJStateMachineActionEx(alma.ACSErrTypeCommon.wrappers.AcsJStateMachineActionEx) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 7 with AcsJIllegalStateEventEx

use of alma.ACSErrTypeCommon.wrappers.AcsJIllegalStateEventEx in project ACS by ACS-Community.

the class MasterComponentImplBase method doTransition.

/**
	 * Dispatches the event to the corresponding state machine method.
	 * <p>
	 * Relies on CORBA to queue concurrent calls, which this synchronized implementation forcefully serializes. 
	 * Note that calls should always return quickly, since the real work is done asynchronously in activity states.
	 * 
	 * @see alma.ACS.MasterComponentOperations#doTransition(alma.ACS.MasterComponentPackage.SubsystemStateEvent)
	 */
public final synchronized void doTransition(SubsystemStateEvent event) throws IllegalStateEventEx {
    if (event == null) {
        AcsJIllegalStateEventEx ex = new AcsJIllegalStateEventEx();
        ex.setEvent("null");
        throw ex.toIllegalStateEventEx();
    }
    String eventName = event2Name(event);
    m_logger.fine("Received event " + eventName);
    try {
        switch(event.value()) {
            case SubsystemStateEvent._SUBSYSEVENT_INITPASS1:
                m_stateMachine.initPass1();
                break;
            case SubsystemStateEvent._SUBSYSEVENT_INITPASS2:
                m_stateMachine.initPass2();
                break;
            case SubsystemStateEvent._SUBSYSEVENT_REINIT:
                m_stateMachine.reinit();
                break;
            case SubsystemStateEvent._SUBSYSEVENT_START:
                m_stateMachine.start();
                break;
            case SubsystemStateEvent._SUBSYSEVENT_STOP:
                m_stateMachine.stop();
                break;
            case SubsystemStateEvent._SUBSYSEVENT_SHUTDOWNPASS1:
                m_stateMachine.shutdownPass1();
                break;
            case SubsystemStateEvent._SUBSYSEVENT_SHUTDOWNPASS2:
                m_stateMachine.shutdownPass2();
                break;
            case SubsystemStateEvent._SUBSYSEVENT_ERROR:
                m_stateMachine.error();
                break;
            default:
                // we can only get here if this code is out of sync with the IDL event definitions
                String msg = "Unexpected SubsystemStateEvent with integer value " + event.value() + " found; most likely " + MasterComponentImplBase.class.getName() + " must be updated.";
                m_logger.warning(msg);
                AcsJIllegalStateEventEx ex = new AcsJIllegalStateEventEx();
                ex.setEvent(event.toString());
                throw ex.toIllegalStateEventEx();
        }
    } catch (AcsJIllegalStateEventEx ex) {
        m_logger.log(Level.WARNING, "Illegal event '" + ex.getEvent() + "' received in state '" + ex.getState() + "'.", ex);
        throw ex.toIllegalStateEventEx();
    }
}
Also used : AcsJIllegalStateEventEx(alma.ACSErrTypeCommon.wrappers.AcsJIllegalStateEventEx)

Aggregations

AcsJIllegalStateEventEx (alma.ACSErrTypeCommon.wrappers.AcsJIllegalStateEventEx)7 CompletionHolder (alma.ACSErr.CompletionHolder)1 AcsJIllegalArgumentEx (alma.ACSErrTypeCommon.wrappers.AcsJIllegalArgumentEx)1 AcsJStateMachineActionEx (alma.ACSErrTypeCommon.wrappers.AcsJStateMachineActionEx)1 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)1 AcsJCompletion (alma.acs.exceptions.AcsJCompletion)1 AcsEventSubscriber (alma.acs.nc.AcsEventSubscriber)1 StopWatch (alma.acs.util.StopWatch)1 OSPushConsumerPOATie (alma.acsnc.OSPushConsumerPOATie)1 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 TriggerEvent (org.apache.commons.scxml.TriggerEvent)1 Test (org.junit.Test)1