com.emc.object.s3.S3Config Java Examples

The following examples show how to use com.emc.object.s3.S3Config. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtendedS3StorageTest.java    From pravega with Apache License 2.0 6 votes vote down vote up
TestContext() throws Exception {
    String bucketName = BUCKET_NAME_PREFIX + UUID.randomUUID().toString();
    this.adapterConfig = ExtendedS3StorageConfig.builder()
            .with(ExtendedS3StorageConfig.CONFIGURI, configUri)
            .with(ExtendedS3StorageConfig.BUCKET, bucketName)
            .with(ExtendedS3StorageConfig.PREFIX, "samplePrefix")
            .build();
    s3Config = new ConfigUri<>(S3Config.class).parseUri(configUri);
    s3Proxy = new S3ProxyImpl(configUri, s3Config);
    s3Proxy.start();
    client = new S3JerseyClientWrapper(s3Config, s3Proxy);
    client.createBucket(bucketName);
    List<ObjectKey> keys = client.listObjects(bucketName).getObjects().stream()
            .map(object -> new ObjectKey(object.getKey()))
            .collect(Collectors.toList());

    if (!keys.isEmpty()) {
        client.deleteObjects(new DeleteObjectsRequest(bucketName).withKeys(keys));
    }
}
 
Example #2
Source File: S3ProxyImpl.java    From pravega with Apache License 2.0 6 votes vote down vote up
public S3ProxyImpl(String endpoint, S3Config s3Config) {
    URI uri = URI.create(endpoint);

    Properties properties = new Properties();
    properties.setProperty("s3proxy.authorization", "none");
    properties.setProperty("s3proxy.endpoint", endpoint);
    properties.setProperty("jclouds.provider", "filesystem");
    properties.setProperty("jclouds.filesystem.basedir", "/tmp/s3proxy");

    ContextBuilder builder = ContextBuilder
            .newBuilder("filesystem")
            .credentials("x", "x")
            .modules(ImmutableList.<Module>of(new SLF4JLoggingModule()))
            .overrides(properties);
    BlobStoreContext context = builder.build(BlobStoreContext.class);
    BlobStore blobStore = context.getBlobStore();
    s3Proxy = S3Proxy.builder().awsAuthentication(AuthenticationType.AWS_V2_OR_V4, "x", "x")
                     .endpoint(uri)
                     .keyStore("", "")
                     .blobStore(blobStore)
                     .ignoreUnknownHeaders(true)
                     .build();
    client = new S3JerseyCopyPartClient(s3Config);
}
 
Example #3
Source File: ServiceInstanceBindingRepository.java    From ecs-cf-service-broker with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void initialize() throws EcsManagementClientException,
        EcsManagementResourceNotFoundException, URISyntaxException {
    S3Config s3Config = new S3Config(
            new URI(broker.getRepositoryEndpoint()));
    s3Config.withIdentity(broker.getPrefixedUserName())
            .withSecretKey(broker.getRepositorySecret());
    this.s3 = new S3JerseyClient(s3Config);
    this.bucket = broker.getPrefixedBucketName();

    // NOTE -- ideally we would not need this code, but for now, the VolumeMount class has
    // custom serialization that is not matched with corresponding deserialization, so
    // deserializing serialized volume mounts doesn't work OOTB.
    SimpleModule module = new SimpleModule();
    module.addDeserializer(VolumeMount.DeviceType.class, new DeviceTypeDeserializer());
    module.addDeserializer(VolumeMount.Mode.class, new ModeDeserializer());
    module.addDeserializer(VolumeDevice.class, new VolumeDeviceDeserializer());
    objectMapper.registerModule(module);
}
 
