use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.
the class SegmentReferencesTest method segmentShouldNotReferenceItself.
@Test
public void segmentShouldNotReferenceItself() throws Exception {
try (FileStore store = newFileStore()) {
// Write two records, one referencing the other.
SegmentWriter writer = defaultSegmentWriterBuilder("test").build(store);
RecordId a = writer.writeNode(EmptyNodeState.EMPTY_NODE);
NodeBuilder builder = EmptyNodeState.EMPTY_NODE.builder();
builder.setChildNode("referred", store.getReader().readNode(a));
RecordId b = writer.writeNode(builder.getNodeState());
writer.flush();
// The two records should be living in the same segment.
assertEquals(b.getSegmentId(), a.getSegmentId());
// This inter-segment reference shouldn't generate a reference from
// this segment to itself.
assertEquals(0, b.getSegment().getReferencedSegmentIdCount());
}
}
use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.
the class SegmentReferencesTest method segmentShouldExposeReferencedSegments.
@Test
public void segmentShouldExposeReferencedSegments() throws Exception {
try (FileStore store = newFileStore()) {
// Write two records, one referencing the other.
SegmentWriter writer = defaultSegmentWriterBuilder("test").build(store);
RecordId a = writer.writeNode(EmptyNodeState.EMPTY_NODE);
writer.flush();
NodeBuilder builder = EmptyNodeState.EMPTY_NODE.builder();
builder.setChildNode("referred", store.getReader().readNode(a));
RecordId b = writer.writeNode(builder.getNodeState());
writer.flush();
// The two records should be living in two different segments.
assertNotEquals(a.getSegmentId(), b.getSegmentId());
// This intra-segment reference should generate a reference from the
// segment containing the list to the segment containing the string.
assertEquals(1, b.getSegment().getReferencedSegmentIdCount());
assertEquals(a.getSegmentId().asUUID(), b.getSegment().getReferencedSegmentId(0));
}
}
use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.
the class BlobIdRecordTest method shortReferencesShouldHaveBlobIdType.
@Test
public void shortReferencesShouldHaveBlobIdType() throws Exception {
try (FileStore ss = newFileStore(new ShortIdMappingBlobStore())) {
SegmentWriter sw = defaultSegmentWriterBuilder("test").build(ss);
byte[] content = new byte[Segment.MEDIUM_LIMIT + 1];
SegmentBlob sb = new SegmentBlob(ss.getBlobStore(), sw.writeBlob(new ArrayBasedBlob(content)));
assertRecordTypeEquals(sb, RecordType.BLOB_ID);
}
}
use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.
the class SegmentBufferWriterTest method dirtyBuffersShouldBeFlushed.
@Test
public void dirtyBuffersShouldBeFlushed() throws Exception {
List<SegmentId> before;
try (FileStore store = openFileStore()) {
// init
}
try (ReadOnlyFileStore store = openReadOnlyFileStore()) {
before = newArrayList(store.getSegmentIds());
}
try (FileStore store = openFileStore()) {
SegmentWriter writer = defaultSegmentWriterBuilder("t").build(store);
writer.writeNode(EmptyNodeState.EMPTY_NODE);
writer.flush();
}
List<SegmentId> after;
try (ReadOnlyFileStore store = openReadOnlyFileStore()) {
after = newArrayList(store.getSegmentIds());
}
assertNotEquals(before, after);
}
use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.
the class IncludeExcludeSidegradeTest method doUpgradeRepository.
@Override
protected void doUpgradeRepository(File source, NodeStore target) throws RepositoryException, IOException {
FileStore fileStore;
try {
fileStore = fileStoreBuilder(source).build();
} catch (InvalidFileStoreVersionException e) {
throw new IllegalStateException(e);
}
SegmentNodeStore segmentNodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
try {
final RepositorySidegrade sidegrade = new RepositorySidegrade(segmentNodeStore, target);
sidegrade.setIncludes("/content/foo/en", "/content/assets/foo", "/content/other");
sidegrade.setExcludes("/content/assets/foo/2013", "/content/assets/foo/2012", "/content/assets/foo/2011", "/content/assets/foo/2010");
sidegrade.copy();
} finally {
fileStore.close();
}
}
Aggregations