use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class ClusterRepositoryInfoTest method checkCustomId.
// below test doesn't make sense anymore in the context
// of getOrCreateId (OAK-4006) where that never returns null
// @Test
// public void checkGetIdWhenNotRegistered() {
// MemoryDocumentStore store = new MemoryDocumentStore();
// DocumentNodeStore ds1 = builderProvider.newBuilder()
// .setAsyncDelay(0)
// .setDocumentStore(store)
// .setClusterId(1)
// .getNodeStore();
// // Should be null and no NPE
// String id = ClusterRepositoryInfo.getOrCreateId(ds1);
// Assert.assertNull(id);
// }
@Test
public void checkCustomId() throws Exception {
MemoryDocumentStore store = new MemoryDocumentStore();
DocumentNodeStore ds1 = builderProvider.newBuilder().setAsyncDelay(0).setDocumentStore(store).setClusterId(1).getNodeStore();
String repoId1 = "yyyyyyy";
setId(ds1, repoId1);
ds1.runBackgroundOperations();
String id = ClusterRepositoryInfo.getOrCreateId(ds1);
Assert.assertEquals(id, repoId1);
}
use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class ClusterRepositoryInfoTest method sameCluster.
@Test
public void sameCluster() throws Exception {
MemoryDocumentStore store = new MemoryDocumentStore();
DocumentNodeStore ds1 = builderProvider.newBuilder().setAsyncDelay(0).setDocumentStore(store).setClusterId(1).setBlobStore(blobStore).getNodeStore();
String repoId1 = ClusterRepositoryInfo.getOrCreateId(ds1);
ds1.runBackgroundOperations();
DocumentNodeStore ds2 = builderProvider.newBuilder().setAsyncDelay(0).setDocumentStore(store).setClusterId(2).setBlobStore(blobStore).getNodeStore();
String repoId2 = ClusterRepositoryInfo.getOrCreateId(ds2);
// Since the same cluster the ids should be equal
Assert.assertEquals(repoId1, repoId2);
}
use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class DocumentMongoFixture method createNodeStore.
@Override
public NodeStore createNodeStore() {
try {
String suffix = String.format("-%d-%d", System.currentTimeMillis(), sequence.incrementAndGet());
DocumentMK.Builder builder = new DocumentMK.Builder();
if (blobStore != null) {
builder.setBlobStore(blobStore);
}
builder.setPersistentCache("target/persistentCache,time");
builder.setMongoDB(getDb(suffix));
DocumentNodeStore ns = builder.getNodeStore();
suffixes.put(ns, suffix);
return ns;
} catch (Exception e) {
throw new AssumptionViolatedException("Mongo instance is not available", e);
}
}
use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class DocumentMongoFixture method dispose.
@Override
public void dispose(NodeStore nodeStore) {
if (nodeStore instanceof DocumentNodeStore) {
((DocumentNodeStore) nodeStore).dispose();
}
if (nodeStore == null) {
return;
}
String suffix = suffixes.remove(nodeStore);
if (suffix != null) {
try {
DB db = getDb(suffix);
db.dropDatabase();
db.getMongo().close();
} catch (Exception e) {
log.error("Can't close Mongo", e);
}
}
}
use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class JournalIT method simpleCacheInvalidationTest.
@Test
public void simpleCacheInvalidationTest() throws Exception {
final DocumentNodeStore ns1 = createMK(1, 0).getNodeStore();
final DocumentNodeStore ns2 = createMK(2, 0).getNodeStore();
// invalidate cache under test first
ns1.getDocumentStore().invalidateCache();
// first create child node in instance 1
getOrCreate(ns1, "/child", true);
assertDocCache(ns1, true, "/child");
{
// modify /child in another instance 2
// read latest changes from ns1
ns2.runBackgroundOperations();
setProperty(ns2, "/child", "p", "ns2" + System.currentTimeMillis(), true);
}
// that should not have changed the fact that we have it cached in 'ns'
assertDocCache(ns1, true, "/child");
// doing a backgroundOp now should trigger invalidation
// which thx to the external modification will remove the entry from the cache:
ns1.runBackgroundOperations();
assertDocCache(ns1, false, "/child");
// when I access it again with 'ns', then it gets cached again:
getOrCreate(ns1, "/child", false);
assertDocCache(ns1, true, "/child");
}
Aggregations