Search in sources :

Example 1 with SharedS3DataStore

use of org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore in project jackrabbit-oak by apache.

the class DataStoreUtils method configureIfCloudDataStore.

public static DataStore configureIfCloudDataStore(String className, DataStore ds, Map<String, ?> config, String bucket, StatisticsProvider statisticsProvider) throws Exception {
    // Add bucket info
    Properties props = new Properties();
    props.putAll(config);
    log.info("Using bucket [ {} ]", bucket);
    if (isS3DataStore(className)) {
        props.setProperty(S3Constants.S3_BUCKET, bucket);
        // Set the props object
        if (S3.getName().equals(className)) {
            ((S3DataStore) ds).setProperties(props);
            ((S3DataStore) ds).setStatisticsProvider(statisticsProvider);
        } else if (JR2_S3.getName().equals(className)) {
            ((org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore) ds).setProperties(props);
        }
    } else if (isAzureDataStore(className)) {
        props.setProperty(AzureConstants.AZURE_BLOB_CONTAINER_NAME, bucket);
        ((AzureDataStore) ds).setProperties(props);
        ((AzureDataStore) ds).setStatisticsProvider(statisticsProvider);
    }
    return ds;
}
Also used : S3DataStore(org.apache.jackrabbit.oak.blob.cloud.s3.S3DataStore) SharedS3DataStore(org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore) Properties(java.util.Properties)

Example 2 with SharedS3DataStore

use of org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore in project jackrabbit-oak by apache.

the class AbstractS3DataStoreService method createDataStore.

@Override
protected DataStore createDataStore(ComponentContext context, Map<String, Object> config) {
    Properties properties = new Properties();
    properties.putAll(config);
    if (JR2_CACHING) {
        SharedS3DataStore dataStore = new SharedS3DataStore();
        dataStore.setProperties(properties);
        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put(Constants.SERVICE_PID, dataStore.getClass().getName());
        props.put(DESCRIPTION, getDescription());
        delegateReg = context.getBundleContext().registerService(new String[] { SharedS3DataStore.class.getName(), SharedS3DataStore.class.getName() }, dataStore, props);
        return dataStore;
    } else {
        S3DataStore dataStore = new S3DataStore();
        dataStore.setStatisticsProvider(getStatisticsProvider());
        dataStore.setProperties(properties);
        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put(Constants.SERVICE_PID, dataStore.getClass().getName());
        props.put(DESCRIPTION, getDescription());
        delegateReg = context.getBundleContext().registerService(new String[] { AbstractSharedCachingDataStore.class.getName(), AbstractSharedCachingDataStore.class.getName() }, dataStore, props);
        return dataStore;
    }
}
Also used : SharedS3DataStore(org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore) Hashtable(java.util.Hashtable) SharedS3DataStore(org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore) Properties(java.util.Properties)

Example 3 with SharedS3DataStore

use of org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore 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);
    OptionSet options = parser.parse(args);
    if (!options.has(s3dsConfig) && !options.has(fdsConfig) && !options.has(azureBlobDSConfig)) {
        return null;
    }
    DataStore delegate;
    if (options.has(s3dsConfig)) {
        SharedS3DataStore s3ds = new SharedS3DataStore();
        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 {
        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) DataStore(org.apache.jackrabbit.core.data.DataStore) AzureDataStore(org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore) SharedS3DataStore(org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore) OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) SharedS3DataStore(org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore) AzureDataStore(org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore) OptionSet(joptsimple.OptionSet) Properties(java.util.Properties) OptionParser(joptsimple.OptionParser) File(java.io.File) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) Nullable(javax.annotation.Nullable)

Example 4 with SharedS3DataStore

use of org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore 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) {
        SharedS3DataStore s3ds = new SharedS3DataStore();
        Properties props = loadAndTransformProps(bsopts.getS3ConfigPath());
        s3ds.setProperties(props);
        File homeDir = Files.createTempDir();
        closer.register(asCloseable(homeDir));
        s3ds.init(homeDir.getAbsolutePath());
        delegate = s3ds;
    } else if (bsType == Type.AZURE) {
        AzureDataStore azureds = new AzureDataStore();
        String cfgPath = bsopts.getAzureConfigPath();
        Properties props = loadAndTransformProps(cfgPath);
        azureds.setProperties(props);
        File homeDir = Files.createTempDir();
        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) SharedS3DataStore(org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore) AzureDataStore(org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore) Properties(java.util.Properties) Type(org.apache.jackrabbit.oak.run.cli.BlobStoreOptions.Type) AzureDataStore(org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore) DataStore(org.apache.jackrabbit.core.data.DataStore) SharedS3DataStore(org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) 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)

Example 5 with SharedS3DataStore

use of org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore in project jackrabbit-oak by apache.

the class S3DataStoreUtils method getS3DataStore.

public static DataStore getS3DataStore(String className, Properties props, String homeDir) throws Exception {
    DataStore ds = Class.forName(className).asSubclass(DataStore.class).newInstance();
    PropertiesUtil.populate(ds, Maps.fromProperties(props), false);
    // Set the props object
    if (S3.getName().equals(className)) {
        ((S3DataStore) ds).setProperties(props);
    } else if (JR2_S3.getName().equals(className)) {
        ((org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore) ds).setProperties(props);
    }
    ds.init(homeDir);
    return ds;
}
Also used : SharedS3DataStore(org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore) DataStore(org.apache.jackrabbit.core.data.DataStore) SharedS3DataStore(org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore)

Aggregations

SharedS3DataStore (org.apache.jackrabbit.oak.blob.cloud.aws.s3.SharedS3DataStore)5 Properties (java.util.Properties)4 DataStore (org.apache.jackrabbit.core.data.DataStore)3 File (java.io.File)2 AzureDataStore (org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore)2 DataStoreBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)2 OakFileDataStore (org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore)2 Closer (com.google.common.io.Closer)1 Hashtable (java.util.Hashtable)1 CheckForNull (javax.annotation.CheckForNull)1 Nullable (javax.annotation.Nullable)1 OptionParser (joptsimple.OptionParser)1 OptionSet (joptsimple.OptionSet)1 FileDataStore (org.apache.jackrabbit.core.data.FileDataStore)1 S3DataStore (org.apache.jackrabbit.oak.blob.cloud.s3.S3DataStore)1 Type (org.apache.jackrabbit.oak.run.cli.BlobStoreOptions.Type)1