/** * Sends a message to the tunnel stream. * * @param msg the message to send * @param errorInfo error structure to be populated in the event of failure * * @return {@link ReactorReturnCodes#SUCCESS}, if submit succeeded or * {@link ReactorReturnCodes#FAILURE}, if submit failed (refer to errorInfo for additional information) */ public int submit(Msg msg, ReactorErrorInfo errorInfo) { if (errorInfo == null) return ReactorReturnCodes.FAILURE; else if (msg == null) return _reactor.populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, "TunnelStream.submit", "msg cannot be null."); else if (_reactor.isShutdown()) return _reactor.populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, "TunnelStream.submit", "Reactor is shutdown, submit aborted."); return handleMsgSubmit(_reactorChannel, msg, errorInfo); }
private void processWorkerShutdown(WorkerEvent event, String location, ReactorErrorInfo errorInfo) { populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "Worker has shutdown, " + event.errorInfo().toString()); }
int sendAndHandleDictionaryMsgCallback(String location, ReactorChannel reactorChannel, TransportBuffer transportBuffer, Msg msg, DictionaryMsg dictionaryMsg, WatchlistStreamInfo streamInfo, ReactorErrorInfo errorInfo) { int retval = sendDictionaryMsgCallback(reactorChannel, transportBuffer, msg, dictionaryMsg, streamInfo); // check return code from callback. if (retval == ReactorCallbackReturnCodes.FAILURE) { populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "ReactorCallbackReturnCodes.FAILURE was returned from rdmDictionaryMsgCallback(). This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } else if (retval != ReactorCallbackReturnCodes.RAISE && retval != ReactorCallbackReturnCodes.SUCCESS) { // retval is not a valid ReactorReturnCodes. populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "retval of " + retval + " was returned from rdmDictionaryMsgCallback() and is not a valid ReactorCallbackReturnCodes. This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } return retval; }
int sendAndHandleLoginMsgCallback(String location, ReactorChannel reactorChannel, TransportBuffer transportBuffer, Msg msg, LoginMsg loginMsg, WatchlistStreamInfo streamInfo, ReactorErrorInfo errorInfo) { int retval = sendLoginMsgCallback(reactorChannel, transportBuffer, msg, loginMsg, streamInfo); // check return code from callback. if (retval == ReactorCallbackReturnCodes.FAILURE) { populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "ReactorCallbackReturnCodes.FAILURE was returned from rdmLoginMsgCallback(). This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } else if (retval != ReactorCallbackReturnCodes.RAISE && retval != ReactorCallbackReturnCodes.SUCCESS) { // retval is not a valid ReactorReturnCodes. populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "retval of " + retval + " was returned from rdmLoginMsgCallback() and is not a valid ReactorCallbackReturnCodes. This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } return retval; }
int sendAndHandleDirectoryMsgCallback(String location, ReactorChannel reactorChannel, TransportBuffer transportBuffer, Msg msg, DirectoryMsg directoryMsg, WatchlistStreamInfo streamInfo, ReactorErrorInfo errorInfo) { int retval = sendDirectoryMsgCallback(reactorChannel, transportBuffer, msg, directoryMsg, streamInfo); // check return code from callback. if (retval == ReactorCallbackReturnCodes.FAILURE) { populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "ReactorCallbackReturnCodes.FAILURE was returned from rdmDirectoryMsgCallback(). This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } else if (retval != ReactorCallbackReturnCodes.RAISE && retval != ReactorCallbackReturnCodes.SUCCESS) { // retval is not a valid ReactorReturnCodes. populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "retval of " + retval + " was returned from rdmDirectoryMsgCallback() and is not a valid ReactorCallbackReturnCodes. This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } return retval; }
private int sendAndHandleDirectoryMsgCallback(String location, ReactorChannel reactorChannel, TransportBuffer transportBuffer, Msg msg, DirectoryMsg directoryMsg, ReactorErrorInfo errorInfo) { int retval = sendDirectoryMsgCallback(reactorChannel, transportBuffer, msg, directoryMsg, null); // check return code from callback. if (retval == ReactorCallbackReturnCodes.FAILURE) { populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "ReactorCallbackReturnCodes.FAILURE was returned from rdmDirectoryMsgCallback(). This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } else if (retval != ReactorCallbackReturnCodes.RAISE && retval != ReactorCallbackReturnCodes.SUCCESS) { // retval is not a valid ReactorReturnCodes. populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "retval of " + retval + " was returned from rdmDirectoryMsgCallback() and is not a valid ReactorCallbackReturnCodes. This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } return retval; }
private int sendAndHandleDictionaryMsgCallback(String location, ReactorChannel reactorChannel, TransportBuffer transportBuffer, Msg msg, DictionaryMsg dictionaryMsg, ReactorErrorInfo errorInfo) { int retval = sendDictionaryMsgCallback(reactorChannel, transportBuffer, msg, dictionaryMsg, null); // check return code from callback. if (retval == ReactorCallbackReturnCodes.FAILURE) { populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "ReactorCallbackReturnCodes.FAILURE was returned from rdmDictionaryMsgCallback(). This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } else if (retval != ReactorCallbackReturnCodes.RAISE && retval != ReactorCallbackReturnCodes.SUCCESS) { // retval is not a valid ReactorReturnCodes. populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "retval of " + retval + " was returned from rdmDictionaryMsgCallback() and is not a valid ReactorCallbackReturnCodes. This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } return retval; }
int sendAndHandleQueueMsgCallback(String location, ReactorChannel reactorChannel, TunnelStream tunnelStream, TransportBuffer transportBuffer, Msg msg, QueueMsg queueMsg, ReactorErrorInfo errorInfo) { int retval = sendQueueMsgCallback(reactorChannel, tunnelStream, transportBuffer, msg, queueMsg); // check return code from callback. if (retval == ReactorCallbackReturnCodes.FAILURE) { populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "ReactorCallbackReturnCodes.FAILURE was returned from queueMsgCallback(). This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } else if (retval != ReactorCallbackReturnCodes.RAISE && retval != ReactorCallbackReturnCodes.SUCCESS) { // retval is not a valid ReactorReturnCodes. populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "retval of " + retval + " was returned from tunnelStreamQueueMsgCallback() and is not a valid ReactorCallbackReturnCodes. This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } return retval; }
private int sendAndHandleLoginMsgCallback(String location, ReactorChannel reactorChannel, TransportBuffer transportBuffer, Msg msg, LoginMsg loginMsg, ReactorErrorInfo errorInfo) { int retval = sendLoginMsgCallback(reactorChannel, transportBuffer, msg, loginMsg, null); // check return code from callback. if (retval == ReactorCallbackReturnCodes.FAILURE) { populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "ReactorCallbackReturnCodes.FAILURE was returned from rdmLoginMsgCallback(). This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } else if (retval != ReactorCallbackReturnCodes.RAISE && retval != ReactorCallbackReturnCodes.SUCCESS) { // retval is not a valid ReactorReturnCodes. populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "retval of " + retval + " was returned from rdmLoginMsgCallback() and is not a valid ReactorCallbackReturnCodes. This caused the Reactor to shutdown."); shutdown(errorInfo); return ReactorReturnCodes.FAILURE; } return retval; }
int aggregateViewAdd(WlView aggView, WlView view, ReactorErrorInfo errorInfo) { if(view.viewType() != aggView.viewType()) { _watchlist.reactor().populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, "ItemHandder", "ViewType mismatch, cannot add to aggregated view"); return CodecReturnCodes.FAILURE; } aggView._newViews.add(view); return CodecReturnCodes.SUCCESS; }
/** * Process this channel's events and messages from the Reactor. These are * passed to the calling application via the callback methods associated * with the channel. * * @param dispatchOptions options for how to dispatch * @param errorInfo error structure to be populated in the event of failure * * @return a positive value if dispatching succeeded and there are more messages to process or * {@link ReactorReturnCodes#SUCCESS} if dispatching succeeded and there are no more messages to process or * {@link ReactorReturnCodes#FAILURE}, if dispatching failed (refer to errorInfo for additional information) */ public int dispatch(ReactorDispatchOptions dispatchOptions, ReactorErrorInfo errorInfo) { if (errorInfo == null) return ReactorReturnCodes.FAILURE; else if (dispatchOptions == null) return reactor().populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, "ReactorChannel.dispatch", "dispatchOptions cannot be null."); else if (_reactor.isShutdown()) return _reactor.populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, "ReactorChannel.dispatch", "Reactor is shutdown, dispatch aborted."); return _reactor.dispatchChannel(this, dispatchOptions, errorInfo); }
int changeServiceNameToID(MsgKey msgKey, String serviceName, ReactorErrorInfo errorInfo) { if (msgKey.checkHasServiceId()) { return _reactor.populateErrorInfo(errorInfo, ReactorReturnCodes.INVALID_USAGE, "Watchlist.changeServiceNameToID", "Message submitted with both service name and service ID."); } int serviceId = _directoryHandler.serviceId(serviceName); if (serviceId < ReactorReturnCodes.SUCCESS) { return _reactor.populateErrorInfo(errorInfo, ReactorReturnCodes.INVALID_USAGE, "Watchlist.changeServiceNameToID", "Message submitted with unknown service name " + serviceName + "."); } else { msgKey.applyHasServiceId(); msgKey.serviceId(serviceId); } return ReactorReturnCodes.SUCCESS; }
int startWatchlistTimer(long expireTime, WlStream wlStream, ReactorErrorInfo errorInfo) { if (!_reactor.sendWorkerEvent(WorkerEventTypes.START_WATCHLIST_TIMER, _reactorChannel, expireTime)) { // _reactor.sendWorkerEvent() failed, send channel down _reactor.sendWorkerEvent(WorkerEventTypes.CHANNEL_DOWN, _reactorChannel); _reactorChannel.state(com.thomsonreuters.upa.valueadd.reactor.ReactorChannel.State.DOWN); _reactor.sendAndHandleChannelEventCallback("Watchlist.startWatchlistTimer", ReactorChannelEventTypes.CHANNEL_DOWN, _reactorChannel, errorInfo); return _reactor.populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, "Watchlist.startWatchlistTimer", "_reactor.sendWorkerEvent() failed"); } _streamTimeoutInfoList.add(wlStream); return ReactorReturnCodes.SUCCESS; }
int callbackUserAndDisconnect(String location, Msg msg, LoginMsg loginMsg, ReactorErrorInfo errorInfo) { int ret; _tempWlInteger.value(msg.streamId()); if ((ret = callbackUser(location, msg, loginMsg, _watchlist.streamIdtoWlRequestTable().get(_tempWlInteger), errorInfo)) != ReactorReturnCodes.SUCCESS) return ret; _watchlist.reactor().populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "Received login response with Closed/Recover stream state. Disconnecting."); return _watchlist._reactor.disconnect( _watchlist.reactorChannel(), location, errorInfo); }
int initializeTransport(ReactorErrorInfo errorInfo) { _initArgs.clear(); _initArgs.globalLocking(true); if (Transport.initialize(_initArgs, errorInfo.error()) != TransportReturnCodes.SUCCESS) { return populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, "Reactor.initializeTransport", errorInfo.error().text()); } return ReactorReturnCodes.SUCCESS; }
private int sendFlushRequest(ReactorChannel reactorChannel, String location, ReactorErrorInfo errorInfo) { if (reactorChannel.flushRequested()) reactorChannel.flushAgain(true); /* Flush already in progress; wait till FLUSH_DONE is received, then request again. */ else { if (!sendWorkerEvent(WorkerEventTypes.FLUSH, reactorChannel)) { // sendWorkerEvent() failed, send channel down reactorChannel.state(State.DOWN); sendAndHandleChannelEventCallback(location, ReactorChannelEventTypes.CHANNEL_DOWN, reactorChannel, errorInfo); return populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, location, "sendWorkerEvent() failed while requesting flush"); } reactorChannel.flushAgain(false); reactorChannel.flushRequested(true); } return ReactorReturnCodes.SUCCESS; }
private int sendChannelEventCallback(int eventType, ReactorChannel reactorChannel, ReactorErrorInfo errorInfo) { ReactorChannelEvent reactorChannelEvent = ReactorFactory.createReactorChannelEvent(); reactorChannelEvent.reactorChannel(reactorChannel); reactorChannelEvent.eventType(eventType); populateErrorInfo(reactorChannelEvent.errorInfo(), errorInfo.code(), errorInfo.location(), errorInfo.error().text()); int retval = reactorChannel.role().channelEventCallback().reactorChannelEventCallback(reactorChannelEvent); reactorChannelEvent.returnToPool(); return retval; }
private int handleViews(WlRequest wlRequest, ReactorErrorInfo errorInfo) { switch(wlRequest.viewAction()) { case VIEW_ACTION_SET: { WlView view = _wlViewHandler.viewCreate(wlRequest.viewFieldIdList(), wlRequest.viewElementNameList(), wlRequest.viewElemCount(), wlRequest.viewType(), errorInfo); if ( view == null ) return CodecReturnCodes.FAILURE; wlRequest.view(view); break; } case VIEW_ACTION_MAINTAIN: break; case VIEW_ACTION_NONE: break; default: { _watchlist.reactor().populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, "ItemHandler", "Invalid View Action <" + wlRequest.viewAction() + ">"); return CodecReturnCodes.FAILURE; } } return addRequestView(wlRequest, errorInfo); }
int submitMsg(MsgBase rdmMsg, ReactorSubmitOptions submitOptions, ReactorErrorInfo errorInfo) { // block user from submitting anything other than login, directory and dictionary domains if (rdmMsg.domainType() != DomainTypes.LOGIN && rdmMsg.domainType() != DomainTypes.SOURCE && rdmMsg.domainType() != DomainTypes.DICTIONARY) { return _reactor.populateErrorInfo(errorInfo, ReactorReturnCodes.INVALID_USAGE, "Watchlist.submitMsg", "Cannot submit domain type " + DomainTypes.toString(rdmMsg.domainType()) + " to watchlist as RDM message."); } // convert to Codec message _tempMsg.clear(); convertRDMToCodecMsg(rdmMsg, _tempMsg); if (rdmMsg.domainType() == DomainTypes.DICTIONARY && ((DictionaryMsg)rdmMsg).rdmMsgType() == DictionaryMsgType.REQUEST && submitOptions.serviceName() != null) { // DictionaryRequest.serviceId is not optional. If a service name was provided, let that take precedence over // serviceId -- remove the serviceId from this message so that we don't get an error for having specified both. _tempMsg.msgKey().flags(_tempMsg.msgKey().flags() & ~MsgKeyFlags.HAS_SERVICE_ID); } // submit with method that takes Codec message as argument return submitMsg(_tempMsg, submitOptions, errorInfo); }
wlRequest.view().viewType() != wlStream.aggregateView().viewType()) _watchlist.reactor().populateErrorInfo(errorInfo, ReactorReturnCodes.FAILURE, "ItemHandler", "ViewType mismatch, cannot be aggregated.");