use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class AbstractOak2OakTest method initContent.
protected void initContent(NodeStore target) throws IOException, RepositoryException, CommitFailedException {
NodeStore initialContent = testContent.open();
try {
RepositorySidegrade sidegrade = new RepositorySidegrade(initialContent, target);
sidegrade.copy();
} finally {
testContent.close();
}
NodeBuilder builder = target.getRoot().builder();
builder.setProperty("binary-prop", getRandomBlob(target));
builder.setProperty("checkpoint-state", "before");
target.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
target.checkpoint(60000, singletonMap("key", "123"));
builder.setProperty("checkpoint-state", "after");
builder.setProperty("binary-prop", getRandomBlob(target));
builder.child(":async").setProperty("test", "123");
target.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class LuceneBlobCacheTest method setUp.
@Before
public void setUp() throws Exception {
fileDataStore = new ReadAccessCountingDataStore();
fileDataStore.init(tempFolder.newFolder().getAbsolutePath());
FileStoreBuilder fileStoreBuilder = FileStoreBuilder.fileStoreBuilder(tempFolder.newFolder()).withBlobStore(new DataStoreBlobStore(fileDataStore)).withMaxFileSize(256).withSegmentCacheSize(64).withMemoryMapping(false);
store = fileStoreBuilder.build();
NodeStore nodeStore = SegmentNodeStoreBuilders.builder(store).build();
root = nodeStore.getRoot();
builder = root.builder();
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore in project jackrabbit-oak by apache.
the class BrokenNetworkIT method useProxy.
private void useProxy(boolean ssl, int skipPosition, int skipBytes, int flipPosition, boolean intermediateChange) throws Exception {
FileStore storeS = serverFileStore.fileStore();
FileStore storeC = clientFileStore1.fileStore();
FileStore storeC2 = clientFileStore2.fileStore();
NodeStore store = SegmentNodeStoreBuilders.builder(storeS).build();
addTestContent(store, "server");
// this speeds up the test a little bit...
storeS.flush();
try (StandbyServerSync serverSync = new StandbyServerSync(serverPort.getPort(), storeS, ssl);
StandbyClientSync clientSync = newStandbyClientSync(storeC, proxyPort.getPort(), ssl)) {
proxy.skipBytes(skipPosition, skipBytes);
proxy.flipByte(flipPosition);
proxy.connect();
serverSync.start();
clientSync.run();
if (skipBytes > 0 || flipPosition >= 0) {
assertFalse("stores are not expected to be equal", storeS.getHead().equals(storeC.getHead()));
assertEquals(storeC2.getHead(), storeC.getHead());
proxy.reset();
if (intermediateChange) {
addTestContent(store, "server2");
storeS.flush();
}
clientSync.run();
}
assertEquals(storeS.getHead(), storeC.getHead());
}
}
use of org.apache.jackrabbit.oak.spi.state.NodeStore 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);
StandbyClientSync clientSync = newStandbyClientSync(secondary, serverPort.getPort())) {
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.spi.state.NodeStore 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);
}
Aggregations