Search in sources :

Example 71 with NodeStore

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

the class AbstractOak2OakTest method initContent.

protected void initContent(NodeStore target) throws IOException, RepositoryException, CommitFailedException {
    NodeStore initialContent = testContent.open();
    try {
        RepositorySidegrade sidegrade = new RepositorySidegrade(initialContent, target);
        sidegrade.copy();
    } finally {
        testContent.close();
    }
    NodeBuilder builder = target.getRoot().builder();
    builder.setProperty("binary-prop", getRandomBlob(target));
    builder.setProperty("checkpoint-state", "before");
    target.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    target.checkpoint(60000, singletonMap("key", "123"));
    builder.setProperty("checkpoint-state", "after");
    builder.setProperty("binary-prop", getRandomBlob(target));
    builder.child(":async").setProperty("test", "123");
    target.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) RepositorySidegrade(org.apache.jackrabbit.oak.upgrade.RepositorySidegrade) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder)

Example 72 with NodeStore

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

the class LuceneBlobCacheTest method setUp.

@Before
public void setUp() throws Exception {
    fileDataStore = new ReadAccessCountingDataStore();
    fileDataStore.init(tempFolder.newFolder().getAbsolutePath());
    FileStoreBuilder fileStoreBuilder = FileStoreBuilder.fileStoreBuilder(tempFolder.newFolder()).withBlobStore(new DataStoreBlobStore(fileDataStore)).withMaxFileSize(256).withSegmentCacheSize(64).withMemoryMapping(false);
    store = fileStoreBuilder.build();
    NodeStore nodeStore = SegmentNodeStoreBuilders.builder(store).build();
    root = nodeStore.getRoot();
    builder = root.builder();
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) Before(org.junit.Before)

Example 73 with NodeStore

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

the class BrokenNetworkIT method useProxy.

private void useProxy(boolean ssl, int skipPosition, int skipBytes, int flipPosition, boolean intermediateChange) throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore1.fileStore();
    FileStore storeC2 = clientFileStore2.fileStore();
    NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
    addTestContent(store, "server");
    // this speeds up the test a little bit...
    storeS.flush();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, ssl);
        StandbyClientSync clientSync = newStandbyClientSync(storeC, proxyPort.getPort(), ssl)) {
        proxy.skipBytes(skipPosition, skipBytes);
        proxy.flipByte(flipPosition);
        proxy.connect();
        serverSync.start();
        clientSync.run();
        if (skipBytes > 0 || flipPosition >= 0) {
            assertFalse("stores are not expected to be equal", storeS.getHead().equals(storeC.getHead()));
            assertEquals(storeC2.getHead(), storeC.getHead());
            proxy.reset();
            if (intermediateChange) {
                addTestContent(store, "server2");
                storeS.flush();
            }
            clientSync.run();
        }
        assertEquals(storeS.getHead(), storeC.getHead());
    }
}
Also used : TemporaryFileStore(org.apache.jackrabbit.oak.segment.test.TemporaryFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) StandbyServerSync(org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync) StandbyClientSync(org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync)

Example 74 with NodeStore

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

the class DataStoreTestBase method testSyncUpdatedBinaryProperty.

/*
     * See OAK-4969.
     */
@Test
public void testSyncUpdatedBinaryProperty() throws Exception {
    final int blobSize = 5 * MB;
    FileStore primary = getPrimary();
    FileStore secondary = getSecondary();
    NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary);
        StandbyClientSync clientSync = newStandbyClientSync(secondary, serverPort.getPort())) {
        serverSync.start();
        addTestContent(store, "server", blobSize);
        primary.flush();
        clientSync.run();
        assertEquals(primary.getHead(), secondary.getHead());
        addTestContent(store, "server", blobSize);
        primary.flush();
        clientSync.run();
        assertEquals(primary.getHead(), secondary.getHead());
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) StandbyServerSync(org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync) StandbyClientSync(org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync) Test(org.junit.Test)

Example 75 with NodeStore

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

the class DataStoreTestBase method useProxy.

private void useProxy(int skipPosition, int skipBytes, int flipPosition, boolean intermediateChange) throws Exception {
    int blobSize = 5 * MB;
    FileStore primary = getPrimary();
    FileStore secondary = getSecondary();
    NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
    byte[] data = addTestContent(store, "server", blobSize);
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary);
        StandbyClientSync clientSync = newStandbyClientSync(secondary, proxyPort.getPort())) {
        proxy.skipBytes(skipPosition, skipBytes);
        proxy.flipByte(flipPosition);
        proxy.connect();
        serverSync.start();
        primary.flush();
        clientSync.run();
        if (skipBytes > 0 || flipPosition >= 0) {
            if (!storesShouldBeEqual()) {
                assertFalse("stores are not expected to be equal", primary.getHead().equals(secondary.getHead()));
            }
            proxy.reset();
            if (intermediateChange) {
                blobSize = 2 * MB;
                data = addTestContent(store, "server", blobSize);
                primary.flush();
            }
            clientSync.run();
        }
        assertEquals(primary.getHead(), secondary.getHead());
    }
    assertTrue(primary.getStats().getApproximateSize() < MB);
    assertTrue(secondary.getStats().getApproximateSize() < MB);
    PropertyState ps = secondary.getHead().getChildNode("root").getChildNode("server").getProperty("testBlob");
    assertNotNull(ps);
    assertEquals(Type.BINARY.tag(), ps.getType().tag());
    Blob b = ps.getValue(Type.BINARY);
    assertEquals(blobSize, b.length());
    byte[] testData = new byte[blobSize];
    ByteStreams.readFully(b.getNewStream(), testData);
    assertArrayEquals(data, testData);
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) Blob(org.apache.jackrabbit.oak.api.Blob) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) StandbyServerSync(org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync) StandbyClientSync(org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

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