Search in sources :

Example 1 with ListBlobItemHolder

use of org.apache.druid.storage.azure.blob.ListBlobItemHolder in project druid by druid-io.

the class AzureStorageDruidModuleTest method testGetListBlobItemDruidFactoryCanCreateListBlobItemDruid.

@Test
public void testGetListBlobItemDruidFactoryCanCreateListBlobItemDruid() {
    injector = makeInjectorWithProperties(PROPERTIES);
    ListBlobItemHolderFactory factory = injector.getInstance(ListBlobItemHolderFactory.class);
    ListBlobItemHolder object1 = factory.create(blobItem1);
    ListBlobItemHolder object2 = factory.create(blobItem2);
    Assert.assertNotNull(object1);
    Assert.assertNotNull(object2);
    Assert.assertNotSame(object1, object2);
}
Also used : ListBlobItemHolderFactory(org.apache.druid.storage.azure.blob.ListBlobItemHolderFactory) ListBlobItemHolder(org.apache.druid.storage.azure.blob.ListBlobItemHolder) Test(org.junit.Test)

Example 2 with ListBlobItemHolder

use of org.apache.druid.storage.azure.blob.ListBlobItemHolder in project druid by druid-io.

the class AzureCloudBlobIteratorTest method test_next_emptyObjects_skipEmptyObjects.

@Test
public void test_next_emptyObjects_skipEmptyObjects() throws URISyntaxException, StorageException {
    EasyMock.expect(config.getMaxTries()).andReturn(MAX_TRIES).atLeastOnce();
    EasyMock.expect(cloudBlobItemPrefixWithOnlyCloudBlobs1.isCloudBlob()).andReturn(true);
    EasyMock.expect(cloudBlobItemPrefixWithOnlyCloudBlobs1.getCloudBlob()).andReturn(cloudBlobDruidPrefixWithOnlyCloudBlobs1).anyTimes();
    EasyMock.expect(blobItemDruidFactory.create(blobItemPrefixWithOnlyCloudBlobs1)).andReturn(cloudBlobItemPrefixWithOnlyCloudBlobs1);
    ListBlobItem emptyBlobItem = createMock(ListBlobItem.class);
    ListBlobItemHolder emptyBlobItemHolder = createMock(ListBlobItemHolder.class);
    CloudBlobHolder emptyBlobHolder = createMock(CloudBlobHolder.class);
    EasyMock.expect(emptyBlobHolder.getBlobLength()).andReturn(0L).anyTimes();
    EasyMock.expect(emptyBlobItemHolder.isCloudBlob()).andReturn(true);
    EasyMock.expect(emptyBlobItemHolder.getCloudBlob()).andReturn(emptyBlobHolder).anyTimes();
    EasyMock.expect(blobItemDruidFactory.create(emptyBlobItem)).andReturn(emptyBlobItemHolder);
    EasyMock.expect(storage.listBlobsWithPrefixInContainerSegmented(CONTAINER1, PREFIX_ONLY_CLOUD_BLOBS, nullResultContinuationToken, MAX_LISTING_LENGTH)).andReturn(resultSegmentPrefixOnlyAndFailLessThanMaxTriesCloudBlobs1);
    EasyMock.expect(resultSegmentPrefixOnlyAndFailLessThanMaxTriesCloudBlobs1.getContinuationToken()).andReturn(nullResultContinuationToken);
    ArrayList<ListBlobItem> resultBlobItemsPrefixWithOnlyCloudBlobs1 = new ArrayList<>();
    resultBlobItemsPrefixWithOnlyCloudBlobs1.add(blobItemPrefixWithOnlyCloudBlobs1);
    resultBlobItemsPrefixWithOnlyCloudBlobs1.add(emptyBlobItem);
    EasyMock.expect(resultSegmentPrefixOnlyAndFailLessThanMaxTriesCloudBlobs1.getResults()).andReturn(resultBlobItemsPrefixWithOnlyCloudBlobs1);
    replayAll();
    azureCloudBlobIterator = new AzureCloudBlobIterator(storage, blobItemDruidFactory, config, ImmutableList.of(PREFIX_ONLY_CLOUD_BLOBS_URI), MAX_LISTING_LENGTH);
    List<CloudBlobHolder> expectedBlobItems = ImmutableList.of(cloudBlobDruidPrefixWithOnlyCloudBlobs1);
    List<CloudBlobHolder> actualBlobItems = Lists.newArrayList(azureCloudBlobIterator);
    Assert.assertEquals(expectedBlobItems.size(), actualBlobItems.size());
    Assert.assertTrue(expectedBlobItems.containsAll(actualBlobItems));
    verifyAll();
}
Also used : ListBlobItem(com.microsoft.azure.storage.blob.ListBlobItem) ArrayList(java.util.ArrayList) ListBlobItemHolder(org.apache.druid.storage.azure.blob.ListBlobItemHolder) CloudBlobHolder(org.apache.druid.storage.azure.blob.CloudBlobHolder) Test(org.junit.Test)

Aggregations

ListBlobItemHolder (org.apache.druid.storage.azure.blob.ListBlobItemHolder)2 Test (org.junit.Test)2 ListBlobItem (com.microsoft.azure.storage.blob.ListBlobItem)1 ArrayList (java.util.ArrayList)1 CloudBlobHolder (org.apache.druid.storage.azure.blob.CloudBlobHolder)1 ListBlobItemHolderFactory (org.apache.druid.storage.azure.blob.ListBlobItemHolderFactory)1