Search in sources :

Example 1 with StandbyClientSync

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

the class BulkTransferBenchmark method test.

private void test(int number, int minExpectedSegments, int maxExpectedSegments, long minExpectedBytes, long maxExpectedBytes, boolean useSSL) throws Exception {
    NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
    NodeBuilder rootbuilder = store.getRoot().builder();
    NodeBuilder b = rootbuilder.child("store");
    for (int j = 0; j <= number / 1000; j++) {
        NodeBuilder builder = b.child("Folder#" + j);
        for (int i = 0; i < (number < 1000 ? number : 1000); i++) {
            builder.child("Test#" + i).setProperty("ts", System.currentTimeMillis());
        }
    }
    store.merge(rootbuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    storeS.flush();
    final StandbyServerSync serverSync = new StandbyServerSync(port, storeS, useSSL);
    serverSync.start();
    System.setProperty(StandbyClientSync.CLIENT_ID_PROPERTY_NAME, "Bar");
    StandbyClientSync clientSync = newStandbyClientSync(storeC, port, useSSL);
    final MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    ObjectName status = new ObjectName(StandbyStatusMBean.JMX_NAME + ",id=*");
    ObjectName clientStatus = new ObjectName(clientSync.getMBeanName());
    ObjectName serverStatus = new ObjectName(serverSync.getMBeanName());
    long start = System.currentTimeMillis();
    clientSync.run();
    try {
        Set<ObjectName> instances = jmxServer.queryNames(status, null);
        ObjectName connectionStatus = null;
        for (ObjectName s : instances) {
            if (!s.equals(clientStatus) && !s.equals(serverStatus))
                connectionStatus = s;
        }
        assert (connectionStatus != null);
        long segments = ((Long) jmxServer.getAttribute(connectionStatus, "TransferredSegments")).longValue();
        long bytes = ((Long) jmxServer.getAttribute(connectionStatus, "TransferredSegmentBytes")).longValue();
        System.out.println("did transfer " + segments + " segments with " + bytes + " bytes in " + (System.currentTimeMillis() - start) / 1000 + " seconds.");
    } finally {
        serverSync.close();
        clientSync.close();
    }
}
Also used : 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) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 2 with StandbyClientSync

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

the class StandbyBulkTransferBenchmark method execute.

@Override
public void execute(Repository repository, Credentials credentials, ExecutionContext context) throws Exception {
    Map<Object, Object> contextMap = context.getMap();
    StandbyClientSync[] clientSyncs = (StandbyClientSync[]) contextMap.get("clientSyncs");
    StandbyServerSync[] serverSyncs = (StandbyServerSync[]) contextMap.get("serverSyncs");
    FileStore[] stores = (FileStore[]) contextMap.get("stores");
    stores[0].flush();
    serverSyncs[0].start();
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    ObjectName status = new ObjectName(StandbyStatusMBean.JMX_NAME + ",id=*");
    ObjectName clientStatus = new ObjectName(clientSyncs[0].getMBeanName());
    ObjectName serverStatus = new ObjectName(serverSyncs[0].getMBeanName());
    Stopwatch stopwatch = Stopwatch.createStarted();
    clientSyncs[0].run();
    stopwatch.stop();
    Set<ObjectName> instances = jmxServer.queryNames(status, null);
    ObjectName connectionStatus = null;
    for (ObjectName s : instances) {
        if (!s.equals(clientStatus) && !s.equals(serverStatus)) {
            connectionStatus = s;
        }
    }
    assert (connectionStatus != null);
    long segments = (Long) jmxServer.getAttribute(connectionStatus, "TransferredSegments");
    long bytes = (Long) jmxServer.getAttribute(connectionStatus, "TransferredSegmentBytes");
    LOG.info("Bulk transfer for {} nodes finished! Segments = {}, segments size = {} bytes, time = {}", Integer.getInteger("nodeCount", 100_000), segments, bytes, stopwatch);
}
Also used : Stopwatch(com.google.common.base.Stopwatch) ObjectName(javax.management.ObjectName) 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) MBeanServer(javax.management.MBeanServer)

Example 3 with StandbyClientSync

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

the class DataStoreTestBase method testSync.

@Test
public void testSync() 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);
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary, MB);
        StandbyClientSync cl = new StandbyClientSync(getServerHost(), serverPort.getPort(), secondary, false, getClientTimeout(), 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());
    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) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 4 with StandbyClientSync

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

the class ExternalPrivateStoreIT method testSyncFailingDueToTooShortTimeout.

@Test
// FIXME OAK-7027
@Ignore("OAK-7027")
public void testSyncFailingDueToTooShortTimeout() throws Exception {
    final int blobSize = 5 * MB;
    FileStore primary = getPrimary();
    FileStore secondary = getSecondary();
    NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
    addTestContent(store, "server", blobSize);
    try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary, MB);
        StandbyClientSync cl = new StandbyClientSync(getServerHost(), 60, secondary, false, getClientTimeout(), false, folder.newFolder())) {
        serverSync.start();
        primary.flush();
        cl.run();
        assertNotEquals(primary.getHead(), secondary.getHead());
        assertEquals(1, cl.getFailedRequests());
    }
}
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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with StandbyClientSync

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

the class FailoverSslTestIT method testFailoverSecureServerPlainClient.

@Test
public void testFailoverSecureServerPlainClient() 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, false, 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)

Aggregations

StandbyClientSync (org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync)24 StandbyServerSync (org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync)21 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)18 Test (org.junit.Test)17 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 File (java.io.File)5 MBeanServer (javax.management.MBeanServer)5 ObjectName (javax.management.ObjectName)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 InputStream (java.io.InputStream)4 NetworkErrorProxy (org.apache.jackrabbit.oak.segment.test.proxy.NetworkErrorProxy)2 Stopwatch (com.google.common.base.Stopwatch)1 ServerSocket (java.net.ServerSocket)1 Hashtable (java.util.Hashtable)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