Search in sources :

Example 1 with ClusterNodeInfoDocument

use of org.apache.jackrabbit.oak.plugins.document.ClusterNodeInfoDocument in project jackrabbit-oak by apache.

the class AcquireRecoveryLockTest method recoveryBy.

// OAK-4131
@Test
public void recoveryBy() throws Exception {
    MongoMissingLastRevSeeker seeker = new MongoMissingLastRevSeeker(store, getTestClock());
    List<ClusterNodeInfoDocument> infoDocs = newArrayList(seeker.getAllClusters());
    assertEquals(1, infoDocs.size());
    int clusterId = infoDocs.get(0).getClusterId();
    int otherClusterId = clusterId + 1;
    getTestClock().waitUntil(getTestClock().getTime() + ClusterNodeInfo.DEFAULT_LEASE_DURATION_MILLIS + 1000);
    assertTrue(seeker.acquireRecoveryLock(clusterId, otherClusterId));
    ClusterNodeInfoDocument doc = seeker.getClusterNodeInfo(clusterId);
    Object recoveryBy = doc.get(ClusterNodeInfo.REV_RECOVERY_BY);
    assertNotNull(recoveryBy);
    assertEquals(Long.class, recoveryBy.getClass());
}
Also used : ClusterNodeInfoDocument(org.apache.jackrabbit.oak.plugins.document.ClusterNodeInfoDocument) Test(org.junit.Test) AbstractMongoConnectionTest(org.apache.jackrabbit.oak.plugins.document.AbstractMongoConnectionTest)

Example 2 with ClusterNodeInfoDocument

use of org.apache.jackrabbit.oak.plugins.document.ClusterNodeInfoDocument 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)2 AbstractMongoConnectionTest (org.apache.jackrabbit.oak.plugins.document.AbstractMongoConnectionTest)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 Test (org.junit.Test)1