use of org.apache.jackrabbit.oak.plugins.document.RevisionContextWrapper 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