Search in sources :

Example 11 with DeleteObjectsRequest

use of software.amazon.awssdk.services.s3.model.DeleteObjectsRequest in project druid by druid-io.

the class S3DataSegmentKillerTest method test_killAll_noException_deletesAllSegments.

@Test
public void test_killAll_noException_deletesAllSegments() throws IOException {
    S3ObjectSummary objectSummary1 = S3TestUtils.newS3ObjectSummary(TEST_BUCKET, KEY_1, TIME_0);
    S3ObjectSummary objectSummary2 = S3TestUtils.newS3ObjectSummary(TEST_BUCKET, KEY_2, TIME_1);
    S3TestUtils.expectListObjects(s3Client, PREFIX_URI, ImmutableList.of(objectSummary1, objectSummary2));
    DeleteObjectsRequest deleteRequest1 = new DeleteObjectsRequest(TEST_BUCKET).withBucketName(TEST_BUCKET).withKeys(ImmutableList.of(new DeleteObjectsRequest.KeyVersion(KEY_1)));
    DeleteObjectsRequest deleteRequest2 = new DeleteObjectsRequest(TEST_BUCKET).withBucketName(TEST_BUCKET).withKeys(ImmutableList.of(new DeleteObjectsRequest.KeyVersion(KEY_2)));
    S3TestUtils.mockS3ClientDeleteObjects(s3Client, ImmutableList.of(deleteRequest1, deleteRequest2), ImmutableMap.of());
    EasyMock.expect(segmentPusherConfig.getBucket()).andReturn(TEST_BUCKET);
    EasyMock.expectLastCall().anyTimes();
    EasyMock.expect(segmentPusherConfig.getBaseKey()).andReturn(TEST_PREFIX);
    EasyMock.expectLastCall().anyTimes();
    EasyMock.expect(inputDataConfig.getMaxListingLength()).andReturn(MAX_KEYS);
    EasyMock.expectLastCall().anyTimes();
    EasyMock.replay(s3Client, segmentPusherConfig, inputDataConfig);
    segmentKiller = new S3DataSegmentKiller(Suppliers.ofInstance(s3Client), segmentPusherConfig, inputDataConfig);
    segmentKiller.killAll();
    EasyMock.verify(s3Client, segmentPusherConfig, inputDataConfig);
}
Also used : S3ObjectSummary(com.amazonaws.services.s3.model.S3ObjectSummary) DeleteObjectsRequest(com.amazonaws.services.s3.model.DeleteObjectsRequest) Test(org.junit.Test)

Example 12 with DeleteObjectsRequest

use of software.amazon.awssdk.services.s3.model.DeleteObjectsRequest in project druid by druid-io.

the class S3TaskLogsTest method test_killAll_nonrecoverableExceptionWhenListingObjects_doesntDeleteAnyTaskLogs.

@Test
public void test_killAll_nonrecoverableExceptionWhenListingObjects_doesntDeleteAnyTaskLogs() {
    boolean ioExceptionThrown = false;
    try {
        S3ObjectSummary objectSummary1 = S3TestUtils.newS3ObjectSummary(TEST_BUCKET, KEY_1, TIME_0);
        EasyMock.expect(timeSupplier.getAsLong()).andReturn(TIME_NOW);
        S3TestUtils.expectListObjects(s3Client, PREFIX_URI, ImmutableList.of(objectSummary1));
        DeleteObjectsRequest deleteRequest1 = new DeleteObjectsRequest(TEST_BUCKET).withBucketName(TEST_BUCKET).withKeys(ImmutableList.of(new DeleteObjectsRequest.KeyVersion(KEY_1)));
        S3TestUtils.mockS3ClientDeleteObjects(s3Client, ImmutableList.of(), ImmutableMap.of(deleteRequest1, NON_RECOVERABLE_EXCEPTION));
        EasyMock.replay(s3Client, timeSupplier);
        S3TaskLogsConfig config = new S3TaskLogsConfig();
        config.setS3Bucket(TEST_BUCKET);
        config.setS3Prefix(TEST_PREFIX);
        S3InputDataConfig inputDataConfig = new S3InputDataConfig();
        inputDataConfig.setMaxListingLength(MAX_KEYS);
        S3TaskLogs s3TaskLogs = new S3TaskLogs(s3Client, config, inputDataConfig, timeSupplier);
        s3TaskLogs.killAll();
    } catch (IOException e) {
        ioExceptionThrown = true;
    }
    Assert.assertTrue(ioExceptionThrown);
    EasyMock.verify(s3Client, timeSupplier);
}
Also used : S3ObjectSummary(com.amazonaws.services.s3.model.S3ObjectSummary) IOException(java.io.IOException) DeleteObjectsRequest(com.amazonaws.services.s3.model.DeleteObjectsRequest) Test(org.junit.Test)

