Search in sources :

Example 1 with DummyDataStore

use of org.apache.jackrabbit.oak.run.cli.DummyDataStore 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)

Aggregations

File (java.io.File)1 Properties (java.util.Properties)1 Nullable (javax.annotation.Nullable)1 OptionParser (joptsimple.OptionParser)1 OptionSet (joptsimple.OptionSet)1 OptionSpecBuilder (joptsimple.OptionSpecBuilder)1 DataStore (org.apache.jackrabbit.core.data.DataStore)1 AzureDataStore (org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore)1 S3DataStore (org.apache.jackrabbit.oak.blob.cloud.s3.S3DataStore)1 DataStoreBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)1 OakFileDataStore (org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore)1 DummyDataStore (org.apache.jackrabbit.oak.run.cli.DummyDataStore)1