Search in sources :

Example 1 with S3Storage

use of org.apache.airavata.datalake.drms.storage.s3.S3Storage in project front by artipie.

the class YamlStorage method storage.

/**
 * Provides a storage.
 *
 * @return Storage instance.
 */
public Storage storage() {
    @SuppressWarnings("deprecation") final YamlMapping strict = new StrictYamlMapping(this.yaml);
    final String type = strict.string("type");
    final Storage storage;
    if ("fs".equals(type)) {
        storage = new FileStorage(Path.of(strict.string("path")));
    } else if ("s3".equals(type)) {
        storage = new S3Storage(this.s3Client(), strict.string("bucket"), !"false".equals(this.yaml.string("multipart")));
    } else if ("etcd".equals(type)) {
        storage = new EtcdStorage(YamlStorage.etcdClient(strict.yamlMapping("connection")));
    } else {
        throw new IllegalStateException(String.format("Unsupported storage type: '%s'", type));
    }
    return storage;
}
Also used : StrictYamlMapping(com.amihaiemil.eoyaml.StrictYamlMapping) EtcdStorage(com.artipie.asto.etcd.EtcdStorage) Storage(com.artipie.asto.Storage) FileStorage(com.artipie.asto.fs.FileStorage) S3Storage(com.artipie.asto.s3.S3Storage) FileStorage(com.artipie.asto.fs.FileStorage) YamlMapping(com.amihaiemil.eoyaml.YamlMapping) StrictYamlMapping(com.amihaiemil.eoyaml.StrictYamlMapping) EtcdStorage(com.artipie.asto.etcd.EtcdStorage) S3Storage(com.artipie.asto.s3.S3Storage)

Example 2 with S3Storage

use of org.apache.airavata.datalake.drms.storage.s3.S3Storage in project airavata-data-lake by apache.

the class AnyStorageSerializer method serializeToMap.

public static Map<String, Object> serializeToMap(AnyStorage anyStorage) {
    Map<String, Object> fields = new HashMap<>();
    Map<Descriptors.FieldDescriptor, Object> allFields = null;
    switch(anyStorage.getStorageCase()) {
        case SSH_STORAGE:
            SSHStorage sshStorage = anyStorage.getSshStorage();
            allFields = sshStorage.getAllFields();
            fields.put(StorageConstants.STORAGE_TYPE_LABEL, StorageConstants.SSH_STORAGE_TYPE_LABEL);
            break;
        case S3_STORAGE:
            S3Storage s3Storage = anyStorage.getS3Storage();
            allFields = s3Storage.getAllFields();
            fields.put(StorageConstants.STORAGE_TYPE_LABEL, StorageConstants.S3_STORAGE_TYPE_LABEL);
            break;
        case STORAGE_NOT_SET:
            break;
    }
    if (allFields != null) {
        allFields.forEach((descriptor, value) -> {
            String fieldName = descriptor.getJsonName();
            fields.put(fieldName, value);
        });
    }
    return fields;
}
Also used : HashMap(java.util.HashMap) SSHStorage(org.apache.airavata.datalake.drms.storage.ssh.SSHStorage) S3Storage(org.apache.airavata.datalake.drms.storage.s3.S3Storage)

Example 3 with S3Storage

use of org.apache.airavata.datalake.drms.storage.s3.S3Storage in project artipie by artipie.

the class YamlStorage method storage.

/**
 * Provides a storage.
 *
 * @return Storage instance.
 */
public Storage storage() {
    @SuppressWarnings("deprecation") final YamlMapping strict = new StrictYamlMapping(this.yaml);
    final String type = strict.string("type");
    final Storage storage;
    if ("fs".equals(type)) {
        storage = new FileStorage(Path.of(strict.string("path")));
    } else if ("s3".equals(type)) {
        storage = new S3Storage(this.s3Client(), strict.string("bucket"), !"false".equals(this.yaml.string("multipart")));
    } else if ("etcd".equals(type)) {
        storage = new EtcdStorage(YamlStorage.etcdClient(strict.yamlMapping("connection")));
    } else {
        throw new IllegalStateException(String.format("Unsupported storage type: '%s'", type));
    }
    return storage;
}
Also used : StrictYamlMapping(com.amihaiemil.eoyaml.StrictYamlMapping) EtcdStorage(com.artipie.asto.etcd.EtcdStorage) Storage(com.artipie.asto.Storage) FileStorage(com.artipie.asto.fs.FileStorage) S3Storage(com.artipie.asto.s3.S3Storage) FileStorage(com.artipie.asto.fs.FileStorage) YamlMapping(com.amihaiemil.eoyaml.YamlMapping) StrictYamlMapping(com.amihaiemil.eoyaml.StrictYamlMapping) EtcdStorage(com.artipie.asto.etcd.EtcdStorage) S3Storage(com.artipie.asto.s3.S3Storage)

Aggregations

StrictYamlMapping (com.amihaiemil.eoyaml.StrictYamlMapping)2 YamlMapping (com.amihaiemil.eoyaml.YamlMapping)2 Storage (com.artipie.asto.Storage)2 EtcdStorage (com.artipie.asto.etcd.EtcdStorage)2 FileStorage (com.artipie.asto.fs.FileStorage)2 S3Storage (com.artipie.asto.s3.S3Storage)2 HashMap (java.util.HashMap)1 S3Storage (org.apache.airavata.datalake.drms.storage.s3.S3Storage)1 SSHStorage (org.apache.airavata.datalake.drms.storage.ssh.SSHStorage)1