Search in sources :

Example 1 with OakFileDataStore

use of org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore in project jackrabbit-oak by apache.

the class LuceneWritesOnSegmentStatsTest method createBlobStore.

private BlobStore createBlobStore() {
    FileDataStore fds = new OakFileDataStore();
    fdsDir = "target/fds-" + codec + copyOnRW + minRecordLength + mergePolicy;
    fds.setPath(fdsDir);
    if (minRecordLength > 0) {
        fds.setMinRecordLength(minRecordLength);
    }
    fds.init(null);
    dataStoreBlobStore = new DataStoreBlobStore(fds);
    StatisticsProvider sp = new DefaultStatisticsProvider(scheduledExecutorService);
    BlobStatsCollector collector = new BlobStoreStats(sp);
    dataStoreBlobStore.setBlobStatsCollector(collector);
    return dataStoreBlobStore;
}
Also used : OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) BlobStatsCollector(org.apache.jackrabbit.oak.spi.blob.stats.BlobStatsCollector) BlobStoreStats(org.apache.jackrabbit.oak.plugins.blob.BlobStoreStats) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)

Example 2 with OakFileDataStore

use of org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore in project jackrabbit-oak by apache.

the class ActiveDeletedBlobSyncTrackerTest method createRepository.

@Override
protected ContentRepository createRepository() {
    try {
        File blobCollectorDeleted = new File(blobCollectionRoot.getRoot(), "deleted-blobs");
        blobCollectorDeleted.mkdirs();
        adbc = new ActiveDeletedBlobCollectorImpl(clock, new File(blobCollectionRoot.getRoot(), "deleted-blobs"), executorService);
        IndexCopier copier = createIndexCopier();
        editorProvider = new LuceneIndexEditorProvider(copier, null, new ExtractedTextCache(10 * FileUtils.ONE_MB, 100), null, Mounts.defaultMountInfoProvider(), adbc);
        provider = new LuceneIndexProvider(copier);
        OakFileDataStore ds = new OakFileDataStore();
        ds.setMinRecordLength(10);
        ds.init(fileDataStoreRoot.getRoot().getAbsolutePath());
        DataStoreBlobStore dsbs = new DataStoreBlobStore(ds);
        this.blobStore = new AbstractActiveDeletedBlobTest.CountingBlobStore(dsbs);
        FileStore store = FileStoreBuilder.fileStoreBuilder(temporaryFolder.getRoot()).withMemoryMapping(false).withBlobStore(blobStore).build();
        nodeStore = SegmentNodeStoreBuilders.builder(store).build();
        BlobTrackingStore trackingStore = (BlobTrackingStore) blobStore;
        trackingStore.addTracker(new BlobIdTracker(blobTrackerRoot.getRoot().getAbsolutePath(), getOrCreateId(nodeStore), 600, dsbs));
        // set the blob store to skip writing blobs through the node store
        editorProvider.setBlobStore(blobStore);
        asyncIndexUpdate = new AsyncIndexUpdate("async", nodeStore, editorProvider);
        return new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with((QueryIndexProvider) provider).with((Observer) provider).with(editorProvider).createContentRepository();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) ActiveDeletedBlobCollectorImpl(org.apache.jackrabbit.oak.plugins.index.lucene.directory.ActiveDeletedBlobCollectorFactory.ActiveDeletedBlobCollectorImpl) AsyncIndexUpdate(org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) IndexCopier(org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier) IOException(java.io.IOException) QueryIndexProvider(org.apache.jackrabbit.oak.spi.query.QueryIndexProvider) ExtractedTextCache(org.apache.jackrabbit.oak.plugins.index.lucene.ExtractedTextCache) InitialContent(org.apache.jackrabbit.oak.InitialContent) FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) BlobIdTracker(org.apache.jackrabbit.oak.plugins.blob.datastore.BlobIdTracker) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) BlobTrackingStore(org.apache.jackrabbit.oak.plugins.blob.BlobTrackingStore) Oak(org.apache.jackrabbit.oak.Oak) LuceneIndexProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider) File(java.io.File) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)

