Search in sources :

Example 6 with SegmentWriter

use of org.apache.jackrabbit.oak.segment.SegmentWriter in project jackrabbit-oak by apache.

the class FileStore method initialNode.

@Nonnull
private Supplier<RecordId> initialNode() {
    return new Supplier<RecordId>() {

        @Override
        public RecordId get() {
            try {
                SegmentWriter writer = segmentWriterBuilder("init").build(FileStore.this);
                NodeBuilder builder = EMPTY_NODE.builder();
                builder.setChildNode("root", EMPTY_NODE);
                SegmentNodeState node = writer.writeNode(builder.getNodeState());
                writer.flush();
                return node.getRecordId();
            } catch (IOException e) {
                String msg = "Failed to write initial node";
                log.error(msg, e);
                throw new IllegalStateException(msg, e);
            }
        }
    };
}
Also used : Supplier(com.google.common.base.Supplier) IOException(java.io.IOException) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) SegmentNodeState(org.apache.jackrabbit.oak.segment.SegmentNodeState) SegmentWriter(org.apache.jackrabbit.oak.segment.SegmentWriter) Nonnull(javax.annotation.Nonnull)

Aggregations

SegmentWriter (org.apache.jackrabbit.oak.segment.SegmentWriter)6 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)4 RecordId (org.apache.jackrabbit.oak.segment.RecordId)3 SegmentNodeState (org.apache.jackrabbit.oak.segment.SegmentNodeState)3 Test (org.junit.Test)3 Stopwatch (com.google.common.base.Stopwatch)2 IOException (java.io.IOException)2 Compactor (org.apache.jackrabbit.oak.segment.Compactor)2 SegmentBufferWriter (org.apache.jackrabbit.oak.segment.SegmentBufferWriter)2 WriterCacheManager (org.apache.jackrabbit.oak.segment.WriterCacheManager)2 SegmentGCOptions (org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions)2 Supplier (com.google.common.base.Supplier)1 Nonnull (javax.annotation.Nonnull)1 FileStoreBuilder (org.apache.jackrabbit.oak.segment.file.FileStoreBuilder)1 ReadOnlyFileStore (org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore)1 BasicReadOnlyBlobStore (org.apache.jackrabbit.oak.segment.file.tooling.BasicReadOnlyBlobStore)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1