use of org.apache.jackrabbit.oak.plugins.document.MissingLastRevSeeker in project jackrabbit-oak by apache.
the class MongoMissingLastRevSeekerTest method completeResult.
@Test
public void completeResult() throws Exception {
final int NUM_DOCS = 200;
// populate the store
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) {
// as soon as we have the first document, update /node-0
UpdateOp op = new UpdateOp(getIdFromPath("/node-0"), false);
// and push out the _modified timestamp
NodeDocument.setModified(op, new Revision(NUM_DOCS * 5000, 0, 1));
// even after the update the document matches the query
assertNotNull(store.findAndUpdate(NODES, op));
updated = true;
}
if (doc.getPath().startsWith("/node-")) {
ids.add(doc.getId());
}
}
// seeker must return all documents
assertEquals(NUM_DOCS, ids.size());
}
use of org.apache.jackrabbit.oak.plugins.document.MissingLastRevSeeker in project jackrabbit-oak by apache.
the class RevisionsCommand method sweep.
private void sweep(RevisionsOptions options, Closer closer) throws IOException {
int clusterId = options.getClusterId();
if (clusterId <= 0) {
System.err.println("clusterId option is required for " + RevisionsOptions.CMD_SWEEP + " command");
return;
}
DocumentMK.Builder builder = createDocumentMKBuilder(options, closer);
if (builder == null) {
System.err.println("revisions mode only available for DocumentNodeStore");
return;
}
DocumentStore store = builder.getDocumentStore();
// cluster node must be inactive
for (ClusterNodeInfoDocument doc : ClusterNodeInfoDocument.all(store)) {
if (doc.getClusterId() == clusterId && doc.isActive()) {
System.err.println("cannot sweep revisions for active " + "clusterId " + clusterId);
return;
}
}
// the root document must have a _lastRev entry for the clusterId
if (!getRootDocument(store).getLastRev().containsKey(clusterId)) {
System.err.println("store does not have changes with " + "clusterId " + clusterId);
return;
}
builder.setReadOnlyMode();
DocumentNodeStore ns = builder.getNodeStore();
closer.register(asCloseable(ns));
MissingLastRevSeeker seeker = builder.createMissingLastRevSeeker();
SweepHelper.sweep(store, new RevisionContextWrapper(ns, clusterId), seeker);
}
Aggregations