Example 3 with OakFileDataStore

use of org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore in project jackrabbit-oak by apache.

the class Utils method bootstrapDataStore.

@Nullable
public static GarbageCollectableBlobStore bootstrapDataStore(String[] args, Closer closer) throws IOException, RepositoryException {
    OptionParser parser = new OptionParser();
    parser.allowsUnrecognizedOptions();
    ArgumentAcceptingOptionSpec<String> s3dsConfig = parser.accepts("s3ds", "S3DataStore config").withRequiredArg().ofType(String.class);
    ArgumentAcceptingOptionSpec<String> fdsConfig = parser.accepts("fds", "FileDataStore config").withRequiredArg().ofType(String.class);
    ArgumentAcceptingOptionSpec<String> azureBlobDSConfig = parser.accepts("azureblobds", "AzureBlobStorageDataStore config").withRequiredArg().ofType(String.class);
    OptionSpecBuilder nods = parser.accepts("nods", "No DataStore ");
    OptionSet options = parser.parse(args);
    if (!options.has(s3dsConfig) && !options.has(fdsConfig) && !options.has(azureBlobDSConfig) && !options.has(nods)) {
        return null;
    }
    DataStore delegate;
    if (options.has(s3dsConfig)) {
        S3DataStore s3ds = new S3DataStore();
        String cfgPath = s3dsConfig.value(options);
        Properties props = loadAndTransformProps(cfgPath);
        s3ds.setProperties(props);
        File homeDir = Files.createTempDir();
        closer.register(asCloseable(homeDir));
        s3ds.init(homeDir.getAbsolutePath());
        delegate = s3ds;
    } else if (options.has(azureBlobDSConfig)) {
        AzureDataStore azureds = new AzureDataStore();
        String cfgPath = azureBlobDSConfig.value(options);
        Properties props = loadAndTransformProps(cfgPath);
        azureds.setProperties(props);
        File homeDir = Files.createTempDir();
        azureds.init(homeDir.getAbsolutePath());
        closer.register(asCloseable(homeDir));
        delegate = azureds;
    } else if (options.has(nods)) {
        delegate = new DummyDataStore();
        File homeDir = Files.createTempDir();
        delegate.init(homeDir.getAbsolutePath());
        closer.register(asCloseable(homeDir));
    } else {
        delegate = new OakFileDataStore();
        String cfgPath = fdsConfig.value(options);
        Properties props = loadAndTransformProps(cfgPath);
        populate(delegate, asMap(props), true);
        delegate.init(null);
    }
    DataStoreBlobStore blobStore = new DataStoreBlobStore(delegate);
    closer.register(Utils.asCloseable(blobStore));
    return blobStore;
}
Also used : OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) DummyDataStore(org.apache.jackrabbit.oak.run.cli.DummyDataStore) AzureDataStore(org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore) Properties(java.util.Properties) OptionParser(joptsimple.OptionParser) S3DataStore(org.apache.jackrabbit.oak.blob.cloud.s3.S3DataStore) OptionSpecBuilder(joptsimple.OptionSpecBuilder) S3DataStore(org.apache.jackrabbit.oak.blob.cloud.s3.S3DataStore) DummyDataStore(org.apache.jackrabbit.oak.run.cli.DummyDataStore) DataStore(org.apache.jackrabbit.core.data.DataStore) AzureDataStore(org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore) OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) OptionSet(joptsimple.OptionSet) File(java.io.File) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) Nullable(javax.annotation.Nullable)

Example 4 with OakFileDataStore

use of org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore in project jackrabbit-oak by apache.

the class CompactionAndCleanupIT method newBlobStore.

private static BlobStore newBlobStore(File directory) {
    OakFileDataStore delegate = new OakFileDataStore();
    delegate.setPath(directory.getAbsolutePath());
    delegate.init(null);
    return new DataStoreBlobStore(delegate);
}
Also used : OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)

