当前位置: 首页>>代码示例>>Java>>正文


Java CloudPageBlob.resize方法代码示例

本文整理汇总了Java中com.microsoft.azure.storage.blob.CloudPageBlob.resize方法的典型用法代码示例。如果您正苦于以下问题:Java CloudPageBlob.resize方法的具体用法?Java CloudPageBlob.resize怎么用?Java CloudPageBlob.resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.microsoft.azure.storage.blob.CloudPageBlob的用法示例。


在下文中一共展示了CloudPageBlob.resize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: conditionalExtendFile

import com.microsoft.azure.storage.blob.CloudPageBlob; //导入方法依赖的package包/类
/**
 * Extend the page blob file if we are close to the end.
 */
private void conditionalExtendFile() {

  // maximum allowed size of an Azure page blob (1 terabyte)
  final long MAX_PAGE_BLOB_SIZE = 1024L * 1024L * 1024L * 1024L;

  // If blob is already at the maximum size, then don't try to extend it.
  if (currentBlobSize == MAX_PAGE_BLOB_SIZE) {
    return;
  }

  // If we are within the maximum write size of the end of the file,
  if (currentBlobSize - currentBlobOffset <= MAX_RAW_BYTES_PER_REQUEST) {

    // Extend the file. Retry up to 3 times with back-off.
    CloudPageBlob cloudPageBlob = (CloudPageBlob) blob.getBlob();
    long newSize = currentBlobSize + configuredPageBlobExtensionSize;

    // Make sure we don't exceed maximum blob size.
    if (newSize > MAX_PAGE_BLOB_SIZE) {
      newSize = MAX_PAGE_BLOB_SIZE;
    }
    final int MAX_RETRIES = 3;
    int retries = 1;
    boolean resizeDone = false;
    while(!resizeDone && retries <= MAX_RETRIES) {
      try {
        cloudPageBlob.resize(newSize);
        resizeDone = true;
        currentBlobSize = newSize;
      } catch (StorageException e) {
        LOG.warn("Failed to extend size of " + cloudPageBlob.getUri());
        try {

          // sleep 2, 8, 18 seconds for up to 3 retries
          Thread.sleep(2000 * retries * retries);
        } catch (InterruptedException e1) {

          // Restore the interrupted status
          Thread.currentThread().interrupt();
        }
      } finally {
        retries++;
      }
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:50,代码来源:PageBlobOutputStream.java


注:本文中的com.microsoft.azure.storage.blob.CloudPageBlob.resize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。