Search in sources :

Example 1 with Builder

use of org.apache.jackrabbit.oak.plugins.segment.file.FileStore.Builder in project jackrabbit-oak by apache.

the class SegmentFactory method hasExternalBlobReferences.

@Override
public boolean hasExternalBlobReferences() throws IOException {
    Builder builder = FileStore.builder(new File(dir, "segmentstore"));
    builder.withMaxFileSize(256);
    builder.withMemoryMapping(false);
    FileStore fs;
    try {
        fs = builder.buildReadOnly();
    } catch (InvalidFileStoreVersionException e) {
        throw new IOException(e);
    }
    try {
        fs.getTracker().collectBlobReferences(new ReferenceCollector() {

            @Override
            public void addReference(String reference, @Nullable String nodeId) {
                // see java.nio.file.FileVisitor
                throw new ExternalBlobFound();
            }
        });
        return false;
    } catch (ExternalBlobFound e) {
        return true;
    } finally {
        fs.close();
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.plugins.segment.file.FileStore) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.plugins.segment.file.InvalidFileStoreVersionException) Builder(org.apache.jackrabbit.oak.plugins.segment.file.FileStore.Builder) IOException(java.io.IOException) ReferenceCollector(org.apache.jackrabbit.oak.plugins.blob.ReferenceCollector) File(java.io.File)

Example 2 with Builder

use of org.apache.jackrabbit.oak.plugins.segment.file.FileStore.Builder in project jackrabbit-oak by apache.

the class SegmentFactory method create.

@Override
public NodeStore create(BlobStore blobStore, Closer closer) throws IOException {
    Builder builder = FileStore.builder(new File(dir, "segmentstore"));
    if (blobStore != null) {
        builder.withBlobStore(blobStore);
    }
    builder.withMaxFileSize(256);
    if (disableMmap) {
        builder.withMemoryMapping(false);
    } else {
        builder.withDefaultMemoryMapping();
    }
    final FileStore fs;
    try {
        if (readOnly) {
            fs = builder.buildReadOnly();
        } else {
            fs = builder.build();
        }
    } catch (InvalidFileStoreVersionException e) {
        throw new IllegalStateException(e);
    }
    closer.register(asCloseable(fs));
    return new TarNodeStore(SegmentNodeStore.builder(fs).build(), new TarNodeStore.SuperRootProvider() {

        @Override
        public NodeState getSuperRoot() {
            return fs.getHead();
        }
    });
}
Also used : FileStore(org.apache.jackrabbit.oak.plugins.segment.file.FileStore) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.plugins.segment.file.InvalidFileStoreVersionException) Builder(org.apache.jackrabbit.oak.plugins.segment.file.FileStore.Builder) File(java.io.File)

Aggregations

File (java.io.File)2 FileStore (org.apache.jackrabbit.oak.plugins.segment.file.FileStore)2 Builder (org.apache.jackrabbit.oak.plugins.segment.file.FileStore.Builder)2 InvalidFileStoreVersionException (org.apache.jackrabbit.oak.plugins.segment.file.InvalidFileStoreVersionException)2 IOException (java.io.IOException)1 ReferenceCollector (org.apache.jackrabbit.oak.plugins.blob.ReferenceCollector)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1