Example 5 with OakFileDataStore

use of org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore in project jackrabbit-oak by apache.

the class BlobStoreFixtureProvider method create.

@CheckForNull
public static BlobStoreFixture create(Options options) throws Exception {
    BlobStoreOptions bsopts = options.getOptionBean(BlobStoreOptions.class);
    if (bsopts == null) {
        return null;
    }
    Type bsType = bsopts.getBlobStoreType();
    if (bsType == Type.NONE) {
        return null;
    }
    Closer closer = Closer.create();
    DataStore delegate;
    if (bsType == Type.S3) {
        S3DataStore s3ds = new S3DataStore();
        Properties props = loadConfig(bsopts.getS3ConfigPath());
        s3ds.setProperties(props);
        File homeDir = Files.createTempDir();
        closer.register(asCloseable(homeDir));
        populate(s3ds, asMap(props), false);
        s3ds.init(homeDir.getAbsolutePath());
        delegate = s3ds;
    } else if (bsType == Type.AZURE) {
        AzureDataStore azureds = new AzureDataStore();
        String cfgPath = bsopts.getAzureConfigPath();
        Properties props = loadConfig(cfgPath);
        azureds.setProperties(props);
        File homeDir = Files.createTempDir();
        populate(azureds, asMap(props), false);
        azureds.init(homeDir.getAbsolutePath());
        closer.register(asCloseable(homeDir));
        delegate = azureds;
    } else if (bsType == Type.FAKE) {
        FileDataStore fakeDs = new DummyDataStore();
        fakeDs.setPath(bsopts.getFakeDataStorePath());
        fakeDs.init(null);
        delegate = fakeDs;
    } else {
        FileDataStore fds = new OakFileDataStore();
        delegate = fds;
        if (bsopts.getFDSPath() != null) {
            fds.setPath(bsopts.getFDSPath());
        } else {
            String cfgPath = bsopts.getFDSConfigPath();
            Properties props = loadAndTransformProps(cfgPath);
            populate(delegate, asMap(props), true);
        }
        delegate.init(null);
    }
    DataStoreBlobStore blobStore = new DataStoreBlobStore(delegate);
    return new DataStoreFixture(blobStore, closer, !options.getCommonOpts().isReadWrite());
}
Also used : Closer(com.google.common.io.Closer) OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) AzureDataStore(org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore) Properties(java.util.Properties) S3DataStore(org.apache.jackrabbit.oak.blob.cloud.s3.S3DataStore) Type(org.apache.jackrabbit.oak.run.cli.BlobStoreOptions.Type) S3DataStore(org.apache.jackrabbit.oak.blob.cloud.s3.S3DataStore) DataStore(org.apache.jackrabbit.core.data.DataStore) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) AzureDataStore(org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore) OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) File(java.io.File) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) CheckForNull(javax.annotation.CheckForNull)

Aggregations

DataStoreBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)9 OakFileDataStore (org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore)9 File (java.io.File)5 Properties (java.util.Properties)3 DataStore (org.apache.jackrabbit.core.data.DataStore)3 FileDataStore (org.apache.jackrabbit.core.data.FileDataStore)3 AzureDataStore (org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore)2 S3DataStore (org.apache.jackrabbit.oak.blob.cloud.s3.S3DataStore)2 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)2 Closer (com.google.common.io.Closer)1 IOException (java.io.IOException)1 Random (java.util.Random)1 CheckForNull (javax.annotation.CheckForNull)1 Nullable (javax.annotation.Nullable)1 OptionParser (joptsimple.OptionParser)1 OptionSet (joptsimple.OptionSet)1 OptionSpecBuilder (joptsimple.OptionSpecBuilder)1 InitialContent (org.apache.jackrabbit.oak.InitialContent)1 Oak (org.apache.jackrabbit.oak.Oak)1 BlobStoreStats (org.apache.jackrabbit.oak.plugins.blob.BlobStoreStats)1