Search in sources :

Example 1 with RevisionContextWrapper

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);
}
Also used : ClusterNodeInfoDocument(org.apache.jackrabbit.oak.plugins.document.ClusterNodeInfoDocument) DocumentStore(org.apache.jackrabbit.oak.plugins.document.DocumentStore) RevisionContextWrapper(org.apache.jackrabbit.oak.plugins.document.RevisionContextWrapper) MissingLastRevSeeker(org.apache.jackrabbit.oak.plugins.document.MissingLastRevSeeker) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)

Aggregations

ClusterNodeInfoDocument (org.apache.jackrabbit.oak.plugins.document.ClusterNodeInfoDocument)1 DocumentMK (org.apache.jackrabbit.oak.plugins.document.DocumentMK)1 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)1 DocumentStore (org.apache.jackrabbit.oak.plugins.document.DocumentStore)1 MissingLastRevSeeker (org.apache.jackrabbit.oak.plugins.document.MissingLastRevSeeker)1 RevisionContextWrapper (org.apache.jackrabbit.oak.plugins.document.RevisionContextWrapper)1