Example 13 with DeleteObjectsRequest

use of software.amazon.awssdk.services.s3.model.DeleteObjectsRequest in project druid by druid-io.

the class S3TaskLogsTest method test_killOlderThan_noException_deletesOnlyTaskLogsOlderThan.

@Test
public void test_killOlderThan_noException_deletesOnlyTaskLogsOlderThan() throws IOException {
    S3ObjectSummary objectSummary1 = S3TestUtils.newS3ObjectSummary(TEST_BUCKET, KEY_1, TIME_0);
    S3ObjectSummary objectSummary2 = S3TestUtils.newS3ObjectSummary(TEST_BUCKET, KEY_2, TIME_FUTURE);
    S3TestUtils.expectListObjects(s3Client, PREFIX_URI, ImmutableList.of(objectSummary1, objectSummary2));
    DeleteObjectsRequest deleteRequest1 = new DeleteObjectsRequest(TEST_BUCKET).withBucketName(TEST_BUCKET).withKeys(ImmutableList.of(new DeleteObjectsRequest.KeyVersion(KEY_1)));
    S3TestUtils.mockS3ClientDeleteObjects(s3Client, ImmutableList.of(deleteRequest1), ImmutableMap.of());
    EasyMock.replay(s3Client, timeSupplier);
    S3TaskLogsConfig config = new S3TaskLogsConfig();
    config.setS3Bucket(TEST_BUCKET);
    config.setS3Prefix(TEST_PREFIX);
    S3InputDataConfig inputDataConfig = new S3InputDataConfig();
    inputDataConfig.setMaxListingLength(MAX_KEYS);
    S3TaskLogs s3TaskLogs = new S3TaskLogs(s3Client, config, inputDataConfig, timeSupplier);
    s3TaskLogs.killOlderThan(TIME_NOW);
    EasyMock.verify(s3Client, timeSupplier);
}
Also used : S3ObjectSummary(com.amazonaws.services.s3.model.S3ObjectSummary) DeleteObjectsRequest(com.amazonaws.services.s3.model.DeleteObjectsRequest) Test(org.junit.Test)

Example 14 with DeleteObjectsRequest

use of software.amazon.awssdk.services.s3.model.DeleteObjectsRequest in project druid by druid-io.

the class S3TaskLogsTest method test_killAll_recoverableExceptionWhenDeletingObjects_deletesAllTaskLogs.

@Test
public void test_killAll_recoverableExceptionWhenDeletingObjects_deletesAllTaskLogs() throws IOException {
    S3ObjectSummary objectSummary1 = S3TestUtils.newS3ObjectSummary(TEST_BUCKET, KEY_1, TIME_0);
    EasyMock.expect(timeSupplier.getAsLong()).andReturn(TIME_NOW);
    S3TestUtils.expectListObjects(s3Client, PREFIX_URI, ImmutableList.of(objectSummary1));
    DeleteObjectsRequest deleteRequest1 = new DeleteObjectsRequest(TEST_BUCKET).withBucketName(TEST_BUCKET).withKeys(ImmutableList.of(new DeleteObjectsRequest.KeyVersion(KEY_1)));
    S3TestUtils.mockS3ClientDeleteObjects(s3Client, ImmutableList.of(deleteRequest1), ImmutableMap.of(deleteRequest1, RECOVERABLE_EXCEPTION));
    EasyMock.replay(s3Client, timeSupplier);
    S3TaskLogsConfig config = new S3TaskLogsConfig();
    config.setS3Bucket(TEST_BUCKET);
    config.setS3Prefix(TEST_PREFIX);
    S3InputDataConfig inputDataConfig = new S3InputDataConfig();
    inputDataConfig.setMaxListingLength(MAX_KEYS);
    S3TaskLogs s3TaskLogs = new S3TaskLogs(s3Client, config, inputDataConfig, timeSupplier);
    s3TaskLogs.killAll();
    EasyMock.verify(s3Client, timeSupplier);
}
Also used : S3ObjectSummary(com.amazonaws.services.s3.model.S3ObjectSummary) DeleteObjectsRequest(com.amazonaws.services.s3.model.DeleteObjectsRequest) Test(org.junit.Test)

