public VisitorResponse getNext(int timeoutMilliseconds) throws InterruptedException { return params.getDataHandler().getNext(timeoutMilliseconds); }
@Override public void reset() { super.reset(); pendingResponses.clear(); }
/** * Called from the constructor to ensure control and data handlers * are set and initialized. */ private void initializeHandlers() { if (this.params.getLocalDataHandler() != null) { this.params.getLocalDataHandler().reset(); this.params.getLocalDataHandler().setSession(this); } else if (this.params.getRemoteDataHandler() == null) { this.params.setLocalDataHandler(new VisitorDataQueue()); this.params.getLocalDataHandler().setSession(this); } if (params.getControlHandler() != null) { params.getControlHandler().reset(); } else { params.setControlHandler(new VisitorControlHandler()); } params.getControlHandler().setSession(this); }
public void handleMessage(Message message) { Reply reply = ((DocumentMessage)message).createReply(); message.swapState(reply); params.getDataHandler().onMessage(message, new AckToken(reply)); }
/** * Creates a message bus visitor destination session. * * @param params the parameters for the visitor destination session * @param bus the message bus to use */ public MessageBusVisitorDestinationSession(VisitorDestinationParameters params, MessageBus bus) { this.params = params; session = bus.createDestinationSession(params.getSessionName(), true, this); params.getDataHandler().setSession(this); }
private void markSessionCompleted() { // 'done' is only ever written when token mutex is held, so safe to check // outside of completionMonitor lock. assert(!done) : "Session was marked as completed more than once"; log.log(LogLevel.DEBUG, "Visitor session '" + sessionName + "' has completed"); if (params.getLocalDataHandler() != null) { params.getLocalDataHandler().onDone(); } // If skipFatalErrors is set and a fatal error did occur, fail // the session now with the first encountered error message. if (progress.getToken().containsFailedBuckets()) { transitionTo(new StateDescription(State.FAILED, progress.getToken().getFirstErrorMsg())); } // NOTE: transitioning to COMPLETED will not override a failure // state, so it's safe to always do this. transitionTo(new StateDescription(State.COMPLETED)); params.getControlHandler().onDone(state.toCompletionCode(), state.getDescription()); synchronized (completionMonitor) { done = true; completionMonitor.notifyAll(); } }
private void handleDocumentMessage(DocumentMessage msg) { Reply reply = msg.createReply(); msg.swapState(reply); if (params.getLocalDataHandler() == null) { log.log(LogLevel.ERROR, sessionName + ": Got visitor data back to client with no local data destination."); reply.addError(new Error(ErrorCode.APP_FATAL_ERROR, "Visitor data with no local data destination")); receiver.reply(reply); return; } try { params.getLocalDataHandler().onMessage(msg, new AckToken(reply)); } catch (Exception e) { handleMessageProcessingException(reply, e, "DocumentMessage"); // Immediately reply since we cannot count on AckToken being registered receiver.reply(reply); } }
public VisitorResponse getNext() { return params.getDataHandler().getNext(); }
@Override public VisitorResponse getNext(int timeoutMilliseconds) throws InterruptedException { if (params.getLocalDataHandler() == null) { throw new IllegalStateException("Data has been routed to external source for this visitor"); } return params.getLocalDataHandler().getNext(timeoutMilliseconds); }
@Override public VisitorResponse getNext() { if (params.getLocalDataHandler() == null) { throw new IllegalStateException("Data has been routed to external source for this visitor"); } return params.getLocalDataHandler().getNext(); }