Search in sources :

Example 96 with FileStore

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());
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 97 with FileStore

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));
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 98 with FileStore

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);
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) ArrayBasedBlob(org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob) Test(org.junit.Test)

Example 99 with FileStore

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);
}
Also used : ReadOnlyFileStore(org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) ReadOnlyFileStore(org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore) Test(org.junit.Test)

Example 100 with FileStore

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();
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore)

Aggregations

FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)106 Test (org.junit.Test)70 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)41 File (java.io.File)25 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)25 StandbyClientSync (org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync)18 StandbyServerSync (org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync)18 IOException (java.io.IOException)17 SegmentNodeStore (org.apache.jackrabbit.oak.segment.SegmentNodeStore)15 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)13 SegmentGCOptions (org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions)13 InvalidFileStoreVersionException (org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException)12 TemporaryFileStore (org.apache.jackrabbit.oak.segment.test.TemporaryFileStore)11 Blob (org.apache.jackrabbit.oak.api.Blob)10 DefaultStatisticsProvider (org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 FileStoreBuilder (org.apache.jackrabbit.oak.segment.file.FileStoreBuilder)9 Before (org.junit.Before)9 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)8 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)7