• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StorageErrorCode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



StorageErrorCode类属于com.microsoft.azure.storage包,在下文中一共展示了StorageErrorCode类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: isFileNotFoundException

import com.microsoft.azure.storage.StorageErrorCode; //导入依赖的package包/类
private boolean isFileNotFoundException(StorageException e) {

      String errorCode = ((StorageException) e).getErrorCode();
      if (errorCode != null
          && (errorCode.equals(StorageErrorCodeStrings.BLOB_NOT_FOUND)
              || errorCode.equals(StorageErrorCodeStrings.RESOURCE_NOT_FOUND)
              || errorCode.equals(StorageErrorCode.BLOB_NOT_FOUND.toString())
              || errorCode.equals(StorageErrorCode.RESOURCE_NOT_FOUND.toString()))) {

        return true;
      }

      return false;
    }
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:15,代码来源:NativeAzureFileSystem.java


示例2: dispatchRead

import com.microsoft.azure.storage.StorageErrorCode; //导入依赖的package包/类
/**
 * Dispatches a read operation of N bytes.
 * 
 * @param readLength
 *            An <code>int</code> which represents the number of bytes to read.
 * 
 * @throws IOException
 *             If an I/O error occurs.
 */
@DoesServiceRequest
private synchronized void dispatchRead(final int readLength) throws IOException {
    try {
        final byte[] byteBuffer = new byte[readLength];

        this.parentFileRef.downloadRangeInternal(this.currentAbsoluteReadPosition, (long) readLength, byteBuffer,
                0, null /* this.accessCondition */, this.options, this.opContext);

        // Check Etag manually for now -- use access condition once conditional headers supported.
        if (this.accessCondition != null) {
            if (!this.accessCondition.getIfMatch().equals(this.parentFileRef.getProperties().getEtag())) {
                throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(),
                        SR.INVALID_CONDITIONAL_HEADERS, HttpURLConnection.HTTP_PRECON_FAILED, null, null);
            }
        }

        this.currentBuffer = new ByteArrayInputStream(byteBuffer);
        this.bufferSize = readLength;
        this.bufferStartOffset = this.currentAbsoluteReadPosition;
    }
    catch (final StorageException e) {
        this.streamFaulted = true;
        this.lastError = Utility.initIOException(e);
        throw this.lastError;
    }
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:36,代码来源:FileInputStream.java


示例3: BlobInputStream

import com.microsoft.azure.storage.StorageErrorCode; //导入依赖的package包/类
/**
 * Initializes a new instance of the BlobInputStream class.
 * 
 * @param parentBlob
 *            A {@link CloudBlob} object which represents the blob that this stream is associated with.
 * @param accessCondition
 *            An {@link AccessCondition} object which represents the access conditions for the blob.
 * @param options
 *            A {@link BlobRequestOptions} object which represents that specifies any additional options for the
 *            request.
 * @param opContext
 *            An {@link OperationContext} object which is used to track the execution of the operation.
 * 
 * @throws StorageException
 *             An exception representing any error which occurred during the operation.
 */
@DoesServiceRequest
protected BlobInputStream(final CloudBlob parentBlob, final AccessCondition accessCondition,
        final BlobRequestOptions options, final OperationContext opContext) throws StorageException {
    this.parentBlobRef = parentBlob;
    this.parentBlobRef.assertCorrectBlobType();
    this.options = new BlobRequestOptions(options);
    this.opContext = opContext;
    this.streamFaulted = false;
    this.currentAbsoluteReadPosition = 0;
    this.readSize = parentBlob.getStreamMinimumReadSizeInBytes();

    if (options.getUseTransactionalContentMD5() && this.readSize > 4 * Constants.MB) {
        throw new IllegalArgumentException(SR.INVALID_RANGE_CONTENT_MD5_HEADER);
    }

    parentBlob.downloadAttributes(accessCondition, this.options, this.opContext);

    this.retrievedContentMD5Value = parentBlob.getProperties().getContentMD5();

    // Will validate it if it was returned
    this.validateBlobMd5 = !options.getDisableContentMD5Validation()
            && !Utility.isNullOrEmpty(this.retrievedContentMD5Value);

    // Validates the first option, and sets future requests to use if match
    // request option.

    // If there is an existing conditional validate it, as we intend to
    // replace if for future requests.
    String previousLeaseId = null;
    if (accessCondition != null) {
        previousLeaseId = accessCondition.getLeaseID();

        if (!accessCondition.verifyConditional(this.parentBlobRef.getProperties().getEtag(), this.parentBlobRef
                .getProperties().getLastModified())) {
            throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(),
                    SR.INVALID_CONDITIONAL_HEADERS, HttpURLConnection.HTTP_PRECON_FAILED, null, null);
        }
    }

    this.accessCondition = AccessCondition.generateIfMatchCondition(this.parentBlobRef.getProperties().getEtag());
    this.accessCondition.setLeaseID(previousLeaseId);

    this.streamLength = parentBlob.getProperties().getLength();

    if (this.validateBlobMd5) {
        try {
            this.md5Digest = MessageDigest.getInstance("MD5");
        }
        catch (final NoSuchAlgorithmException e) {
            // This wont happen, throw fatal.
            throw Utility.generateNewUnexpectedStorageException(e);
        }
    }

    this.reposition(0);
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:73,代码来源:BlobInputStream.java


