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");
}
use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class AsyncIndexUpdateClusterTestIT method create.
private DocumentNodeStore create(int clusterId) {
DocumentMK.Builder builder = new DocumentMK.Builder();
if (ds == null) {
ds = new MemoryDocumentStore();
}
if (bs == null) {
bs = new MemoryBlobStore();
}
builder.setDocumentStore(ds).setBlobStore(bs);
DocumentNodeStore store = builder.setClusterId(++clusterId).setLeaseCheck(false).open().getNodeStore();
return store;
}
use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class NonLocalObservationIT method getFixture.
@Override
protected NodeStoreFixture getFixture() {
/**
* Fixes the cluster use case plus allowing to control the cache sizes.
* In theory other users of DocumentMongoFixture might have similar
* test cases - but keeping it simple for now - thus going via subclass.
*/
return new DocumentMongoFixture() {
private String clusterSuffix = System.currentTimeMillis() + "-NonLocalObservationIT";
private DB db;
/** keep a reference to the node stores so that the db only gets closed after the last nodeStore was closed */
private Set<NodeStore> nodeStores = new HashSet<NodeStore>();
/**
* This is not implemented in the super class at all.
* <ul>
* <li>use a specific suffix to make sure we have our own, new db and clean it up after the test</li>
* <li>properly drop that db created above in dispose</li>
* <li>use only 32MB (vs default of 256MB) memory to ensure we're not going OOM just because of this (which happens with the default)</li>
* <li>disable the persistent cache for the same reason</li>
* </ul>
*/
@Override
public NodeStore createNodeStore(int clusterNodeId) {
try {
DocumentMK.Builder builder = new DocumentMK.Builder();
// keep this one low to avoid OOME
builder.memoryCacheSize(32 * 1024 * 1024);
// turn this one off to avoid OOME
builder.setPersistentCache(null);
final String suffix = clusterSuffix;
// db will be overwritten - but that's fine
db = getDb(suffix);
builder.setMongoDB(db);
DocumentNodeStore ns = builder.getNodeStore();
nodeStores.add(ns);
return ns;
} catch (Exception e) {
throw new AssumptionViolatedException("Mongo instance is not available", e);
}
}
@Override
public void dispose(NodeStore nodeStore) {
super.dispose(nodeStore);
nodeStores.remove(nodeStore);
if (db != null && nodeStores.size() == 0) {
try {
db.dropDatabase();
db.getMongo().close();
db = null;
} catch (Exception e) {
log.error("dispose: Can't close Mongo", e);
}
}
}
@Override
public String toString() {
return "NonLocalObservationIT's DocumentMongoFixture flavour";
}
};
}
use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class AtomicCounterIT method setup.
@Before
public void setup() throws Exception {
DocumentNodeStore ns = builderProvider.newBuilder().getNodeStore();
NodeBuilder builder = ns.getRoot().builder();
NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
NodeBuilder lucene = newLuceneIndexDefinition(index, "lucene", ImmutableSet.of("String"), null, "async");
lucene.setProperty("async", of("async", "nrt"), STRINGS);
IndexDefinition.updateDefinition(index.child("lucene"));
ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider();
editorProvider.setIndexingQueue(mock(DocumentQueue.class));
LuceneIndexProvider provider = new LuceneIndexProvider();
ContentRepository repository = new Oak(ns).with(// Clusterable
ns).with(new OpenSecurityProvider()).with((QueryIndexProvider) provider).with((Observer) provider).with(editorProvider).with(executorService).withAtomicCounter().withAsyncIndexing("async", 1).withFailOnMissingIndexProvider().createContentRepository();
session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()), null);
while (isReindexing(session)) {
Thread.sleep(100);
}
}
use of org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore in project jackrabbit-oak by apache.
the class SameNodeSiblingsTest method snsNewNameAlreadyExists.
@Test
public void snsNewNameAlreadyExists() 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("child_2_", "nt:folder");
parent.addNode("child_3_", "nt:folder");
parent.addNode("child_3_2", "nt:folder");
session.save();
parent.setPrimaryType("nt:folder");
session.save();
}
});
try {
NodeState parent = nodeStore.getRoot().getChildNode("parent");
Set<String> children = newHashSet(parent.getChildNodeNames());
assertEquals(of("child", "child_2_", "child_3_", "child_2_2", "child_3_2", "child_3_3"), children);
} finally {
nodeStore.dispose();
}
}
Aggregations