@Override public DocumentReply createReply() { return new CreateVisitorReply(DocumentProtocol.REPLY_CREATEVISITOR); }
private void handleCreateVisitorReply(CreateVisitorReply reply) { CreateVisitorMessage msg = (CreateVisitorMessage)reply.getMessage(); BucketId superbucket = msg.getBuckets().get(0); BucketId subBucketProgress = reply.getLastBucket(); log.log(LogLevel.DEBUG, sessionName + ": received CreateVisitorReply for bucket " + superbucket + " with progress " + subBucketProgress); progress.getIterator().update(superbucket, subBucketProgress); params.getControlHandler().onProgress(progress.getToken()); statistics.add(reply.getVisitorStatistics()); params.getControlHandler().onVisitorStatistics(statistics); trace.getRoot().addChild(reply.getTrace().getRoot()); if (params.getDynamicallyIncreaseMaxBucketsPerVisitor() && (reply.getVisitorStatistics().getDocumentsReturned() < params.getMaxFirstPassHits() / 2.0)) { // Attempt to increase parallelism to reduce latency of visiting // Ensure new count is within [1, 128] int newMaxBuckets = Math.max(Math.min((int)(params.getMaxBucketsPerVisitor() * params.getDynamicMaxBucketsIncreaseFactor()), 128), 1); params.setMaxBucketsPerVisitor(newMaxBuckets); log.log(LogLevel.DEBUG, sessionName + ": increasing max buckets per visitor to " + params.getMaxBucketsPerVisitor()); } }
@Override protected DocumentReply doDecode(DocumentDeserializer buf) { CreateVisitorReply reply = new CreateVisitorReply(DocumentProtocol.REPLY_CREATEVISITOR); reply.setLastBucket(new BucketId(buf.getLong(null))); VisitorStatistics vs = new VisitorStatistics(); vs.setBucketsVisited(buf.getInt(null)); vs.setDocumentsVisited(buf.getLong(null)); vs.setBytesVisited(buf.getLong(null)); vs.setDocumentsReturned(buf.getLong(null)); vs.setBytesReturned(buf.getLong(null)); vs.setSecondPassDocumentsReturned(buf.getLong(null)); vs.setSecondPassBytesReturned(buf.getLong(null)); reply.setVisitorStatistics(vs); return reply; }
@Override protected boolean doEncode(DocumentReply obj, DocumentSerializer buf) { CreateVisitorReply reply = (CreateVisitorReply)obj; buf.putLong(null, reply.getLastBucket().getRawId()); buf.putInt(null, reply.getVisitorStatistics().getBucketsVisited()); buf.putLong(null, reply.getVisitorStatistics().getDocumentsVisited()); buf.putLong(null, reply.getVisitorStatistics().getBytesVisited()); buf.putLong(null, reply.getVisitorStatistics().getDocumentsReturned()); buf.putLong(null, reply.getVisitorStatistics().getBytesReturned()); buf.putLong(null, reply.getVisitorStatistics().getSecondPassDocumentsReturned()); buf.putLong(null, reply.getVisitorStatistics().getSecondPassBytesReturned()); return true; } }