Search in sources :

Example 6 with NodeStore

use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.

the class S3DataStoreStatsTest method testIsFileSyncedBinarySyncedAndBinariesNotSyncedReturnsFalse.

@Test
public void testIsFileSyncedBinarySyncedAndBinariesNotSyncedReturnsFalse() throws Exception {
    Blob mockBlob2 = mock(Blob.class);
    final String id2 = getIdForInputStream(getStream("testContents2"));
    when(mockBlob2.getContentIdentity()).thenReturn(id2);
    Blob mockBlob3 = mock(Blob.class);
    final String id3 = getIdForInputStream(getStream("testContents3"));
    when(mockBlob2.getContentIdentity()).thenReturn(id3);
    List<Blob> blobPropList = Lists.newArrayList(mockBlob2, mockBlob3);
    NodeStore nodeStore = initNodeStore(Optional.of(mockBlob), Optional.<Blob>absent(), Optional.<String>absent(), Optional.<Integer>absent(), Optional.of(blobPropList));
    stats = new S3DataStoreStats();
    stats.nodeStore = nodeStore;
    stats.s3ds = autoSyncMockS3ds;
    assertSyncedFalse(stats, autoSyncMockS3ds, new FileInputStream(testFile), getStream("testContents2"));
}
Also used : Blob(org.apache.jackrabbit.oak.api.Blob) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) Hex.encodeHexString(org.apache.commons.codec.binary.Hex.encodeHexString) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 7 with NodeStore

use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.

the class S3DataStoreStatsTest method testIsFileSyncedBinaryAndBinariesSyncedReturnsTrue.

@Test
public void testIsFileSyncedBinaryAndBinariesSyncedReturnsTrue() throws Exception {
    Blob mockBlob2 = mock(Blob.class);
    final String id2 = getIdForInputStream(getStream("testContents2"));
    when(mockBlob2.getContentIdentity()).thenReturn(id2);
    Blob mockBlob3 = mock(Blob.class);
    final String id3 = getIdForInputStream(getStream("testContents3"));
    when(mockBlob2.getContentIdentity()).thenReturn(id3);
    List<Blob> blobPropList = Lists.newArrayList(mockBlob2, mockBlob3);
    NodeStore nodeStore = initNodeStore(Optional.of(mockBlob), Optional.<Blob>absent(), Optional.<String>absent(), Optional.<Integer>absent(), Optional.of(blobPropList));
    stats = new S3DataStoreStats();
    stats.nodeStore = nodeStore;
    stats.s3ds = autoSyncMockS3ds;
    assertSyncedFalse(stats, autoSyncMockS3ds, new FileInputStream(testFile), getStream("testContents2"), getStream("testContents3"));
}
Also used : Blob(org.apache.jackrabbit.oak.api.Blob) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) Hex.encodeHexString(org.apache.commons.codec.binary.Hex.encodeHexString) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 8 with NodeStore

use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.

the class S3DataStoreStatsTest method testIsFileSyncedMultipleBinaryPropertiesNotAllSyncedReturnsFalse.

@Test
public void testIsFileSyncedMultipleBinaryPropertiesNotAllSyncedReturnsFalse() throws Exception {
    Blob mockBlob2 = mock(Blob.class);
    final String id2 = getIdForInputStream(getStream("testContents2"));
    when(mockBlob2.getContentIdentity()).thenReturn(id2);
    NodeStore nodeStore = initNodeStore(Optional.of(mockBlob), Optional.of(mockBlob2), Optional.<String>absent(), Optional.<Integer>absent(), Optional.<List<Blob>>absent());
    stats = new S3DataStoreStats();
    stats.nodeStore = nodeStore;
    stats.s3ds = autoSyncMockS3ds;
    assertSyncedFalse(stats, autoSyncMockS3ds, new FileInputStream(testFile));
}
Also used : Blob(org.apache.jackrabbit.oak.api.Blob) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) Hex.encodeHexString(org.apache.commons.codec.binary.Hex.encodeHexString) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 9 with NodeStore

use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.

the class AsyncIndexUpdateTest method testAsyncDoubleSubtree.

/**
     * Async Index Test with 2 index defs at different tree locations
     * <ul>
     * <li>Add an index definition</li>
     * <li>Add some content</li>
     * <li>Search & verify</li>
     * </ul>
     * 
     */
