Search in sources :

Example 6 with StandbyClientSync

use of org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync 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)

Example 7 with StandbyClientSync

use of org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync in project jackrabbit-oak by apache.

the class FailoverIPRangeIT method createTestWithConfig.

private void createTestWithConfig(String host, String[] ipRanges, boolean expectedToWork) throws Exception {
    FileStore storeS = serverFileStore.fileStore();
    FileStore storeC = clientFileStore.fileStore();
    NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, ipRanges);
        StandbyClientSync clientSync = new StandbyClientSync(host, serverPort.getPort(), storeC, false, getClientTimeout(), false)) {
        serverSync.start();
        addTestContent(store, "server");
        // this speeds up the test a little bit...
        storeS.flush();
        clientSync.run();
        if (expectedToWork) {
            assertEquals(storeS.getHead(), storeC.getHead());
        } else {
            assertFalse("stores are equal but shouldn't!", storeS.getHead().equals(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 8 with StandbyClientSync

use of org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync 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);
        StandbyClientSync cl1 = newStandbyClientSync(storeC, serverPort.getPort());
        StandbyClientSync cl2 = newStandbyClientSync(storeC2, serverPort.getPort())) {
        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 9 with StandbyClientSync

use of org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync 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, true);
        StandbyClientSync clientSync = newStandbyClientSync(storeC, serverPort.getPort(), true)) {
        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 10 with StandbyClientSync

use of org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync 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);
        StandbyClientSync clientSync = newStandbyClientSync(storeC, serverPort.getPort(), true)) {
        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)

Aggregations

StandbyClientSync (org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync)17 StandbyServerSync (org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync)14 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)12 Test (org.junit.Test)12 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)10 TemporaryFileStore (org.apache.jackrabbit.oak.segment.test.TemporaryFileStore)9 MBeanServer (javax.management.MBeanServer)4 ObjectName (javax.management.ObjectName)4 Blob (org.apache.jackrabbit.oak.api.Blob)4 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)4 Hashtable (java.util.Hashtable)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1 ServiceRegistration (org.osgi.framework.ServiceRegistration)1