本文整理汇总了Java中com.microsoft.azure.storage.DoesServiceRequest类的典型用法代码示例。如果您正苦于以下问题:Java DoesServiceRequest类的具体用法?Java DoesServiceRequest怎么用?Java DoesServiceRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DoesServiceRequest类属于com.microsoft.azure.storage包,在下文中一共展示了DoesServiceRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasNext
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
/**
* Indicates if the iterator has another element.
*/
@Override
@DoesServiceRequest
public boolean hasNext() {
while (this.currentSegment == null
|| (!this.currentSegmentIterator.hasNext() && this.currentSegment != null && this.currentSegment
.getHasMoreResults())) {
try {
this.currentSegment = ExecutionEngine.executeWithRetry(this.client, this.parentObject,
this.segmentGenerator, this.policyFactory, this.opContext);
}
catch (final StorageException e) {
final NoSuchElementException ex = new NoSuchElementException(SR.ENUMERATION_ERROR);
ex.initCause(e);
throw ex;
}
this.currentSegmentIterator = this.currentSegment.getResults().iterator();
if (!this.currentSegmentIterator.hasNext() && !this.currentSegment.getHasMoreResults()) {
return false;
}
}
return this.currentSegmentIterator.hasNext();
}
示例2: createIfNotExists
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
/**
* Creates the directory if it does not exist, using the specified request options and operation context.
*
* @param options
* A {@link FileRequestOptions} object that specifies any additional options for the request.
* Specifying <code>null</code> will use the default request options from the associated service client
* ({@link CloudFileClient}).
* @param opContext
* An {@link OperationContext} object that represents the context for the current operation. This object
* is used to track requests to the storage service, and to provide additional runtime information about
* the operation.
*
* @return <code>true</code> if the directory did not already exist and was created; otherwise, <code>false</code>.
*
* @throws StorageException
* If a storage service error occurred.
*/
@DoesServiceRequest
public boolean createIfNotExists(FileRequestOptions options, OperationContext opContext) throws StorageException {
options = FileRequestOptions.applyDefaults(options, this.fileServiceClient);
boolean exists = this.exists(true /* primaryOnly */, null /* accessCondition */, options, opContext);
if (exists) {
return false;
}
else {
try {
this.create(options, opContext);
return true;
}
catch (StorageException e) {
if (e.getHttpStatusCode() == HttpURLConnection.HTTP_CONFLICT
&& StorageErrorCodeStrings.RESOURCE_ALREADY_EXISTS.equals(e.getErrorCode())) {
return false;
}
else {
throw e;
}
}
}
}
示例3: dispatchRead
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
/**
* Dispatches a read operation of N bytes. When using sparspe page blobs the page ranges are evaluated and zero
* bytes may be generated on the client side for some ranges that do not exist.
*
* @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.parentBlobRef.downloadRangeInternal(this.currentAbsoluteReadPosition, (long) readLength, byteBuffer,
0, this.accessCondition, this.options, this.opContext);
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;
}
}
示例4: delete
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
/**
* Deletes the table from the storage service, using the specified request options and operation context.
*
* @param options
* A {@link TableRequestOptions} object that specifies any additional options for the request. Specifying
* <code>null</code> will use the default request options from the associated service client (
* {@link CloudTableClient}).
* @param opContext
* An {@link OperationContext} object that represents the context for the current operation. This object
* is used to track requests to the storage service, and to provide additional runtime information about
* the operation.
*
* @throws StorageException
* If a storage service error occurred during the operation.
*/
@DoesServiceRequest
public void delete(TableRequestOptions options, OperationContext opContext) throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = TableRequestOptions.populateAndApplyDefaults(options, this.tableServiceClient);
Utility.assertNotNullOrEmpty("tableName", this.name);
final DynamicTableEntity tableEntry = new DynamicTableEntity();
tableEntry.getProperties().put(TableConstants.TABLE_NAME, new EntityProperty(this.name));
TableOperation deleteOp = new TableOperation(tableEntry, TableOperationType.DELETE);
deleteOp.execute(this.tableServiceClient, TableConstants.TABLES_SERVICE_TABLES_NAME, options, opContext);
}
示例5: exists
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
@DoesServiceRequest
private boolean exists(final boolean primaryOnly, QueueRequestOptions options, OperationContext opContext)
throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = QueueRequestOptions.populateAndApplyDefaults(options, this.queueServiceClient);
return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, this.existsImpl(primaryOnly, options),
options.getRetryPolicyFactory(), opContext);
}
示例6: upload
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
/**
* Uploads the source stream data to the file using the specified access condition, request options, and operation
* context. If the file already exists on the service, it will be overwritten.
*
* @param sourceStream
* An {@link InputStream} object to read from.
* @param length
* A <code>long</code> which represents the length, in bytes, of the stream data. This must be greater than
* or equal to zero.
* @param accessCondition
* An {@link AccessCondition} object which represents the access conditions for the file.
* @param options
* A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
* <code>null</code> will use the default request options from the associated service client (
* {@link CloudFileClient}).
* @param opContext
* An {@link OperationContext} object which represents the context for the current operation. This object
* is used to track requests to the storage service, and to provide additional runtime information about
* the operation.
*
* @throws IOException
* If an I/O exception occurred.
* @throws StorageException
* If a storage service error occurred.
* @throws URISyntaxException
*/
@DoesServiceRequest
public void upload(final InputStream sourceStream, final long length, final AccessCondition accessCondition,
FileRequestOptions options, OperationContext opContext) throws StorageException, IOException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
this.getShare().assertNoSnapshot();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
if (length < 0) {
throw new IllegalArgumentException(SR.INVALID_FILE_LENGTH);
}
if (sourceStream.markSupported()) {
// Mark sourceStream for current position.
sourceStream.mark(Constants.MAX_MARK_LENGTH);
}
final FileOutputStream streamRef = this.openWriteNew(length, accessCondition, options, opContext);
try {
streamRef.write(sourceStream, length);
}
finally {
streamRef.close();
}
}
示例7: FileOutputStream
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
/**
* Initializes a new instance of the FileOutputStream class.
*
* @param parentFile
* A {@link CloudFile} object which represents the file that this stream is associated with.
* @param length
* A <code>long</code> which represents the length of the file in bytes.
* @param accessCondition
* An {@link AccessCondition} object which represents the access conditions for the file.
* @param options
* A {@link FileRequestOptions} object which 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 FileOutputStream(final CloudFile parentFile, final long length, final AccessCondition accessCondition,
final FileRequestOptions options, final OperationContext opContext) throws StorageException {
this.accessCondition = accessCondition;
this.parentFileRef = parentFile;
this.options = new FileRequestOptions(options);
this.outBuffer = new ByteArrayOutputStream();
this.opContext = opContext;
this.streamFaulted = false;
if (this.options.getConcurrentRequestCount() < 1) {
throw new IllegalArgumentException("ConcurrentRequestCount");
}
if (this.options.getStoreFileContentMD5()) {
try {
this.md5Digest = MessageDigest.getInstance("MD5");
}
catch (final NoSuchAlgorithmException e) {
// This wont happen, throw fatal.
throw Utility.generateNewUnexpectedStorageException(e);
}
}
// V2 cachedThreadPool for perf.
this.threadExecutor = Executors.newFixedThreadPool(this.options.getConcurrentRequestCount());
this.completionService = new ExecutorCompletionService<Void>(this.threadExecutor);
this.internalWriteThreshold = (int) Math.min(this.parentFileRef.getStreamWriteSizeInBytes(), length);
}
示例8: exists
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
@DoesServiceRequest
private boolean exists(final boolean primaryOnly, final AccessCondition accessCondition,
BlobRequestOptions options, OperationContext opContext) throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = BlobRequestOptions.applyDefaults(options, BlobType.UNSPECIFIED, this.blobServiceClient);
return ExecutionEngine.executeWithRetry(this.blobServiceClient, this,
this.existsImpl(primaryOnly, accessCondition, options), options.getRetryPolicyFactory(), opContext);
}
示例9: exists
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
@DoesServiceRequest
private boolean exists(final boolean primaryOnly, QueueRequestOptions options, OperationContext opContext)
throws StorageException {
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = QueueRequestOptions.applyDefaults(options, this.queueServiceClient);
return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, this.existsImpl(primaryOnly, options),
options.getRetryPolicyFactory(), opContext);
}
示例10: uploadRange
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
/**
* Uploads a range to a file using the specified lease ID, request options, and operation context.
*
* @param sourceStream
* An {@link IntputStream} object which represents the input stream to write to the file.
* @param offset
* A <code>long</code> which represents the offset, in number of bytes, at which to begin writing the
* data.
* @param length
* A <code>long</code> which represents the length, in bytes, of the data to write.
* @param accessCondition
* An {@link AccessCondition} object which represents the access conditions for the file.
* @param options
* A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
* <code>null</code> will use the default request options from the associated service client (
* {@link CloudFileClient}).
* @param opContext
* An {@link OperationContext} object which represents the context for the current operation. This object
* is used to track requests to the storage service, and to provide additional runtime information about
* the operation.
*
* @throws IOException
* If an I/O exception occurred.
* @throws StorageException
* If a storage service error occurred.
*/
@DoesServiceRequest
public void uploadRange(final InputStream sourceStream, final long offset, final long length,
final AccessCondition accessCondition, FileRequestOptions options, OperationContext opContext)
throws StorageException, IOException {
if (opContext == null) {
opContext = new OperationContext();
}
options = FileRequestOptions.applyDefaults(options, this.fileServiceClient);
final FileRange range = new FileRange(offset, offset + length - 1);
final byte[] data = new byte[(int) length];
String md5 = null;
int count = 0;
int total = 0;
while (total < length) {
count = sourceStream.read(data, total, (int) Math.min(length - total, Integer.MAX_VALUE));
total += count;
}
if (options.getUseTransactionalContentMD5()) {
try {
final MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(data, 0, data.length);
md5 = Base64.encode(digest.digest());
}
catch (final NoSuchAlgorithmException e) {
// This wont happen, throw fatal.
throw Utility.generateNewUnexpectedStorageException(e);
}
}
this.putRangeInternal(range, FileRangeOperationType.UPDATE, data, length, md5, accessCondition, options,
opContext);
}
示例11: upload
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
/**
* Uploads the source stream data to the page blob using the specified lease ID, request options, and operation
* context. If the blob already exists on the service, it will be overwritten.
*
* @param sourceStream
* An {@link InputStream} object to read from.
* @param length
* A <code>long</code> which represents the length, in bytes, of the stream data. This must be great than
* zero and a multiple of 512.
* @param premiumBlobTier
* A {@link PremiumPageBlobTier} object which represents the tier of the blob.
* @param accessCondition
* An {@link AccessCondition} object which represents the access conditions for the blob.
* @param options
* A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying
* <code>null</code> will use the default request options from the associated service client (
* {@link CloudBlobClient}).
* @param opContext
* An {@link OperationContext} object which represents the context for the current operation. This object
* is used to track requests to the storage service, and to provide additional runtime information about
* the operation.
*
* @throws IOException
* If an I/O exception occurred.
* @throws StorageException
* If a storage service error occurred.
*/
@DoesServiceRequest
public void upload(final InputStream sourceStream, final long length, final PremiumPageBlobTier premiumBlobTier, final AccessCondition accessCondition,
BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException {
assertNoWriteOperationForSnapshot();
if (opContext == null) {
opContext = new OperationContext();
}
options = BlobRequestOptions.populateAndApplyDefaults(options, BlobType.PAGE_BLOB, this.blobServiceClient);
if (length <= 0 || length % Constants.PAGE_SIZE != 0) {
throw new IllegalArgumentException(SR.INVALID_PAGE_BLOB_LENGTH);
}
if (options.getStoreBlobContentMD5()) {
throw new IllegalArgumentException(SR.BLOB_MD5_NOT_SUPPORTED_FOR_PAGE_BLOBS);
}
if (sourceStream.markSupported()) {
// Mark sourceStream for current position.
sourceStream.mark(Constants.MAX_MARK_LENGTH);
}
final BlobOutputStream streamRef = this.openWriteNew(length, premiumBlobTier, accessCondition, options, opContext);
try {
streamRef.write(sourceStream, length);
}
finally {
streamRef.close();
}
}
示例12: downloadToByteArray
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
/**
* Downloads a range of bytes from the blob to the given byte buffer, using the specified request options and
* operation context.
*
* @param buffer
* A <code>byte</code> array which represents the buffer to which the blob bytes are downloaded.
* @param bufferOffset
* A <code>long</code> which represents the byte offset to use as the starting point for the target.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
* @param options
* A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying
* <code>null</code> will use the default request options from the associated service client (
* {@link CloudBlobClient}).
* @param opContext
* An {@link OperationContext} object that represents the context for the current operation. This object
* is used to track requests to the storage service, and to provide additional runtime information about
* the operation.
*
* @throws StorageException
* If a storage service error occurred.
*/
@DoesServiceRequest
public final int downloadToByteArray(final byte[] buffer, final int bufferOffset,
final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
throws StorageException {
Utility.assertNotNull("buffer", buffer);
if (bufferOffset < 0) {
throw new IndexOutOfBoundsException();
}
if (bufferOffset >= buffer.length) {
throw new IndexOutOfBoundsException();
}
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = BlobRequestOptions.populateAndApplyDefaults(options, this.properties.getBlobType(), this.blobServiceClient);
WrappedByteArrayOutputStream outputStream = new WrappedByteArrayOutputStream(buffer, bufferOffset);
ExecutionEngine.executeWithRetry(this.blobServiceClient, this,
this.downloadToStreamImpl(null, null, outputStream, accessCondition, options, opContext),
options.getRetryPolicyFactory(), opContext);
return outputStream.getPosition();
}
示例13: uploadProperties
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
/**
* Updates the blob's properties using the specified lease ID, request options, and operation context.
* <p>
* Use {@link CloudBlob#downloadAttributes} to retrieve the latest values for the blob's properties and metadata
* from the Microsoft Azure storage service.
*
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
* @param options
* A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying
* <code>null</code> will use the default request options from the associated service client (
* {@link CloudBlobClient}).
* @param opContext
* An {@link OperationContext} object that represents the context for the current operation. This object
* is used to track requests to the storage service, and to provide additional runtime information about
* the operation.
*
* @throws StorageException
* If a storage service error occurred.
*/
@DoesServiceRequest
public final void uploadProperties(final AccessCondition accessCondition, BlobRequestOptions options,
OperationContext opContext) throws StorageException {
assertNoWriteOperationForSnapshot();
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = BlobRequestOptions.populateAndApplyDefaults(options, this.properties.getBlobType(), this.blobServiceClient);
ExecutionEngine.executeWithRetry(this.blobServiceClient, this,
this.uploadPropertiesImpl(accessCondition, options), options.getRetryPolicyFactory(), opContext);
}
示例14: downloadBlockList
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
/**
* Downloads the block list from the block blob using the specified block listing filter, request options, and
* operation context.
* <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.
*
* @param blockListingFilter
* A {@link BlockListingFilter} value that specifies whether to download committed blocks, uncommitted
* blocks, or all blocks.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
* @param options
* A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying
* <code>null</code> will use the default request options from the associated service client (
* {@link CloudBlobClient}).
* @param opContext
* An {@link OperationContext} object that represents the context for the current operation. This object
* is used to track requests to the storage service, and to provide additional runtime information about
* the operation.
*
* @return An <code>ArrayList</code> object of {@link BlockEntry} objects that represent the list block items
* downloaded from the block blob.
*
* @throws StorageException
* If a storage service error occurred.
*/
@DoesServiceRequest
public ArrayList<BlockEntry> downloadBlockList(final BlockListingFilter blockListingFilter,
final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
throws StorageException {
Utility.assertNotNull("blockListingFilter", blockListingFilter);
if (opContext == null) {
opContext = new OperationContext();
}
opContext.initialize();
options = BlobRequestOptions.applyDefaults(options, BlobType.BLOCK_BLOB, this.blobServiceClient);
return ExecutionEngine.executeWithRetry(this.blobServiceClient, this,
this.downloadBlockListImpl(blockListingFilter, accessCondition, options),
options.getRetryPolicyFactory(), opContext);
}
示例15: uploadProperties
import com.microsoft.azure.storage.DoesServiceRequest; //导入依赖的package包/类
/**
* Updates the file's properties using the access condition, request options, and operation context.
* <p>
* Use {@link CloudFile#downloadAttributes} to retrieve the latest values for the file's properties and metadata
* from the Microsoft Azure storage service.
*
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the file.
* @param options
* A {@link FileRequestOptions} object that specifies any additional options for the request. Specifying
* <code>null</code> will use the default request options from the associated service client (
* {@link CloudFileClient}).
* @param opContext
* An {@link OperationContext} object that represents the context for the current operation. This object
* is used to track requests to the storage service, and to provide additional runtime information about
* the operation.
*
* @throws StorageException
* If a storage service error occurred.
* @throws URISyntaxException
*/
@DoesServiceRequest
public final void uploadProperties(final AccessCondition accessCondition, FileRequestOptions options,
OperationContext opContext) throws StorageException, URISyntaxException {
if (opContext == null) {
opContext = new OperationContext();
}
this.getShare().assertNoSnapshot();
opContext.initialize();
options = FileRequestOptions.populateAndApplyDefaults(options, this.fileServiceClient);
ExecutionEngine.executeWithRetry(this.fileServiceClient, this,
this.uploadPropertiesImpl(accessCondition, options), options.getRetryPolicyFactory(), opContext);
}