/** * Resizes the page blob to the specified size. * * @param size * A <code>long</code> which represents the size of the page blob, in bytes. * * @throws StorageException * If a storage service error occurred. */ public void resize(long size) throws StorageException { this.resize(size, null /* accessCondition */, null /* options */, null /* operationContext */); }
/** * Resizes the page blob to the specified size. * * @param size * A <code>long</code> which represents the size of the page blob, in bytes. * * @throws StorageException * If a storage service error occurred. */ public void resize(long size) throws StorageException { this.resize(size, null /* accessCondition */, null /* options */, null /* operationContext */); }
private void resize(long streamSize) { if (streamSize > currentPageSize) { currentPageSize = roundToPageBlobSize(streamSize); try { pageBlob.resize(currentPageSize); } catch (StorageException e) { this.lastError = new AzureIOException("Unable to resize blob.", e); } } }
while(!resizeDone && retries <= MAX_RETRIES) { try { cloudPageBlob.resize(newSize); resizeDone = true; currentBlobSize = newSize;
private void resizePageBlob(Exchange exchange) throws Exception { LOG.trace("Resizing a page blob [{}] from exchange [{}]...", getConfiguration().getBlobName(), exchange); CloudPageBlob client = BlobServiceUtil.createPageBlobClient(getConfiguration()); BlobServiceRequestOptions opts = BlobServiceUtil.getRequestOptions(exchange); Long pageSize = getPageBlobSize(exchange); client.resize(pageSize, opts.getAccessCond(), opts.getRequestOpts(), opts.getOpContext()); }
@Test public void testEightTBBlob() throws StorageException, URISyntaxException, IOException { CloudPageBlob blob = this.container.getPageBlobReference("blob1"); CloudPageBlob blob2 = this.container.getPageBlobReference("blob1"); long eightTb = 8L * 1024L * 1024L * 1024L * 1024L; blob.create(eightTb); assertEquals(eightTb, blob.getProperties().getLength()); blob2.downloadAttributes(); assertEquals(eightTb, blob2.getProperties().getLength()); for (ListBlobItem listBlob : this.container.listBlobs()) { CloudPageBlob listPageBlob = (CloudPageBlob)listBlob; assertEquals(eightTb, listPageBlob.getProperties().getLength()); } CloudPageBlob blob3 = this.container.getPageBlobReference("blob3"); blob3.create(1024); blob3.resize(eightTb); final Random randGenerator = new Random(); final byte[] buffer = new byte[1024]; randGenerator.nextBytes(buffer); blob.uploadPages(new ByteArrayInputStream(buffer), eightTb - 512L, 512L); ArrayList<PageRange> ranges = blob.downloadPageRanges(); assertEquals(1, ranges.size()); assertEquals(eightTb - 512L, ranges.get(0).getStartOffset()); assertEquals(eightTb - 1L, ranges.get(0).getEndOffset()); }
@Test public void testResize() throws StorageException, URISyntaxException { CloudPageBlob blob = this.container.getPageBlobReference("blob1"); CloudPageBlob blob2 = this.container.getPageBlobReference("blob1"); blob.create(1024); assertEquals(1024, blob.getProperties().getLength()); assertNull(blob.getProperties().getPageBlobSequenceNumber()); blob2.downloadAttributes(); assertEquals(1024, blob2.getProperties().getLength()); assertNull(blob.getProperties().getPageBlobSequenceNumber()); blob2.getProperties().setContentType("text/plain"); blob2.uploadProperties(); blob.resize(2048); assertEquals(2048, blob.getProperties().getLength()); assertNotNull(blob.getProperties().getPageBlobSequenceNumber()); blob.downloadAttributes(); assertEquals("text/plain", blob.getProperties().getContentType()); assertNotNull(blob.getProperties().getPageBlobSequenceNumber()); blob2.downloadAttributes(); assertEquals(2048, blob2.getProperties().getLength()); assertNotNull(blob.getProperties().getPageBlobSequenceNumber()); }