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