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());
}
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);
}
Aggregations