@Override public List<BlockEntry> downloadBlockList(BlockListingFilter filter, BlobRequestOptions options, OperationContext opContext) throws IOException, StorageException { return ((CloudBlockBlob) getBlob()).downloadBlockList(filter, null, options, opContext); }
@Override public List<BlockEntry> downloadBlockList(BlockListingFilter filter, BlobRequestOptions options, OperationContext opContext) throws IOException, StorageException { return ((CloudBlockBlob) getBlob()).downloadBlockList(filter, null, options, opContext); }
/** * Downloads the committed block list from the block blob. * <p> * The committed block list includes the list of blocks that have been successfully committed to the block blob. The * list of committed blocks is returned in the same order that they were committed to the blob. No block may appear * more than once in the committed block list. * * @return An <code>ArrayList</code> object of {@link BlockEntry} objects that represent the committed list * block items downloaded from the block blob. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public ArrayList<BlockEntry> downloadBlockList() throws StorageException { return this.downloadBlockList(BlockListingFilter.COMMITTED, null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Downloads the committed block list from the block blob. * <p> * The committed block list includes the list of blocks that have been successfully committed to the block blob. The * list of committed blocks is returned in the same order that they were committed to the blob. No block may appear * more than once in the committed block list. * * @return An <code>ArrayList</code> object of {@link BlockEntry} objects that represent the committed list * block items downloaded from the block blob. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public ArrayList<BlockEntry> downloadBlockList() throws StorageException { return this.downloadBlockList(BlockListingFilter.COMMITTED, null /* accessCondition */, null /* options */, null /* opContext */); }
private void getBlobBlockList(Exchange exchange) throws Exception { CloudBlockBlob client = BlobServiceUtil.createBlockBlobClient(getConfiguration()); BlobServiceRequestOptions opts = BlobServiceUtil.getRequestOptions(exchange); LOG.trace("Getting the blob block list [{}] from exchange [{}]...", getConfiguration().getBlobName(), exchange); BlockListingFilter filter = exchange.getIn().getBody(BlockListingFilter.class); if (filter == null) { filter = BlockListingFilter.COMMITTED; } List<BlockEntry> blockEntries = client.downloadBlockList(filter, opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext()); ExchangeUtil.getMessageForResponse(exchange).setBody(blockEntries); }
List<BlockEntry> blocks = blob.downloadBlockList( BlockListingFilter.UNCOMMITTED, AccessCondition.generateEmptyCondition(),
@Test public void testBlockBlobFlush() throws Exception { Path path = getBlobPathWithTestName(BLOCK_BLOB_DIR); byte[] buffer = getRandomBytes(); try (FSDataOutputStream stream = fs.create(path)) { for (int i = 0; i < 10; i++) { stream.write(buffer); stream.flush(); } } String blobPath = path.toUri().getPath(); // Create a blob reference to read and validate the block list CloudBlockBlob blob = testAccount.getBlobReference(blobPath.substring(1)); // after the stream is closed, the block list should be non-empty ArrayList<BlockEntry> blockList = blob.downloadBlockList( BlockListingFilter.COMMITTED, null,null, null); assertEquals(1, blockList.size()); }
@Test public void testBlockBlobHFlush() throws Exception { Path path = getBlobPathWithTestName(BLOCK_BLOB_DIR); byte[] buffer = getRandomBytes(); try (FSDataOutputStream stream = fs.create(path)) { for (int i = 0; i < 10; i++) { stream.write(buffer); stream.hflush(); } } String blobPath = path.toUri().getPath(); // Create a blob reference to read and validate the block list CloudBlockBlob blob = testAccount.getBlobReference(blobPath.substring(1)); // after the stream is closed, the block list should be non-empty ArrayList<BlockEntry> blockList = blob.downloadBlockList( BlockListingFilter.COMMITTED, null,null, null); assertEquals(1, blockList.size()); }
@Test public void testBlockBlobHSync() throws Exception { Path path = getBlobPathWithTestName(BLOCK_BLOB_DIR); byte[] buffer = getRandomBytes(); try (FSDataOutputStream stream = fs.create(path)) { for (int i = 0; i < 10; i++) { stream.write(buffer); stream.hsync(); } } String blobPath = path.toUri().getPath(); // Create a blob reference to read and validate the block list CloudBlockBlob blob = testAccount.getBlobReference(blobPath.substring(1)); // after the stream is closed, the block list should be non-empty ArrayList<BlockEntry> blockList = blob.downloadBlockList( BlockListingFilter.COMMITTED, null,null, null); assertEquals(1, blockList.size()); }
@Test public void testBlockBlobCompactionFlush() throws Exception { Path path = getBlobPathWithTestName(BLOCK_BLOB_COMPACTION_DIR); byte[] buffer = getRandomBytes(); try (FSDataOutputStream stream = fs.create(path)) { assertTrue(isBlockBlobAppendStreamWrapper(stream)); for (int i = 0; i < 10; i++) { stream.write(buffer); stream.flush(); } } String blobPath = path.toUri().getPath(); // Create a blob reference to read and validate the block list CloudBlockBlob blob = testAccount.getBlobReference(blobPath.substring(1)); // after the stream is closed, the block list should be non-empty ArrayList<BlockEntry> blockList = blob.downloadBlockList( BlockListingFilter.COMMITTED, null,null, null); assertEquals(1, blockList.size()); }
@Test public void testBlockBlobCompactionHFlush() throws Exception { Path path = getBlobPathWithTestName(BLOCK_BLOB_COMPACTION_DIR); byte[] buffer = getRandomBytes(); try (FSDataOutputStream stream = fs.create(path)) { assertTrue(isBlockBlobAppendStreamWrapper(stream)); for (int i = 0; i < 10; i++) { stream.write(buffer); stream.hflush(); } } String blobPath = path.toUri().getPath(); // Create a blob reference to read and validate the block list CloudBlockBlob blob = testAccount.getBlobReference(blobPath.substring(1)); // after the stream is closed, the block list should be non-empty ArrayList<BlockEntry> blockList = blob.downloadBlockList( BlockListingFilter.COMMITTED, null,null, null); assertEquals(10, blockList.size()); }
@Test public void testBlockBlobCompactionHSync() throws Exception { Path path = getBlobPathWithTestName(BLOCK_BLOB_COMPACTION_DIR); byte[] buffer = getRandomBytes(); try (FSDataOutputStream stream = fs.create(path)) { assertTrue(isBlockBlobAppendStreamWrapper(stream)); for (int i = 0; i < 10; i++) { stream.write(buffer); stream.hsync(); } } String blobPath = path.toUri().getPath(); // Create a blob reference to read and validate the block list CloudBlockBlob blob = testAccount.getBlobReference(blobPath.substring(1)); // after the stream is closed, the block list should be non-empty ArrayList<BlockEntry> blockList = blob.downloadBlockList( BlockListingFilter.COMMITTED, null,null, null); assertEquals(10, blockList.size()); }
blocks = blockBlob.downloadBlockList(BlockListingFilter.UNCOMMITTED, null, null, null); assertEquals((int)Math.ceil((i+1)/flushPeriod), blocks.size()); blocks = blockBlob.downloadBlockList(BlockListingFilter.COMMITTED, null, null, null);
@Test public void testClose() throws URISyntaxException, StorageException, IOException { String blobName = BlobTestHelper.generateRandomBlobNameWithPrefix("testblob"); CloudBlockBlob blockBlob = this.container.getBlockBlobReference(blobName); BlobOutputStream str = blockBlob.openOutputStream(); str.close(); try { str.close(); fail("Can't close twice."); } catch(IOException e) { assertEquals(SR.STREAM_CLOSED, e.getMessage()); } str = blockBlob.openOutputStream(); str.write(8); ArrayList<BlockEntry> blocks = blockBlob.downloadBlockList(BlockListingFilter.ALL, null, null, null); assertEquals(0, blocks.size()); str.close(); blocks = blockBlob.downloadBlockList(BlockListingFilter.COMMITTED, null, null, null); assertEquals(1, blocks.size()); }
private void smallPutThresholdHelper(int length, int writes, BlobRequestOptions options) throws URISyntaxException, StorageException, IOException { byte[] buffer = BlobTestHelper.getRandomBuffer(length*writes); String blobName = BlobTestHelper.generateRandomBlobNameWithPrefix("concurrency"); CloudBlockBlob blockBlob = this.container.getBlockBlobReference(blobName); blockBlob.setStreamWriteSizeInBytes(length); BlobOutputStream blobOutputStream = blockBlob.openOutputStream(null, options, null); for (int i = 0; i < writes; i ++) { blobOutputStream.write(buffer, i*length, length); } blobOutputStream.flush(); ArrayList<BlockEntry> blocks = blockBlob.downloadBlockList(BlockListingFilter.UNCOMMITTED, null, null, null); assertEquals(writes, blocks.size()); blobOutputStream.close(); blocks = blockBlob.downloadBlockList(BlockListingFilter.COMMITTED, null, null, null); assertEquals(writes, blocks.size()); byte[] outBuffer = new byte[writes*length]; blockBlob.downloadToByteArray(outBuffer, 0); for (int i = 0; i < length*writes; i ++) { assertEquals(buffer[i], outBuffer[i]); } }
ArrayList<BlockEntry> blocks = blockBlob.downloadBlockList(BlockListingFilter.UNCOMMITTED, null, null, null); assertEquals(1, blocks.size()); assertEquals(511, blocks.get(0).getSize()); blocks = blockBlob.downloadBlockList(BlockListingFilter.COMMITTED, null, null, null); assertEquals(2, blocks.size()); assertEquals(513, blocks.get(1).getSize());
@Test public void testEmpty() throws URISyntaxException, StorageException, IOException { String blobName = BlobTestHelper.generateRandomBlobNameWithPrefix("testblob"); CloudBlockBlob blockBlob = this.container.getBlockBlobReference(blobName); BlobOutputStream str = blockBlob.openOutputStream(); str.close(); CloudBlockBlob blockBlob2 = this.container.getBlockBlobReference(blobName); blockBlob2.downloadAttributes(); assertEquals(0, blockBlob2.getProperties().getLength()); ArrayList<BlockEntry> blocks = blockBlob2.downloadBlockList(BlockListingFilter.ALL, null, null, null); assertEquals(0, blocks.size()); }
assertEquals(1024 * blocks.size(), blob2.getProperties().getLength()); List<BlockEntry> blockList = blob2.downloadBlockList(); assertEquals(3, blockList.size()); for (BlockEntry blockItem : blockList) { blockList = blob2.downloadBlockList(BlockListingFilter.UNCOMMITTED, null, null, null); assertEquals(2, blockList.size()); for (BlockEntry blockItem : blockList) { blockList = blob2.downloadBlockList(BlockListingFilter.ALL, null, null, null); assertEquals(5, blockList.size());
ArrayList<BlockEntry> blocks = blockBlob.downloadBlockList(BlockListingFilter.UNCOMMITTED, null, null, null); assertTrue(blocks.size() != 0);
blockBlobRef.downloadBlockList(); assertEquals(length, blockBlobRef.getProperties().getLength());