use of org.apache.druid.storage.azure.blob.CloudBlobHolder in project druid by druid-io.
the class AzureTaskLogsTest method test_killAll_noException_deletesAllTaskLogs.
@Test
public void test_killAll_noException_deletesAllTaskLogs() throws Exception {
EasyMock.expect(inputDataConfig.getMaxListingLength()).andReturn(MAX_KEYS);
EasyMock.expect(accountConfig.getMaxTries()).andReturn(MAX_TRIES).atLeastOnce();
EasyMock.expect(timeSupplier.getAsLong()).andReturn(TIME_NOW);
CloudBlobHolder object1 = AzureTestUtils.newCloudBlobHolder(CONTAINER, KEY_1, TIME_0);
CloudBlobHolder object2 = AzureTestUtils.newCloudBlobHolder(CONTAINER, KEY_2, TIME_1);
AzureCloudBlobIterable azureCloudBlobIterable = AzureTestUtils.expectListObjects(azureCloudBlobIterableFactory, MAX_KEYS, PREFIX_URI, ImmutableList.of(object1, object2));
EasyMock.replay(object1, object2);
AzureTestUtils.expectDeleteObjects(azureStorage, ImmutableList.of(object1, object2), ImmutableMap.of());
EasyMock.replay(inputDataConfig, accountConfig, timeSupplier, azureCloudBlobIterable, azureCloudBlobIterableFactory, azureStorage);
azureTaskLogs.killAll();
EasyMock.verify(inputDataConfig, accountConfig, timeSupplier, object1, object2, azureCloudBlobIterable, azureCloudBlobIterableFactory, azureStorage);
}
use of org.apache.druid.storage.azure.blob.CloudBlobHolder in project druid by druid-io.
the class AzureTestUtils method expectDeleteObjects.
public static void expectDeleteObjects(AzureStorage storage, List<CloudBlobHolder> deleteRequestsExpected, Map<CloudBlobHolder, Exception> deleteRequestToException) throws Exception {
Map<CloudBlobHolder, IExpectationSetters<CloudBlobHolder>> requestToResultExpectationSetter = new HashMap<>();
for (Map.Entry<CloudBlobHolder, Exception> requestsAndErrors : deleteRequestToException.entrySet()) {
CloudBlobHolder deleteObject = requestsAndErrors.getKey();
Exception exception = requestsAndErrors.getValue();
IExpectationSetters<CloudBlobHolder> resultExpectationSetter = requestToResultExpectationSetter.get(deleteObject);
if (resultExpectationSetter == null) {
storage.emptyCloudBlobDirectory(deleteObject.getContainerName(), deleteObject.getName());
resultExpectationSetter = EasyMock.<CloudBlobHolder>expectLastCall().andThrow(exception);
requestToResultExpectationSetter.put(deleteObject, resultExpectationSetter);
} else {
resultExpectationSetter.andThrow(exception);
}
}
for (CloudBlobHolder deleteObject : deleteRequestsExpected) {
IExpectationSetters<CloudBlobHolder> resultExpectationSetter = requestToResultExpectationSetter.get(deleteObject);
if (resultExpectationSetter == null) {
storage.emptyCloudBlobDirectory(deleteObject.getContainerName(), deleteObject.getName());
resultExpectationSetter = EasyMock.expectLastCall();
requestToResultExpectationSetter.put(deleteObject, resultExpectationSetter);
}
resultExpectationSetter.andReturn(null);
}
}
use of org.apache.druid.storage.azure.blob.CloudBlobHolder in project druid by druid-io.
the class AzureTestUtils method newCloudBlobHolder.
public static CloudBlobHolder newCloudBlobHolder(String container, String prefix, long lastModifiedTimestamp) throws Exception {
CloudBlobHolder object = EasyMock.createMock(CloudBlobHolder.class);
EasyMock.expect(object.getContainerName()).andReturn(container).anyTimes();
EasyMock.expect(object.getName()).andReturn(prefix).anyTimes();
EasyMock.expect(object.getLastModifed()).andReturn(new Date(lastModifiedTimestamp)).anyTimes();
return object;
}
use of org.apache.druid.storage.azure.blob.CloudBlobHolder in project druid by druid-io.
the class AzureTaskLogsTest method test_killOlderThan_nonrecoverableExceptionWhenListingObjects_doesntDeleteAnyTaskLogs.
@Test
public void test_killOlderThan_nonrecoverableExceptionWhenListingObjects_doesntDeleteAnyTaskLogs() throws Exception {
boolean ioExceptionThrown = false;
CloudBlobHolder object1 = null;
AzureCloudBlobIterable azureCloudBlobIterable = null;
try {
EasyMock.expect(inputDataConfig.getMaxListingLength()).andReturn(MAX_KEYS);
EasyMock.expect(accountConfig.getMaxTries()).andReturn(MAX_TRIES).atLeastOnce();
object1 = AzureTestUtils.newCloudBlobHolder(CONTAINER, KEY_1, TIME_0);
azureCloudBlobIterable = AzureTestUtils.expectListObjects(azureCloudBlobIterableFactory, MAX_KEYS, PREFIX_URI, ImmutableList.of(object1));
EasyMock.replay(object1);
AzureTestUtils.expectDeleteObjects(azureStorage, ImmutableList.of(), ImmutableMap.of(object1, NON_RECOVERABLE_EXCEPTION));
EasyMock.replay(inputDataConfig, accountConfig, timeSupplier, azureCloudBlobIterable, azureCloudBlobIterableFactory, azureStorage);
azureTaskLogs.killOlderThan(TIME_NOW);
} catch (IOException e) {
ioExceptionThrown = true;
}
Assert.assertTrue(ioExceptionThrown);
EasyMock.verify(inputDataConfig, accountConfig, timeSupplier, object1, azureCloudBlobIterable, azureCloudBlobIterableFactory, azureStorage);
}
use of org.apache.druid.storage.azure.blob.CloudBlobHolder in project druid by druid-io.
the class AzureTaskLogsTest method test_killOlderThan_noException_deletesOnlyTaskLogsOlderThan.
@Test
public void test_killOlderThan_noException_deletesOnlyTaskLogsOlderThan() throws Exception {
EasyMock.expect(inputDataConfig.getMaxListingLength()).andReturn(MAX_KEYS);
EasyMock.expect(accountConfig.getMaxTries()).andReturn(MAX_TRIES).atLeastOnce();
CloudBlobHolder object1 = AzureTestUtils.newCloudBlobHolder(CONTAINER, KEY_1, TIME_0);
CloudBlobHolder object2 = AzureTestUtils.newCloudBlobHolder(CONTAINER, KEY_2, TIME_FUTURE);
AzureCloudBlobIterable azureCloudBlobIterable = AzureTestUtils.expectListObjects(azureCloudBlobIterableFactory, MAX_KEYS, PREFIX_URI, ImmutableList.of(object1, object2));
EasyMock.replay(object1, object2);
AzureTestUtils.expectDeleteObjects(azureStorage, ImmutableList.of(object1), ImmutableMap.of());
EasyMock.replay(inputDataConfig, accountConfig, timeSupplier, azureCloudBlobIterable, azureCloudBlobIterableFactory, azureStorage);
azureTaskLogs.killOlderThan(TIME_NOW);
EasyMock.verify(inputDataConfig, accountConfig, timeSupplier, object1, object2, azureCloudBlobIterable, azureCloudBlobIterableFactory, azureStorage);
}
Aggregations