Search in sources :

Example 1 with CreateBucketResponse

use of software.amazon.awssdk.services.s3.model.CreateBucketResponse in project edison-microservice by otto-de.

the class S3TogglzRepositoryIntegrationTest method setup.

@BeforeEach
void setup() throws InterruptedException {
    // final Integer mappedPort = localstackContainer.getMappedPort(TEST_PORT_S3);
    s3Client = new LocalS3Client();
    testBucket = "test-togglz" + UUID.randomUUID().toString();
    final CreateBucketRequest createBucketRequest = CreateBucketRequest.builder().bucket(testBucket).acl(BucketCannedACL.PUBLIC_READ_WRITE).build();
    CreateBucketResponse bucket = s3Client.createBucket(createBucketRequest);
    togglzProperties = new TogglzProperties();
    togglzProperties.getS3().setBucketName(testBucket);
    featureStateConverter = new FeatureStateConverter(s3Client, togglzProperties);
    repository = new S3TogglzRepository(featureStateConverter);
}
Also used : LocalS3Client(de.otto.edison.togglz.s3.testsupport.LocalS3Client) CreateBucketResponse(software.amazon.awssdk.services.s3.model.CreateBucketResponse) CreateBucketRequest(software.amazon.awssdk.services.s3.model.CreateBucketRequest) TogglzProperties(de.otto.edison.togglz.configuration.TogglzProperties) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with CreateBucketResponse

use of software.amazon.awssdk.services.s3.model.CreateBucketResponse in project newrelic-java-agent by newrelic.

the class S3AsyncClient_Instrumentation method createBucket.

public CompletableFuture<CreateBucketResponse> createBucket(CreateBucketRequest createBucketRequest) {
    String uri = "s3://" + createBucketRequest.bucket();
    Segment segment = NewRelic.getAgent().getTransaction().startSegment("S3", "createBucket");
    AgentBridge.getAgent().getTracedMethod().setTrackChildThreads(false);
    CompletableFuture<CreateBucketResponse> result = Weaver.callOriginal();
    return result.whenComplete(new S3ResponseResultWrapper<>(segment, uri, "createBucket"));
}
Also used : CreateBucketResponse(software.amazon.awssdk.services.s3.model.CreateBucketResponse) Segment(com.newrelic.api.agent.Segment)

Example 3 with CreateBucketResponse

use of software.amazon.awssdk.services.s3.model.CreateBucketResponse in project newrelic-java-agent by newrelic.

the class S3Client_Instrumentation method createBucket.

@Trace
public CreateBucketResponse createBucket(CreateBucketRequest createBucketRequest) {
    String uri = "s3://" + createBucketRequest.bucket();
    try {
        CreateBucketResponse createBucketResponse = Weaver.callOriginal();
        S3MetricUtil.reportExternalMetrics(NewRelic.getAgent().getTracedMethod(), uri, createBucketResponse, "createBucket");
        return createBucketResponse;
    } catch (Exception e) {
        S3MetricUtil.reportExternalMetrics(NewRelic.getAgent().getTracedMethod(), uri, "createBucket");
        throw e;
    }
}
Also used : CreateBucketResponse(software.amazon.awssdk.services.s3.model.CreateBucketResponse) NoSuchKeyException(software.amazon.awssdk.services.s3.model.NoSuchKeyException) S3Exception(software.amazon.awssdk.services.s3.model.S3Exception) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) SdkClientException(software.amazon.awssdk.core.exception.SdkClientException) Trace(com.newrelic.api.agent.Trace)

Example 4 with CreateBucketResponse

use of software.amazon.awssdk.services.s3.model.CreateBucketResponse in project aws-sdk-java-v2 by aws.

the class S3TestRunner method runTests.

@Override
public void runTests() {
    logger.info("starting to run S3 tests");
    CreateBucketResponse bucketResponse = null;
    try {
        bucketResponse = s3UrlConnectionHttpClient.createBucket(b -> b.bucket(BUCKET_NAME));
        s3UrlConnectionHttpClient.waiter().waitUntilBucketExists(b -> b.bucket(BUCKET_NAME));
        RequestBody requestBody = RequestBody.fromBytes("helloworld".getBytes(StandardCharsets.UTF_8));
        s3ApacheHttpClient.putObject(b -> b.bucket(BUCKET_NAME).key(KEY), requestBody);
        s3NettyClient.getObject(b -> b.bucket(BUCKET_NAME).key(KEY), AsyncResponseTransformer.toBytes()).join();
    } finally {
        if (bucketResponse != null) {
            s3NettyClient.deleteObject(b -> b.bucket(BUCKET_NAME).key(KEY)).join();
            s3NettyClient.deleteBucket(b -> b.bucket(BUCKET_NAME)).join();
        }
    }
}
Also used : Logger(org.slf4j.Logger) S3AsyncClient(software.amazon.awssdk.services.s3.S3AsyncClient) S3Client(software.amazon.awssdk.services.s3.S3Client) LoggerFactory(org.slf4j.LoggerFactory) RequestBody(software.amazon.awssdk.core.sync.RequestBody) AsyncResponseTransformer(software.amazon.awssdk.core.async.AsyncResponseTransformer) CreateBucketResponse(software.amazon.awssdk.services.s3.model.CreateBucketResponse) UUID(java.util.UUID) StandardCharsets(java.nio.charset.StandardCharsets) CreateBucketResponse(software.amazon.awssdk.services.s3.model.CreateBucketResponse) RequestBody(software.amazon.awssdk.core.sync.RequestBody)

Aggregations

CreateBucketResponse (software.amazon.awssdk.services.s3.model.CreateBucketResponse)4 Segment (com.newrelic.api.agent.Segment)1 Trace (com.newrelic.api.agent.Trace)1 TogglzProperties (de.otto.edison.togglz.configuration.TogglzProperties)1 LocalS3Client (de.otto.edison.togglz.s3.testsupport.LocalS3Client)1 StandardCharsets (java.nio.charset.StandardCharsets)1 UUID (java.util.UUID)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 AwsServiceException (software.amazon.awssdk.awscore.exception.AwsServiceException)1 AsyncResponseTransformer (software.amazon.awssdk.core.async.AsyncResponseTransformer)1 SdkClientException (software.amazon.awssdk.core.exception.SdkClientException)1 RequestBody (software.amazon.awssdk.core.sync.RequestBody)1 S3AsyncClient (software.amazon.awssdk.services.s3.S3AsyncClient)1 S3Client (software.amazon.awssdk.services.s3.S3Client)1 CreateBucketRequest (software.amazon.awssdk.services.s3.model.CreateBucketRequest)1 NoSuchKeyException (software.amazon.awssdk.services.s3.model.NoSuchKeyException)1 S3Exception (software.amazon.awssdk.services.s3.model.S3Exception)1