use of com.aliyun.oss.model.DeleteObjectsRequest in project druid by druid-io.
the class OssDataSegmentKillerTest method test_killAll_recoverableExceptionWhenListingObjects_deletesAllSegments.
@Test
public void test_killAll_recoverableExceptionWhenListingObjects_deletesAllSegments() throws IOException {
OSSObjectSummary objectSummary1 = OssTestUtils.newOSSObjectSummary(TEST_BUCKET, KEY_1, TIME_0);
OssTestUtils.expectListObjects(client, PREFIX_URI, ImmutableList.of(objectSummary1));
DeleteObjectsRequest deleteRequest1 = new DeleteObjectsRequest(TEST_BUCKET);
deleteRequest1.setKeys(Collections.singletonList(KEY_1));
OssTestUtils.mockClientDeleteObjects(client, ImmutableList.of(deleteRequest1), ImmutableMap.of(deleteRequest1, RECOVERABLE_EXCEPTION));
EasyMock.expect(segmentPusherConfig.getBucket()).andReturn(TEST_BUCKET);
EasyMock.expectLastCall().anyTimes();
EasyMock.expect(segmentPusherConfig.getPrefix()).andReturn(TEST_PREFIX);
EasyMock.expectLastCall().anyTimes();
EasyMock.expect(inputDataConfig.getMaxListingLength()).andReturn(MAX_KEYS);
EasyMock.expectLastCall().anyTimes();
EasyMock.replay(client, segmentPusherConfig, inputDataConfig);
segmentKiller = new OssDataSegmentKiller(Suppliers.ofInstance(client), segmentPusherConfig, inputDataConfig);
segmentKiller.killAll();
EasyMock.verify(client, segmentPusherConfig, inputDataConfig);
}
use of com.aliyun.oss.model.DeleteObjectsRequest in project druid by druid-io.
the class OssTaskLogsTest method test_killAll_noException_deletesAllTaskLogs.
@Test
public void test_killAll_noException_deletesAllTaskLogs() throws IOException {
OSSObjectSummary objectSummary1 = OssTestUtils.newOSSObjectSummary(TEST_BUCKET, KEY_1, TIME_0);
OSSObjectSummary objectSummary2 = OssTestUtils.newOSSObjectSummary(TEST_BUCKET, KEY_2, TIME_1);
EasyMock.expect(timeSupplier.getAsLong()).andReturn(TIME_NOW);
OssTestUtils.expectListObjects(ossClient, PREFIX_URI, ImmutableList.of(objectSummary1, objectSummary2));
DeleteObjectsRequest deleteRequest1 = new DeleteObjectsRequest(TEST_BUCKET);
deleteRequest1.setKeys(Collections.singletonList(KEY_1));
DeleteObjectsRequest deleteRequest2 = new DeleteObjectsRequest(TEST_BUCKET);
deleteRequest2.setKeys(Collections.singletonList(KEY_2));
OssTestUtils.mockClientDeleteObjects(ossClient, ImmutableList.of(deleteRequest1, deleteRequest2), ImmutableMap.of());
EasyMock.replay(ossClient, timeSupplier);
OssTaskLogsConfig config = new OssTaskLogsConfig();
config.setBucket(TEST_BUCKET);
config.setPrefix(TEST_PREFIX);
OssInputDataConfig inputDataConfig = new OssInputDataConfig();
inputDataConfig.setMaxListingLength(MAX_KEYS);
OssTaskLogs taskLogs = new OssTaskLogs(ossClient, config, inputDataConfig, timeSupplier);
taskLogs.killAll();
EasyMock.verify(ossClient, timeSupplier);
}
use of com.aliyun.oss.model.DeleteObjectsRequest in project druid by druid-io.
the class OssTaskLogsTest method test_killOlderThan_nonrecoverableExceptionWhenListingObjects_doesntDeleteAnyTaskLogs.
@Test
public void test_killOlderThan_nonrecoverableExceptionWhenListingObjects_doesntDeleteAnyTaskLogs() {
boolean ioExceptionThrown = false;
try {
OSSObjectSummary objectSummary1 = OssTestUtils.newOSSObjectSummary(TEST_BUCKET, KEY_1, TIME_0);
OssTestUtils.expectListObjects(ossClient, PREFIX_URI, ImmutableList.of(objectSummary1));
DeleteObjectsRequest deleteRequest1 = new DeleteObjectsRequest(TEST_BUCKET);
deleteRequest1.setKeys(Collections.singletonList(KEY_1));
OssTestUtils.mockClientDeleteObjects(ossClient, ImmutableList.of(), ImmutableMap.of(deleteRequest1, NON_RECOVERABLE_EXCEPTION));
EasyMock.replay(ossClient, timeSupplier);
OssTaskLogsConfig config = new OssTaskLogsConfig();
config.setBucket(TEST_BUCKET);
config.setPrefix(TEST_PREFIX);
OssInputDataConfig inputDataConfig = new OssInputDataConfig();
inputDataConfig.setMaxListingLength(MAX_KEYS);
OssTaskLogs taskLogs = new OssTaskLogs(ossClient, config, inputDataConfig, timeSupplier);
taskLogs.killOlderThan(TIME_NOW);
} catch (IOException e) {
ioExceptionThrown = true;
}
Assert.assertTrue(ioExceptionThrown);
EasyMock.verify(ossClient, timeSupplier);
}
Aggregations