@Test public void completeResult() throws Exception { final int NUM_DOCS = 200; List<UpdateOp> ops = Lists.newArrayList(); for (int i = 0; i < NUM_DOCS; i++) { UpdateOp op = new UpdateOp(getIdFromPath("/node-" + i), true); NodeDocument.setModified(op, new Revision(i * 5000, 0, 1)); ops.add(op); } assertTrue(store.create(NODES, ops)); Set<String> ids = Sets.newHashSet(); boolean updated = false; MissingLastRevSeeker seeker = builder.createMissingLastRevSeeker(); for (NodeDocument doc : seeker.getCandidates(0)) { if (!updated) { UpdateOp op = new UpdateOp(getIdFromPath("/node-0"), false); NodeDocument.setModified(op, new Revision(NUM_DOCS * 5000, 0, 1)); assertNotNull(store.findAndUpdate(NODES, op)); updated = true; } if (doc.getPath().toString().startsWith("/node-")) { ids.add(doc.getId()); } } assertEquals(NUM_DOCS, ids.size()); }
@Override @NotNull public CloseableIterable<NodeDocument> getCandidates(final long startTime) { Bson query = Filters.gte(NodeDocument.MODIFIED_IN_SECS, NodeDocument.getModifiedInSecs(startTime)); Bson sortFields = new BasicDBObject(NodeDocument.MODIFIED_IN_SECS, 1); FindIterable<BasicDBObject> cursor = getNodeCollection() .find(query).sort(sortFields); return CloseableIterable.wrap(transform(cursor, input -> store.convertFromDBObject(NODES, input))); }
MongoMissingLastRevSeeker extends MissingLastRevSeeker { @Override @NotNull public CloseableIterable<NodeDocument> getCandidates(final long startTime) { Bson query = Filters.gte(NodeDocument.MODIFIED_IN_SECS, NodeDocument.getModifiedInSecs(startTime)); Bson sortFields = new BasicDBObject(NodeDocument.MODIFIED_IN_SECS, 1); FindIterable<BasicDBObject> cursor = getNodeCollection() .find(query).sort(sortFields); return CloseableIterable.wrap(transform(cursor, input -> store.convertFromDBObject(NODES, input))); } }
MongoMissingLastRevSeeker extends MissingLastRevSeeker { @Override @NotNull public CloseableIterable<NodeDocument> getCandidates(final long startTime) { Bson query = Filters.gte(NodeDocument.MODIFIED_IN_SECS, NodeDocument.getModifiedInSecs(startTime)); Bson sortFields = new BasicDBObject(NodeDocument.MODIFIED_IN_SECS, 1); FindIterable<BasicDBObject> cursor = getNodeCollection() .find(query).sort(sortFields); return CloseableIterable.wrap(transform(cursor, input -> store.convertFromDBObject(NODES, input))); } MongoMissingLastRevSeeker(MongoDocumentStore store, Clock clock); }
MongoMissingLastRevSeeker extends MissingLastRevSeeker { @Override @NotNull public CloseableIterable<NodeDocument> getCandidates(final long startTime) { Bson query = Filters.gte(NodeDocument.MODIFIED_IN_SECS, NodeDocument.getModifiedInSecs(startTime)); Bson sortFields = new BasicDBObject(NodeDocument.MODIFIED_IN_SECS, 1); FindIterable<BasicDBObject> cursor = getNodeCollection() .find(query).sort(sortFields); return CloseableIterable.wrap(transform(cursor, input -> store.convertFromDBObject(NODES, input))); } MongoMissingLastRevSeeker(MongoDocumentStore store, Clock clock); @Override @NotNull CloseableIterable<NodeDocument> getCandidates(final long startTime); @Override boolean isRecoveryNeeded(); }
MongoMissingLastRevSeeker extends MissingLastRevSeeker { @Override @NotNull public CloseableIterable<NodeDocument> getCandidates(final long startTime) { Bson query = Filters.gte(NodeDocument.MODIFIED_IN_SECS, NodeDocument.getModifiedInSecs(startTime)); Bson sortFields = new BasicDBObject(NodeDocument.MODIFIED_IN_SECS, 1); FindIterable<BasicDBObject> cursor = getNodeCollection() .find(query).sort(sortFields); return CloseableIterable.wrap(transform(cursor, input -> store.convertFromDBObject(NODES, input))); } MongoMissingLastRevSeeker(MongoDocumentStore store, Clock clock); @Override @NotNull CloseableIterable<NodeDocument> getCandidates(final long startTime); @Override boolean isRecoveryNeeded();  }