use of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore in project jackrabbit-oak by apache.
the class LastRevRecoveryRandomizedIT method checkStore.
private void checkStore() {
MemoryDocumentStore s = store.copy();
// force lease expire
UpdateOp op = new UpdateOp(String.valueOf(ns.getClusterId()), false);
op.set(ClusterNodeInfo.LEASE_END_KEY, clock.getTime() - 1000);
if (s.findAndUpdate(Collection.CLUSTER_NODES, op) == null) {
fail("failed to set lease end");
}
// will trigger recovery on startup
DocumentNodeStore dns = new DocumentMK.Builder().setClusterId(ns.getClusterId()).clock(clock).setLeaseCheck(false).setDocumentStore(s).setAsyncDelay(0).getNodeStore();
Map<String, NodeState> states = Maps.newHashMap(currentState);
NodeState root = dns.getRoot().getChildNode("root");
compareAndTraverse(root, "/root", states);
assertTrue("missing nodes: " + states.keySet() + " (seed=" + SEED + ")", states.isEmpty());
dns.dispose();
}
use of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore in project jackrabbit-oak by apache.
the class FormatVersionTest method versionOf.
@Test
public void versionOf() throws Exception {
DocumentStore store = new MemoryDocumentStore();
FormatVersion v = FormatVersion.versionOf(store);
assertSame(V0, v);
}
use of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore in project jackrabbit-oak by apache.
the class FormatVersionTest method activeClusterNodes.
@Test(expected = DocumentStoreException.class)
public void activeClusterNodes() throws Exception {
DocumentStore store = new MemoryDocumentStore();
V1_0.writeTo(store);
ClusterNodeInfo info = ClusterNodeInfo.getInstance(store, 1);
info.renewLease();
V1_2.writeTo(store);
}
use of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore in project jackrabbit-oak by apache.
the class DocumentNodeStoreTest method updateClusterState.
@Test
public void updateClusterState() {
DocumentStore docStore = new MemoryDocumentStore();
DocumentNodeStore ns1 = builderProvider.newBuilder().setAsyncDelay(0).setClusterId(1).setDocumentStore(docStore).getNodeStore();
int cId1 = ns1.getClusterId();
DocumentNodeStore ns2 = builderProvider.newBuilder().setAsyncDelay(0).setClusterId(2).setDocumentStore(docStore).getNodeStore();
int cId2 = ns2.getClusterId();
ns1.updateClusterState();
ns2.updateClusterState();
assertEquals(0, ns1.getMBean().getInactiveClusterNodes().length);
assertEquals(0, ns2.getMBean().getInactiveClusterNodes().length);
assertEquals(2, ns1.getMBean().getActiveClusterNodes().length);
assertEquals(2, ns2.getMBean().getActiveClusterNodes().length);
ns1.dispose();
ns2.updateClusterState();
String[] inactive = ns2.getMBean().getInactiveClusterNodes();
String[] active = ns2.getMBean().getActiveClusterNodes();
assertEquals(1, inactive.length);
assertTrue(inactive[0].startsWith(cId1 + "="));
assertEquals(1, active.length);
assertTrue(active[0].startsWith(cId2 + "="));
}
use of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore in project jackrabbit-oak by apache.
the class DocumentNodeStoreTest method ignoreUncommitted.
// OAK-3474
@Test
public void ignoreUncommitted() throws Exception {
final AtomicLong numPreviousFinds = new AtomicLong();
MemoryDocumentStore store = new MemoryDocumentStore() {
@Override
public <T extends Document> T find(Collection<T> collection, String key) {
if (Utils.getPathFromId(key).startsWith("p")) {
numPreviousFinds.incrementAndGet();
}
return super.find(collection, key);
}
};
DocumentNodeStore ns = builderProvider.newBuilder().setDocumentStore(store).setAsyncDelay(0).getNodeStore();
String id = Utils.getIdFromPath("/test");
NodeBuilder b = ns.getRoot().builder();
b.child("test").setProperty("p", "a");
merge(ns, b);
NodeDocument doc;
int i = 0;
do {
b = ns.getRoot().builder();
b.child("test").setProperty("q", i++);
merge(ns, b);
doc = store.find(NODES, id);
assertNotNull(doc);
if (i % 100 == 0) {
ns.runBackgroundOperations();
}
} while (doc.getPreviousRanges().isEmpty());
Revision r = ns.newRevision();
UpdateOp op = new UpdateOp(id, false);
NodeDocument.setCommitRoot(op, r, 0);
op.setMapEntry("p", r, "b");
assertNotNull(store.findAndUpdate(NODES, op));
doc = store.find(NODES, id);
numPreviousFinds.set(0);
doc.getNodeAtRevision(ns, ns.getHeadRevision(), null);
assertEquals(0, numPreviousFinds.get());
}
Aggregations