Example #4
Source File: ExtendedS3IntegrationTest.java    From pravega with Apache License 2.0 5 votes vote down vote up
@Override
public Storage createStorageAdapter() {
    URI uri = URI.create(s3ConfigUri);
    S3Config s3Config = new S3Config(uri);

    s3Config = s3Config
            .withRetryEnabled(false)
            .withInitialRetryDelay(1)
            .withProperty("com.sun.jersey.client.property.connectTimeout", 100);

    S3JerseyClient client = new S3ClientWrapper(s3Config, filesystemS3);
    return new AsyncStorageWrapper(new RollingStorage(new ExtendedS3Storage(client, config)), this.storageExecutor);
}
 
Example #5
Source File: ExtendedS3StorageConfig.java    From pravega with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of the ExtendedS3StorageConfig class.
 *
 * @param properties The TypedProperties object to read Properties from.
 */
private ExtendedS3StorageConfig(TypedProperties properties) throws ConfigurationException {
    ConfigUri<S3Config> s3ConfigUri = new ConfigUri<S3Config>(S3Config.class);
    this.s3Config = Preconditions.checkNotNull(s3ConfigUri.parseUri(properties.get(CONFIGURI)), "configUri");
    this.accessKey = Preconditions.checkNotNull(s3Config.getIdentity(), "identity");
    this.secretKey = Preconditions.checkNotNull(s3Config.getSecretKey(), "secretKey");
    this.bucket = Preconditions.checkNotNull(properties.get(BUCKET), "bucket");
    String givenPrefix = Preconditions.checkNotNull(properties.get(PREFIX), "prefix");
    this.prefix = givenPrefix.endsWith(PATH_SEPARATOR) ? givenPrefix : givenPrefix + PATH_SEPARATOR;
    this.useNoneMatch = properties.getBoolean(USENONEMATCH);
    this.smallObjectSizeLimitForConcat = properties.getInt(SMALL_OBJECT_THRESHOLD);
}
 
Example #6
Source File: BucketWipeFactory.java    From ecs-cf-service-broker with Apache License 2.0 5 votes vote down vote up
public BucketWipeOperations getBucketWipe(BrokerConfig broker) throws URISyntaxException {
    S3Config s3Config = new S3Config(new URI(broker.getRepositoryEndpoint()));
    s3Config.withIdentity(broker.getPrefixedUserName())
        .withSecretKey(broker.getRepositorySecret());

    return new BucketWipeOperations(new S3JerseyClient(s3Config));
}
 
Example #7
Source File: S3ClientWrapper.java    From pravega with Apache License 2.0 4 votes vote down vote up
public S3ClientWrapper(S3Config s3Config, S3ImplBase s3Impl) {
    super(s3Config);
    this.s3Impl = s3Impl;
}
 
Example #8
Source File: S3JerseyClientWrapper.java    From pravega with Apache License 2.0 4 votes vote down vote up
public S3JerseyClientWrapper(S3Config s3Config, S3ImplBase proxy) {
    super(s3Config);
    this.proxy = proxy;
}
 
Example #9
Source File: S3ProxyImpl.java    From pravega with Apache License 2.0 4 votes vote down vote up
public S3JerseyCopyPartClient(S3Config s3Config) {
    super(s3Config);
}
 
Example #10
Source File: ServiceInstanceRepository.java    From ecs-cf-service-broker with Apache License 2.0 4 votes vote down vote up
@PostConstruct
public void initialize() throws URISyntaxException {
    logger.info(format("Creating S3 config with repository endpoint %s", broker.getRepositoryEndpoint()));

    S3Config s3Config = new S3Config(new URI(broker.getRepositoryEndpoint()));

    logger.debug(format("Created S3 config %s", s3Config));

    s3Config.withIdentity(broker.getPrefixedUserName()).withSecretKey(broker.getRepositorySecret());

    this.s3 = new S3JerseyClient(s3Config, new URLConnectionClientHandler());

    logger.debug(format("JerseyClient S3 config %s", this.s3.getS3Config()));

    this.bucket = broker.getPrefixedBucketName();

    logger.info("Service repository bucket name: {}", this.bucket);
}