示例4: preProcessDownloadResponse

import com.microsoft.azure.storage.StorageErrorCode; //导入依赖的package包/类
private Integer preProcessDownloadResponse(final StorageRequest<CloudFileClient, CloudFile, Integer> request,
        final FileRequestOptions options, final CloudFileClient client, final CloudFile file,
        final OperationContext context, final boolean isRangeGet) throws StorageException {
    if (request.getResult().getStatusCode() != HttpURLConnection.HTTP_PARTIAL
            && request.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) {
        request.setNonExceptionedRetryableFailure(true);
        return null;
    }

    if (!request.getArePropertiesPopulated()) {
        String originalContentMD5 = null;

        final FileAttributes retrievedAttributes = FileResponse.getFileAttributes(request.getConnection(),
                file.getStorageUri());

        // Do not update Content-MD5 if it is a range get. 
        if (isRangeGet) {
            originalContentMD5 = file.properties.getContentMD5();
        }
        else {
            originalContentMD5 = retrievedAttributes.getProperties().getContentMD5();
        }

        if (!options.getDisableContentMD5Validation() && options.getUseTransactionalContentMD5()
                && Utility.isNullOrEmpty(retrievedAttributes.getProperties().getContentMD5())) {
            throw new StorageException(StorageErrorCodeStrings.MISSING_MD5_HEADER, SR.MISSING_MD5,
                    Constants.HeaderConstants.HTTP_UNUSED_306, null, null);
        }

        file.properties = retrievedAttributes.getProperties();
        file.metadata = retrievedAttributes.getMetadata();
        request.setContentMD5(retrievedAttributes.getProperties().getContentMD5());
        file.properties.setContentMD5(originalContentMD5);
        request.setLockedETag(file.properties.getEtag());
        request.setArePropertiesPopulated(true);
    }
    else {
        if (request.getLockedETag() != null) {
            if (!request.getLockedETag().equals(file.properties.getEtag())) {
                throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(),
                        SR.INVALID_CONDITIONAL_HEADERS, HttpURLConnection.HTTP_PRECON_FAILED, null, null);
            }
        }
    }

    // If the download fails and Get File needs to resume the download, going to the
    // same storage location is important to prevent a possible ETag mismatch.
    request.setRequestLocationMode(request.getResult().getTargetLocation() == StorageLocation.PRIMARY ? RequestLocationMode.PRIMARY_ONLY
            : RequestLocationMode.SECONDARY_ONLY);
    return null;
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:52,代码来源:CloudFile.java


示例5: generateNewUnexpectedStorageException

import com.microsoft.azure.storage.StorageErrorCode; //导入依赖的package包/类
/**
 * Returns an unexpected storage exception.
 * 
 * @param cause
 *            An <code>Exception</code> object that represents the initial exception that caused the unexpected
 *            error.
 * 
 * @return A {@link StorageException} object that represents the unexpected storage exception being thrown.
 */
public static StorageException generateNewUnexpectedStorageException(final Exception cause) {
    final StorageException exceptionRef = new StorageException(StorageErrorCode.NONE.toString(),
            "Unexpected internal storage client error.", 306, // unused
            null, null);
    exceptionRef.initCause(cause);
    return exceptionRef;
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:17,代码来源:Utility.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AlignCellsAction类代码示例发布时间:2022-05-22
下一篇:
Java ZkTimeoutException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap