use of org.apache.jackrabbit.oak.plugins.document.NodeDocument in project jackrabbit-oak by apache.
the class RDBDocumentSerializerTest method testSimpleString.
@Test
public void testSimpleString() {
RDBRow row = new RDBRow("_foo", 1L, true, 1l, 2l, 3l, "{}", null);
NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
assertEquals("_foo", doc.getId());
assertEquals(true, doc.hasBinary());
assertEquals(true, doc.get(NodeDocument.DELETED_ONCE));
assertEquals(2L, doc.getModCount().longValue());
}
use of org.apache.jackrabbit.oak.plugins.document.NodeDocument in project jackrabbit-oak by apache.
the class UtilsTest method alignWithExternalRevisions.
@Test
public void alignWithExternalRevisions() throws Exception {
Clock c = new Clock.Virtual();
c.waitUntil(System.currentTimeMillis());
// past
Revision lastRev1 = new Revision(c.getTime() - 1000, 0, 1);
// future
Revision lastRev2 = new Revision(c.getTime() + 1000, 0, 2);
// create a root document
NodeDocument doc = new NodeDocument(new MemoryDocumentStore(), c.getTime());
UpdateOp op = new UpdateOp(Utils.getIdFromPath("/"), true);
NodeDocument.setLastRev(op, lastRev1);
NodeDocument.setLastRev(op, lastRev2);
UpdateUtils.applyChanges(doc, op);
// must not wait even if revision is in the future
Utils.alignWithExternalRevisions(doc, c, 2);
assertThat(c.getTime(), is(lessThan(lastRev2.getTimestamp())));
// must wait until after lastRev2 timestamp
Utils.alignWithExternalRevisions(doc, c, 1);
assertThat(c.getTime(), is(greaterThan(lastRev2.getTimestamp())));
}
use of org.apache.jackrabbit.oak.plugins.document.NodeDocument in project jackrabbit-oak by apache.
the class RecoveryCommand method execute.
@Override
public void execute(String... args) throws Exception {
MapFactory.setInstance(new MapDBMapFactory());
Closer closer = Closer.create();
String h = "recovery mongodb://host:port/database { dryRun }";
try {
NodeStore store = Utils.bootstrapNodeStore(args, closer, h);
if (!(store instanceof DocumentNodeStore)) {
System.err.println("Recovery only available for DocumentNodeStore");
System.exit(1);
}
DocumentNodeStore dns = (DocumentNodeStore) store;
if (!(dns.getDocumentStore() instanceof MongoDocumentStore)) {
System.err.println("Recovery only available for MongoDocumentStore");
System.exit(1);
}
MongoDocumentStore docStore = (MongoDocumentStore) dns.getDocumentStore();
LastRevRecoveryAgent agent = new LastRevRecoveryAgent(dns);
MongoMissingLastRevSeeker seeker = new MongoMissingLastRevSeeker(docStore, dns.getClock());
CloseableIterable<NodeDocument> docs = seeker.getCandidates(0);
closer.register(docs);
boolean dryRun = Arrays.asList(args).contains("dryRun");
agent.recover(docs, dns.getClusterId(), dryRun);
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
}
Aggregations