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))); } }
while (progress.getIterator().hasNext()) { VisitorIterator.BucketProgress bucket = progress.getIterator().getNext(); Result result = sender.send(createMessage(bucket)); if (result.isAccepted()) { log.log(LogLevel.DEBUG, sessionName + ": sent CreateVisitor for bucket " +
private CreateVisitorMessage createMessage(VisitorIterator.BucketProgress bucket) { CreateVisitorMessage msg = new CreateVisitorMessage( params.getVisitorLibrary(), getNextVisitorId(), receiver.getConnectionSpec(), dataDestination); msg.getTrace().setLevel(params.getTraceLevel()); msg.setTimeRemaining(messageTimeoutMs); msg.setBuckets(Arrays.asList(bucket.getSuperbucket(), bucket.getProgress())); msg.setDocumentSelection(params.getDocumentSelection()); msg.setBucketSpace(params.getBucketSpace()); msg.setFromTimestamp(params.getFromTimestamp()); msg.setToTimestamp(params.getToTimestamp()); msg.setMaxPendingReplyCount(params.getMaxPending()); msg.setFieldSet(params.fieldSet()); msg.setVisitInconsistentBuckets(params.visitInconsistentBuckets()); msg.setVisitRemoves(params.visitRemoves()); msg.setParameters(params.getLibraryParameters()); msg.setRoute(params.getRoute()); msg.setVisitorOrdering(params.getVisitorOrdering()); msg.setMaxBucketsPerVisitor(params.getMaxBucketsPerVisitor()); msg.setLoadType(params.getLoadType()); msg.setPriority(params.getPriority()); msg.setRetryEnabled(false); return msg; }
/** * Schedule a new SendCreateVisitors task iff there are still buckets to * visit, the visiting has not failed fatally and we haven't already * scheduled such a task. */ private void scheduleSendCreateVisitorsIfApplicable(long delay, TimeUnit unit) { final long elapsedMillis = elapsedTimeMillis(); if (!isInfiniteTimeout(sessionTimeoutMillis()) && (elapsedMillis >= sessionTimeoutMillis())) { transitionTo(new StateDescription(State.TIMED_OUT, String.format("Session timeout of %d ms expired", sessionTimeoutMillis()))); if (visitingCompleted()) { markSessionCompleted(); } return; } if (!mayScheduleCreateVisitorsTask()) { return; } final long messageTimeoutMillis = computeBoundedMessageTimeoutMillis(elapsedMillis); taskExecutor.scheduleTask(new SendCreateVisitorsTask(messageTimeoutMillis), delay, unit); scheduledSendCreateVisitors = true; }