use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class MongoFactory method create.
@Override
public NodeStore create(BlobStore blobStore, Closer closer) throws IOException {
System.setProperty(DocumentNodeStore.SYS_PROP_DISABLE_JOURNAL, "true");
DocumentMK.Builder builder = getBuilder(cacheSize);
builder.setMongoDB(getDB(closer));
if (blobStore != null) {
builder.setBlobStore(blobStore);
}
if (readOnly) {
builder.setReadOnlyMode();
}
DocumentNodeStore documentNodeStore = builder.getNodeStore();
// TODO probably we should disable all observers, see OAK-5651
documentNodeStore.getBundlingConfigHandler().unregisterObserver();
closer.register(asCloseable(documentNodeStore));
return documentNodeStore;
}
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);
}
}
}
Aggregations