Search in sources :

Example 11 with StandbyServerSync

use of org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync in project jackrabbit-oak by apache.

the class FailoverSslTestIT method testFailoverSecure.

@Test
public void testFailoverSecure() throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore.fileStore();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, MB, true);
        StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), storeC, true, getClientTimeout(), false, folder.newFolder())) {
        assertTrue(synchronizeAndCompareHead(serverSync, clientSync));
    }
}
Also used : TemporaryFileStore(org.apache.jackrabbit.oak.segment.test.TemporaryFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) StandbyServerSync(org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync) StandbyClientSync(org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync) Test(org.junit.Test)

Example 12 with StandbyServerSync

use of org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync in project jackrabbit-oak by apache.

the class FailoverSslTestIT method testFailoverPlainServerSecureClient.

@Test
public void testFailoverPlainServerSecureClient() throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore.fileStore();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, MB);
        StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), storeC, true, getClientTimeout(), false, folder.newFolder())) {
        assertFalse(synchronizeAndCompareHead(serverSync, clientSync));
    }
}
Also used : TemporaryFileStore(org.apache.jackrabbit.oak.segment.test.TemporaryFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) StandbyServerSync(org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync) StandbyClientSync(org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync) Test(org.junit.Test)

Example 13 with StandbyServerSync

use of org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync in project jackrabbit-oak by apache.

the class RecoverTestIT method testLocalChanges.

@Test
public void testLocalChanges() throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore.fileStore();
    NodeStore store = SegmentNodeStoreBuilders.builder(storeC).build();
    addTestContent(store, "client");
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, MB);
        StandbyClientSync cl = new StandbyClientSync(getServerHost(), serverPort.getPort(), storeC, false, getClientTimeout(), false, folder.newFolder())) {
        serverSync.start();
        store = SegmentNodeStoreBuilders.builder(storeS).build();
        addTestContent(store, "server");
        storeS.flush();
        assertFalse("stores are not expected to be equal", storeS.getHead().equals(storeC.getHead()));
        cl.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 14 with StandbyServerSync

use of org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync 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);
    primary.flush();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary, MB)) {
        serverSync.start();
        File spoolFolder = folder.newFolder();
        try (NetworkErrorProxy ignored = new NetworkErrorProxy(proxyPort.getPort(), getServerHost(), serverPort.getPort(), flipPosition, skipPosition, skipBytes);
            StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), proxyPort.getPort(), secondary, false, getClientTimeout(), false, spoolFolder)) {
            clientSync.run();
        }
        if (storesShouldBeDifferent()) {
            assertFalse("stores are equal", primary.getHead().equals(secondary.getHead()));
        }
        if (intermediateChange) {
            blobSize = 2 * MB;
            data = addTestContent(store, "server", blobSize);
            primary.flush();
        }
        try (StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), secondary, false, getClientTimeout(), false, spoolFolder)) {
            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];
    try (InputStream blobInputStream = b.getNewStream()) {
        ByteStreams.readFully(blobInputStream, 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) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) StandbyClientSync(org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync) File(java.io.File) NetworkErrorProxy(org.apache.jackrabbit.oak.segment.test.proxy.NetworkErrorProxy) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Example 15 with StandbyServerSync

use of org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync in project jackrabbit-oak by apache.

the class DataStoreTestBase method testResilientSync.

@Test
public void testResilientSync() throws Exception {
    final int blobSize = 5 * MB;
    FileStore primary = getPrimary();
    FileStore secondary = getSecondary();
    NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
    byte[] data = addTestContent(store, "server", blobSize);
    File spoolFolder = folder.newFolder();
    // run 1: unsuccessful
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary, MB);
        StandbyClientSync cl = new StandbyClientSync(getServerHost(), serverPort.getPort(), secondary, false, 4_000, false, spoolFolder)) {
        serverSync.start();
        // no persisted head on primary
        // sync shouldn't be successful, but shouldn't throw exception either,
        // timeout too low for TarMK flush thread to kick-in
        cl.run();
        assertNotEquals(primary.getHead(), secondary.getHead());
    }
    // run 2: successful
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary, MB);
        StandbyClientSync cl = new StandbyClientSync(getServerHost(), serverPort.getPort(), secondary, false, 4_000, false, spoolFolder)) {
        serverSync.start();
        // this time persisted head will be available on primary
        // waited at least 4s + 4s > 5s (TarMK flush thread run frequency)
        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());
    byte[] testData = new byte[blobSize];
    try (InputStream blobInputStream = b.getNewStream()) {
        ByteStreams.readFully(blobInputStream, 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) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) StandbyClientSync(org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync) File(java.io.File) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Aggregations

StandbyServerSync (org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync)23 StandbyClientSync (org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync)21 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)18 Test (org.junit.Test)16 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)15 TemporaryFileStore (org.apache.jackrabbit.oak.segment.test.TemporaryFileStore)12 Blob (org.apache.jackrabbit.oak.api.Blob)6 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 File (java.io.File)4 InputStream (java.io.InputStream)4 MBeanServer (javax.management.MBeanServer)4 ObjectName (javax.management.ObjectName)4 NetworkErrorProxy (org.apache.jackrabbit.oak.segment.test.proxy.NetworkErrorProxy)2 Stopwatch (com.google.common.base.Stopwatch)1 ServerSocket (java.net.ServerSocket)1 SegmentGCOptions (org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions)1 FileStoreBuilder (org.apache.jackrabbit.oak.segment.file.FileStoreBuilder)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1 Ignore (org.junit.Ignore)1