use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class SameNodeSiblingsTest method snsShouldntBeRenamed.
@Test
public void snsShouldntBeRenamed() throws RepositoryException, IOException {
DocumentNodeStore nodeStore = migrate(new SourceDataCreator() {
@Override
public void create(Session session) throws RepositoryException {
Node parent = session.getRootNode().addNode("parent");
parent.addNode("child", "nt:folder");
parent.addNode("child", "nt:folder");
parent.addNode("child", "nt:folder");
parent.addNode("something_else", "nt:folder");
session.save();
}
});
try {
NodeState parent = nodeStore.getRoot().getChildNode("parent");
Set<String> children = newHashSet(parent.getChildNodeNames());
assertEquals(of("child", "child[2]", "child[3]", "something_else"), children);
} finally {
nodeStore.dispose();
}
}
use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class SameNodeSiblingsTest method snsShouldBeRenamed.
@Test
public void snsShouldBeRenamed() throws RepositoryException, IOException {
DocumentNodeStore nodeStore = migrate(new SourceDataCreator() {
@Override
public void create(Session session) throws RepositoryException {
Node parent = session.getRootNode().addNode("parent");
parent.addNode("child", "nt:folder");
parent.addNode("child", "nt:folder");
parent.addNode("child", "nt:folder");
parent.addNode("something_else", "nt:folder");
session.save();
// change parent type to
parent.setPrimaryType("nt:folder");
// something that doesn't
// allow SNS
session.save();
}
});
try {
NodeState parent = nodeStore.getRoot().getChildNode("parent");
Set<String> children = newHashSet(parent.getChildNodeNames());
assertEquals(of("child", "child_2_", "child_3_", "something_else"), children);
} finally {
nodeStore.dispose();
}
}
use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class ReadOnlyDocumentStoreWrapperTest method backgroundRead.
@Test
public void backgroundRead() throws Exception {
DocumentStore docStore = new MemoryDocumentStore();
DocumentNodeStore store = builderProvider.newBuilder().setAsyncDelay(0).setDocumentStore(docStore).setClusterId(2).getNodeStore();
DocumentNodeStore readOnlyStore = builderProvider.newBuilder().setAsyncDelay(0).setDocumentStore(docStore).setClusterId(1).setReadOnlyMode().getNodeStore();
NodeBuilder builder = store.getRoot().builder();
builder.child("node");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
store.runBackgroundOperations();
// at this point node must not be visible
assertFalse(readOnlyStore.getRoot().hasChildNode("node"));
readOnlyStore.runBackgroundOperations();
// at this point node should get visible
assertTrue(readOnlyStore.getRoot().hasChildNode("node"));
}
use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class UtilsTest method getAllDocuments.
@Test
public void getAllDocuments() throws CommitFailedException {
DocumentNodeStore store = new DocumentMK.Builder().getNodeStore();
try {
NodeBuilder builder = store.getRoot().builder();
for (int i = 0; i < 1000; i++) {
builder.child("test-" + i);
}
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
assertEquals(1001, /* root + 1000 children */
Iterables.size(Utils.getAllDocuments(store.getDocumentStore())));
} finally {
store.dispose();
}
}
use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class JdbcFactory method create.
@Override
public NodeStore create(BlobStore blobStore, Closer closer) throws IOException {
System.setProperty(DocumentNodeStore.SYS_PROP_DISABLE_JOURNAL, "true");
DocumentMK.Builder builder = MongoFactory.getBuilder(cacheSize);
if (blobStore != null) {
builder.setBlobStore(blobStore);
}
builder.setRDBConnection(getDataSource(closer));
if (readOnly) {
builder.setReadOnlyMode();
}
log.info("Initialized DocumentNodeStore on RDB with Cache size : {} MB, Fast migration : {}", cacheSize, builder.isDisableBranches());
DocumentNodeStore documentNodeStore = builder.getNodeStore();
// TODO probably we should disable all observers, see OAK-5651
documentNodeStore.getBundlingConfigHandler().unregisterObserver();
closer.register(MongoFactory.asCloseable(documentNodeStore));
return documentNodeStore;
}
Aggregations