Search in sources :

Example 6 with FileStoreBuilder

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

the class SegmentTarFactory method hasExternalBlobReferences.

@Override
public boolean hasExternalBlobReferences() throws IOException {
    final FileStoreBuilder builder = fileStoreBuilder(new File(dir, "segmentstore"));
    builder.withMaxFileSize(256);
    builder.withMemoryMapping(false);
    ReadOnlyFileStore fs;
    try {
        fs = builder.buildReadOnly();
    } catch (InvalidFileStoreVersionException e) {
        throw new IOException(e);
    }
    try {
        for (SegmentId id : fs.getSegmentIds()) {
            if (!id.isDataSegmentId()) {
                continue;
            }
            id.getSegment().forEachRecord(new Segment.RecordConsumer() {

                @Override
                public void consume(int number, RecordType type, int offset) {
                    // see java.nio.file.FileVisitor
                    if (type == RecordType.BLOB_ID) {
                        throw new ExternalBlobFound();
                    }
                }
            });
        }
        return false;
    } catch (ExternalBlobFound e) {
        return true;
    } finally {
        fs.close();
    }
}
Also used : FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) RecordType(org.apache.jackrabbit.oak.segment.RecordType) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException) SegmentId(org.apache.jackrabbit.oak.segment.SegmentId) ReadOnlyFileStore(org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore) IOException(java.io.IOException) File(java.io.File) Segment(org.apache.jackrabbit.oak.segment.Segment)

Example 7 with FileStoreBuilder

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

the class CompositeStoreFixture method getNodeStore.

private NodeStore getNodeStore() throws IOException, InvalidFileStoreVersionException {
    if (inMemory) {
        return new MemoryNodeStore();
    }
    FileStoreBuilder fsBuilder = fileStoreBuilder(new File(base, unique)).withMaxFileSize(maxFileSizeMB).withSegmentCacheSize(cacheSizeMB).withMemoryMapping(memoryMapping);
    fileStore = fsBuilder.build();
    return SegmentNodeStoreBuilders.builder(fileStore).build();
}
Also used : MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) File(java.io.File)

Example 8 with FileStoreBuilder

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

the class SegmentTarFixture method setUpCluster.

@Override
public Oak[] setUpCluster(int n, StatisticsProvider statsProvider) throws Exception {
    Oak[] cluster = new Oak[n];
    stores = new FileStore[cluster.length];
    if (useBlobStore) {
        blobStoreFixtures = new BlobStoreFixture[cluster.length];
    }
    for (int i = 0; i < cluster.length; i++) {
        BlobStore blobStore = null;
        if (useBlobStore) {
            blobStoreFixtures[i] = BlobStoreFixture.create(base, true, dsCacheSizeInMB, statsProvider);
            blobStore = blobStoreFixtures[i].setUp();
        }
        FileStoreBuilder builder = fileStoreBuilder(new File(base, unique));
        if (blobStore != null) {
            builder.withBlobStore(blobStore);
        }
        stores[i] = builder.withMaxFileSize(maxFileSizeMB).withStatisticsProvider(statsProvider).withSegmentCacheSize(cacheSizeMB).withMemoryMapping(memoryMapping).build();
        cluster[i] = newOak(SegmentNodeStoreBuilders.builder(stores[i]).build());
    }
    return cluster;
}
Also used : FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) Oak(org.apache.jackrabbit.oak.Oak) File(java.io.File) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore)

Example 9 with FileStoreBuilder

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

the class LuceneBlobCacheTest method setUp.

@Before
public void setUp() throws Exception {
    fileDataStore = new ReadAccessCountingDataStore();
    fileDataStore.init(tempFolder.newFolder().getAbsolutePath());
    FileStoreBuilder fileStoreBuilder = FileStoreBuilder.fileStoreBuilder(tempFolder.newFolder()).withBlobStore(new DataStoreBlobStore(fileDataStore)).withMaxFileSize(256).withSegmentCacheSize(64).withMemoryMapping(false);
    store = fileStoreBuilder.build();
    NodeStore nodeStore = SegmentNodeStoreBuilders.builder(store).build();
    root = nodeStore.getRoot();
    builder = root.builder();
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) Before(org.junit.Before)

Example 10 with FileStoreBuilder

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

the class SegmentTarFactory method create.

@Override
public NodeStore create(BlobStore blobStore, Closer closer) throws IOException {
    final FileStoreBuilder builder = fileStoreBuilder(new File(dir, "segmentstore"));
    if (blobStore != null) {
        builder.withBlobStore(blobStore);
    }
    builder.withMaxFileSize(256);
    if (disableMmap) {
        builder.withMemoryMapping(false);
    } else {
        builder.withDefaultMemoryMapping();
    }
    try {
        if (readOnly) {
            final ReadOnlyFileStore fs;
            fs = builder.buildReadOnly();
            closer.register(asCloseable(fs));
            return new TarNodeStore(SegmentNodeStoreBuilders.builder(fs).build(), new SegmentTarSuperRootProvider(fs));
        } else {
            final FileStore fs;
            fs = builder.build();
            closer.register(asCloseable(fs));
            return new TarNodeStore(SegmentNodeStoreBuilders.builder(fs).build(), new SegmentTarSuperRootProvider(fs));
        }
    } catch (InvalidFileStoreVersionException e) {
        throw new IllegalStateException(e);
    }
}
Also used : ReadOnlyFileStore(org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException) ReadOnlyFileStore(org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore) File(java.io.File)

Aggregations

FileStoreBuilder (org.apache.jackrabbit.oak.segment.file.FileStoreBuilder)13 File (java.io.File)7 InvalidFileStoreVersionException (org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException)5 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)4 SegmentGCOptions (org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions)3 ReadOnlyFileStore (org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore)3 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)3 Supplier (com.google.common.base.Supplier)2 IOException (java.io.IOException)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 CacheStatsMBean (org.apache.jackrabbit.oak.api.jmx.CacheStatsMBean)2 SegmentRevisionGC (org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGC)2 SegmentRevisionGCMBean (org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGCMBean)2 MetricsIOMonitor (org.apache.jackrabbit.oak.segment.file.MetricsIOMonitor)2 RevisionGC (org.apache.jackrabbit.oak.spi.state.RevisionGC)2 DefaultStatisticsProvider (org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider)2 Stopwatch (com.google.common.base.Stopwatch)1 ListeningScheduledExecutorService (com.google.common.util.concurrent.ListeningScheduledExecutorService)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HashMap (java.util.HashMap)1