Search in sources :

Example 91 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.

the class DataStoreTestBase method testSyncBigBlob.

/*
     * See OAK-5902.
     */
@Test
public void testSyncBigBlob() throws Exception {
    final long blobSize = GB;
    final int seed = 13;
    FileStore primary = getPrimary();
    FileStore secondary = getSecondary();
    NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
    addTestContentOnTheFly(store, "server", blobSize, seed);
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary, 8 * MB);
        StandbyClientSync cl = new StandbyClientSync(getServerHost(), serverPort.getPort(), secondary, false, 2 * 60 * 1000, false, folder.newFolder())) {
        serverSync.start();
        primary.flush();
        cl.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());
    try (InputStream randomInputStream = newRandomInputStream(blobSize, seed);
        InputStream blobInputStream = b.getNewStream()) {
        assertTrue(IOUtils.contentEquals(randomInputStream, blobInputStream));
    }
}
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) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) StandbyClientSync(org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 92 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore 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, MB);
        StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), secondary, false, getClientTimeout(), false, folder.newFolder())) {
        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 93 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.

the class FailoverMultipleClientsTestIT method testMultipleClients.

@Test
public void testMultipleClients() throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore1.fileStore();
    FileStore storeC2 = clientFileStore2.fileStore();
    NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, MB);
        StandbyClientSync cl1 = new StandbyClientSync(getServerHost(), serverPort.getPort(), storeC, false, getClientTimeout(), false, folder.newFolder());
        StandbyClientSync cl2 = new StandbyClientSync(getServerHost(), serverPort.getPort(), storeC2, false, getClientTimeout(), false, folder.newFolder())) {
        serverSync.start();
        SegmentTestUtils.addTestContent(store, "server");
        // this speeds up the test a little bit...
        storeS.flush();
        assertFalse("first client has invalid initial store!", storeS.getHead().equals(storeC.getHead()));
        assertFalse("second client has invalid initial store!", storeS.getHead().equals(storeC2.getHead()));
        assertEquals(storeC.getHead(), storeC2.getHead());
        cl1.run();
        cl2.run();
        assertEquals(storeS.getHead(), storeC.getHead());
        assertEquals(storeS.getHead(), storeC2.getHead());
        cl1.stop();
        SegmentTestUtils.addTestContent(store, "test");
        storeS.flush();
        cl1.run();
        cl2.run();
        assertEquals(storeS.getHead(), storeC2.getHead());
        assertFalse("first client updated in stopped state!", storeS.getHead().equals(storeC.getHead()));
        cl1.start();
        cl1.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) Test(org.junit.Test)

Example 94 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.

the class StandbyTestIT method testSyncLoop.

/**
 * OAK-2430
 */
@Test
public void testSyncLoop() throws Exception {
    final int blobSize = 25 * 1024;
    final int dataNodes = 5000;
    FileStore primary = serverFileStore.fileStore();
    FileStore secondary = clientFileStore.fileStore();
    NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary, MB);
        StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), secondary, false, getClientTimeout(), false, folder.newFolder())) {
        serverSync.start();
        byte[] data = addTestContent(store, "server", blobSize, dataNodes);
        primary.flush();
        for (int i = 0; i < 5; i++) {
            String cp = store.checkpoint(Long.MAX_VALUE);
            primary.flush();
            clientSync.run();
            assertEquals(primary.getHead(), secondary.getHead());
            assertTrue(store.release(cp));
            clientSync.cleanup();
            assertTrue(secondary.getStats().getApproximateSize() > blobSize);
        }
        assertTrue(primary.getStats().getApproximateSize() > blobSize);
        assertTrue(secondary.getStats().getApproximateSize() > blobSize);
        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 : TemporaryFileStore(org.apache.jackrabbit.oak.segment.test.TemporaryFileStore) 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) Test(org.junit.Test)

Example 95 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.

the class StandbyTestIT method testSync.

@Test
public void testSync() throws Exception {
    int blobSize = 5 * MB;
    FileStore primary = serverFileStore.fileStore();
    FileStore secondary = clientFileStore.fileStore();
    NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary, MB);
        StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), secondary, false, getClientTimeout(), false, folder.newFolder())) {
        serverSync.start();
        byte[] data = addTestContent(store, "server", blobSize, 150);
        primary.flush();
        clientSync.run();
        assertEquals(primary.getHead(), secondary.getHead());
        assertTrue(primary.getStats().getApproximateSize() > blobSize);
        assertTrue(secondary.getStats().getApproximateSize() > blobSize);
        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 : TemporaryFileStore(org.apache.jackrabbit.oak.segment.test.TemporaryFileStore) 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) Test(org.junit.Test)

Aggregations

FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)106 Test (org.junit.Test)70 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)41 File (java.io.File)25 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)25 StandbyClientSync (org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync)18 StandbyServerSync (org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync)18 IOException (java.io.IOException)17 SegmentNodeStore (org.apache.jackrabbit.oak.segment.SegmentNodeStore)15 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)13 SegmentGCOptions (org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions)13 InvalidFileStoreVersionException (org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException)12 TemporaryFileStore (org.apache.jackrabbit.oak.segment.test.TemporaryFileStore)11 Blob (org.apache.jackrabbit.oak.api.Blob)10 DefaultStatisticsProvider (org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 FileStoreBuilder (org.apache.jackrabbit.oak.segment.file.FileStoreBuilder)9 Before (org.junit.Before)9 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)8 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)7