Skip to content

Commit

Permalink
[Storage] [DataMovement] Made the respective members public to `pro…
Browse files Browse the repository at this point in the history
…tected internal` members (#37604)

* Changed all valid members of the StorageResource class to either protected or protected internal

* Updated Changelog

* PR comments
  • Loading branch information
amnguye authored Jul 17, 2023
1 parent d9bba26 commit b14a49d
Show file tree
Hide file tree
Showing 22 changed files with 478 additions and 274 deletions.
17 changes: 16 additions & 1 deletion sdk/storage/Azure.Storage.DataMovement.Blobs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@
### Features Added

### Breaking Changes

- [BREAKING CHANGE] Made the following members `public` to `protected` members (including all derived classes):
- `BlobStorageResourceContainer.CanProduceUri`
- `BlobStorageResourceContainer.GetStorageResourcesAsync`
- `*BlobStorageResource.CanProduceUri`
- `*BlobStorageResource.Length`
- `*BlobStorageResource.MaxChunkSize`
- `*BlobStorageResource.ResourceId`
- `*BlobStorageResource.TransferType`
- `*BlobStorageResource.CompleteTransferAsync`
- `*BlobStorageResource.CopyBlockFromUriAsync`
- `*BlobStorageResource.CopyFromUriAsync`
- `*BlobStorageResource.DeleteIfExistsAsync`
- `*BlobStorageResource.GetCopyAuthorizationHeaderAsync`
- `*BlobStorageResource.GetPropertiesAsync`
- `*BlobStorageResource.ReadStreamAsync`
- `*BlobStorageResource.WriteFromStreamAsync`
### Bugs Fixed

### Other Changes
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public class AppendBlobStorageResource : StorageResourceSingle
{
internal AppendBlobClient BlobClient { get; set; }
internal AppendBlobStorageResourceOptions _options;
private long? _length;
private ETag? _etagDownloadLock = default;
internal long? _length;
internal ETag? _etagDownloadLock = default;

/// <summary>
/// The identifier for the type of storage resource.
/// </summary>
public override string ResourceId => "AppendBlob";
protected override string ResourceId => "AppendBlob";

/// <summary>
/// Gets the URL of the storage resource.
Expand All @@ -40,24 +40,24 @@ public class AppendBlobStorageResource : StorageResourceSingle
/// <summary>
/// Defines whether the storage resource type can produce a web URL.
/// </summary>
public override bool CanProduceUri => true;
protected override bool CanProduceUri => true;

/// <summary>
/// Defines the recommended Transfer Type for the storage resource.
/// </summary>
public override TransferType TransferType => TransferType.Sequential;
protected override TransferType TransferType => TransferType.Sequential;

/// <summary>
/// Defines the maximum chunk size for the storage resource.
/// </summary>
public override long MaxChunkSize => Constants.Blob.Append.MaxAppendBlockBytes;
protected override long MaxChunkSize => Constants.Blob.Append.MaxAppendBlockBytes;

/// <summary>
/// Length of the storage resource. This information is obtained during a GetStorageResources API call.
///
/// Will return default if the length was not set by a GetStorageResources API call.
/// </summary>
public override long? Length => _length;
protected override long? Length => _length;

/// <summary>
/// The constructor for a new instance of the <see cref="AppendBlobStorageResource"/>
Expand Down Expand Up @@ -104,7 +104,7 @@ internal AppendBlobStorageResource(
/// notifications that the operation should be cancelled.
/// </param>
/// <returns>The <see cref="ReadStreamStorageResourceResult"/> resulting from the upload operation.</returns>
public override async Task<ReadStreamStorageResourceResult> ReadStreamAsync(
protected override async Task<ReadStreamStorageResourceResult> ReadStreamAsync(
long position = 0,
long? length = default,
CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -135,7 +135,7 @@ public override async Task<ReadStreamStorageResourceResult> ReadStreamAsync(
/// notifications that the operation should be cancelled.
/// </param>
/// <returns></returns>
public override async Task WriteFromStreamAsync(
protected override async Task WriteFromStreamAsync(
Stream stream,
long streamLength,
bool overwrite,
Expand Down Expand Up @@ -176,7 +176,7 @@ await BlobClient.AppendBlockAsync(
/// notifications that the operation should be cancelled.
/// </param>
/// <returns></returns>
public override async Task CopyFromUriAsync(
protected override async Task CopyFromUriAsync(
StorageResourceSingle sourceResource,
bool overwrite,
long completeLength,
Expand Down Expand Up @@ -218,7 +218,7 @@ await BlobClient.AppendBlockFromUriAsync(
/// notifications that the operation should be cancelled.
/// </param>
/// <returns></returns>
public override async Task CopyBlockFromUriAsync(
protected override async Task CopyBlockFromUriAsync(
StorageResourceSingle sourceResource,
HttpRange range,
bool overwrite,
Expand Down Expand Up @@ -247,7 +247,7 @@ await BlobClient.AppendBlockFromUriAsync(
/// See <see cref="StorageResourceProperties"/>.
/// </summary>
/// <returns>Returns the properties of the Append Blob Storage Resource. See <see cref="StorageResourceProperties"/>.</returns>
public override async Task<StorageResourceProperties> GetPropertiesAsync(CancellationToken cancellationToken = default)
protected override async Task<StorageResourceProperties> GetPropertiesAsync(CancellationToken cancellationToken = default)
{
Response<BlobProperties> response = await BlobClient.GetPropertiesAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
GrabEtag(response.GetRawResponse());
Expand All @@ -265,15 +265,15 @@ public override async Task<StorageResourceProperties> GetPropertiesAsync(Cancell
/// Gets the HTTP Authorization header for the storage resource if available. If not available
/// will return default.
/// </returns>
public override async Task<HttpAuthorization> GetCopyAuthorizationHeaderAsync(CancellationToken cancellationToken = default)
protected override async Task<HttpAuthorization> GetCopyAuthorizationHeaderAsync(CancellationToken cancellationToken = default)
{
return await BlobBaseClientInternals.GetCopyAuthorizationTokenAsync(BlobClient, cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Commits the block list given.
/// </summary>
public override Task CompleteTransferAsync(bool overwrite, CancellationToken cancellationToken = default)
protected override Task CompleteTransferAsync(bool overwrite, CancellationToken cancellationToken = default)
{
// no-op for now
return Task.CompletedTask;
Expand All @@ -290,7 +290,7 @@ public override Task CompleteTransferAsync(bool overwrite, CancellationToken can
/// If the storage resource exists and is deleted, true will be returned.
/// Otherwise if the storage resource does not exist, false will be returned.
/// </returns>
public override async Task<bool> DeleteIfExistsAsync(CancellationToken cancellationToken = default)
protected override async Task<bool> DeleteIfExistsAsync(CancellationToken cancellationToken = default)
{
return await BlobClient.DeleteIfExistsAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public BlobStorageResourceContainer(BlobContainerClient blobContainerClient, Blo
/// <summary>
/// Defines whether the storage resource type can produce a web URL.
/// </summary>
public override bool CanProduceUri => true;
protected override bool CanProduceUri => true;

/// <summary>
/// Gets the path of the storage resource.
Expand All @@ -67,7 +67,7 @@ public BlobStorageResourceContainer(BlobContainerClient blobContainerClient, Blo
/// Retrieves a single blob resource based on this respective resource.
/// </summary>
/// <param name="path">The path to the storage resource, relative to the directory prefix if any.</param>
public override StorageResourceSingle GetChildStorageResource(string path)
protected override StorageResourceSingle GetChildStorageResource(string path)
=> GetBlobAsStorageResource(ApplyOptionalPrefix(path), type: _options?.BlobType ?? BlobType.Block);

/// <summary>
Expand Down Expand Up @@ -123,7 +123,7 @@ private StorageResourceSingle GetBlobAsStorageResource(
/// Because blobs is a flat namespace, virtual directories will not be returned.
/// </summary>
/// <returns>List of the child resources in the storage container.</returns>
public override async IAsyncEnumerable<StorageResource> GetStorageResourcesAsync(
protected override async IAsyncEnumerable<StorageResource> GetStorageResourcesAsync(
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
AsyncPageable<BlobItem> pages = _blobContainerClient.GetBlobsAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Azure.Storage.Blobs.Models;
using Azure.Storage.Blobs.Specialized;
using Azure.Storage.DataMovement.Models;
using Azure.Storage.Shared;

namespace Azure.Storage.DataMovement.Blobs
{
Expand All @@ -22,19 +23,19 @@ public class BlockBlobStorageResource : StorageResourceSingle
{
internal BlockBlobClient BlobClient { get; set; }
internal BlockBlobStorageResourceOptions _options;
internal long? _length;
internal ETag? _etagDownloadLock = default;

/// <summary>
/// In order to ensure the block list is sent in the correct order
/// we will order them by the offset (i.e. {offset, block_id}).
/// </summary>
private ConcurrentDictionary<long, string> _blocks;
private long? _length;
private ETag? _etagDownloadLock = default;

/// <summary>
/// The identifier for the type of storage resource.
/// </summary>
public override string ResourceId => "BlockBlob";
protected override string ResourceId => "BlockBlob";

/// <summary>
/// Gets the URL of the storage resource.
Expand All @@ -49,12 +50,12 @@ public class BlockBlobStorageResource : StorageResourceSingle
/// <summary>
/// Defines whether the storage resource type can produce a web URL.
/// </summary>
public override bool CanProduceUri => true;
protected override bool CanProduceUri => true;

/// <summary>
/// Defines the recommended Transfer Type of the storage resource.
/// </summary>
public override TransferType TransferType => TransferType.Concurrent;
protected override TransferType TransferType => TransferType.Concurrent;

/// <summary>
/// Store Max Initial Size that a Put Blob can get to.
Expand All @@ -64,14 +65,14 @@ public class BlockBlobStorageResource : StorageResourceSingle
/// <summary>
/// Defines the maximum chunk size for the storage resource.
/// </summary>
public override long MaxChunkSize => Constants.Blob.Block.MaxStageBytes;
protected override long MaxChunkSize => Constants.Blob.Block.MaxStageBytes;

/// <summary>
/// Length of the storage resource. This information is can obtained during a GetStorageResources API call.
///
/// Will return default if the length was not set by a GetStorageResources API call.
/// </summary>
public override long? Length => _length;
protected override long? Length => _length;

/// <summary>
/// The constructor for a new instance of the <see cref="AppendBlobStorageResource"/>
Expand Down Expand Up @@ -120,7 +121,7 @@ internal BlockBlobStorageResource(
/// Optional <see cref="CancellationToken"/> to propagate
/// notifications that the operation should be cancelled.</param>
/// <returns>The <see cref="ReadStreamStorageResourceResult"/> resulting from the upload operation.</returns>
public override async Task<ReadStreamStorageResourceResult> ReadStreamAsync(
protected override async Task<ReadStreamStorageResourceResult> ReadStreamAsync(
long position = 0,
long? length = default,
CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -153,7 +154,7 @@ await BlobClient.DownloadStreamingAsync(
/// notifications that the operation should be cancelled.
/// </param>
/// <returns></returns>
public override async Task WriteFromStreamAsync(
protected override async Task WriteFromStreamAsync(
Stream stream,
long streamLength,
bool overwrite,
Expand All @@ -174,7 +175,7 @@ await BlobClient.UploadAsync(
return;
}

string id = Shared.StorageExtensions.GenerateBlockId(position);
string id = Azure.Storage.Shared.StorageExtensions.GenerateBlockId(position);
if (!_blocks.TryAdd(position, id))
{
throw new ArgumentException($"Cannot Stage Block to the specific offset \"{position}\", it already exists in the block list.");
Expand Down Expand Up @@ -203,7 +204,7 @@ await BlobClient.StageBlockAsync(
/// notifications that the operation should be cancelled.
/// </param>
/// <returns></returns>
public override async Task CopyFromUriAsync(
protected override async Task CopyFromUriAsync(
StorageResourceSingle sourceResource,
bool overwrite,
long completeLength,
Expand Down Expand Up @@ -238,7 +239,7 @@ await BlobClient.SyncUploadFromUriAsync(
/// notifications that the operation should be cancelled.
/// </param>
/// <returns></returns>
public override async Task CopyBlockFromUriAsync(
protected override async Task CopyBlockFromUriAsync(
StorageResourceSingle sourceResource,
HttpRange range,
bool overwrite,
Expand Down Expand Up @@ -270,7 +271,7 @@ await BlobClient.StageBlockFromUriAsync(
/// notifications that the operation should be cancelled.
/// </param>
/// <returns>Returns the properties of the Storage Resource. See <see cref="StorageResourceProperties"/>.</returns>
public override async Task<StorageResourceProperties> GetPropertiesAsync(CancellationToken cancellationToken = default)
protected override async Task<StorageResourceProperties> GetPropertiesAsync(CancellationToken cancellationToken = default)
{
CancellationHelper.ThrowIfCancellationRequested(cancellationToken);
Response<BlobProperties> response = await BlobClient.GetPropertiesAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
Expand All @@ -289,7 +290,7 @@ public override async Task<StorageResourceProperties> GetPropertiesAsync(Cancell
/// Gets the HTTP Authorization header for the storage resource if available. If not available
/// will return default.
/// </returns>
public override async Task<HttpAuthorization> GetCopyAuthorizationHeaderAsync(CancellationToken cancellationToken = default)
protected override async Task<HttpAuthorization> GetCopyAuthorizationHeaderAsync(CancellationToken cancellationToken = default)
{
return await BlobBaseClientInternals.GetCopyAuthorizationTokenAsync(BlobClient, cancellationToken).ConfigureAwait(false);
}
Expand All @@ -305,7 +306,7 @@ public override async Task<HttpAuthorization> GetCopyAuthorizationHeaderAsync(Ca
/// notifications that the operation should be cancelled.
/// </param>
/// <returns>The Task which Commits the list of ids</returns>
public override async Task CompleteTransferAsync(
protected override async Task CompleteTransferAsync(
bool overwrite,
CancellationToken cancellationToken = default)
{
Expand All @@ -332,7 +333,7 @@ await BlobClient.CommitBlockListAsync(
/// If the storage resource exists and is deleted, true will be returned.
/// Otherwise if the storage resource does not exist, false will be returned.
/// </returns>
public override async Task<bool> DeleteIfExistsAsync(CancellationToken cancellationToken = default)
protected override async Task<bool> DeleteIfExistsAsync(CancellationToken cancellationToken = default)
{
return await BlobClient.DeleteIfExistsAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.IO;
using System.Threading.Tasks;
using System.Threading;
using Azure.Storage.Blobs.Models;
Expand Down
Loading

0 comments on commit b14a49d

Please sign in to comment.