use of org.apache.jackrabbit.oak.segment.SegmentNodeBuilder in project jackrabbit-oak by apache.
the class FileStoreIT method testRecovery.
@Test
public void testRecovery() throws Exception {
FileStore store = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(1).withMemoryMapping(false).build();
store.flush();
RandomAccessFile data0 = new RandomAccessFile(new File(getFileStoreFolder(), "data00000a.tar"), "r");
long pos0 = data0.length();
SegmentNodeState base = store.getHead();
SegmentNodeBuilder builder = base.builder();
builder.setProperty("step", "a");
store.getRevisions().setHead(base.getRecordId(), builder.getNodeState().getRecordId());
store.flush();
long pos1 = data0.length();
data0.close();
base = store.getHead();
builder = base.builder();
builder.setProperty("step", "b");
store.getRevisions().setHead(base.getRecordId(), builder.getNodeState().getRecordId());
store.close();
store = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(1).withMemoryMapping(false).build();
assertEquals("b", store.getHead().getString("step"));
store.close();
RandomAccessFile file = new RandomAccessFile(new File(getFileStoreFolder(), "data00000a.tar"), "rw");
file.setLength(pos1);
file.close();
store = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(1).withMemoryMapping(false).build();
assertEquals("a", store.getHead().getString("step"));
store.close();
file = new RandomAccessFile(new File(getFileStoreFolder(), "data00000a.tar"), "rw");
file.setLength(pos0);
file.close();
store = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(1).withMemoryMapping(false).build();
assertFalse(store.getHead().hasProperty("step"));
store.close();
}
use of org.apache.jackrabbit.oak.segment.SegmentNodeBuilder in project jackrabbit-oak by apache.
the class TarRevisionsTest method addChild.
@Nonnull
private static SegmentNodeState addChild(SegmentNodeState node, String name) {
SegmentNodeBuilder builder = node.builder();
builder.setChildNode(name);
return builder.getNodeState();
}
use of org.apache.jackrabbit.oak.segment.SegmentNodeBuilder in project jackrabbit-oak by apache.
the class FileStoreIT method testRestartAndGC.
public void testRestartAndGC(boolean memoryMapping) throws Exception {
FileStore store = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(1).withMemoryMapping(memoryMapping).build();
store.close();
store = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(1).withMemoryMapping(memoryMapping).build();
SegmentNodeState base = store.getHead();
SegmentNodeBuilder builder = base.builder();
byte[] data = new byte[10 * 1024 * 1024];
new Random().nextBytes(data);
Blob blob = builder.createBlob(new ByteArrayInputStream(data));
builder.setProperty("foo", blob);
store.getRevisions().setHead(base.getRecordId(), builder.getNodeState().getRecordId());
store.flush();
store.getRevisions().setHead(store.getRevisions().getHead(), base.getRecordId());
store.close();
store = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(1).withMemoryMapping(memoryMapping).build();
store.gc();
store.flush();
store.close();
store = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(1).withMemoryMapping(memoryMapping).build();
store.close();
}
Aggregations