Example 15 with DeleteObjectsRequest

use of software.amazon.awssdk.services.s3.model.DeleteObjectsRequest in project druid by druid-io.

the class S3TaskLogsTest method test_killOlderThan_nonrecoverableExceptionWhenListingObjects_doesntDeleteAnyTaskLogs.

@Test
public void test_killOlderThan_nonrecoverableExceptionWhenListingObjects_doesntDeleteAnyTaskLogs() {
    boolean ioExceptionThrown = false;
    try {
        S3ObjectSummary objectSummary1 = S3TestUtils.newS3ObjectSummary(TEST_BUCKET, KEY_1, TIME_0);
        S3TestUtils.expectListObjects(s3Client, PREFIX_URI, ImmutableList.of(objectSummary1));
        DeleteObjectsRequest deleteRequest1 = new DeleteObjectsRequest(TEST_BUCKET).withBucketName(TEST_BUCKET).withKeys(ImmutableList.of(new DeleteObjectsRequest.KeyVersion(KEY_1)));
        S3TestUtils.mockS3ClientDeleteObjects(s3Client, ImmutableList.of(), ImmutableMap.of(deleteRequest1, NON_RECOVERABLE_EXCEPTION));
        EasyMock.replay(s3Client, timeSupplier);
        S3TaskLogsConfig config = new S3TaskLogsConfig();
        config.setS3Bucket(TEST_BUCKET);
        config.setS3Prefix(TEST_PREFIX);
        S3InputDataConfig inputDataConfig = new S3InputDataConfig();
        inputDataConfig.setMaxListingLength(MAX_KEYS);
        S3TaskLogs s3TaskLogs = new S3TaskLogs(s3Client, config, inputDataConfig, timeSupplier);
        s3TaskLogs.killOlderThan(TIME_NOW);
    } catch (IOException e) {
        ioExceptionThrown = true;
    }
    Assert.assertTrue(ioExceptionThrown);
    EasyMock.verify(s3Client, timeSupplier);
}
Also used : S3ObjectSummary(com.amazonaws.services.s3.model.S3ObjectSummary) IOException(java.io.IOException) DeleteObjectsRequest(com.amazonaws.services.s3.model.DeleteObjectsRequest) Test(org.junit.Test)

Aggregations

DeleteObjectsRequest (com.amazonaws.services.s3.model.DeleteObjectsRequest)39 ArrayList (java.util.ArrayList)26 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)24 ObjectListing (com.amazonaws.services.s3.model.ObjectListing)15 DeleteObjectsResult (com.amazonaws.services.s3.model.DeleteObjectsResult)14 IOException (java.io.IOException)10 Test (org.junit.Test)10 KeyVersion (com.amazonaws.services.s3.model.DeleteObjectsRequest.KeyVersion)9 AmazonClientException (com.amazonaws.AmazonClientException)8 AmazonS3 (com.amazonaws.services.s3.AmazonS3)5 MultiObjectDeleteException (com.amazonaws.services.s3.model.MultiObjectDeleteException)5 ListObjectsRequest (com.amazonaws.services.s3.model.ListObjectsRequest)4 DeleteObjectsRequest (software.amazon.awssdk.services.s3.model.DeleteObjectsRequest)4 ObjectIdentifier (software.amazon.awssdk.services.s3.model.ObjectIdentifier)4 AmazonServiceException (com.amazonaws.AmazonServiceException)3 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)3 TransferManager (com.amazonaws.services.s3.transfer.TransferManager)3 ExecutorService (java.util.concurrent.ExecutorService)3 NamedThreadFactory (org.apache.jackrabbit.core.data.util.NamedThreadFactory)3 S3Exception (software.amazon.awssdk.services.s3.model.S3Exception)3