@Test
public void testAsyncDoubleSubtree() throws Exception {
    NodeStore store = new MemoryNodeStore();
    IndexEditorProvider provider = new PropertyIndexEditorProvider();
    NodeBuilder builder = store.getRoot().builder();
    createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
    createIndexDefinition(builder.child("newchild").child("other").child(INDEX_DEFINITIONS_NAME), "subIndex", true, false, ImmutableSet.of("foo"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
    builder.child("testRoot").setProperty("foo", "abc");
    builder.child("newchild").child("other").child("testChild").setProperty("foo", "xyz");
    // merge it back in
    store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider);
    async.run();
    NodeState root = store.getRoot();
    // first check that the index content nodes exist
    checkPathExists(root, INDEX_DEFINITIONS_NAME, "rootIndex", INDEX_CONTENT_NODE_NAME);
    checkPathExists(root, "newchild", "other", INDEX_DEFINITIONS_NAME, "subIndex", INDEX_CONTENT_NODE_NAME);
    PropertyIndexLookup lookup = new PropertyIndexLookup(root);
    assertEquals(ImmutableSet.of("testRoot"), find(lookup, "foo", "abc"));
    PropertyIndexLookup lookupChild = new PropertyIndexLookup(root.getChildNode("newchild").getChildNode("other"));
    assertEquals(ImmutableSet.of("testChild"), find(lookupChild, "foo", "xyz"));
    assertEquals(ImmutableSet.<String>of(), find(lookupChild, "foo", "abc"));
}
Also used : ProxyNodeStore(org.apache.jackrabbit.oak.spi.state.ProxyNodeStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) PropertyIndexLookup(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexLookup) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 10 with NodeStore

use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.

the class AsyncIndexUpdateTest method testAsyncDouble.

/**
     * Async Index Test with 2 index defs at the same location
     * <ul>
     * <li>Add an index definition</li>
     * <li>Add some content</li>
     * <li>Search & verify</li>
     * </ul>
     * 
     */
@Test
public void testAsyncDouble() throws Exception {
    NodeStore store = new MemoryNodeStore();
    IndexEditorProvider provider = new PropertyIndexEditorProvider();
    NodeBuilder builder = store.getRoot().builder();
    createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
    createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndexSecond", true, false, ImmutableSet.of("bar"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
    builder.child("testRoot").setProperty("foo", "abc").setProperty("bar", "def");
    builder.child("testSecond").setProperty("bar", "ghi");
    // merge it back in
    store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider);
    async.run();
    NodeState root = store.getRoot();
    // first check that the index content nodes exist
    checkPathExists(root, INDEX_DEFINITIONS_NAME, "rootIndex", INDEX_CONTENT_NODE_NAME);
    checkPathExists(root, INDEX_DEFINITIONS_NAME, "rootIndexSecond", INDEX_CONTENT_NODE_NAME);
    PropertyIndexLookup lookup = new PropertyIndexLookup(root);
    assertEquals(ImmutableSet.of("testRoot"), find(lookup, "foo", "abc"));
    assertEquals(ImmutableSet.<String>of(), find(lookup, "foo", "def"));
    assertEquals(ImmutableSet.<String>of(), find(lookup, "foo", "ghi"));
    assertEquals(ImmutableSet.<String>of(), find(lookup, "bar", "abc"));
    assertEquals(ImmutableSet.of("testRoot"), find(lookup, "bar", "def"));
    assertEquals(ImmutableSet.of("testSecond"), find(lookup, "bar", "ghi"));
}
Also used : ProxyNodeStore(org.apache.jackrabbit.oak.spi.state.ProxyNodeStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) PropertyIndexLookup(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexLookup) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Aggregations

NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)141 Test (org.junit.Test)81 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)58 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)52 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)29 Blob (org.apache.jackrabbit.oak.api.Blob)24 Before (org.junit.Before)18 FileInputStream (java.io.FileInputStream)16 Hex.encodeHexString (org.apache.commons.codec.binary.Hex.encodeHexString)16 File (java.io.File)14 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)14 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)14 ProxyNodeStore (org.apache.jackrabbit.oak.spi.state.ProxyNodeStore)13 Oak (org.apache.jackrabbit.oak.Oak)10 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)10 StandbyClientSync (org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync)10 StandbyServerSync (org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync)10 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)9 MemoryStore (org.apache.jackrabbit.oak.segment.memory.MemoryStore)9 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)9