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();
}
}
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);
}
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);
}
}
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());
}
}
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));
}
}
Aggregations