use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class HybridIndexTest method createRepository.
@Override
protected ContentRepository createRepository() {
IndexCopier copier;
try {
copier = new IndexCopier(executorService, temporaryFolder.getRoot());
} catch (IOException e) {
throw new RuntimeException(e);
}
MountInfoProvider mip = defaultMountInfoProvider();
NRTIndexFactory nrtIndexFactory = new NRTIndexFactory(copier, clock, TimeUnit.MILLISECONDS.toSeconds(refreshDelta), StatisticsProvider.NOOP);
LuceneIndexReaderFactory indexReaderFactory = new DefaultIndexReaderFactory(mip, copier);
IndexTracker tracker = new IndexTracker(indexReaderFactory, nrtIndexFactory);
LuceneIndexProvider provider = new LuceneIndexProvider(tracker);
queue = new DocumentQueue(100, tracker, sameThreadExecutor());
LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider(copier, tracker, null, null, mip);
editorProvider.setIndexingQueue(queue);
LocalIndexObserver localIndexObserver = new LocalIndexObserver(queue, StatisticsProvider.NOOP);
nodeStore = new MemoryNodeStore();
Oak oak = new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with((QueryIndexProvider) provider).with((Observer) provider).with(localIndexObserver).with(editorProvider).with(new PropertyIndexEditorProvider()).with(new NodeTypeIndexProvider()).with(optionalEditorProvider).with(new NodeCounterEditorProvider()).withAsyncIndexing("async", TimeUnit.DAYS.toSeconds(1));
wb = oak.getWhiteboard();
return oak.createContentRepository();
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class CompositeChildrenCountTest method contributingStoreReturnsInfinity.
@Test
public void contributingStoreReturnsInfinity() {
MountInfoProvider mip = Mounts.newBuilder().mount("libs", "/libs", "/libs1", "/libs2", "/libs3", "/libs4").build();
NodeStore globalStore = new MemoryNodeStore();
NodeStore libsStore = new MemoryNodeStore();
List<MountedNodeStore> mounts = Lists.newArrayList();
mounts.add(new MountedNodeStore(mip.getMountByName("libs"), libsStore));
CompositeNodeStore compositeNodeStore = new CompositeNodeStore(mip, globalStore, mounts);
CompositeNodeStoreBuilder b = new CompositeNodeStoreBuilder(compositeNodeStore.ctx);
TestingNodeState globalTestingNS = b.configureMount("/", 5);
TestingNodeState libsTestingNS = b.configureMount("/libs", MAX_VALUE);
CompositeNodeState mns = b.getNodeState();
assertEquals(MAX_VALUE, mns.getChildNodeCount(100));
assertEquals(5, globalTestingNS.fetchedChildren);
assertEquals(0, libsTestingNS.fetchedChildren);
globalTestingNS.fetchedChildren = 0;
libsTestingNS.fetchedChildren = 0;
assertEquals(MAX_VALUE, mns.builder().getChildNodeCount(100));
assertEquals(5, globalTestingNS.fetchedChildren);
assertEquals(0, libsTestingNS.fetchedChildren);
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class CompositeChildrenCountTest method singleContributingStore.
@Test
public void singleContributingStore() {
MountInfoProvider mip = Mounts.newBuilder().build();
NodeStore globalStore = new MemoryNodeStore();
CompositeNodeStore compositeNodeStore = new CompositeNodeStore.Builder(mip, globalStore).build();
CompositeNodeStoreBuilder b = new CompositeNodeStoreBuilder(compositeNodeStore.ctx);
b.configureMount("/", MAX_VALUE);
assertEquals(MAX_VALUE, b.getNodeState().getChildNodeCount(123));
b.clear().configureMount("/", 10);
assertEquals(10, b.getNodeState().getChildNodeCount(200));
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class CompositeCompareTest method nodesOutsideTheMountsAreIgnored.
@Test
public void nodesOutsideTheMountsAreIgnored() throws CommitFailedException {
MountInfoProvider mip = Mounts.newBuilder().mount("libs", "/libs").build();
NodeStore globalStore = new MemoryNodeStore();
NodeStore libsStore = new MemoryNodeStore();
List<MountedNodeStore> mounts = Lists.newArrayList();
mounts.add(new MountedNodeStore(mip.getMountByName("libs"), libsStore));
CompositeNodeStore compositeNodeStore = new CompositeNodeStore(mip, globalStore, mounts);
NodeState empty = compositeNodeStore.getRoot();
NodeBuilder builder = globalStore.getRoot().builder();
builder.child("global-child-1");
builder.child("global-child-2");
globalStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
NodeBuilder libsBuilder = libsStore.getRoot().builder();
libsBuilder.child("libs");
libsBuilder.child("libs-child-1");
libsBuilder.child("libs-child-2");
libsStore.merge(libsBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
NodeState modified = compositeNodeStore.getRoot();
final Set<String> addedChildren = newHashSet();
modified.compareAgainstBaseState(empty, new DefaultNodeStateDiff() {
@Override
public boolean childNodeAdded(String name, NodeState after) {
addedChildren.add(name);
return true;
}
});
assertEquals(ImmutableSet.of("global-child-1", "global-child-2", "libs"), addedChildren);
}
use of org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore in project jackrabbit-oak by apache.
the class S3DataStoreStatsTest method testIsFileSyncedDifferentPaths.
@Test
public void testIsFileSyncedDifferentPaths() throws Exception {
final String path1 = "path/to/node/1";
final String path2 = "path/to/node/2";
final String path3 = "shortpath";
final String path4 = "a/very/very/long/path/leads/to/node/4";
final List<String> paths = Lists.newArrayList(path1, path2, path3, path4);
final String leadingSlashPath = "/" + path1;
final List<String> blobContents = Lists.newArrayList("1", "2", "3", "4");
final List<Blob> blobs = Lists.newArrayList(mock(Blob.class), mock(Blob.class), mock(Blob.class), mock(Blob.class));
final List<String> blobIds = Lists.newArrayList(getIdForInputStream(getStream(blobContents.get(0))), getIdForInputStream(getStream(blobContents.get(1))), getIdForInputStream(getStream(blobContents.get(2))), getIdForInputStream(getStream(blobContents.get(3))));
when(blobs.get(0).getContentIdentity()).thenReturn(blobIds.get(0));
when(blobs.get(1).getContentIdentity()).thenReturn(blobIds.get(1));
when(blobs.get(2).getContentIdentity()).thenReturn(blobIds.get(2));
when(blobs.get(3).getContentIdentity()).thenReturn(blobIds.get(3));
final NodeStore nodeStore = new MemoryNodeStore();
final NodeBuilder rootBuilder = nodeStore.getRoot().builder();
final List<NodeBuilder> builders = Lists.newArrayList();
for (final String path : paths) {
NodeBuilder builder = rootBuilder;
for (final String nodeName : PathUtils.elements(path)) {
builder = builder.child(nodeName);
}
builders.add(builder);
}
builders.get(0).setProperty("blob1", blobs.get(0));
builders.get(1).setProperty("blob2", blobs.get(1));
builders.get(2).setProperty("blob3", blobs.get(2));
builders.get(3).setProperty("blob4", blobs.get(3));
nodeStore.merge(rootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
stats = new S3DataStoreStats();
stats.nodeStore = nodeStore;
stats.s3ds = autoSyncMockS3ds;
final List<DataRecord> records = Lists.newArrayList();
try {
for (final String s : blobContents) {
records.add(autoSyncMockS3ds.addRecord(getStream(s)));
}
for (final String path : Lists.newArrayList(path1, path2, path3, path4, leadingSlashPath)) {
assertTrue(stats.isFileSynced(path));
}
for (final String invalidPath : Lists.newArrayList(path1 + "/", "/" + path1 + "/", "/path//to/node///1")) {
try {
stats.isFileSynced(invalidPath);
// shouldn't get here on an invalid path
assertFalse(false);
} catch (AssertionError e) {
// expected
}
}
} finally {
delete(autoSyncMockS3ds, records);
}
}
Aggregations