use of org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore 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;
}
use of org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.AzureDataStore 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());
}
Aggregations