use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.
the class DataStoreTestBase method testSyncBigBlob.
/*
* See OAK-5902.
*/
@Test
public void testSyncBigBlob() throws Exception {
final long blobSize = GB;
final int seed = 13;
FileStore primary = getPrimary();
FileStore secondary = getSecondary();
NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
addTestContentOnTheFly(store, "server", blobSize, seed);
try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary, 8 * MB);
StandbyClientSync cl = new StandbyClientSync(getServerHost(), serverPort.getPort(), secondary, false, 2 * 60 * 1000, 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());
try (InputStream randomInputStream = newRandomInputStream(blobSize, seed);
InputStream blobInputStream = b.getNewStream()) {
assertTrue(IOUtils.contentEquals(randomInputStream, blobInputStream));
}
}
use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.
the class DataStoreTestBase method testSyncUpdatedBinaryProperty.
/*
* See OAK-4969.
*/
@Test
public void testSyncUpdatedBinaryProperty() throws Exception {
final int blobSize = 5 * MB;
FileStore primary = getPrimary();
FileStore secondary = getSecondary();
NodeStore store = SegmentNodeStoreBuilders.builder(primary).build();
try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), primary, MB);
StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), secondary, false, getClientTimeout(), false, folder.newFolder())) {
serverSync.start();
addTestContent(store, "server", blobSize);
primary.flush();
clientSync.run();
assertEquals(primary.getHead(), secondary.getHead());
addTestContent(store, "server", blobSize);
primary.flush();
clientSync.run();
assertEquals(primary.getHead(), secondary.getHead());
}
}
use of org.apache.jackrabbit.oak.segment.file.FileStore 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, MB);
StandbyClientSync cl1 = new StandbyClientSync(getServerHost(), serverPort.getPort(), storeC, false, getClientTimeout(), false, folder.newFolder());
StandbyClientSync cl2 = new StandbyClientSync(getServerHost(), serverPort.getPort(), storeC2, false, getClientTimeout(), false, folder.newFolder())) {
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.file.FileStore 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, MB);
StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), secondary, false, getClientTimeout(), false, folder.newFolder())) {
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);
}
}
use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.
the class StandbyTestIT method testSync.
@Test
public void testSync() throws Exception {
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, MB);
StandbyClientSync clientSync = new StandbyClientSync(getServerHost(), serverPort.getPort(), secondary, false, getClientTimeout(), false, folder.newFolder())) {
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);
}
}
Aggregations