use of org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync in project jackrabbit-oak by apache.
the class StandbyTestIT method testSync.
@Test
public void testSync() throws Exception {
final int mb = 1 * 1024 * 1024;
final 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);
StandbyClientSync clientSync = newStandbyClientSync(secondary, serverPort.getPort())) {
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);
}
}
use of org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync 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);
StandbyClientSync clientSync = newStandbyClientSync(secondary, serverPort.getPort())) {
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);
}
}
Aggregations