@Override public void abort() { synchronized (progress.getToken()) { transitionTo(new StateDescription(State.ABORTED, "Visitor aborted by user")); } }
@Override public MessageBusSyncSession createSyncSession(SyncParameters parameters) { return new MessageBusSyncSession(parameters, messageBus(), this.params); }
private void updateStateUnlessAlreadyFailed(StateDescription newState) { if (!state.failed()) { state = newState; } // else: don't override existing failure state }
public void start() { synchronized (progress.getToken()) { this.startTimeNanos = clock.monotonicNanoTime(); if (progress.getIterator().isDone()) { log.log(LogLevel.DEBUG, sessionName + ": progress token indicates " + "session is done before it could even start; no-op"); return; } transitionTo(new StateDescription(State.WORKING)); taskExecutor.submitTask(new SendCreateVisitorsTask(computeBoundedMessageTimeoutMillis(0))); } }
public static MessageBusVisitorSession createForMessageBus(final MessageBus mbus, final ScheduledExecutorService scheduledExecutorService, final VisitorParameters params) throws ParseException { final AsyncTaskExecutor executor = new ThreadAsyncTaskExecutor(scheduledExecutorService); final MessageBusSenderFactory senderFactory = new MessageBusSenderFactory(mbus); final MessageBusReceiverFactory receiverFactory = new MessageBusReceiverFactory(mbus); final RoutingTable table = mbus.getRoutingTable(DocumentProtocol.NAME); return new MessageBusVisitorSession(params, executor, senderFactory, receiverFactory, table); }
private boolean mayScheduleCreateVisitorsTask() { return ! (scheduledSendCreateVisitors || !progress.getIterator().hasNext() || state.failed() || enoughHitsReceived()); }
@Override public MessageBusAsyncSession createAsyncSession(AsyncParameters parameters) { return new MessageBusAsyncSession(parameters, messageBus(), this.params); }
/** * <p>This is a convenience method to return a document access object with * all default parameter values. The client that calls this method is also * responsible for shutting the object down when done. If an error occurred * while attempting to create such an object, this method will throw an * exception.</p> * * @return A running document access object with all default configuration. */ public static DocumentAccess createDefault() { return new com.yahoo.documentapi.messagebus.MessageBusDocumentAccess(); }
/** * Creates a new document access using default values for all parameters. */ public MessageBusDocumentAccess() { this(new MessageBusParams()); }
@Override public Sender createSender(ReplyHandler replyHandler, VisitorParameters visitorParameters) { messageBus.setMaxPendingCount(0); SourceSessionParams sessionParams = createSourceSessionParams(visitorParameters); return new MessageBusSender(messageBus.createSourceSession(replyHandler, sessionParams)); } }
/** * Sets the name of the route to send appropriate requests to. This is a convenience method for prefixing a route * with "route:", and using {@link #setRoute} instead. * * @param routeName The route name. * @return This object for chaining. */ public MessageBusParams setRouteName(String routeName) { return setRoute("route:" + routeName); }
@Override public String getRoute() { return session.getRoute(); }
@Override public Result remove(DocumentId id) { return remove(id, DocumentProtocol.Priority.NORMAL_2); }
@Override public void destroy() { session.destroy(); }
@Override public Document get(DocumentId id, Duration timeout) { return get(id, "[all]", DocumentProtocol.Priority.NORMAL_1, timeout); }
@Override public boolean update(DocumentUpdate update) { return update(update, DocumentProtocol.Priority.NORMAL_2); }
public MessageBusParams setRouteNameForGet(String routeName) { return setRouteForGet("route:" + routeName); } public MessageBusParams setRouteForGet(String route) {
@Override public Result get(DocumentId id) { return get(id, DocumentProtocol.Priority.NORMAL_1); }
public boolean failed() { return state.isFailure(); }
/** * Perform a synchronous sending of a message. This method block until the message is successfuly sent and a * corresponding reply has been received. * * @param msg The message to send. * @return The reply received. */ public Reply syncSend(Message msg) { return syncSend(msg, defaultTimeout); }