Search in sources :

Example 41 with NodeStore

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

the class ConsolidatedDataStoreStatsTest method binaryNotSyncedAndBinariesSynced.

@Test
public void binaryNotSyncedAndBinariesSynced() 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));
    assertSyncedFalse(stats, dataStore, 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) Test(org.junit.Test)

Example 42 with NodeStore

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

the class ConsolidatedDataStoreStatsTest method binariesPropertyNotAllSynced.

@Test
public void binariesPropertyNotAllSynced() throws Exception {
    Blob mockBlob2 = mock(Blob.class);
    final String id2 = getIdForInputStream(getStream("testContents2"));
    when(mockBlob2.getContentIdentity()).thenReturn(id2);
    List<Blob> blobPropList = Lists.newArrayList(mockBlob, mockBlob2);
    NodeStore nodeStore = initNodeStore(Optional.<Blob>absent(), Optional.<Blob>absent(), Optional.<String>absent(), Optional.<Integer>absent(), Optional.of(blobPropList));
    assertSyncedFalse(stats, dataStore, 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 43 with NodeStore

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

the class ConsolidatedDataStoreStatsTest method binaryAndBinariesSynced.

@Test
public void binaryAndBinariesSynced() 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(mockBlob3.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));
    assertSyncedFalse(stats, dataStore, 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 44 with NodeStore

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

the class ConsolidatedDataStoreStatsTest method multiplePropertiesAndBinarySynced.

@Test
public void multiplePropertiesAndBinarySynced() throws Exception {
    NodeStore nodeStore = initNodeStore(Optional.of(mockBlob), Optional.<Blob>absent(), Optional.of("abc"), Optional.of(123), Optional.<List<Blob>>absent());
    assertSyncedTrue(stats, dataStore, 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) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 45 with NodeStore

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

the class ManyChildNodesTest method manyChildNodes.

@Test
public void manyChildNodes() throws Exception {
    TestStore store = new TestStore();
    DocumentMK mk = new DocumentMK.Builder().setDocumentStore(store).open();
    NodeStore ns = mk.getNodeStore();
    NodeBuilder builder = ns.getRoot().builder();
    for (int i = 0; i < DocumentNodeState.MAX_FETCH_SIZE * 2; i++) {
        builder.child("c-" + i);
    }
    ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    store.queries.clear();
    // must fetch in batches
    for (ChildNodeEntry entry : ns.getRoot().getChildNodeEntries()) {
        entry.getName();
    }
    // maximum fetch size is MAX_FETCH_SIZE plus one because
    // DocumentNodeStore will use this value to find out if there
    // are more child nodes than requested
    int maxFetchSize = DocumentNodeState.MAX_FETCH_SIZE + 1;
    for (Map.Entry<String, Integer> e : store.queries.entrySet()) {
        assertTrue(e.getValue() + " > " + maxFetchSize, e.getValue() <= maxFetchSize);
    }
    mk.dispose();
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Map(java.util.Map) 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