@Override public SyncSession create() { return documentAccess.createSyncSession(new SyncParameters.Builder().build()); } }
@Override public Result update(DocumentUpdate update, DocumentProtocol.Priority pri) { long req = getNextRequestId(); if (syncSession.update(update, pri)) { addResponse(new UpdateResponse(req, true)); } else { addResponse(new DocumentUpdateResponse(req, update, "Document not found.", false)); } return new Result(req); }
@Override public Result remove(DocumentId id, DocumentProtocol.Priority pri) { long req = getNextRequestId(); if (syncSession.remove(new DocumentRemove(id), pri)) { addResponse(new RemoveResponse(req, true)); } else { addResponse(new DocumentIdResponse(req, id, "Document not found.", false)); } return new Result(req); }
public BucketProgress getNext() { assert(hasNext()) : "getNext() called with hasNext() == false"; long currentPosition = progressToken.getBucketCursor(); long key = ProgressToken.makeNthBucketKey(currentPosition, distributionBitCount); ++currentPosition; progressToken.setBucketCursor(currentPosition); return new BucketProgress( new BucketId(ProgressToken.keyToBucketId(key)), new BucketId()); }
@Override public boolean waitUntilDone(long timeoutMs) throws InterruptedException { return params.getControlHandler().waitUntilDone(timeoutMs); }
@Override public VisitorStatistics getStatistics() { return params.getControlHandler().getVisitorStatistics(); }
private void reportVisitorError(String message) { params.getControlHandler().onVisitorError(message); }
public VisitorResponse getNext(int timeoutMilliseconds) throws InterruptedException { return params.getDataHandler().getNext(timeoutMilliseconds); }
/** * <p>Gets a document.</p> * * @param id The id of the document to get. * @return The known document having this id, or null if there is no * document having this id. * @throws UnsupportedOperationException Thrown if this access does not * support retrieving. */ default Document get(DocumentId id) { return get(id, null); }
/** * @return The total number of iterable buckets that remain to be processed * * Note: currently includes all non-finished (i.e. active and pending * buckets) as well */ public long getRemainingBucketCount() { return progressToken.getTotalBucketCount() - progressToken.getFinishedBucketCount(); }
/** * <p>Puts a document. When this method returns, the document is safely * received.</p> * * @param documentPut The DocumentPut operation * @param priority The priority with which to perform this operation. */ default void put(DocumentPut documentPut, DocumentProtocol.Priority priority) { put(documentPut); }
@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(); }
@Override public String toString() { return "Update" + super.toString() + " " + wasFound; } }
public boolean addAll(Collection<? extends M> ms) { for (M m : ms) { if (!offer(m)) { return false; } } return true; } }
public void update(BucketId superbucket, BucketId progress, ProgressToken token) { // Simply delegate to ProgressToken, as it maintains all progress state token.updateProgress(superbucket, progress); } }
/** * Function used to ack data. You need to ack data periodically, as storage * will halt visiting when it has too much client requests pending. * * @param token The token to ack. Gotten from an earlier callback. */ public void ack(AckToken token) { session.ack(token); }
public VisitorResponse getNext() { return params.getDataHandler().getNext(); }
@Override public String toString() { return "Remove" + super.toString() + " " + wasFound; } }