diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/CHANGELOG.md b/sdk/storage/Azure.Storage.DataMovement.Blobs/CHANGELOG.md index 7b464913527ba..78511803539c2 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/CHANGELOG.md +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/CHANGELOG.md @@ -21,6 +21,11 @@ - `*BlobStorageResource.GetPropertiesAsync` - `*BlobStorageResource.ReadStreamAsync` - `*BlobStorageResource.WriteFromStreamAsync` +- [BREAKING CHANGE] Renamed `BlobStorageResourceProvider.MakeResourceAsync` to `BlobStorageResourceProvider.CreateResourceAsync` +- [BREAKING CHANGE] Renamed `BlobStorageResourceContainerOptions.DirectoryPrefix` to `BlobDirectoryPrefix` +- [BREAKING CHANGE] Renamed `BlobStorageResourceContainerOptions.ResourceOptions` to `BlobOptions` +- [BREAKING CHANGE] Moved `BlobContainerClientTransferOptions` to the `Azure.Storage.DataMovement.Blobs` namespace + ### Bugs Fixed ### Other Changes diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/README.md b/sdk/storage/Azure.Storage.DataMovement.Blobs/README.md index beee7d543ee00..dbe8941187ed4 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/README.md +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/README.md @@ -97,11 +97,11 @@ BlobContainerClientTransferOptions options = new BlobContainerClientTransferOpti { BlobContainerOptions = new BlobStorageResourceContainerOptions { - DirectoryPrefix = blobDirectoryPrefix + BlobDirectoryPrefix = blobDirectoryPrefix }, - TransferOptions = new TransferOptions() + TransferOptions = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, } }; @@ -130,11 +130,11 @@ BlobContainerClientTransferOptions options = new BlobContainerClientTransferOpti { BlobContainerOptions = new BlobStorageResourceContainerOptions { - DirectoryPrefix = blobDirectoryPrefix + BlobDirectoryPrefix = blobDirectoryPrefix }, - TransferOptions = new TransferOptions() + TransferOptions = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, } }; @@ -159,7 +159,7 @@ Blob `StorageResource` objects can be constructed with optional "options" argume ```C# Snippet:ResourceConstruction_Blobs_WithOptions_VirtualDirectory BlobStorageResourceContainerOptions virtualDirectoryOptions = new() { - DirectoryPrefix = "blob/directory/prefix" + BlobDirectoryPrefix = "blob/directory/prefix" }; StorageResource virtualDirectoryResource = new BlobStorageResourceContainer( @@ -190,9 +190,9 @@ if (BlobStorageResources.TryGetResourceProviders( out BlobStorageResourceProvider blobSrcProvider, out BlobStorageResourceProvider blobDstProvider)) { - sourceResource ??= await blobSrcProvider?.MakeResourceAsync( + sourceResource ??= await blobSrcProvider?.CreateResourceAsync( GenerateMySasCredential(info.SourcePath)); - destinationResource ??= await blobSrcProvider?.MakeResourceAsync( + destinationResource ??= await blobSrcProvider?.CreateResourceAsync( GenerateMySasCredential(info.DestinationPath)); } ``` @@ -221,7 +221,7 @@ DataTransfer dataTransfer = await transferManager.StartTransferAsync( { // Block blobs are the default if not specified BlobType = BlobType.Block, - DirectoryPrefix = optionalDestinationPrefix, + BlobDirectoryPrefix = optionalDestinationPrefix, }), transferOptions: options); await dataTransfer.WaitForCompletionAsync(); @@ -248,7 +248,7 @@ DataTransfer dataTransfer = await transferManager.StartTransferAsync( blobContainerClient, new BlobStorageResourceContainerOptions() { - DirectoryPrefix = optionalSourcePrefix + BlobDirectoryPrefix = optionalSourcePrefix }), destinationResource: new LocalDirectoryStorageResourceContainer(downloadPath)); await dataTransfer.WaitForCompletionAsync(); @@ -275,7 +275,7 @@ DataTransfer dataTransfer = await transferManager.StartTransferAsync( sourceContainer, new BlobStorageResourceContainerOptions() { - DirectoryPrefix = sourceDirectoryName + BlobDirectoryPrefix = sourceDirectoryName }), destinationResource: new BlobStorageResourceContainer( destinationContainer, @@ -284,7 +284,7 @@ DataTransfer dataTransfer = await transferManager.StartTransferAsync( // all source blobs will be copied as a single type of destination blob // defaults to block blobs if unspecified BlobType = BlobType.Block, - DirectoryPrefix = downloadPath + BlobDirectoryPrefix = downloadPath })); ``` diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/api/Azure.Storage.DataMovement.Blobs.net6.0.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/api/Azure.Storage.DataMovement.Blobs.net6.0.cs index 72037cac651eb..7ea896a45d817 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/api/Azure.Storage.DataMovement.Blobs.net6.0.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/api/Azure.Storage.DataMovement.Blobs.net6.0.cs @@ -2,24 +2,15 @@ namespace Azure.Storage.Blobs { public static partial class BlobContainerClientExtensions { - public static System.Threading.Tasks.Task StartDownloadToDirectoryAsync(this Azure.Storage.Blobs.BlobContainerClient client, string localDirectoryPath, Azure.Storage.Blobs.Models.BlobContainerClientTransferOptions options) { throw null; } + public static System.Threading.Tasks.Task StartDownloadToDirectoryAsync(this Azure.Storage.Blobs.BlobContainerClient client, string localDirectoryPath, Azure.Storage.DataMovement.Blobs.BlobContainerClientTransferOptions options) { throw null; } public static System.Threading.Tasks.Task StartDownloadToDirectoryAsync(this Azure.Storage.Blobs.BlobContainerClient client, string localDirectoryPath, string blobDirectoryPrefix = null) { throw null; } - public static System.Threading.Tasks.Task StartUploadDirectoryAsync(this Azure.Storage.Blobs.BlobContainerClient client, string localDirectoryPath, Azure.Storage.Blobs.Models.BlobContainerClientTransferOptions options) { throw null; } + public static System.Threading.Tasks.Task StartUploadDirectoryAsync(this Azure.Storage.Blobs.BlobContainerClient client, string localDirectoryPath, Azure.Storage.DataMovement.Blobs.BlobContainerClientTransferOptions options) { throw null; } public static System.Threading.Tasks.Task StartUploadDirectoryAsync(this Azure.Storage.Blobs.BlobContainerClient client, string localDirectoryPath, string blobDirectoryPrefix = null) { throw null; } } } -namespace Azure.Storage.Blobs.Models -{ - public partial class BlobContainerClientTransferOptions - { - public BlobContainerClientTransferOptions() { } - public Azure.Storage.DataMovement.Blobs.BlobStorageResourceContainerOptions BlobContainerOptions { get { throw null; } set { } } - public Azure.Storage.DataMovement.TransferOptions TransferOptions { get { throw null; } set { } } - } -} namespace Azure.Storage.DataMovement.Blobs { - public partial class AppendBlobStorageResource : Azure.Storage.DataMovement.StorageResourceSingle + public partial class AppendBlobStorageResource : Azure.Storage.DataMovement.StorageResourceItem { public AppendBlobStorageResource(Azure.Storage.Blobs.Specialized.AppendBlobClient blobClient, Azure.Storage.DataMovement.Blobs.AppendBlobStorageResourceOptions options = null) { } protected override bool CanProduceUri { get { throw null; } } @@ -27,16 +18,16 @@ public AppendBlobStorageResource(Azure.Storage.Blobs.Specialized.AppendBlobClien protected override long MaxChunkSize { get { throw null; } } public override string Path { get { throw null; } } protected override string ResourceId { get { throw null; } } - protected override Azure.Storage.DataMovement.TransferType TransferType { get { throw null; } } + protected override Azure.Storage.DataMovement.DataTransferOrder TransferType { get { throw null; } } public override System.Uri Uri { get { throw null; } } protected override System.Threading.Tasks.Task CompleteTransferAsync(bool overwrite, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task DeleteIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task GetCopyAuthorizationHeaderAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task GetPropertiesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task WriteFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class AppendBlobStorageResourceOptions : Azure.Storage.DataMovement.Blobs.BlobStorageResourceOptions { @@ -44,21 +35,27 @@ public AppendBlobStorageResourceOptions() { } public Azure.Storage.Blobs.Models.AppendBlobRequestConditions DestinationConditions { get { throw null; } set { } } public Azure.Storage.Blobs.Models.AppendBlobRequestConditions SourceConditions { get { throw null; } set { } } } + public partial class BlobContainerClientTransferOptions + { + public BlobContainerClientTransferOptions() { } + public Azure.Storage.DataMovement.Blobs.BlobStorageResourceContainerOptions BlobContainerOptions { get { throw null; } set { } } + public Azure.Storage.DataMovement.DataTransferOptions TransferOptions { get { throw null; } set { } } + } public partial class BlobStorageResourceContainer : Azure.Storage.DataMovement.StorageResourceContainer { public BlobStorageResourceContainer(Azure.Storage.Blobs.BlobContainerClient blobContainerClient, Azure.Storage.DataMovement.Blobs.BlobStorageResourceContainerOptions options = null) { } protected override bool CanProduceUri { get { throw null; } } public override string Path { get { throw null; } } public override System.Uri Uri { get { throw null; } } - protected override Azure.Storage.DataMovement.StorageResourceSingle GetChildStorageResource(string path) { throw null; } + protected override Azure.Storage.DataMovement.StorageResourceItem GetStorageResourceReference(string path) { throw null; } protected override System.Collections.Generic.IAsyncEnumerable GetStorageResourcesAsync([System.Runtime.CompilerServices.EnumeratorCancellationAttribute] System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class BlobStorageResourceContainerOptions { public BlobStorageResourceContainerOptions() { } + public string BlobDirectoryPrefix { get { throw null; } set { } } + public Azure.Storage.DataMovement.Blobs.BlobStorageResourceOptions BlobOptions { get { throw null; } set { } } public Azure.Storage.Blobs.Models.BlobType BlobType { get { throw null; } set { } } - public string DirectoryPrefix { get { throw null; } set { } } - public Azure.Storage.DataMovement.Blobs.BlobStorageResourceOptions ResourceOptions { get { throw null; } set { } } } public partial class BlobStorageResourceOptions { @@ -75,16 +72,16 @@ public BlobStorageResourceOptions() { } public partial class BlobStorageResourceProvider { internal BlobStorageResourceProvider() { } - public System.Threading.Tasks.Task MakeResourceAsync(Azure.AzureSasCredential credential, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public System.Threading.Tasks.Task MakeResourceAsync(Azure.Core.TokenCredential credential, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public System.Threading.Tasks.Task CreateResourceAsync(Azure.AzureSasCredential credential, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public System.Threading.Tasks.Task CreateResourceAsync(Azure.Core.TokenCredential credential, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public System.Threading.Tasks.Task CreateResourceAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public System.Threading.Tasks.Task MakeResourceAsync(Azure.Storage.StorageSharedKeyCredential credential, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public System.Threading.Tasks.Task MakeResourceAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public static partial class BlobStorageResources { public static bool TryGetResourceProviders(Azure.Storage.DataMovement.DataTransferProperties info, out Azure.Storage.DataMovement.Blobs.BlobStorageResourceProvider sourceProvider, out Azure.Storage.DataMovement.Blobs.BlobStorageResourceProvider destinationProvider) { throw null; } } - public partial class BlockBlobStorageResource : Azure.Storage.DataMovement.StorageResourceSingle + public partial class BlockBlobStorageResource : Azure.Storage.DataMovement.StorageResourceItem { public BlockBlobStorageResource(Azure.Storage.Blobs.Specialized.BlockBlobClient blobClient, Azure.Storage.DataMovement.Blobs.BlockBlobStorageResourceOptions options = null) { } protected override bool CanProduceUri { get { throw null; } } @@ -92,16 +89,16 @@ public BlockBlobStorageResource(Azure.Storage.Blobs.Specialized.BlockBlobClient protected override long MaxChunkSize { get { throw null; } } public override string Path { get { throw null; } } protected override string ResourceId { get { throw null; } } - protected override Azure.Storage.DataMovement.TransferType TransferType { get { throw null; } } + protected override Azure.Storage.DataMovement.DataTransferOrder TransferType { get { throw null; } } public override System.Uri Uri { get { throw null; } } protected override System.Threading.Tasks.Task CompleteTransferAsync(bool overwrite, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task DeleteIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task GetCopyAuthorizationHeaderAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task GetPropertiesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task WriteFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class BlockBlobStorageResourceOptions : Azure.Storage.DataMovement.Blobs.BlobStorageResourceOptions { @@ -109,7 +106,7 @@ public BlockBlobStorageResourceOptions() { } public Azure.Storage.Blobs.Models.BlobRequestConditions DestinationConditions { get { throw null; } set { } } public Azure.Storage.Blobs.Models.BlobRequestConditions SourceConditions { get { throw null; } set { } } } - public partial class PageBlobStorageResource : Azure.Storage.DataMovement.StorageResourceSingle + public partial class PageBlobStorageResource : Azure.Storage.DataMovement.StorageResourceItem { public PageBlobStorageResource(Azure.Storage.Blobs.Specialized.PageBlobClient blobClient, Azure.Storage.DataMovement.Blobs.PageBlobStorageResourceOptions options = null) { } protected override bool CanProduceUri { get { throw null; } } @@ -117,16 +114,16 @@ public PageBlobStorageResource(Azure.Storage.Blobs.Specialized.PageBlobClient bl protected override long MaxChunkSize { get { throw null; } } public override string Path { get { throw null; } } protected override string ResourceId { get { throw null; } } - protected override Azure.Storage.DataMovement.TransferType TransferType { get { throw null; } } + protected override Azure.Storage.DataMovement.DataTransferOrder TransferType { get { throw null; } } public override System.Uri Uri { get { throw null; } } protected override System.Threading.Tasks.Task CompleteTransferAsync(bool overwrite, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task DeleteIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task GetCopyAuthorizationHeaderAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task GetPropertiesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task WriteFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class PageBlobStorageResourceOptions : Azure.Storage.DataMovement.Blobs.BlobStorageResourceOptions { diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/api/Azure.Storage.DataMovement.Blobs.netstandard2.0.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/api/Azure.Storage.DataMovement.Blobs.netstandard2.0.cs index 72037cac651eb..7ea896a45d817 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/api/Azure.Storage.DataMovement.Blobs.netstandard2.0.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/api/Azure.Storage.DataMovement.Blobs.netstandard2.0.cs @@ -2,24 +2,15 @@ namespace Azure.Storage.Blobs { public static partial class BlobContainerClientExtensions { - public static System.Threading.Tasks.Task StartDownloadToDirectoryAsync(this Azure.Storage.Blobs.BlobContainerClient client, string localDirectoryPath, Azure.Storage.Blobs.Models.BlobContainerClientTransferOptions options) { throw null; } + public static System.Threading.Tasks.Task StartDownloadToDirectoryAsync(this Azure.Storage.Blobs.BlobContainerClient client, string localDirectoryPath, Azure.Storage.DataMovement.Blobs.BlobContainerClientTransferOptions options) { throw null; } public static System.Threading.Tasks.Task StartDownloadToDirectoryAsync(this Azure.Storage.Blobs.BlobContainerClient client, string localDirectoryPath, string blobDirectoryPrefix = null) { throw null; } - public static System.Threading.Tasks.Task StartUploadDirectoryAsync(this Azure.Storage.Blobs.BlobContainerClient client, string localDirectoryPath, Azure.Storage.Blobs.Models.BlobContainerClientTransferOptions options) { throw null; } + public static System.Threading.Tasks.Task StartUploadDirectoryAsync(this Azure.Storage.Blobs.BlobContainerClient client, string localDirectoryPath, Azure.Storage.DataMovement.Blobs.BlobContainerClientTransferOptions options) { throw null; } public static System.Threading.Tasks.Task StartUploadDirectoryAsync(this Azure.Storage.Blobs.BlobContainerClient client, string localDirectoryPath, string blobDirectoryPrefix = null) { throw null; } } } -namespace Azure.Storage.Blobs.Models -{ - public partial class BlobContainerClientTransferOptions - { - public BlobContainerClientTransferOptions() { } - public Azure.Storage.DataMovement.Blobs.BlobStorageResourceContainerOptions BlobContainerOptions { get { throw null; } set { } } - public Azure.Storage.DataMovement.TransferOptions TransferOptions { get { throw null; } set { } } - } -} namespace Azure.Storage.DataMovement.Blobs { - public partial class AppendBlobStorageResource : Azure.Storage.DataMovement.StorageResourceSingle + public partial class AppendBlobStorageResource : Azure.Storage.DataMovement.StorageResourceItem { public AppendBlobStorageResource(Azure.Storage.Blobs.Specialized.AppendBlobClient blobClient, Azure.Storage.DataMovement.Blobs.AppendBlobStorageResourceOptions options = null) { } protected override bool CanProduceUri { get { throw null; } } @@ -27,16 +18,16 @@ public AppendBlobStorageResource(Azure.Storage.Blobs.Specialized.AppendBlobClien protected override long MaxChunkSize { get { throw null; } } public override string Path { get { throw null; } } protected override string ResourceId { get { throw null; } } - protected override Azure.Storage.DataMovement.TransferType TransferType { get { throw null; } } + protected override Azure.Storage.DataMovement.DataTransferOrder TransferType { get { throw null; } } public override System.Uri Uri { get { throw null; } } protected override System.Threading.Tasks.Task CompleteTransferAsync(bool overwrite, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task DeleteIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task GetCopyAuthorizationHeaderAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task GetPropertiesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task WriteFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class AppendBlobStorageResourceOptions : Azure.Storage.DataMovement.Blobs.BlobStorageResourceOptions { @@ -44,21 +35,27 @@ public AppendBlobStorageResourceOptions() { } public Azure.Storage.Blobs.Models.AppendBlobRequestConditions DestinationConditions { get { throw null; } set { } } public Azure.Storage.Blobs.Models.AppendBlobRequestConditions SourceConditions { get { throw null; } set { } } } + public partial class BlobContainerClientTransferOptions + { + public BlobContainerClientTransferOptions() { } + public Azure.Storage.DataMovement.Blobs.BlobStorageResourceContainerOptions BlobContainerOptions { get { throw null; } set { } } + public Azure.Storage.DataMovement.DataTransferOptions TransferOptions { get { throw null; } set { } } + } public partial class BlobStorageResourceContainer : Azure.Storage.DataMovement.StorageResourceContainer { public BlobStorageResourceContainer(Azure.Storage.Blobs.BlobContainerClient blobContainerClient, Azure.Storage.DataMovement.Blobs.BlobStorageResourceContainerOptions options = null) { } protected override bool CanProduceUri { get { throw null; } } public override string Path { get { throw null; } } public override System.Uri Uri { get { throw null; } } - protected override Azure.Storage.DataMovement.StorageResourceSingle GetChildStorageResource(string path) { throw null; } + protected override Azure.Storage.DataMovement.StorageResourceItem GetStorageResourceReference(string path) { throw null; } protected override System.Collections.Generic.IAsyncEnumerable GetStorageResourcesAsync([System.Runtime.CompilerServices.EnumeratorCancellationAttribute] System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class BlobStorageResourceContainerOptions { public BlobStorageResourceContainerOptions() { } + public string BlobDirectoryPrefix { get { throw null; } set { } } + public Azure.Storage.DataMovement.Blobs.BlobStorageResourceOptions BlobOptions { get { throw null; } set { } } public Azure.Storage.Blobs.Models.BlobType BlobType { get { throw null; } set { } } - public string DirectoryPrefix { get { throw null; } set { } } - public Azure.Storage.DataMovement.Blobs.BlobStorageResourceOptions ResourceOptions { get { throw null; } set { } } } public partial class BlobStorageResourceOptions { @@ -75,16 +72,16 @@ public BlobStorageResourceOptions() { } public partial class BlobStorageResourceProvider { internal BlobStorageResourceProvider() { } - public System.Threading.Tasks.Task MakeResourceAsync(Azure.AzureSasCredential credential, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public System.Threading.Tasks.Task MakeResourceAsync(Azure.Core.TokenCredential credential, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public System.Threading.Tasks.Task CreateResourceAsync(Azure.AzureSasCredential credential, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public System.Threading.Tasks.Task CreateResourceAsync(Azure.Core.TokenCredential credential, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public System.Threading.Tasks.Task CreateResourceAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public System.Threading.Tasks.Task MakeResourceAsync(Azure.Storage.StorageSharedKeyCredential credential, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public System.Threading.Tasks.Task MakeResourceAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public static partial class BlobStorageResources { public static bool TryGetResourceProviders(Azure.Storage.DataMovement.DataTransferProperties info, out Azure.Storage.DataMovement.Blobs.BlobStorageResourceProvider sourceProvider, out Azure.Storage.DataMovement.Blobs.BlobStorageResourceProvider destinationProvider) { throw null; } } - public partial class BlockBlobStorageResource : Azure.Storage.DataMovement.StorageResourceSingle + public partial class BlockBlobStorageResource : Azure.Storage.DataMovement.StorageResourceItem { public BlockBlobStorageResource(Azure.Storage.Blobs.Specialized.BlockBlobClient blobClient, Azure.Storage.DataMovement.Blobs.BlockBlobStorageResourceOptions options = null) { } protected override bool CanProduceUri { get { throw null; } } @@ -92,16 +89,16 @@ public BlockBlobStorageResource(Azure.Storage.Blobs.Specialized.BlockBlobClient protected override long MaxChunkSize { get { throw null; } } public override string Path { get { throw null; } } protected override string ResourceId { get { throw null; } } - protected override Azure.Storage.DataMovement.TransferType TransferType { get { throw null; } } + protected override Azure.Storage.DataMovement.DataTransferOrder TransferType { get { throw null; } } public override System.Uri Uri { get { throw null; } } protected override System.Threading.Tasks.Task CompleteTransferAsync(bool overwrite, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task DeleteIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task GetCopyAuthorizationHeaderAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task GetPropertiesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task WriteFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class BlockBlobStorageResourceOptions : Azure.Storage.DataMovement.Blobs.BlobStorageResourceOptions { @@ -109,7 +106,7 @@ public BlockBlobStorageResourceOptions() { } public Azure.Storage.Blobs.Models.BlobRequestConditions DestinationConditions { get { throw null; } set { } } public Azure.Storage.Blobs.Models.BlobRequestConditions SourceConditions { get { throw null; } set { } } } - public partial class PageBlobStorageResource : Azure.Storage.DataMovement.StorageResourceSingle + public partial class PageBlobStorageResource : Azure.Storage.DataMovement.StorageResourceItem { public PageBlobStorageResource(Azure.Storage.Blobs.Specialized.PageBlobClient blobClient, Azure.Storage.DataMovement.Blobs.PageBlobStorageResourceOptions options = null) { } protected override bool CanProduceUri { get { throw null; } } @@ -117,16 +114,16 @@ public PageBlobStorageResource(Azure.Storage.Blobs.Specialized.PageBlobClient bl protected override long MaxChunkSize { get { throw null; } } public override string Path { get { throw null; } } protected override string ResourceId { get { throw null; } } - protected override Azure.Storage.DataMovement.TransferType TransferType { get { throw null; } } + protected override Azure.Storage.DataMovement.DataTransferOrder TransferType { get { throw null; } } public override System.Uri Uri { get { throw null; } } protected override System.Threading.Tasks.Task CompleteTransferAsync(bool overwrite, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task DeleteIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task GetCopyAuthorizationHeaderAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected override System.Threading.Tasks.Task GetPropertiesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected override System.Threading.Tasks.Task WriteFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class PageBlobStorageResourceOptions : Azure.Storage.DataMovement.Blobs.BlobStorageResourceOptions { diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/samples/Sample01b_HelloWorldAsync.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/samples/Sample01b_HelloWorldAsync.cs index 9ff24986ad81a..b9cb32ed9e0a6 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/samples/Sample01b_HelloWorldAsync.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/samples/Sample01b_HelloWorldAsync.cs @@ -65,7 +65,7 @@ public async Task ResourceConstructionDemonstration() #region Snippet:ResourceConstruction_Blobs_WithOptions_VirtualDirectory BlobStorageResourceContainerOptions virtualDirectoryOptions = new() { - DirectoryPrefix = "blob/directory/prefix" + BlobDirectoryPrefix = "blob/directory/prefix" }; StorageResource virtualDirectoryResource = new BlobStorageResourceContainer( @@ -161,7 +161,7 @@ public async Task RehydrateBlobResource_SasAsync() DataTransfer dataTransfer = await transferManager.StartTransferAsync( sourceResource: source, destinationResource: destination); - await dataTransfer.PauseIfRunningAsync(); + await dataTransfer.PauseAsync(); DataTransferProperties info = await transferManager.GetResumableTransfersAsync().FirstAsync(); @@ -181,9 +181,9 @@ AzureSasCredential GenerateMySasCredential(string blobUri) out BlobStorageResourceProvider blobSrcProvider, out BlobStorageResourceProvider blobDstProvider)) { - sourceResource ??= await blobSrcProvider?.MakeResourceAsync( + sourceResource ??= await blobSrcProvider?.CreateResourceAsync( GenerateMySasCredential(info.SourcePath)); - destinationResource ??= await blobSrcProvider?.MakeResourceAsync( + destinationResource ??= await blobSrcProvider?.CreateResourceAsync( GenerateMySasCredential(info.DestinationPath)); } #endregion @@ -249,7 +249,7 @@ public async Task DownloadSingle_SharedKeyAuthAsync() // Create Blob Data Controller to skip through all failures TransferManagerOptions options = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; TransferManager transferManager = new TransferManager(options); @@ -340,14 +340,14 @@ public async Task UploadDirectory_SasAsync() // Get a storage resource to a destination blob directory StorageResourceContainer directoryDestination = new BlobStorageResourceContainer( blobContainerClient, - new BlobStorageResourceContainerOptions() { DirectoryPrefix = "sample-directory" }); + new BlobStorageResourceContainerOptions() { BlobDirectoryPrefix = "sample-directory" }); // Create BlobTransferManager with event handler in Options bag TransferManagerOptions transferManagerOptions = new TransferManagerOptions(); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { MaximumTransferChunkSize = 4 * Constants.MB, - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; TransferManager transferManager = new TransferManager(transferManagerOptions); @@ -362,7 +362,7 @@ public async Task UploadDirectory_SasAsync() { // Block blobs are the default if not specified BlobType = BlobType.Block, - DirectoryPrefix = optionalDestinationPrefix, + BlobDirectoryPrefix = optionalDestinationPrefix, }), transferOptions: options); await dataTransfer.WaitForCompletionAsync(); @@ -437,8 +437,8 @@ public async Task UploadDirectory_CompletedEventHandler() { // Create BlobTransferManager with event handler in Options bag TransferManagerOptions options = new TransferManagerOptions(); - TransferOptions transferOptions = new TransferOptions(); - transferOptions.SingleTransferCompleted += (SingleTransferCompletedEventArgs args) => + DataTransferOptions transferOptions = new DataTransferOptions(); + transferOptions.ItemTransferCompleted += (TransferItemCompletedEventArgs args) => { using (StreamWriter logStream = File.AppendText(logFile)) { @@ -453,7 +453,7 @@ public async Task UploadDirectory_CompletedEventHandler() new LocalDirectoryStorageResourceContainer(sourcePath), new BlobStorageResourceContainer( container, - new BlobStorageResourceContainerOptions() { DirectoryPrefix = "sample-blob-directory" })); + new BlobStorageResourceContainerOptions() { BlobDirectoryPrefix = "sample-blob-directory" })); } finally { @@ -524,10 +524,10 @@ public async Task UploadDirectory_EventHandler_SasAsync() { // Create BlobTransferManager with event handler in Options bag TransferManagerOptions options = new TransferManagerOptions(); - TransferOptions transferOptions = new TransferOptions(); - transferOptions.TransferStatus += (TransferStatusEventArgs args) => + DataTransferOptions transferOptions = new DataTransferOptions(); + transferOptions.TransferStatusChanged += (TransferStatusEventArgs args) => { - if (args.StorageTransferStatus == StorageTransferStatus.Completed) + if (args.StorageTransferStatus == DataTransferStatus.Completed) { using (StreamWriter logStream = File.AppendText(logFile)) { @@ -536,7 +536,7 @@ public async Task UploadDirectory_EventHandler_SasAsync() } return Task.CompletedTask; }; - transferOptions.TransferFailed += (TransferFailedEventArgs args) => + transferOptions.ItemTransferFailed += (TransferItemFailedEventArgs args) => { using (StreamWriter logStream = File.AppendText(logFile)) { @@ -556,7 +556,7 @@ public async Task UploadDirectory_EventHandler_SasAsync() new LocalDirectoryStorageResourceContainer(sourcePath), new BlobStorageResourceContainer( container, - new BlobStorageResourceContainerOptions() { DirectoryPrefix = "sample-blob-directory" })); + new BlobStorageResourceContainerOptions() { BlobDirectoryPrefix = "sample-blob-directory" })); } finally { @@ -609,9 +609,9 @@ public async Task DownloadDirectory_EventHandler_ActiveDirectoryAuthAsync() { // Get a reference to a source blobs and upload sample content to download StorageResourceContainer sourceDirectory = new BlobStorageResourceContainer(blobContainerClient, - new BlobStorageResourceContainerOptions() { DirectoryPrefix = "sample-blob-directory" }); + new BlobStorageResourceContainerOptions() { BlobDirectoryPrefix = "sample-blob-directory" }); StorageResourceContainer sourceDirectory2 = new BlobStorageResourceContainer(blobContainerClient, - new BlobStorageResourceContainerOptions() { DirectoryPrefix = "sample-blob-directory2" }); + new BlobStorageResourceContainerOptions() { BlobDirectoryPrefix = "sample-blob-directory2" }); StorageResourceContainer destinationDirectory = new LocalDirectoryStorageResourceContainer(downloadPath); StorageResourceContainer destinationDirectory2 = new LocalDirectoryStorageResourceContainer(downloadPath2); @@ -624,8 +624,8 @@ public async Task DownloadDirectory_EventHandler_ActiveDirectoryAuthAsync() // Create BlobTransferManager with event handler in Options bag TransferManagerOptions options = new TransferManagerOptions(); - TransferOptions downloadOptions = new TransferOptions(); - downloadOptions.TransferFailed += async (TransferFailedEventArgs args) => + DataTransferOptions downloadOptions = new DataTransferOptions(); + downloadOptions.ItemTransferFailed += async (TransferItemFailedEventArgs args) => { // Log Exception Message Console.WriteLine(args.Exception.Message); @@ -646,7 +646,7 @@ await transferManager.StartTransferAsync( blobContainerClient, new BlobStorageResourceContainerOptions() { - DirectoryPrefix = optionalSourcePrefix + BlobDirectoryPrefix = optionalSourcePrefix }), destinationResource: new LocalDirectoryStorageResourceContainer(downloadPath)); await dataTransfer.WaitForCompletionAsync(); @@ -713,7 +713,7 @@ public async Task CopySingle_ConnectionStringAsync() #endregion Assert.IsTrue(await destinationAppendBlobClient.ExistsAsync()); - Assert.AreEqual(dataTransfer.TransferStatus, StorageTransferStatus.Completed); + Assert.AreEqual(dataTransfer.TransferStatus, DataTransferStatus.Completed); } finally { @@ -767,9 +767,9 @@ public async Task CopyDirectory() // Get a reference to a source blobs and upload sample content to download StorageResourceContainer sourceDirectory1 = new BlobStorageResourceContainer(container, - new BlobStorageResourceContainerOptions() { DirectoryPrefix = sourceDirectoryName }); + new BlobStorageResourceContainerOptions() { BlobDirectoryPrefix = sourceDirectoryName }); StorageResourceContainer sourceDirectory2 = new BlobStorageResourceContainer(container, - new BlobStorageResourceContainerOptions() { DirectoryPrefix = sourceDirectoryName2 }); + new BlobStorageResourceContainerOptions() { BlobDirectoryPrefix = sourceDirectoryName2 }); // Create destination paths StorageResourceContainer destinationDirectory1 = new LocalDirectoryStorageResourceContainer(downloadPath); @@ -786,8 +786,8 @@ public async Task CopyDirectory() // Create Blob Transfer Manager TransferManager transferManager = new TransferManager(default); #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously - TransferOptions options = new TransferOptions(); - options.TransferFailed += async (TransferFailedEventArgs args) => + DataTransferOptions options = new DataTransferOptions(); + options.ItemTransferFailed += async (TransferItemFailedEventArgs args) => { //await LogFailedFileAsync(args.SourceFileUri, args.DestinationFileClient.Uri, args.Exception.Message); }; @@ -802,7 +802,7 @@ public async Task CopyDirectory() sourceContainer, new BlobStorageResourceContainerOptions() { - DirectoryPrefix = sourceDirectoryName + BlobDirectoryPrefix = sourceDirectoryName }), destinationResource: new BlobStorageResourceContainer( destinationContainer, @@ -811,7 +811,7 @@ public async Task CopyDirectory() // all source blobs will be copied as a single type of destination blob // defaults to block blobs if unspecified BlobType = BlobType.Block, - DirectoryPrefix = downloadPath + BlobDirectoryPrefix = downloadPath })); #endregion } @@ -878,8 +878,8 @@ StorageSharedKeyCredential GetMyCredential(string uri) out LocalStorageResourceProvider localSrcProvider, out LocalStorageResourceProvider localDstProvider)) { - sourceResource ??= localSrcProvider.MakeResource(); - destinationResource ??= localDstProvider.MakeResource(); + sourceResource ??= localSrcProvider.CreateResource(); + destinationResource ??= localDstProvider.CreateResource(); } return (sourceResource, destinationResource); } @@ -942,7 +942,7 @@ public async Task PauseAndResumeAsync_DataTransferPause() destinationResource: destinationResource); // Pause from the DataTransfer object - await dataTransfer.PauseIfRunningAsync(); + await dataTransfer.PauseAsync(); DataTransfer resumedTransfer = await transferManager.ResumeTransferAsync( transferId: dataTransfer.Id, @@ -1007,11 +1007,11 @@ public async Task UploadDirectory() { BlobContainerOptions = new BlobStorageResourceContainerOptions { - DirectoryPrefix = blobDirectoryPrefix + BlobDirectoryPrefix = blobDirectoryPrefix }, - TransferOptions = new TransferOptions() + TransferOptions = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, } }; @@ -1077,11 +1077,11 @@ public async Task DownloadDirectory() { BlobContainerOptions = new BlobStorageResourceContainerOptions { - DirectoryPrefix = blobDirectoryPrefix + BlobDirectoryPrefix = blobDirectoryPrefix }, - TransferOptions = new TransferOptions() + TransferOptions = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, } }; diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/AppendBlobStorageResource.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/AppendBlobStorageResource.cs index 57ee2f8c59925..c1d8c26d278aa 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/AppendBlobStorageResource.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/AppendBlobStorageResource.cs @@ -15,7 +15,7 @@ namespace Azure.Storage.DataMovement.Blobs /// /// The AppendBlobStorageResource class. /// - public class AppendBlobStorageResource : StorageResourceSingle + public class AppendBlobStorageResource : StorageResourceItem { internal AppendBlobClient BlobClient { get; set; } internal AppendBlobStorageResourceOptions _options; @@ -45,7 +45,7 @@ public class AppendBlobStorageResource : StorageResourceSingle /// /// Defines the recommended Transfer Type for the storage resource. /// - protected override TransferType TransferType => TransferType.Sequential; + protected override DataTransferOrder TransferType => DataTransferOrder.Sequential; /// /// Defines the maximum chunk size for the storage resource. @@ -103,8 +103,8 @@ internal AppendBlobStorageResource( /// Optional to propagate /// notifications that the operation should be cancelled. /// - /// The resulting from the upload operation. - protected override async Task ReadStreamAsync( + /// The resulting from the upload operation. + protected override async Task ReadStreamAsync( long position = 0, long? length = default, CancellationToken cancellationToken = default) @@ -135,7 +135,7 @@ protected override async Task ReadStreamAsync( /// notifications that the operation should be cancelled. /// /// - protected override async Task WriteFromStreamAsync( + protected override async Task CopyFromStreamAsync( Stream stream, long streamLength, bool overwrite, @@ -162,7 +162,7 @@ await BlobClient.AppendBlockAsync( /// /// Uploads/copy the blob from a URL. /// - /// An instance of + /// An instance of /// that contains the data to be uploaded. /// /// If set to true, will overwrite the blob if it currently exists. @@ -177,7 +177,7 @@ await BlobClient.AppendBlockAsync( /// /// protected override async Task CopyFromUriAsync( - StorageResourceSingle sourceResource, + StorageResourceItem sourceResource, bool overwrite, long completeLength, StorageResourceCopyFromUriOptions options = default, @@ -203,7 +203,7 @@ await BlobClient.AppendBlockFromUriAsync( /// /// Uploads/copy the blob from a URL. Supports ranged operations. /// - /// An instance of + /// An instance of /// that contains the data to be uploaded. /// /// If set to true, will overwrite the blob if it already exists. @@ -219,7 +219,7 @@ await BlobClient.AppendBlockFromUriAsync( /// /// protected override async Task CopyBlockFromUriAsync( - StorageResourceSingle sourceResource, + StorageResourceItem sourceResource, HttpRange range, bool overwrite, long completeLength = 0, diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/Azure.Storage.DataMovement.Blobs.csproj b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/Azure.Storage.DataMovement.Blobs.csproj index 2021ed804969e..bd3b0634b701a 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/Azure.Storage.DataMovement.Blobs.csproj +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/Azure.Storage.DataMovement.Blobs.csproj @@ -101,7 +101,6 @@ - diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobContainerClientExtensions.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobContainerClientExtensions.cs index c0743924b478f..1e2a14bb3a448 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobContainerClientExtensions.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobContainerClientExtensions.cs @@ -34,7 +34,7 @@ public static Task StartUploadDirectoryAsync( { BlobContainerOptions = new() { - DirectoryPrefix = blobDirectoryPrefix, + BlobDirectoryPrefix = blobDirectoryPrefix, } }); @@ -71,7 +71,7 @@ public static Task StartDownloadToDirectoryAsync( { BlobContainerOptions = new() { - DirectoryPrefix = blobDirectoryPrefix + BlobDirectoryPrefix = blobDirectoryPrefix }, }); diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobContainerClientTransferOptions.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobContainerClientTransferOptions.cs index 41b749cbc0cea..5bba76575758c 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobContainerClientTransferOptions.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobContainerClientTransferOptions.cs @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Azure.Storage.DataMovement; -using Azure.Storage.DataMovement.Blobs; +using Azure.Storage.Blobs; -namespace Azure.Storage.Blobs.Models +namespace Azure.Storage.DataMovement.Blobs { /// /// Options applying to data transfer uploads and downloads using the extension methods @@ -21,6 +20,6 @@ public class BlobContainerClientTransferOptions /// /// Options pertaining to the data tranfer. /// - public TransferOptions TransferOptions { get; set; } + public DataTransferOptions TransferOptions { get; set; } } } diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobStorageResourceContainer.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobStorageResourceContainer.cs index 458e197073f1b..436a4f58ea36e 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobStorageResourceContainer.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobStorageResourceContainer.cs @@ -36,7 +36,7 @@ public BlobStorageResourceContainer(BlobContainerClient blobContainerClient, Blo { _blobContainerClient = blobContainerClient; _options = options; - _directoryPrefix = _options?.DirectoryPrefix; + _directoryPrefix = _options?.BlobDirectoryPrefix; Uri = _directoryPrefix != null ? new BlobUriBuilder(_blobContainerClient.Uri) @@ -66,7 +66,7 @@ public BlobStorageResourceContainer(BlobContainerClient blobContainerClient, Blo /// Retrieves a single blob resource based on this respective resource. /// /// The path to the storage resource, relative to the directory prefix if any. - protected override StorageResourceSingle GetChildStorageResource(string path) + protected override StorageResourceItem GetStorageResourceReference(string path) => GetBlobAsStorageResource(ApplyOptionalPrefix(path), type: _options?.BlobType ?? BlobType.Block); /// @@ -77,10 +77,10 @@ protected override StorageResourceSingle GetChildStorageResource(string path) /// The type of that the storage resource is. /// Etag for the resource to lock on. /// - /// which represents the child blob client of + /// which represents the child blob client of /// this respective blob virtual directory resource. /// - private StorageResourceSingle GetBlobAsStorageResource( + private StorageResourceItem GetBlobAsStorageResource( string blobName, long? length = default, BlobType type = BlobType.Block, diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobStorageResourceContainerOptions.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobStorageResourceContainerOptions.cs index 6fe55f181c1e9..a311ab7c086ed 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobStorageResourceContainerOptions.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobStorageResourceContainerOptions.cs @@ -20,11 +20,11 @@ public class BlobStorageResourceContainerOptions /// /// Optional. The directory prefix within the Blob Storage Container to use in the transfer. /// - public string DirectoryPrefix { get; set; } + public string BlobDirectoryPrefix { get; set; } /// /// Optional. Additional options applied to each resource in the container. /// - public BlobStorageResourceOptions ResourceOptions { get; set; } + public BlobStorageResourceOptions BlobOptions { get; set; } } } diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobStorageResourceProvider.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobStorageResourceProvider.cs index 38b5ca77d0471..6c506c9f008ce 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobStorageResourceProvider.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlobStorageResourceProvider.cs @@ -61,7 +61,7 @@ public async Task MakeResourceAsync(StorageSharedKeyCredential /// Creates the configured instance using the given . /// /// - public async Task MakeResourceAsync(AzureSasCredential credential, CancellationToken cancellationToken = default) + public async Task CreateResourceAsync(AzureSasCredential credential, CancellationToken cancellationToken = default) { return ResourceType switch { @@ -85,7 +85,7 @@ public async Task MakeResourceAsync(AzureSasCredential credenti /// Creates the configured instance using the given . /// /// - public async Task MakeResourceAsync(TokenCredential credential, CancellationToken cancellationToken = default) + public async Task CreateResourceAsync(TokenCredential credential, CancellationToken cancellationToken = default) { return ResourceType switch { @@ -109,7 +109,7 @@ public async Task MakeResourceAsync(TokenCredential credential, /// Creates the configured instance using no credential. /// /// - public async Task MakeResourceAsync(CancellationToken cancellationToken = default) + public async Task CreateResourceAsync(CancellationToken cancellationToken = default) { return ResourceType switch { diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlockBlobStorageResource.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlockBlobStorageResource.cs index 830f1be57afdd..6a26817faf98b 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlockBlobStorageResource.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/BlockBlobStorageResource.cs @@ -18,7 +18,7 @@ namespace Azure.Storage.DataMovement.Blobs /// /// The BlockBlobStorageResource class. /// - public class BlockBlobStorageResource : StorageResourceSingle + public class BlockBlobStorageResource : StorageResourceItem { internal BlockBlobClient BlobClient { get; set; } internal BlockBlobStorageResourceOptions _options; @@ -54,7 +54,7 @@ public class BlockBlobStorageResource : StorageResourceSingle /// /// Defines the recommended Transfer Type of the storage resource. /// - protected override TransferType TransferType => TransferType.Concurrent; + protected override DataTransferOrder TransferType => DataTransferOrder.Unordered; /// /// Store Max Initial Size that a Put Blob can get to. @@ -119,8 +119,8 @@ internal BlockBlobStorageResource( /// /// Optional to propagate /// notifications that the operation should be cancelled. - /// The resulting from the upload operation. - protected override async Task ReadStreamAsync( + /// The resulting from the upload operation. + protected override async Task ReadStreamAsync( long position = 0, long? length = default, CancellationToken cancellationToken = default) @@ -153,7 +153,7 @@ await BlobClient.DownloadStreamingAsync( /// notifications that the operation should be cancelled. /// /// - protected override async Task WriteFromStreamAsync( + protected override async Task CopyFromStreamAsync( Stream stream, long streamLength, bool overwrite, @@ -189,7 +189,7 @@ await BlobClient.StageBlockAsync( /// /// Uploads/copy the blob from a URL. /// - /// An instance of + /// An instance of /// that contains the data to be uploaded. /// /// If set to true, will overwrite the blob if exists. @@ -204,7 +204,7 @@ await BlobClient.StageBlockAsync( /// /// protected override async Task CopyFromUriAsync( - StorageResourceSingle sourceResource, + StorageResourceItem sourceResource, bool overwrite, long completeLength, StorageResourceCopyFromUriOptions options = default, @@ -223,7 +223,7 @@ await BlobClient.SyncUploadFromUriAsync( /// /// Uploads/copy the blob from a URL. Supports ranged operations. /// - /// An instance of + /// An instance of /// that contains the data to be uploaded. /// The range of the blob to upload/copy. /// @@ -239,7 +239,7 @@ await BlobClient.SyncUploadFromUriAsync( /// /// protected override async Task CopyBlockFromUriAsync( - StorageResourceSingle sourceResource, + StorageResourceItem sourceResource, HttpRange range, bool overwrite, long completeLength = 0, diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/DataMovementBlobsExtensions.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/DataMovementBlobsExtensions.cs index 1dba104e1ef4e..25e981c11c551 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/DataMovementBlobsExtensions.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/DataMovementBlobsExtensions.cs @@ -62,9 +62,9 @@ internal static StorageResourceProperties ToStorageResourceProperties(this BlobD lastAccessed: blobProperties.LastAccessed); } - internal static ReadStreamStorageResourceResult ToReadStreamStorageResourceInfo(this BlobDownloadStreamingResult result) + internal static StorageResourceReadStreamResult ToReadStreamStorageResourceInfo(this BlobDownloadStreamingResult result) { - return new ReadStreamStorageResourceResult( + return new StorageResourceReadStreamResult( content: result.Content, contentRange: result.Details.ContentRange, acceptRanges: result.Details.AcceptRanges, @@ -131,7 +131,7 @@ internal static PageBlobRequestConditions CreateRequestConditions(PageBlobReques internal static AppendBlobStorageResourceOptions ToAppendBlobStorageResourceOptions( this BlobStorageResourceContainerOptions options) { - return new AppendBlobStorageResourceOptions(options?.ResourceOptions); + return new AppendBlobStorageResourceOptions(options?.BlobOptions); } internal static BlobDownloadOptions ToBlobDownloadOptions( @@ -211,7 +211,7 @@ internal static AppendBlobAppendBlockFromUriOptions ToAppendBlockFromUriOptions( internal static BlockBlobStorageResourceOptions ToBlockBlobStorageResourceOptions( this BlobStorageResourceContainerOptions options) { - return new BlockBlobStorageResourceOptions(options?.ResourceOptions); + return new BlockBlobStorageResourceOptions(options?.BlobOptions); } internal static BlobDownloadOptions ToBlobDownloadOptions( @@ -334,7 +334,7 @@ internal static CommitBlockListOptions ToCommitBlockOptions(this BlockBlobStorag internal static PageBlobStorageResourceOptions ToPageBlobStorageResourceOptions( this BlobStorageResourceContainerOptions options) { - return new PageBlobStorageResourceOptions(options?.ResourceOptions); + return new PageBlobStorageResourceOptions(options?.BlobOptions); } internal static BlobDownloadOptions ToBlobDownloadOptions( @@ -506,8 +506,8 @@ internal static async Task GetBlobContainer cancellationToken).ConfigureAwait(false); BlobStorageResourceContainerOptions options = new() { - DirectoryPrefix = directoryPrefix, - ResourceOptions = baseOptions, + BlobDirectoryPrefix = directoryPrefix, + BlobOptions = baseOptions, }; return options; diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/PageBlobStorageResource.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/PageBlobStorageResource.cs index 97b954a334cd8..05c0f49aba996 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/PageBlobStorageResource.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/PageBlobStorageResource.cs @@ -15,7 +15,7 @@ namespace Azure.Storage.DataMovement.Blobs /// /// The PageBlobStorageResource class. /// - public class PageBlobStorageResource : StorageResourceSingle + public class PageBlobStorageResource : StorageResourceItem { internal PageBlobClient BlobClient { get; set; } internal PageBlobStorageResourceOptions _options; @@ -45,7 +45,7 @@ public class PageBlobStorageResource : StorageResourceSingle /// /// Defines the recommended Transfer Type for the storage resource. /// - protected override TransferType TransferType => TransferType.Concurrent; + protected override DataTransferOrder TransferType => DataTransferOrder.Unordered; /// /// Defines the maximum chunk size for the storage resource. @@ -102,8 +102,8 @@ internal PageBlobStorageResource( /// Optional to propagate /// notifications that the operation should be cancelled. /// - /// The resulting from the upload operation. - protected override async Task ReadStreamAsync( + /// The resulting from the upload operation. + protected override async Task ReadStreamAsync( long position = 0, long? length = default, CancellationToken cancellationToken = default) @@ -136,7 +136,7 @@ protected override async Task ReadStreamAsync( /// notifications that the operation should be cancelled. /// /// - protected override async Task WriteFromStreamAsync( + protected override async Task CopyFromStreamAsync( Stream stream, long streamLength, bool overwrite, @@ -166,7 +166,7 @@ await BlobClient.UploadPagesAsync( /// /// Uploads/copy the blob from a URL. /// - /// An instance of + /// An instance of /// that contains the data to be uploaded. /// /// If set to true, will overwrite the blob if it currently exists. @@ -181,7 +181,7 @@ await BlobClient.UploadPagesAsync( /// /// protected override async Task CopyFromUriAsync( - StorageResourceSingle sourceResource, + StorageResourceItem sourceResource, bool overwrite, long completeLength, StorageResourceCopyFromUriOptions options = default, @@ -209,7 +209,7 @@ await BlobClient.UploadPagesFromUriAsync( /// /// Uploads/copy the blob from a url /// - /// An instance of + /// An instance of /// that contains the data to be uploaded. /// /// If set to true, will overwrite the blob if it already exists. @@ -225,7 +225,7 @@ await BlobClient.UploadPagesFromUriAsync( /// /// protected override async Task CopyBlockFromUriAsync( - StorageResourceSingle sourceResource, + StorageResourceItem sourceResource, HttpRange range, bool overwrite, long completeLength = 0, diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/MockAppendBlobStorageResource.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/MockAppendBlobStorageResource.cs index ce6a42efc0632..f0a6b034711ae 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/MockAppendBlobStorageResource.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/MockAppendBlobStorageResource.cs @@ -37,7 +37,7 @@ internal MockAppendBlobStorageResource( public async Task MockGetPropertiesAsync(CancellationToken cancellationToken = default) => await base.GetPropertiesAsync(cancellationToken); - public async Task MockReadStreamAsync( + public async Task MockReadStreamAsync( long position = 0, long? length = default, CancellationToken cancellationToken = default) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/MockBlockBlobStorageResource.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/MockBlockBlobStorageResource.cs index b37623f603e67..aa4d34a9acd2b 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/MockBlockBlobStorageResource.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/MockBlockBlobStorageResource.cs @@ -37,7 +37,7 @@ internal MockBlockBlobStorageResource( public async Task MockGetPropertiesAsync(CancellationToken cancellationToken = default) => await base.GetPropertiesAsync(cancellationToken); - public async Task MockReadStreamAsync( + public async Task MockReadStreamAsync( long position = 0, long? length = default, CancellationToken cancellationToken = default) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/MockPageBlobStorageResource.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/MockPageBlobStorageResource.cs index 5734545983235..1823909a92d36 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/MockPageBlobStorageResource.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/MockPageBlobStorageResource.cs @@ -37,7 +37,7 @@ internal MockPageBlobStorageResource( public async Task MockGetPropertiesAsync(CancellationToken cancellationToken = default) => await base.GetPropertiesAsync(cancellationToken); - public async Task MockReadStreamAsync( + public async Task MockReadStreamAsync( long position = 0, long? length = default, CancellationToken cancellationToken = default) diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/RehydrateBlobResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/RehydrateBlobResourceTests.cs index 92477c0e7d1b1..56d3e6aa05745 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/RehydrateBlobResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/RehydrateBlobResourceTests.cs @@ -71,7 +71,7 @@ private static Mock GetProperties( { var mock = new Mock(MockBehavior.Strict); mock.Setup(p => p.TransferId).Returns(transferId); - mock.Setup(p => p.Checkpointer).Returns(new TransferCheckpointerOptions(checkpointerPath)); + mock.Setup(p => p.Checkpointer).Returns(new TransferCheckpointStoreOptions(checkpointerPath)); mock.Setup(p => p.SourcePath).Returns(sourcePath); mock.Setup(p => p.DestinationPath).Returns(destinationPath); mock.Setup(p => p.SourceTypeId).Returns(sourceResourceId); @@ -164,7 +164,7 @@ private async Task AzureBlobStorageResourcesInlineTryGet(DataTr { return null; } - return getSource ? await sourceProvider.MakeResourceAsync() : await destinationProvider.MakeResourceAsync(); + return getSource ? await sourceProvider.CreateResourceAsync() : await destinationProvider.CreateResourceAsync(); } [Test] @@ -204,7 +204,7 @@ await AddJobPartToCheckpointer( { RehydrateApi.ResourceStaticApi => await BlockBlobStorageResource.RehydrateResourceAsync(transferProperties, isSource), RehydrateApi.ProviderInstance => (BlockBlobStorageResource)await new BlobStorageResourceProvider( - transferProperties, isSource, BlobStorageResources.ResourceType.BlockBlob).MakeResourceAsync(), + transferProperties, isSource, BlobStorageResources.ResourceType.BlockBlob).CreateResourceAsync(), RehydrateApi.PublicStaticApi => (BlockBlobStorageResource)await AzureBlobStorageResourcesInlineTryGet( transferProperties, isSource), _ => throw new ArgumentException("Unrecognized test parameter"), @@ -262,7 +262,7 @@ await AddJobPartToCheckpointer( { RehydrateApi.ResourceStaticApi => await BlockBlobStorageResource.RehydrateResourceAsync(transferProperties, false), RehydrateApi.ProviderInstance => (BlockBlobStorageResource)await new BlobStorageResourceProvider( - transferProperties, false, BlobStorageResources.ResourceType.BlockBlob).MakeResourceAsync(), + transferProperties, false, BlobStorageResources.ResourceType.BlockBlob).CreateResourceAsync(), RehydrateApi.PublicStaticApi => (BlockBlobStorageResource)await AzureBlobStorageResourcesInlineTryGet( transferProperties, false), _ => throw new ArgumentException("Unrecognized test parameter"), @@ -311,7 +311,7 @@ await AddJobPartToCheckpointer( { RehydrateApi.ResourceStaticApi => await PageBlobStorageResource.RehydrateResourceAsync(transferProperties, isSource), RehydrateApi.ProviderInstance => (PageBlobStorageResource)await new BlobStorageResourceProvider( - transferProperties, isSource, BlobStorageResources.ResourceType.PageBlob).MakeResourceAsync(), + transferProperties, isSource, BlobStorageResources.ResourceType.PageBlob).CreateResourceAsync(), RehydrateApi.PublicStaticApi => (PageBlobStorageResource)await AzureBlobStorageResourcesInlineTryGet( transferProperties, isSource), _ => throw new ArgumentException("Unrecognized test parameter"), @@ -369,7 +369,7 @@ await AddJobPartToCheckpointer( { RehydrateApi.ResourceStaticApi => await PageBlobStorageResource.RehydrateResourceAsync(transferProperties, false), RehydrateApi.ProviderInstance => (PageBlobStorageResource)await new BlobStorageResourceProvider( - transferProperties, false, BlobStorageResources.ResourceType.PageBlob).MakeResourceAsync(), + transferProperties, false, BlobStorageResources.ResourceType.PageBlob).CreateResourceAsync(), RehydrateApi.PublicStaticApi => (PageBlobStorageResource)await AzureBlobStorageResourcesInlineTryGet( transferProperties, false), _ => throw new ArgumentException("Unrecognized test parameter"), @@ -418,7 +418,7 @@ await AddJobPartToCheckpointer( { RehydrateApi.ResourceStaticApi => await AppendBlobStorageResource.RehydrateResourceAsync(transferProperties, isSource), RehydrateApi.ProviderInstance => (AppendBlobStorageResource)await new BlobStorageResourceProvider( - transferProperties, isSource, BlobStorageResources.ResourceType.AppendBlob).MakeResourceAsync(), + transferProperties, isSource, BlobStorageResources.ResourceType.AppendBlob).CreateResourceAsync(), RehydrateApi.PublicStaticApi => (AppendBlobStorageResource)await AzureBlobStorageResourcesInlineTryGet( transferProperties, isSource), _ => throw new ArgumentException("Unrecognized test parameter"), @@ -475,7 +475,7 @@ await AddJobPartToCheckpointer( { RehydrateApi.ResourceStaticApi => await AppendBlobStorageResource.RehydrateResourceAsync(transferProperties, false), RehydrateApi.ProviderInstance => (AppendBlobStorageResource)await new BlobStorageResourceProvider( - transferProperties, false, BlobStorageResources.ResourceType.AppendBlob).MakeResourceAsync(), + transferProperties, false, BlobStorageResources.ResourceType.AppendBlob).CreateResourceAsync(), RehydrateApi.PublicStaticApi => (AppendBlobStorageResource)await AzureBlobStorageResourcesInlineTryGet( transferProperties, false), _ => throw new ArgumentException("Unrecognized test parameter"), @@ -534,7 +534,7 @@ await AddJobPartToCheckpointer( { RehydrateApi.ResourceStaticApi => await BlobStorageResourceContainer.RehydrateResourceAsync(transferProperties, isSource), RehydrateApi.ProviderInstance => (BlobStorageResourceContainer)await new BlobStorageResourceProvider( - transferProperties, isSource, BlobStorageResources.ResourceType.BlobContainer).MakeResourceAsync(), + transferProperties, isSource, BlobStorageResources.ResourceType.BlobContainer).CreateResourceAsync(), RehydrateApi.PublicStaticApi => (BlobStorageResourceContainer)await AzureBlobStorageResourcesInlineTryGet( transferProperties, isSource), _ => throw new ArgumentException("Unrecognized test parameter"), diff --git a/sdk/storage/Azure.Storage.DataMovement/CHANGELOG.md b/sdk/storage/Azure.Storage.DataMovement/CHANGELOG.md index 98eadc5deadad..909a1e040a7f9 100644 --- a/sdk/storage/Azure.Storage.DataMovement/CHANGELOG.md +++ b/sdk/storage/Azure.Storage.DataMovement/CHANGELOG.md @@ -21,6 +21,43 @@ - `StorageResourceSingle.GetPropertiesAsync` - `StorageResourceSingle.ReadStreamAsync` - `StorageResourceSingle.WriteFromStreamAsync` +- [BREAKING CHANGE] Renamed `DataTransfer.AwaitCompletion` to `DataTransfer.WaitForCompletionAsync` +- [BREAKING CHANGE] Renamed `DataTransfer.EnsureCompleted` to `DataTransfer.WaitForCompletion` +- [BREAKING CHANGE] Renamed `DataTransfer.PauseIfRunningAsync` to `DataTransfer.PauseAsync` +- [BREAKING CHANGE] Removed `Azure.Storage.DataMovement.Models` and moved all classes to the `Azure.Storage.DataMovement` namespace +- [BREAKING CHANGE] Moved all classes in the Azure.Storage.DataMovement/src/Models folder up into the Azure.Storage.DataMovement/src parent folder +- [BREAKING CHANGE] Removed `Azure.Storage.DataMovement.Models.JobPlan` and replaced with `Azure.Storage.DataMovement.JobPlan` (has no public effect since it's internal) +- [BREAKING CHANGE] Removed `DataTransfer.PauseTransferIfRunningAsync(DataTransfer)` +- [BREAKING CHANGE] Renamed `DataTransferProperties.SourceScheme` to `DataTransferProperties.SourceTypeId` +- [BREAKING CHANGE] Renamed `DataTransferProperties.DestinationScheme` to `DataTransferProperties.DestinationTypeId` +- [BREAKING CHANGE] Removed `StorageResourceType` including removing `StorageResourceProperties.ResourceType` +- [BREAKING CHANGE] Removed `ServiceCopyStatus` including removing `StorageResourceProperties.CopyStatus` +- [BREAKING CHANGE] Renamed `TransferOptions` to `DataTransferOptions` +- [BREAKING CHANGE] Renamed `TransferCheckpointerOptions` to `TransferCheckpointStoreOptions` +- [BREAKING CHANGE] Renamed `TransferOptions.TransferFailed` to `DataTransferOptions.ItemTransferFailed` +- [BREAKING CHANGE] Renamed `TransferOptions.SingleTransferCompleted` to `DataTransferOptions.ItemTransferCompleted` +- [BREAKING CHANGE] Renamed `TransferOptions.TransferSkipped` to `DataTransferOptions.ItemTransferSkipped` +- [BREAKING CHANGE] Renamed `TransferOptions.TransferStatus` to `TransferOptions.TransferStatusChanged` +- [BREAKING CHANGE] Renamed `SingleTransferCompletedEventArgs` to `TransferItemCompletedEventArgs` +- [BREAKING CHANGE] Renamed `TransferItemFailedEventArgs` to `TransferItemFailedEventArgs` +- [BREAKING CHANGE] Renamed `TransferItemSkippedEventArgs` to `TransferItemSkippedEventArgs` +- [BREAKING CHANGE] Renamed `StorageResourceSingle` to `StorageResourceItem` +- [BREAKING CHANGE] Renamed `StorageResourceItem.WriteFromStreamAsync` to `CopyFromStreamAsync` +- [BREAKING CHANGE] Renamed `StorageResourceContainer.GetChildStorageResource` to `StorageResourceContainer.GetStorageResourceReference` +- [BREAKING CHANGE] Renamed `ReadStreamStorageResourceResult` to `StorageResourceReadStreamResult` +- [BREAKING CHANGE] Changed constructor `StorageResourceReadStreamResult(Stream)` from public to internal +- [BREAKING CHANGE] Renamed `LocalStorageResourceProvider.MakeResource` to `LocalStorageResourceProvider.CreateResource` +- [BREAKING CHANGE] Renamed `ErrorHandlingBehavior` to `DataTransferErrorMode` +- [BREAKING CHANGE] Renamed `DataTransferErrorMode.StopOnAnyFailures` to `StopOnAnyFailure` +- [BREAKING CHANGE] Renamed `TransferType` to `DataTransferOrder` +- [BREAKING CHANGE] Renamed `DataTransferOrder.Unordered` to `Unordered` +- [BREAKING CHANGE] Renamed `StorageTransferStatus` to `DataTransferStatus` +- [BREAKING CHANGE] Renamed `StorageResourceCreateMode` to `StorageResourceCreationPreference`. +- [BREAKING CHANGE] Renamed `StorageResourceCreationPreference` values from `Fail` to `FailIfExists`, `Overwrite` to `OverwriteIfExists` and `Skip` to `SkipIfExists`. `None` was removed, use `FailIfExists` instead. +- [BREAKING CHANGE] Renamed `DataTransferOptions.CreateMode` to `CreationPreference`. +- [BREAKING CHANGE] Changed `StorageTransferProgress` constructor from `public` to `protected internal`. +- [BREAKING CHANGE] Renamed `StorageTransferProgress` to `DataTransferProgress`. +- [BREAKING CHANGE] Renamed `StorageTransferEventArgs` to `DataTransferEventArgs`. ### Bugs Fixed diff --git a/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net6.0.cs b/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net6.0.cs index ae5572b7f4a71..41323160e7bbb 100644 --- a/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net6.0.cs +++ b/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net6.0.cs @@ -6,15 +6,64 @@ internal DataTransfer() { } public bool HasCompleted { get { throw null; } } public string Id { get { throw null; } } public Azure.Storage.DataMovement.TransferManager TransferManager { get { throw null; } } - public Azure.Storage.DataMovement.StorageTransferStatus TransferStatus { get { throw null; } } - public void EnsureCompleted(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { } - public virtual System.Threading.Tasks.Task PauseIfRunningAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public Azure.Storage.DataMovement.DataTransferStatus TransferStatus { get { throw null; } } + public virtual System.Threading.Tasks.Task PauseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public void WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { } public System.Threading.Tasks.Task WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } + [System.FlagsAttribute] + public enum DataTransferErrorMode + { + StopOnAnyFailure = 0, + ContinueOnFailure = 1, + } + public abstract partial class DataTransferEventArgs : Azure.SyncAsyncEventArgs + { + protected DataTransferEventArgs(string transferId, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(bool), default(System.Threading.CancellationToken)) { } + public string TransferId { get { throw null; } } + } + public partial class DataTransferOptions : System.IEquatable + { + public DataTransferOptions() { } + public Azure.Storage.DataMovement.StorageResourceCreationPreference CreationPreference { get { throw null; } set { } } + public long? InitialTransferSize { get { throw null; } set { } } + public long? MaximumTransferChunkSize { get { throw null; } set { } } + public System.IProgress ProgressHandler { get { throw null; } set { } } + public Azure.Storage.DataMovement.ProgressHandlerOptions ProgressHandlerOptions { get { throw null; } set { } } + public event Azure.Core.SyncAsyncEventHandler ItemTransferCompleted { add { } remove { } } + public event Azure.Core.SyncAsyncEventHandler ItemTransferFailed { add { } remove { } } + public event Azure.Core.SyncAsyncEventHandler ItemTransferSkipped { add { } remove { } } + public event Azure.Core.SyncAsyncEventHandler TransferStatusChanged { add { } remove { } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public bool Equals(Azure.Storage.DataMovement.DataTransferOptions obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static bool operator ==(Azure.Storage.DataMovement.DataTransferOptions left, Azure.Storage.DataMovement.DataTransferOptions right) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static bool operator !=(Azure.Storage.DataMovement.DataTransferOptions left, Azure.Storage.DataMovement.DataTransferOptions right) { throw null; } + } + public enum DataTransferOrder + { + Unordered = 0, + Sequential = 1, + } + public partial class DataTransferProgress + { + protected internal DataTransferProgress() { } + public long? BytesTransferred { get { throw null; } } + public long CompletedCount { get { throw null; } } + public long FailedCount { get { throw null; } } + public long InProgressCount { get { throw null; } } + public long QueuedCount { get { throw null; } } + public long SkippedCount { get { throw null; } } + } public partial class DataTransferProperties { protected internal DataTransferProperties() { } - public virtual Azure.Storage.DataMovement.TransferCheckpointerOptions Checkpointer { get { throw null; } } + public virtual Azure.Storage.DataMovement.TransferCheckpointStoreOptions Checkpointer { get { throw null; } } public virtual string DestinationPath { get { throw null; } } public virtual string DestinationTypeId { get { throw null; } } public virtual bool IsContainer { get { throw null; } } @@ -22,11 +71,17 @@ protected internal DataTransferProperties() { } public virtual string SourceTypeId { get { throw null; } } public virtual string TransferId { get { throw null; } } } - [System.FlagsAttribute] - public enum ErrorHandlingBehavior + public enum DataTransferStatus { - StopOnAllFailures = 0, - ContinueOnFailure = 1, + None = 0, + Queued = 1, + InProgress = 2, + Paused = 3, + Completed = 4, + CompletedWithSkippedTransfers = 5, + CompletedWithFailedTransfers = 6, + PauseInProgress = 7, + CancellationInProgress = 8, } public partial class LocalDirectoryStorageResourceContainer : Azure.Storage.DataMovement.StorageResourceContainer { @@ -34,10 +89,10 @@ public LocalDirectoryStorageResourceContainer(string path) { } protected internal override bool CanProduceUri { get { throw null; } } public override string Path { get { throw null; } } public override System.Uri Uri { get { throw null; } } - protected internal override Azure.Storage.DataMovement.StorageResourceSingle GetChildStorageResource(string childPath) { throw null; } + protected internal override Azure.Storage.DataMovement.StorageResourceItem GetStorageResourceReference(string childPath) { throw null; } protected internal override System.Collections.Generic.IAsyncEnumerable GetStorageResourcesAsync([System.Runtime.CompilerServices.EnumeratorCancellationAttribute] System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class LocalFileStorageResource : Azure.Storage.DataMovement.StorageResourceSingle + public partial class LocalFileStorageResource : Azure.Storage.DataMovement.StorageResourceItem { public LocalFileStorageResource(string path) { } protected internal override bool CanProduceUri { get { throw null; } } @@ -45,21 +100,21 @@ public LocalFileStorageResource(string path) { } protected internal override long MaxChunkSize { get { throw null; } } public override string Path { get { throw null; } } protected internal override string ResourceId { get { throw null; } } - protected internal override Azure.Storage.DataMovement.TransferType TransferType { get { throw null; } } + protected internal override Azure.Storage.DataMovement.DataTransferOrder TransferType { get { throw null; } } public override System.Uri Uri { get { throw null; } } protected internal override System.Threading.Tasks.Task CompleteTransferAsync(bool overwrite, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected internal override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected internal override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected internal override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected internal override System.Threading.Tasks.Task CopyFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected internal override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected internal override System.Threading.Tasks.Task DeleteIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected internal override System.Threading.Tasks.Task GetCopyAuthorizationHeaderAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected internal override System.Threading.Tasks.Task GetPropertiesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected internal override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected internal override System.Threading.Tasks.Task WriteFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected internal override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class LocalStorageResourceProvider { internal LocalStorageResourceProvider() { } - public Azure.Storage.DataMovement.StorageResource MakeResource() { throw null; } + public Azure.Storage.DataMovement.StorageResource CreateResource() { throw null; } } public static partial class LocalStorageResources { @@ -70,17 +125,6 @@ public partial class ProgressHandlerOptions public ProgressHandlerOptions() { } public bool TrackBytesTransferred { get { throw null; } set { } } } - public partial class ReadStreamStorageResourceResult - { - public ReadStreamStorageResourceResult(System.IO.Stream content) { } - public ReadStreamStorageResourceResult(System.IO.Stream content, string contentRange, string acceptRanges, byte[] rangeContentHash, Azure.Storage.DataMovement.StorageResourceProperties properties) { } - } - public partial class SingleTransferCompletedEventArgs : Azure.Storage.DataMovement.StorageTransferEventArgs - { - public SingleTransferCompletedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.Storage.DataMovement.StorageResourceSingle destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResourceSingle DestinationResource { get { throw null; } } - public Azure.Storage.DataMovement.StorageResourceSingle SourceResource { get { throw null; } } - } public abstract partial class StorageResource { protected StorageResource() { } @@ -93,7 +137,7 @@ public abstract partial class StorageResourceContainer : Azure.Storage.DataMovem { protected StorageResourceContainer() { } protected internal override bool IsContainer { get { throw null; } } - protected internal abstract Azure.Storage.DataMovement.StorageResourceSingle GetChildStorageResource(string path); + protected internal abstract Azure.Storage.DataMovement.StorageResourceItem GetStorageResourceReference(string path); protected internal abstract System.Collections.Generic.IAsyncEnumerable GetStorageResourcesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } public partial class StorageResourceCopyFromUriOptions @@ -102,136 +146,94 @@ public StorageResourceCopyFromUriOptions() { } public string BlockId { get { throw null; } } public Azure.HttpAuthorization SourceAuthentication { get { throw null; } set { } } } - public enum StorageResourceCreateMode + public enum StorageResourceCreationPreference { - None = 0, - Overwrite = 1, - Fail = 2, - Skip = 3, + FailIfExists = 0, + OverwriteIfExists = 1, + SkipIfExists = 2, } - public partial class StorageResourceProperties + public abstract partial class StorageResourceItem : Azure.Storage.DataMovement.StorageResource { - protected StorageResourceProperties() { } - public StorageResourceProperties(System.DateTimeOffset lastModified, System.DateTimeOffset createdOn, System.Collections.Generic.IDictionary metadata, System.DateTimeOffset copyCompletedOn, string copyStatusDescription, string copyId, string copyProgress, System.Uri copySource, long contentLength, string contentType, Azure.ETag eTag, byte[] contentHash, long blobSequenceNumber, int blobCommittedBlockCount, bool isServerEncrypted, string encryptionKeySha256, string encryptionScope, string versionId, bool isLatestVersion, System.DateTimeOffset expiresOn, System.DateTimeOffset lastAccessed) { } - public StorageResourceProperties(System.DateTimeOffset lastModified, System.DateTimeOffset createdOn, long contentLength, System.DateTimeOffset lastAccessed) { } - } - public abstract partial class StorageResourceSingle : Azure.Storage.DataMovement.StorageResource - { - protected StorageResourceSingle() { } + protected StorageResourceItem() { } protected internal override bool IsContainer { get { throw null; } } protected internal abstract long? Length { get; } protected internal abstract long MaxChunkSize { get; } protected internal abstract string ResourceId { get; } - protected internal abstract Azure.Storage.DataMovement.TransferType TransferType { get; } + protected internal abstract Azure.Storage.DataMovement.DataTransferOrder TransferType { get; } protected internal abstract System.Threading.Tasks.Task CompleteTransferAsync(bool overwrite, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - protected internal abstract System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - protected internal abstract System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + protected internal abstract System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + protected internal abstract System.Threading.Tasks.Task CopyFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + protected internal abstract System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); protected internal abstract System.Threading.Tasks.Task DeleteIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); protected internal abstract System.Threading.Tasks.Task GetCopyAuthorizationHeaderAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); protected internal abstract System.Threading.Tasks.Task GetPropertiesAsync(System.Threading.CancellationToken token = default(System.Threading.CancellationToken)); - protected internal abstract System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - protected internal abstract System.Threading.Tasks.Task WriteFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + protected internal abstract System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } - public partial class StorageResourceWriteToOffsetOptions + public partial class StorageResourceProperties { - public StorageResourceWriteToOffsetOptions() { } - public string BlockId { get { throw null; } } + protected StorageResourceProperties() { } + public StorageResourceProperties(System.DateTimeOffset lastModified, System.DateTimeOffset createdOn, System.Collections.Generic.IDictionary metadata, System.DateTimeOffset copyCompletedOn, string copyStatusDescription, string copyId, string copyProgress, System.Uri copySource, long contentLength, string contentType, Azure.ETag eTag, byte[] contentHash, long blobSequenceNumber, int blobCommittedBlockCount, bool isServerEncrypted, string encryptionKeySha256, string encryptionScope, string versionId, bool isLatestVersion, System.DateTimeOffset expiresOn, System.DateTimeOffset lastAccessed) { } + public StorageResourceProperties(System.DateTimeOffset lastModified, System.DateTimeOffset createdOn, long contentLength, System.DateTimeOffset lastAccessed) { } } - public abstract partial class StorageTransferEventArgs : Azure.SyncAsyncEventArgs + public partial class StorageResourceReadStreamResult { - protected StorageTransferEventArgs(string transferId, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(bool), default(System.Threading.CancellationToken)) { } - public string TransferId { get { throw null; } } + public readonly string AcceptRanges; + public readonly System.IO.Stream Content; + public readonly string ContentRange; + public readonly byte[] RangeContentHash; + public StorageResourceReadStreamResult(System.IO.Stream content, string contentRange, string acceptRanges, byte[] rangeContentHash, Azure.Storage.DataMovement.StorageResourceProperties properties) { } } - public partial class StorageTransferProgress + public partial class StorageResourceWriteToOffsetOptions { - public StorageTransferProgress() { } - public long? BytesTransferred { get { throw null; } } - public long CompletedCount { get { throw null; } } - public long FailedCount { get { throw null; } } - public long InProgressCount { get { throw null; } } - public long QueuedCount { get { throw null; } } - public long SkippedCount { get { throw null; } } + public StorageResourceWriteToOffsetOptions() { } + public string BlockId { get { throw null; } } } - public enum StorageTransferStatus + public partial class TransferCheckpointStoreOptions { - None = 0, - Queued = 1, - InProgress = 2, - Paused = 3, - Completed = 4, - CompletedWithSkippedTransfers = 5, - CompletedWithFailedTransfers = 6, - PauseInProgress = 7, - CancellationInProgress = 8, + public TransferCheckpointStoreOptions(string localCheckpointerPath) { } + public string CheckpointerPath { get { throw null; } } } - public partial class TransferCheckpointerOptions + public partial class TransferItemCompletedEventArgs : Azure.Storage.DataMovement.DataTransferEventArgs { - public TransferCheckpointerOptions(string localCheckpointerPath) { } - public string CheckpointerPath { get { throw null; } } + public TransferItemCompletedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.Storage.DataMovement.StorageResourceItem destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } + public Azure.Storage.DataMovement.StorageResourceItem DestinationResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem SourceResource { get { throw null; } } } - public partial class TransferFailedEventArgs : Azure.Storage.DataMovement.StorageTransferEventArgs + public partial class TransferItemFailedEventArgs : Azure.Storage.DataMovement.DataTransferEventArgs { - public TransferFailedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.Storage.DataMovement.StorageResourceSingle destinationResource, System.Exception exception, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResourceSingle DestinationResource { get { throw null; } } + public TransferItemFailedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.Storage.DataMovement.StorageResourceItem destinationResource, System.Exception exception, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } + public Azure.Storage.DataMovement.StorageResourceItem DestinationResource { get { throw null; } } public System.Exception Exception { get { throw null; } } - public Azure.Storage.DataMovement.StorageResourceSingle SourceResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem SourceResource { get { throw null; } } + } + public partial class TransferItemSkippedEventArgs : Azure.Storage.DataMovement.DataTransferEventArgs + { + public TransferItemSkippedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.Storage.DataMovement.StorageResourceItem destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } + public Azure.Storage.DataMovement.StorageResourceItem DestinationResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem SourceResource { get { throw null; } } } public partial class TransferManager : System.IAsyncDisposable { protected TransferManager() { } public TransferManager(Azure.Storage.DataMovement.TransferManagerOptions options = null) { } public virtual System.Collections.Generic.IAsyncEnumerable GetResumableTransfersAsync() { throw null; } - public virtual System.Collections.Generic.IAsyncEnumerable GetTransfersAsync(params Azure.Storage.DataMovement.StorageTransferStatus[] filterByStatus) { throw null; } + public virtual System.Collections.Generic.IAsyncEnumerable GetTransfersAsync(params Azure.Storage.DataMovement.DataTransferStatus[] filterByStatus) { throw null; } public virtual System.Threading.Tasks.Task PauseTransferIfRunningAsync(string transferId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task ResumeTransferAsync(string transferId, Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, Azure.Storage.DataMovement.TransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task StartTransferAsync(Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, Azure.Storage.DataMovement.TransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task ResumeTransferAsync(string transferId, Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, Azure.Storage.DataMovement.DataTransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task StartTransferAsync(Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, Azure.Storage.DataMovement.DataTransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } System.Threading.Tasks.ValueTask System.IAsyncDisposable.DisposeAsync() { throw null; } } public partial class TransferManagerOptions { public TransferManagerOptions() { } - public Azure.Storage.DataMovement.TransferCheckpointerOptions CheckpointerOptions { get { throw null; } set { } } + public Azure.Storage.DataMovement.TransferCheckpointStoreOptions CheckpointerOptions { get { throw null; } set { } } public Azure.Core.DiagnosticsOptions Diagnostics { get { throw null; } } - public Azure.Storage.DataMovement.ErrorHandlingBehavior ErrorHandling { get { throw null; } set { } } + public Azure.Storage.DataMovement.DataTransferErrorMode ErrorHandling { get { throw null; } set { } } public int? MaximumConcurrency { get { throw null; } set { } } } - public partial class TransferOptions : System.IEquatable - { - public TransferOptions() { } - public Azure.Storage.DataMovement.StorageResourceCreateMode CreateMode { get { throw null; } set { } } - public long? InitialTransferSize { get { throw null; } set { } } - public long? MaximumTransferChunkSize { get { throw null; } set { } } - public System.IProgress ProgressHandler { get { throw null; } set { } } - public Azure.Storage.DataMovement.ProgressHandlerOptions ProgressHandlerOptions { get { throw null; } set { } } - public event Azure.Core.SyncAsyncEventHandler SingleTransferCompleted { add { } remove { } } - public event Azure.Core.SyncAsyncEventHandler TransferFailed { add { } remove { } } - public event Azure.Core.SyncAsyncEventHandler TransferSkipped { add { } remove { } } - public event Azure.Core.SyncAsyncEventHandler TransferStatus { add { } remove { } } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public bool Equals(Azure.Storage.DataMovement.TransferOptions obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public static bool operator ==(Azure.Storage.DataMovement.TransferOptions left, Azure.Storage.DataMovement.TransferOptions right) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public static bool operator !=(Azure.Storage.DataMovement.TransferOptions left, Azure.Storage.DataMovement.TransferOptions right) { throw null; } - } - public partial class TransferSkippedEventArgs : Azure.Storage.DataMovement.StorageTransferEventArgs - { - public TransferSkippedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.Storage.DataMovement.StorageResourceSingle destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResourceSingle DestinationResource { get { throw null; } } - public Azure.Storage.DataMovement.StorageResourceSingle SourceResource { get { throw null; } } - } - public partial class TransferStatusEventArgs : Azure.Storage.DataMovement.StorageTransferEventArgs + public partial class TransferStatusEventArgs : Azure.Storage.DataMovement.DataTransferEventArgs { - public TransferStatusEventArgs(string transferId, Azure.Storage.DataMovement.StorageTransferStatus transferStatus, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageTransferStatus StorageTransferStatus { get { throw null; } } - } - public enum TransferType - { - Concurrent = 0, - Sequential = 1, + public TransferStatusEventArgs(string transferId, Azure.Storage.DataMovement.DataTransferStatus transferStatus, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } + public Azure.Storage.DataMovement.DataTransferStatus StorageTransferStatus { get { throw null; } } } } diff --git a/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.netstandard2.0.cs b/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.netstandard2.0.cs index ae5572b7f4a71..41323160e7bbb 100644 --- a/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.netstandard2.0.cs +++ b/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.netstandard2.0.cs @@ -6,15 +6,64 @@ internal DataTransfer() { } public bool HasCompleted { get { throw null; } } public string Id { get { throw null; } } public Azure.Storage.DataMovement.TransferManager TransferManager { get { throw null; } } - public Azure.Storage.DataMovement.StorageTransferStatus TransferStatus { get { throw null; } } - public void EnsureCompleted(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { } - public virtual System.Threading.Tasks.Task PauseIfRunningAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public Azure.Storage.DataMovement.DataTransferStatus TransferStatus { get { throw null; } } + public virtual System.Threading.Tasks.Task PauseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public void WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { } public System.Threading.Tasks.Task WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } + [System.FlagsAttribute] + public enum DataTransferErrorMode + { + StopOnAnyFailure = 0, + ContinueOnFailure = 1, + } + public abstract partial class DataTransferEventArgs : Azure.SyncAsyncEventArgs + { + protected DataTransferEventArgs(string transferId, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(bool), default(System.Threading.CancellationToken)) { } + public string TransferId { get { throw null; } } + } + public partial class DataTransferOptions : System.IEquatable + { + public DataTransferOptions() { } + public Azure.Storage.DataMovement.StorageResourceCreationPreference CreationPreference { get { throw null; } set { } } + public long? InitialTransferSize { get { throw null; } set { } } + public long? MaximumTransferChunkSize { get { throw null; } set { } } + public System.IProgress ProgressHandler { get { throw null; } set { } } + public Azure.Storage.DataMovement.ProgressHandlerOptions ProgressHandlerOptions { get { throw null; } set { } } + public event Azure.Core.SyncAsyncEventHandler ItemTransferCompleted { add { } remove { } } + public event Azure.Core.SyncAsyncEventHandler ItemTransferFailed { add { } remove { } } + public event Azure.Core.SyncAsyncEventHandler ItemTransferSkipped { add { } remove { } } + public event Azure.Core.SyncAsyncEventHandler TransferStatusChanged { add { } remove { } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public bool Equals(Azure.Storage.DataMovement.DataTransferOptions obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static bool operator ==(Azure.Storage.DataMovement.DataTransferOptions left, Azure.Storage.DataMovement.DataTransferOptions right) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static bool operator !=(Azure.Storage.DataMovement.DataTransferOptions left, Azure.Storage.DataMovement.DataTransferOptions right) { throw null; } + } + public enum DataTransferOrder + { + Unordered = 0, + Sequential = 1, + } + public partial class DataTransferProgress + { + protected internal DataTransferProgress() { } + public long? BytesTransferred { get { throw null; } } + public long CompletedCount { get { throw null; } } + public long FailedCount { get { throw null; } } + public long InProgressCount { get { throw null; } } + public long QueuedCount { get { throw null; } } + public long SkippedCount { get { throw null; } } + } public partial class DataTransferProperties { protected internal DataTransferProperties() { } - public virtual Azure.Storage.DataMovement.TransferCheckpointerOptions Checkpointer { get { throw null; } } + public virtual Azure.Storage.DataMovement.TransferCheckpointStoreOptions Checkpointer { get { throw null; } } public virtual string DestinationPath { get { throw null; } } public virtual string DestinationTypeId { get { throw null; } } public virtual bool IsContainer { get { throw null; } } @@ -22,11 +71,17 @@ protected internal DataTransferProperties() { } public virtual string SourceTypeId { get { throw null; } } public virtual string TransferId { get { throw null; } } } - [System.FlagsAttribute] - public enum ErrorHandlingBehavior + public enum DataTransferStatus { - StopOnAllFailures = 0, - ContinueOnFailure = 1, + None = 0, + Queued = 1, + InProgress = 2, + Paused = 3, + Completed = 4, + CompletedWithSkippedTransfers = 5, + CompletedWithFailedTransfers = 6, + PauseInProgress = 7, + CancellationInProgress = 8, } public partial class LocalDirectoryStorageResourceContainer : Azure.Storage.DataMovement.StorageResourceContainer { @@ -34,10 +89,10 @@ public LocalDirectoryStorageResourceContainer(string path) { } protected internal override bool CanProduceUri { get { throw null; } } public override string Path { get { throw null; } } public override System.Uri Uri { get { throw null; } } - protected internal override Azure.Storage.DataMovement.StorageResourceSingle GetChildStorageResource(string childPath) { throw null; } + protected internal override Azure.Storage.DataMovement.StorageResourceItem GetStorageResourceReference(string childPath) { throw null; } protected internal override System.Collections.Generic.IAsyncEnumerable GetStorageResourcesAsync([System.Runtime.CompilerServices.EnumeratorCancellationAttribute] System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } - public partial class LocalFileStorageResource : Azure.Storage.DataMovement.StorageResourceSingle + public partial class LocalFileStorageResource : Azure.Storage.DataMovement.StorageResourceItem { public LocalFileStorageResource(string path) { } protected internal override bool CanProduceUri { get { throw null; } } @@ -45,21 +100,21 @@ public LocalFileStorageResource(string path) { } protected internal override long MaxChunkSize { get { throw null; } } public override string Path { get { throw null; } } protected internal override string ResourceId { get { throw null; } } - protected internal override Azure.Storage.DataMovement.TransferType TransferType { get { throw null; } } + protected internal override Azure.Storage.DataMovement.DataTransferOrder TransferType { get { throw null; } } public override System.Uri Uri { get { throw null; } } protected internal override System.Threading.Tasks.Task CompleteTransferAsync(bool overwrite, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected internal override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected internal override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected internal override System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected internal override System.Threading.Tasks.Task CopyFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected internal override System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected internal override System.Threading.Tasks.Task DeleteIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected internal override System.Threading.Tasks.Task GetCopyAuthorizationHeaderAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } protected internal override System.Threading.Tasks.Task GetPropertiesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected internal override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - protected internal override System.Threading.Tasks.Task WriteFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected internal override System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class LocalStorageResourceProvider { internal LocalStorageResourceProvider() { } - public Azure.Storage.DataMovement.StorageResource MakeResource() { throw null; } + public Azure.Storage.DataMovement.StorageResource CreateResource() { throw null; } } public static partial class LocalStorageResources { @@ -70,17 +125,6 @@ public partial class ProgressHandlerOptions public ProgressHandlerOptions() { } public bool TrackBytesTransferred { get { throw null; } set { } } } - public partial class ReadStreamStorageResourceResult - { - public ReadStreamStorageResourceResult(System.IO.Stream content) { } - public ReadStreamStorageResourceResult(System.IO.Stream content, string contentRange, string acceptRanges, byte[] rangeContentHash, Azure.Storage.DataMovement.StorageResourceProperties properties) { } - } - public partial class SingleTransferCompletedEventArgs : Azure.Storage.DataMovement.StorageTransferEventArgs - { - public SingleTransferCompletedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.Storage.DataMovement.StorageResourceSingle destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResourceSingle DestinationResource { get { throw null; } } - public Azure.Storage.DataMovement.StorageResourceSingle SourceResource { get { throw null; } } - } public abstract partial class StorageResource { protected StorageResource() { } @@ -93,7 +137,7 @@ public abstract partial class StorageResourceContainer : Azure.Storage.DataMovem { protected StorageResourceContainer() { } protected internal override bool IsContainer { get { throw null; } } - protected internal abstract Azure.Storage.DataMovement.StorageResourceSingle GetChildStorageResource(string path); + protected internal abstract Azure.Storage.DataMovement.StorageResourceItem GetStorageResourceReference(string path); protected internal abstract System.Collections.Generic.IAsyncEnumerable GetStorageResourcesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } public partial class StorageResourceCopyFromUriOptions @@ -102,136 +146,94 @@ public StorageResourceCopyFromUriOptions() { } public string BlockId { get { throw null; } } public Azure.HttpAuthorization SourceAuthentication { get { throw null; } set { } } } - public enum StorageResourceCreateMode + public enum StorageResourceCreationPreference { - None = 0, - Overwrite = 1, - Fail = 2, - Skip = 3, + FailIfExists = 0, + OverwriteIfExists = 1, + SkipIfExists = 2, } - public partial class StorageResourceProperties + public abstract partial class StorageResourceItem : Azure.Storage.DataMovement.StorageResource { - protected StorageResourceProperties() { } - public StorageResourceProperties(System.DateTimeOffset lastModified, System.DateTimeOffset createdOn, System.Collections.Generic.IDictionary metadata, System.DateTimeOffset copyCompletedOn, string copyStatusDescription, string copyId, string copyProgress, System.Uri copySource, long contentLength, string contentType, Azure.ETag eTag, byte[] contentHash, long blobSequenceNumber, int blobCommittedBlockCount, bool isServerEncrypted, string encryptionKeySha256, string encryptionScope, string versionId, bool isLatestVersion, System.DateTimeOffset expiresOn, System.DateTimeOffset lastAccessed) { } - public StorageResourceProperties(System.DateTimeOffset lastModified, System.DateTimeOffset createdOn, long contentLength, System.DateTimeOffset lastAccessed) { } - } - public abstract partial class StorageResourceSingle : Azure.Storage.DataMovement.StorageResource - { - protected StorageResourceSingle() { } + protected StorageResourceItem() { } protected internal override bool IsContainer { get { throw null; } } protected internal abstract long? Length { get; } protected internal abstract long MaxChunkSize { get; } protected internal abstract string ResourceId { get; } - protected internal abstract Azure.Storage.DataMovement.TransferType TransferType { get; } + protected internal abstract Azure.Storage.DataMovement.DataTransferOrder TransferType { get; } protected internal abstract System.Threading.Tasks.Task CompleteTransferAsync(bool overwrite, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - protected internal abstract System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - protected internal abstract System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceSingle sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + protected internal abstract System.Threading.Tasks.Task CopyBlockFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.HttpRange range, bool overwrite, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + protected internal abstract System.Threading.Tasks.Task CopyFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + protected internal abstract System.Threading.Tasks.Task CopyFromUriAsync(Azure.Storage.DataMovement.StorageResourceItem sourceResource, bool overwrite, long completeLength, Azure.Storage.DataMovement.StorageResourceCopyFromUriOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); protected internal abstract System.Threading.Tasks.Task DeleteIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); protected internal abstract System.Threading.Tasks.Task GetCopyAuthorizationHeaderAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); protected internal abstract System.Threading.Tasks.Task GetPropertiesAsync(System.Threading.CancellationToken token = default(System.Threading.CancellationToken)); - protected internal abstract System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - protected internal abstract System.Threading.Tasks.Task WriteFromStreamAsync(System.IO.Stream stream, long streamLength, bool overwrite, long position = (long)0, long completeLength = (long)0, Azure.Storage.DataMovement.StorageResourceWriteToOffsetOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + protected internal abstract System.Threading.Tasks.Task ReadStreamAsync(long position = (long)0, long? length = default(long?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } - public partial class StorageResourceWriteToOffsetOptions + public partial class StorageResourceProperties { - public StorageResourceWriteToOffsetOptions() { } - public string BlockId { get { throw null; } } + protected StorageResourceProperties() { } + public StorageResourceProperties(System.DateTimeOffset lastModified, System.DateTimeOffset createdOn, System.Collections.Generic.IDictionary metadata, System.DateTimeOffset copyCompletedOn, string copyStatusDescription, string copyId, string copyProgress, System.Uri copySource, long contentLength, string contentType, Azure.ETag eTag, byte[] contentHash, long blobSequenceNumber, int blobCommittedBlockCount, bool isServerEncrypted, string encryptionKeySha256, string encryptionScope, string versionId, bool isLatestVersion, System.DateTimeOffset expiresOn, System.DateTimeOffset lastAccessed) { } + public StorageResourceProperties(System.DateTimeOffset lastModified, System.DateTimeOffset createdOn, long contentLength, System.DateTimeOffset lastAccessed) { } } - public abstract partial class StorageTransferEventArgs : Azure.SyncAsyncEventArgs + public partial class StorageResourceReadStreamResult { - protected StorageTransferEventArgs(string transferId, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(bool), default(System.Threading.CancellationToken)) { } - public string TransferId { get { throw null; } } + public readonly string AcceptRanges; + public readonly System.IO.Stream Content; + public readonly string ContentRange; + public readonly byte[] RangeContentHash; + public StorageResourceReadStreamResult(System.IO.Stream content, string contentRange, string acceptRanges, byte[] rangeContentHash, Azure.Storage.DataMovement.StorageResourceProperties properties) { } } - public partial class StorageTransferProgress + public partial class StorageResourceWriteToOffsetOptions { - public StorageTransferProgress() { } - public long? BytesTransferred { get { throw null; } } - public long CompletedCount { get { throw null; } } - public long FailedCount { get { throw null; } } - public long InProgressCount { get { throw null; } } - public long QueuedCount { get { throw null; } } - public long SkippedCount { get { throw null; } } + public StorageResourceWriteToOffsetOptions() { } + public string BlockId { get { throw null; } } } - public enum StorageTransferStatus + public partial class TransferCheckpointStoreOptions { - None = 0, - Queued = 1, - InProgress = 2, - Paused = 3, - Completed = 4, - CompletedWithSkippedTransfers = 5, - CompletedWithFailedTransfers = 6, - PauseInProgress = 7, - CancellationInProgress = 8, + public TransferCheckpointStoreOptions(string localCheckpointerPath) { } + public string CheckpointerPath { get { throw null; } } } - public partial class TransferCheckpointerOptions + public partial class TransferItemCompletedEventArgs : Azure.Storage.DataMovement.DataTransferEventArgs { - public TransferCheckpointerOptions(string localCheckpointerPath) { } - public string CheckpointerPath { get { throw null; } } + public TransferItemCompletedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.Storage.DataMovement.StorageResourceItem destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } + public Azure.Storage.DataMovement.StorageResourceItem DestinationResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem SourceResource { get { throw null; } } } - public partial class TransferFailedEventArgs : Azure.Storage.DataMovement.StorageTransferEventArgs + public partial class TransferItemFailedEventArgs : Azure.Storage.DataMovement.DataTransferEventArgs { - public TransferFailedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.Storage.DataMovement.StorageResourceSingle destinationResource, System.Exception exception, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResourceSingle DestinationResource { get { throw null; } } + public TransferItemFailedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.Storage.DataMovement.StorageResourceItem destinationResource, System.Exception exception, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } + public Azure.Storage.DataMovement.StorageResourceItem DestinationResource { get { throw null; } } public System.Exception Exception { get { throw null; } } - public Azure.Storage.DataMovement.StorageResourceSingle SourceResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem SourceResource { get { throw null; } } + } + public partial class TransferItemSkippedEventArgs : Azure.Storage.DataMovement.DataTransferEventArgs + { + public TransferItemSkippedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.Storage.DataMovement.StorageResourceItem destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } + public Azure.Storage.DataMovement.StorageResourceItem DestinationResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem SourceResource { get { throw null; } } } public partial class TransferManager : System.IAsyncDisposable { protected TransferManager() { } public TransferManager(Azure.Storage.DataMovement.TransferManagerOptions options = null) { } public virtual System.Collections.Generic.IAsyncEnumerable GetResumableTransfersAsync() { throw null; } - public virtual System.Collections.Generic.IAsyncEnumerable GetTransfersAsync(params Azure.Storage.DataMovement.StorageTransferStatus[] filterByStatus) { throw null; } + public virtual System.Collections.Generic.IAsyncEnumerable GetTransfersAsync(params Azure.Storage.DataMovement.DataTransferStatus[] filterByStatus) { throw null; } public virtual System.Threading.Tasks.Task PauseTransferIfRunningAsync(string transferId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task ResumeTransferAsync(string transferId, Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, Azure.Storage.DataMovement.TransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task StartTransferAsync(Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, Azure.Storage.DataMovement.TransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task ResumeTransferAsync(string transferId, Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, Azure.Storage.DataMovement.DataTransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task StartTransferAsync(Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, Azure.Storage.DataMovement.DataTransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } System.Threading.Tasks.ValueTask System.IAsyncDisposable.DisposeAsync() { throw null; } } public partial class TransferManagerOptions { public TransferManagerOptions() { } - public Azure.Storage.DataMovement.TransferCheckpointerOptions CheckpointerOptions { get { throw null; } set { } } + public Azure.Storage.DataMovement.TransferCheckpointStoreOptions CheckpointerOptions { get { throw null; } set { } } public Azure.Core.DiagnosticsOptions Diagnostics { get { throw null; } } - public Azure.Storage.DataMovement.ErrorHandlingBehavior ErrorHandling { get { throw null; } set { } } + public Azure.Storage.DataMovement.DataTransferErrorMode ErrorHandling { get { throw null; } set { } } public int? MaximumConcurrency { get { throw null; } set { } } } - public partial class TransferOptions : System.IEquatable - { - public TransferOptions() { } - public Azure.Storage.DataMovement.StorageResourceCreateMode CreateMode { get { throw null; } set { } } - public long? InitialTransferSize { get { throw null; } set { } } - public long? MaximumTransferChunkSize { get { throw null; } set { } } - public System.IProgress ProgressHandler { get { throw null; } set { } } - public Azure.Storage.DataMovement.ProgressHandlerOptions ProgressHandlerOptions { get { throw null; } set { } } - public event Azure.Core.SyncAsyncEventHandler SingleTransferCompleted { add { } remove { } } - public event Azure.Core.SyncAsyncEventHandler TransferFailed { add { } remove { } } - public event Azure.Core.SyncAsyncEventHandler TransferSkipped { add { } remove { } } - public event Azure.Core.SyncAsyncEventHandler TransferStatus { add { } remove { } } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public bool Equals(Azure.Storage.DataMovement.TransferOptions obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public static bool operator ==(Azure.Storage.DataMovement.TransferOptions left, Azure.Storage.DataMovement.TransferOptions right) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public static bool operator !=(Azure.Storage.DataMovement.TransferOptions left, Azure.Storage.DataMovement.TransferOptions right) { throw null; } - } - public partial class TransferSkippedEventArgs : Azure.Storage.DataMovement.StorageTransferEventArgs - { - public TransferSkippedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceSingle sourceResource, Azure.Storage.DataMovement.StorageResourceSingle destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResourceSingle DestinationResource { get { throw null; } } - public Azure.Storage.DataMovement.StorageResourceSingle SourceResource { get { throw null; } } - } - public partial class TransferStatusEventArgs : Azure.Storage.DataMovement.StorageTransferEventArgs + public partial class TransferStatusEventArgs : Azure.Storage.DataMovement.DataTransferEventArgs { - public TransferStatusEventArgs(string transferId, Azure.Storage.DataMovement.StorageTransferStatus transferStatus, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageTransferStatus StorageTransferStatus { get { throw null; } } - } - public enum TransferType - { - Concurrent = 0, - Sequential = 1, + public TransferStatusEventArgs(string transferId, Azure.Storage.DataMovement.DataTransferStatus transferStatus, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } + public Azure.Storage.DataMovement.DataTransferStatus StorageTransferStatus { get { throw null; } } } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/CommitChunkHandler.cs b/sdk/storage/Azure.Storage.DataMovement/src/CommitChunkHandler.cs index 94f265625b2d3..b2147c33b5be4 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/CommitChunkHandler.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/CommitChunkHandler.cs @@ -49,14 +49,14 @@ public struct Behaviors private long _bytesTransferred; private readonly long _expectedLength; private readonly long _blockSize; - private readonly TransferType _transferType; + private readonly DataTransferOrder _transferOrder; private readonly ClientDiagnostics _clientDiagnostics; public CommitChunkHandler( long expectedLength, long blockSize, Behaviors behaviors, - TransferType transferType, + DataTransferOrder transferOrder, ClientDiagnostics clientDiagnostics, CancellationToken cancellationToken) { @@ -97,8 +97,8 @@ public CommitChunkHandler( _bytesTransferred = blockSize; _blockSize = blockSize; - _transferType = transferType; - if (_transferType == TransferType.Sequential) + _transferOrder = transferOrder; + if (_transferOrder == DataTransferOrder.Sequential) { _commitBlockHandler += SequentialBlockEvent; } @@ -121,7 +121,7 @@ public async ValueTask DisposeAsync() private void DipsoseHandlers() { - if (_transferType == TransferType.Sequential) + if (_transferOrder == DataTransferOrder.Sequential) { _commitBlockHandler -= SequentialBlockEvent; } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/StorageTransferEventArgs.cs b/sdk/storage/Azure.Storage.DataMovement/src/DataTransferEventArgs.cs similarity index 89% rename from sdk/storage/Azure.Storage.DataMovement/src/StorageTransferEventArgs.cs rename to sdk/storage/Azure.Storage.DataMovement/src/DataTransferEventArgs.cs index e987040c95936..5a36628d0d311 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/StorageTransferEventArgs.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/DataTransferEventArgs.cs @@ -11,7 +11,7 @@ namespace Azure.Storage.DataMovement /// /// Event Arguments for any Storage Transfer Event Handler. /// - public abstract class StorageTransferEventArgs : SyncAsyncEventArgs + public abstract class DataTransferEventArgs : SyncAsyncEventArgs { /// /// Job ID. @@ -19,7 +19,7 @@ public abstract class StorageTransferEventArgs : SyncAsyncEventArgs public string TransferId { get; internal set; } /// - /// Initializes a new instance of the . + /// Initializes a new instance of the . /// /// The transfer ID. /// @@ -37,7 +37,7 @@ public abstract class StorageTransferEventArgs : SyncAsyncEventArgs /// /// Thrown if is empty or null. /// - protected StorageTransferEventArgs( + protected DataTransferEventArgs( string transferId, bool isRunningSynchronously, CancellationToken cancellationToken) diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferOptions.cs b/sdk/storage/Azure.Storage.DataMovement/src/DataTransferOptions.cs similarity index 75% rename from sdk/storage/Azure.Storage.DataMovement/src/TransferOptions.cs rename to sdk/storage/Azure.Storage.DataMovement/src/DataTransferOptions.cs index 0a57a26e029c8..2ab7579211286 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferOptions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/DataTransferOptions.cs @@ -8,9 +8,9 @@ namespace Azure.Storage.DataMovement { /// - /// is used to provide options for a transfer. + /// is used to provide options for a transfer. /// - public class TransferOptions : IEquatable + public class DataTransferOptions : IEquatable { /// /// The maximum length of a network transfer in bytes. @@ -32,9 +32,9 @@ public class TransferOptions : IEquatable /// /// Optional. An for tracking progress of the transfer. - /// See for details on what is tracked. + /// See for details on what is tracked. /// - public IProgress ProgressHandler { get; set; } + public IProgress ProgressHandler { get; set; } /// /// Optional. Options for changing behavior of the ProgressHandler. @@ -67,7 +67,7 @@ public override int GetHashCode() /// The second instance to compare. /// True if they're equal, false otherwise. [EditorBrowsable(EditorBrowsableState.Never)] - public static bool operator ==(TransferOptions left, TransferOptions right) => left.Equals(right); + public static bool operator ==(DataTransferOptions left, DataTransferOptions right) => left.Equals(right); /// /// Check if two ParallelTransferOptions instances are equal. @@ -76,7 +76,7 @@ public override int GetHashCode() /// The second instance to compare. /// True if they're not equal, false otherwise. [EditorBrowsable(EditorBrowsableState.Never)] - public static bool operator !=(TransferOptions left, TransferOptions right) => !(left == right); + public static bool operator !=(DataTransferOptions left, DataTransferOptions right) => !(left == right); /// /// Check if two ParallelTransferOptions instances are equal. @@ -84,28 +84,28 @@ public override int GetHashCode() /// The instance to compare to. /// True if they're equal, false otherwise. [EditorBrowsable(EditorBrowsableState.Never)] - public bool Equals(TransferOptions obj) + public bool Equals(DataTransferOptions obj) => MaximumTransferChunkSize == obj?.MaximumTransferChunkSize && InitialTransferSize == obj?.InitialTransferSize; /// - /// Optional to configure overwrite - /// behavior. Will default to . + /// Optional to configure overwrite + /// behavior. Will default to . /// - public StorageResourceCreateMode CreateMode { get; set; } + public StorageResourceCreationPreference CreationPreference { get; set; } /// /// If the transfer status of the job changes then the event will get added to this handler. /// - public event SyncAsyncEventHandler TransferStatus; - internal SyncAsyncEventHandler GetTransferStatus() => TransferStatus; + public event SyncAsyncEventHandler TransferStatusChanged; + internal SyncAsyncEventHandler GetTransferStatus() => TransferStatusChanged; /// /// If the transfer has any failed events that occur the event will get added to this handler. /// - public event SyncAsyncEventHandler TransferFailed; + public event SyncAsyncEventHandler ItemTransferFailed; - internal SyncAsyncEventHandler GetFailed() => TransferFailed; + internal SyncAsyncEventHandler GetFailed() => ItemTransferFailed; /// /// If a single transfer within the resource container gets transferred successfully the event @@ -113,16 +113,16 @@ public bool Equals(TransferOptions obj) /// /// Only applies to container transfers, not single resource transfers. /// - public event SyncAsyncEventHandler SingleTransferCompleted; - internal SyncAsyncEventHandler GetCompleted() => SingleTransferCompleted; + public event SyncAsyncEventHandler ItemTransferCompleted; + internal SyncAsyncEventHandler GetCompleted() => ItemTransferCompleted; /// /// If the transfer has any skipped events that occur the event will get added to this handler. /// Skipped transfer occur during Transfer due to no overwrite allowed as specified in - /// + /// /// - public event SyncAsyncEventHandler TransferSkipped; + public event SyncAsyncEventHandler ItemTransferSkipped; - internal SyncAsyncEventHandler GetSkipped() => TransferSkipped; + internal SyncAsyncEventHandler GetSkipped() => ItemTransferSkipped; } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/StorageTransferProgress.cs b/sdk/storage/Azure.Storage.DataMovement/src/DataTransferProgress.cs similarity index 90% rename from sdk/storage/Azure.Storage.DataMovement/src/StorageTransferProgress.cs rename to sdk/storage/Azure.Storage.DataMovement/src/DataTransferProgress.cs index 6cac0ecf2a33a..a642466c489ff 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/StorageTransferProgress.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/DataTransferProgress.cs @@ -6,8 +6,13 @@ namespace Azure.Storage.DataMovement /// /// Progress Handler to track how many files and bytes were transferred, along with files that failed or were skipped in transfer. /// - public class StorageTransferProgress + public class DataTransferProgress { + /// + /// Constructor for mocking. + /// + protected internal DataTransferProgress() { } + /// /// Number of files that were transferred successfully. /// diff --git a/sdk/storage/Azure.Storage.DataMovement/src/DataTransferProperties.cs b/sdk/storage/Azure.Storage.DataMovement/src/DataTransferProperties.cs index be52cb3db1228..369887dd736a4 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/DataTransferProperties.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/DataTransferProperties.cs @@ -4,14 +4,14 @@ namespace Azure.Storage.DataMovement { /// - /// Storage Resource Item properties returned by + /// Storage Resource Item properties returned by /// public class DataTransferProperties { /// /// Contains the checkpointer information to rehydrate the StorageResource from. /// - public virtual TransferCheckpointerOptions Checkpointer { get; internal set; } + public virtual TransferCheckpointStoreOptions Checkpointer { get; internal set; } /// /// Contains the transfer ID which to rehydrate the StorageResource from. diff --git a/sdk/storage/Azure.Storage.DataMovement/src/StorageTransferStatus.cs b/sdk/storage/Azure.Storage.DataMovement/src/DataTransferStatus.cs similarity index 86% rename from sdk/storage/Azure.Storage.DataMovement/src/StorageTransferStatus.cs rename to sdk/storage/Azure.Storage.DataMovement/src/DataTransferStatus.cs index 3dfdc2b07f5ba..0a56b039e54e2 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/StorageTransferStatus.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/DataTransferStatus.cs @@ -8,23 +8,23 @@ namespace Azure.Storage.DataMovement /// /// Defines the status of the Transfer Job. /// - public enum StorageTransferStatus + public enum DataTransferStatus { /// /// Default value. - /// Equivalent to . + /// Equivalent to . /// None = 0, /// /// The Job has been queued up but has not yet begun any transfers. - /// Equivalent to . + /// Equivalent to . /// Queued = 1, /// /// The Job has started, but has not yet completed. - /// Equivalent to . + /// Equivalent to . /// InProgress = 2, @@ -33,7 +33,7 @@ public enum StorageTransferStatus /// this will be the value. /// /// This status is a resumable state, only - /// transfers that failed will be retried when + /// transfers that failed will be retried when /// with the respective transfer ID to resume. /// Paused = 3, diff --git a/sdk/storage/Azure.Storage.DataMovement/src/DownloadRangeEventArgs.cs b/sdk/storage/Azure.Storage.DataMovement/src/DownloadRangeEventArgs.cs index 3d2ad5f46cf81..a241de280acff 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/DownloadRangeEventArgs.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/DownloadRangeEventArgs.cs @@ -8,7 +8,7 @@ namespace Azure.Storage.DataMovement { - internal class DownloadRangeEventArgs : StorageTransferEventArgs + internal class DownloadRangeEventArgs : DataTransferEventArgs { public bool Success { get; } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/JobPartFailureType.cs b/sdk/storage/Azure.Storage.DataMovement/src/JobPartFailureType.cs index 3c9a9ad9adf70..652a825396dfa 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/JobPartFailureType.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/JobPartFailureType.cs @@ -15,8 +15,8 @@ internal enum JobPartFailureType AccessDenied = 3, /// - /// If the storage resource already exists and - /// or was not enabled, then it's a failure caused + /// If the storage resource already exists and + /// or was not enabled, then it's a failure caused /// by the file already existing. /// CannotOvewrite = 2, diff --git a/sdk/storage/Azure.Storage.DataMovement/src/JobPartInternal.cs b/sdk/storage/Azure.Storage.DataMovement/src/JobPartInternal.cs index 5e39ee0a67c43..92e532488fadd 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/JobPartInternal.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/JobPartInternal.cs @@ -48,22 +48,22 @@ internal abstract class JobPartInternal /// /// Specifies the source resource. /// - internal StorageResourceSingle _sourceResource; + internal StorageResourceItem _sourceResource; /// /// Specifies the destination resource. /// - internal StorageResourceSingle _destinationResource; + internal StorageResourceItem _destinationResource; /// /// Specifies the options for error handling. /// - internal ErrorHandlingBehavior _errorHandling; + internal DataTransferErrorMode _errorHandling; /// /// Determines how files are created and overwrite behavior for files that already exists. /// - internal StorageResourceCreateMode _createMode; + internal StorageResourceCreationPreference _createMode; /// /// If a failure occurred during a job, this defines the type of failure. @@ -95,7 +95,7 @@ internal abstract class JobPartInternal /// /// The current status of each job part. /// - public StorageTransferStatus JobPartStatus { get; set; } + public DataTransferStatus JobPartStatus { get; set; } private object _statusLock = new object(); /// @@ -125,18 +125,18 @@ internal abstract class JobPartInternal /// /// If the transfer has any failed events that occur the event will get added to this handler. /// - public SyncAsyncEventHandler TransferSkippedEventHandler { get; internal set; } + public SyncAsyncEventHandler TransferSkippedEventHandler { get; internal set; } /// /// If the transfer has any failed events that occur the event will get added to this handler. /// - public SyncAsyncEventHandler TransferFailedEventHandler { get; internal set; } + public SyncAsyncEventHandler TransferFailedEventHandler { get; internal set; } /// /// If a single transfer within the resource container gets transferred successfully the event /// will get added to this handler /// - public SyncAsyncEventHandler SingleTransferCompletedEventHandler { get; internal set; } + public SyncAsyncEventHandler SingleTransferCompletedEventHandler { get; internal set; } private List> _chunkTasks; private List> _chunkTaskSources; @@ -152,24 +152,24 @@ protected JobPartInternal() { } internal JobPartInternal( DataTransfer dataTransfer, int partNumber, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, long? maximumTransferChunkSize, long? initialTransferSize, - ErrorHandlingBehavior errorHandling, - StorageResourceCreateMode createMode, + DataTransferErrorMode errorHandling, + StorageResourceCreationPreference createMode, TransferCheckpointer checkpointer, TransferProgressTracker progressTracker, ArrayPool arrayPool, bool isFinalPart, SyncAsyncEventHandler jobPartEventHandler, SyncAsyncEventHandler statusEventHandler, - SyncAsyncEventHandler failedEventHandler, - SyncAsyncEventHandler skippedEventHandler, - SyncAsyncEventHandler singleTransferEventHandler, + SyncAsyncEventHandler failedEventHandler, + SyncAsyncEventHandler skippedEventHandler, + SyncAsyncEventHandler singleTransferEventHandler, ClientDiagnostics clientDiagnostics, CancellationToken cancellationToken, - StorageTransferStatus jobPartStatus = StorageTransferStatus.Queued, + DataTransferStatus jobPartStatus = DataTransferStatus.Queued, long? length = default) { Argument.AssertNotNull(clientDiagnostics, nameof(clientDiagnostics)); @@ -259,28 +259,28 @@ await QueueChunk( /// /// Triggers the cancellation for the Job Part. /// - /// If the status is set to - /// and any chunks is still processing to be cancelled is will be set to - /// until the chunks finish then it will be set to . + /// If the status is set to + /// and any chunks is still processing to be cancelled is will be set to + /// until the chunks finish then it will be set to . /// - /// If the status is set to - /// and any chunks is still processing to be cancelled is will be set to - /// until the chunks finish then it will be set to . + /// If the status is set to + /// and any chunks is still processing to be cancelled is will be set to + /// until the chunks finish then it will be set to . /// /// The task to wait until the cancellation has been triggered. internal async Task TriggerCancellationAsync() { // Set the status to Pause/CancellationInProgress - if (StorageTransferStatus.PauseInProgress == _dataTransfer.TransferStatus) + if (DataTransferStatus.PauseInProgress == _dataTransfer.TransferStatus) { // It's possible that the status hasn't propagated down to the job part // status yet here since we pause from the data transfer object. - await OnTransferStatusChanged(StorageTransferStatus.PauseInProgress).ConfigureAwait(false); + await OnTransferStatusChanged(DataTransferStatus.PauseInProgress).ConfigureAwait(false); } else { // It's a cancellation if a pause wasn't called. - await OnTransferStatusChanged(StorageTransferStatus.CancellationInProgress).ConfigureAwait(false); + await OnTransferStatusChanged(DataTransferStatus.CancellationInProgress).ConfigureAwait(false); } await CleanupAbortedJobPartAsync().ConfigureAwait(false); } @@ -289,12 +289,12 @@ internal async Task TriggerCancellationAsync() /// To change all transfer statues at the same time /// /// - internal async Task OnTransferStatusChanged(StorageTransferStatus transferStatus) + internal async Task OnTransferStatusChanged(DataTransferStatus transferStatus) { bool statusChanged = false; lock (_statusLock) { - if (transferStatus != StorageTransferStatus.None + if (transferStatus != DataTransferStatus.None && JobPartStatus != transferStatus) { statusChanged = true; @@ -304,24 +304,24 @@ internal async Task OnTransferStatusChanged(StorageTransferStatus transferStatus if (statusChanged) { // Progress tracking, do before invoking the event below - if (transferStatus == StorageTransferStatus.InProgress) + if (transferStatus == DataTransferStatus.InProgress) { _progressTracker.IncrementInProgressFiles(); } - else if (transferStatus == StorageTransferStatus.Completed) + else if (transferStatus == DataTransferStatus.Completed) { _progressTracker.IncrementCompletedFiles(); } - else if (transferStatus == StorageTransferStatus.CompletedWithSkippedTransfers) + else if (transferStatus == DataTransferStatus.CompletedWithSkippedTransfers) { _progressTracker.IncrementSkippedFiles(); } - else if (transferStatus == StorageTransferStatus.CompletedWithFailedTransfers) + else if (transferStatus == DataTransferStatus.CompletedWithFailedTransfers) { _progressTracker.IncrementFailedFiles(); } - if (JobPartStatus == StorageTransferStatus.Completed) + if (JobPartStatus == DataTransferStatus.Completed) { await InvokeSingleCompletedArg().ConfigureAwait(false); } @@ -357,7 +357,7 @@ public async virtual Task InvokeSingleCompletedArg() if (SingleTransferCompletedEventHandler != null) { await SingleTransferCompletedEventHandler.RaiseAsync( - new SingleTransferCompletedEventArgs( + new TransferItemCompletedEventArgs( _dataTransfer.Id, _sourceResource, _destinationResource, @@ -379,7 +379,7 @@ public async virtual Task InvokeSkippedArg() { // TODO: change to RaiseAsync await TransferSkippedEventHandler.RaiseAsync( - new TransferSkippedEventArgs( + new TransferItemSkippedEventArgs( _dataTransfer.Id, _sourceResource, _destinationResource, @@ -390,7 +390,7 @@ await TransferSkippedEventHandler.RaiseAsync( ClientDiagnostics) .ConfigureAwait(false); } - await OnTransferStatusChanged(StorageTransferStatus.CompletedWithSkippedTransfers).ConfigureAwait(false); + await OnTransferStatusChanged(DataTransferStatus.CompletedWithSkippedTransfers).ConfigureAwait(false); } /// @@ -406,7 +406,7 @@ public async virtual Task InvokeFailedArg(Exception ex) { // TODO: change to RaiseAsync await TransferFailedEventHandler.RaiseAsync( - new TransferFailedEventArgs( + new TransferItemFailedEventArgs( _dataTransfer.Id, _sourceResource, _destinationResource, @@ -452,7 +452,7 @@ public async virtual Task CleanupAbortedJobPartAsync() public async virtual Task AddJobPartToCheckpointerAsync(int chunksTotal, bool isFinalPart) { JobPartPlanHeader header = this.ToJobPartPlanHeader( - jobStatus: StorageTransferStatus.InProgress, + jobStatus: DataTransferStatus.InProgress, isFinalPart: isFinalPart); using (Stream stream = new MemoryStream()) { @@ -466,7 +466,7 @@ await _checkpointer.AddNewJobPartAsync( } } - internal async virtual Task SetCheckpointerStatus(StorageTransferStatus status) + internal async virtual Task SetCheckpointerStatus(DataTransferStatus status) { await _checkpointer.SetJobPartTransferStatusAsync( transferId: _dataTransfer.Id, @@ -567,13 +567,13 @@ internal async Task CheckAndUpdateCancellationStatusAsync() { if (_chunkTasks.All((Task task) => (task.IsCompleted))) { - if (JobPartStatus == StorageTransferStatus.PauseInProgress) + if (JobPartStatus == DataTransferStatus.PauseInProgress) { - await OnTransferStatusChanged(StorageTransferStatus.Paused).ConfigureAwait(false); + await OnTransferStatusChanged(DataTransferStatus.Paused).ConfigureAwait(false); } - else if (JobPartStatus == StorageTransferStatus.CancellationInProgress) + else if (JobPartStatus == DataTransferStatus.CancellationInProgress) { - await OnTransferStatusChanged(StorageTransferStatus.CompletedWithFailedTransfers).ConfigureAwait(false); + await OnTransferStatusChanged(DataTransferStatus.CompletedWithFailedTransfers).ConfigureAwait(false); } } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/LocalDirectoryStorageResourceContainer.cs b/sdk/storage/Azure.Storage.DataMovement/src/LocalDirectoryStorageResourceContainer.cs index c572ce2bc3031..89094d0d88ff6 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/LocalDirectoryStorageResourceContainer.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/LocalDirectoryStorageResourceContainer.cs @@ -48,7 +48,7 @@ public LocalDirectoryStorageResourceContainer(string path) /// /// /// - protected internal override StorageResourceSingle GetChildStorageResource(string childPath) + protected internal override StorageResourceItem GetStorageResourceReference(string childPath) { string concatPath = System.IO.Path.Combine(Path, childPath); return new LocalFileStorageResource(concatPath); diff --git a/sdk/storage/Azure.Storage.DataMovement/src/LocalFileStorageResource.cs b/sdk/storage/Azure.Storage.DataMovement/src/LocalFileStorageResource.cs index c8e30c92dbc92..d2fbc61deb0d9 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/LocalFileStorageResource.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/LocalFileStorageResource.cs @@ -12,7 +12,7 @@ namespace Azure.Storage.DataMovement /// /// Local File Storage Resource /// - public class LocalFileStorageResource : StorageResourceSingle + public class LocalFileStorageResource : StorageResourceItem { private string _path; @@ -39,7 +39,7 @@ public class LocalFileStorageResource : StorageResourceSingle /// /// Defines the recommended Transfer Type of the resource /// - protected internal override TransferType TransferType => TransferType.Sequential; + protected internal override DataTransferOrder TransferType => DataTransferOrder.Sequential; /// /// Defines the maximum chunk size for the storage resource. @@ -75,14 +75,14 @@ public LocalFileStorageResource(string path) /// /// /// - protected internal override Task ReadStreamAsync( + protected internal override Task ReadStreamAsync( long position = 0, long? length = default, CancellationToken cancellationToken = default) { FileStream stream = new FileStream(_path, FileMode.Open, FileAccess.Read); stream.Position = position; - return Task.FromResult(new ReadStreamStorageResourceResult(stream)); + return Task.FromResult(new StorageResourceReadStreamResult(stream)); } /// @@ -120,7 +120,7 @@ internal Task CreateAsync(bool overwrite) /// /// /// - protected internal override async Task WriteFromStreamAsync( + protected internal override async Task CopyFromStreamAsync( Stream stream, long streamLength, bool overwrite, @@ -170,7 +170,7 @@ await stream.CopyToAsync( /// /// protected internal override Task CopyFromUriAsync( - StorageResourceSingle sourceResource, + StorageResourceItem sourceResource, bool overwrite, long completeLength, StorageResourceCopyFromUriOptions options = default, @@ -194,7 +194,7 @@ protected internal override Task CopyFromUriAsync( /// /// protected internal override Task CopyBlockFromUriAsync( - StorageResourceSingle sourceResource, + StorageResourceItem sourceResource, HttpRange range, bool overwrite, long completeLength = 0, diff --git a/sdk/storage/Azure.Storage.DataMovement/src/LocalStorageResourceProvider.cs b/sdk/storage/Azure.Storage.DataMovement/src/LocalStorageResourceProvider.cs index 6a90d871f8864..2b9c33cc842d2 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/LocalStorageResourceProvider.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/LocalStorageResourceProvider.cs @@ -31,7 +31,7 @@ internal LocalStorageResourceProvider( /// /// The this provider is configured for. /// - public StorageResource MakeResource() + public StorageResource CreateResource() { if (_isFolder) { diff --git a/sdk/storage/Azure.Storage.DataMovement/src/ProgressHandlerOptions.cs b/sdk/storage/Azure.Storage.DataMovement/src/ProgressHandlerOptions.cs index bca4769c333e0..96e81cb07d142 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/ProgressHandlerOptions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/ProgressHandlerOptions.cs @@ -9,7 +9,7 @@ namespace Azure.Storage.DataMovement public class ProgressHandlerOptions { /// - /// Set to true to populate BytesTransferred of in + /// Set to true to populate BytesTransferred of in /// progress reports. Set to false to not track BytesTransferred (value will be null). /// Default value is false. /// diff --git a/sdk/storage/Azure.Storage.DataMovement/src/ServiceToServiceJobPart.cs b/sdk/storage/Azure.Storage.DataMovement/src/ServiceToServiceJobPart.cs index 72c7386318c39..277a045fe6e30 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/ServiceToServiceJobPart.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/ServiceToServiceJobPart.cs @@ -30,8 +30,8 @@ private ServiceToServiceJobPart(ServiceToServiceTransferJob job, int partNumber, destinationResource: job._destinationResource, maximumTransferChunkSize: job._maximumTransferChunkSize, initialTransferSize: job._initialTransferSize, - errorHandling: job._errorHandling, - createMode: job._createMode, + errorHandling: job._errorMode, + createMode: job._creationPreference, checkpointer: job._checkpointer, progressTracker: job._progressTracker, arrayPool: job.UploadArrayPool, @@ -40,7 +40,7 @@ private ServiceToServiceJobPart(ServiceToServiceTransferJob job, int partNumber, statusEventHandler: job.TransferStatusEventHandler, failedEventHandler: job.TransferFailedEventHandler, skippedEventHandler: job.TransferSkippedEventHandler, - singleTransferEventHandler: job.SingleTransferCompletedEventHandler, + singleTransferEventHandler: job.TransferItemCompletedEventHandler, clientDiagnostics: job.ClientDiagnostics, cancellationToken: job._cancellationToken) { @@ -52,10 +52,10 @@ private ServiceToServiceJobPart(ServiceToServiceTransferJob job, int partNumber, private ServiceToServiceJobPart( ServiceToServiceTransferJob job, int partNumber, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, bool isFinalPart, - StorageTransferStatus jobPartStatus = StorageTransferStatus.Queued, + DataTransferStatus jobPartStatus = DataTransferStatus.Queued, long? length = default) : base(dataTransfer: job._dataTransfer, partNumber: partNumber, @@ -63,8 +63,8 @@ private ServiceToServiceJobPart( destinationResource :destinationResource, maximumTransferChunkSize: job._maximumTransferChunkSize, initialTransferSize: job._initialTransferSize, - errorHandling: job._errorHandling, - createMode: job._createMode, + errorHandling: job._errorMode, + createMode: job._creationPreference, checkpointer: job._checkpointer, progressTracker: job._progressTracker, arrayPool: job.UploadArrayPool, @@ -73,7 +73,7 @@ private ServiceToServiceJobPart( statusEventHandler: job.TransferStatusEventHandler, failedEventHandler: job.TransferFailedEventHandler, skippedEventHandler: job.TransferSkippedEventHandler, - singleTransferEventHandler: job.SingleTransferCompletedEventHandler, + singleTransferEventHandler: job.TransferItemCompletedEventHandler, clientDiagnostics: job.ClientDiagnostics, cancellationToken: job._cancellationToken, jobPartStatus: jobPartStatus, @@ -103,10 +103,10 @@ public static async Task CreateJobPartAsync( public static async Task CreateJobPartAsync( ServiceToServiceTransferJob job, int partNumber, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, bool isFinalPart, - StorageTransferStatus jobPartStatus = default, + DataTransferStatus jobPartStatus = default, long? length = default, bool partPlanFileExists = false) { @@ -128,7 +128,7 @@ public static async Task CreateJobPartAsync( public override async Task ProcessPartToChunkAsync() { - await OnTransferStatusChanged(StorageTransferStatus.InProgress).ConfigureAwait(false); + await OnTransferStatusChanged(DataTransferStatus.InProgress).ConfigureAwait(false); // Attempt to get the length, it's possible the file could // not be accessible (or does not exist). @@ -176,7 +176,7 @@ await StartSingleCallCopy(length).ConfigureAwait(false)) if (await CreateDestinationResource(length, blockSize).ConfigureAwait(false)) { List<(long Offset, long Length)> commitBlockList = GetRangeList(blockSize, length); - if (_destinationResource.TransferType == TransferType.Concurrent) + if (_destinationResource.TransferType == DataTransferOrder.Unordered) { await QueueStageBlockRequests(commitBlockList, length).ConfigureAwait(false); } @@ -205,16 +205,16 @@ internal async Task StartSingleCallCopy(long completeLength) await GetCopyFromUriOptionsAsync(_cancellationToken).ConfigureAwait(false); await _destinationResource.CopyFromUriAsync( sourceResource: _sourceResource, - overwrite: _createMode == StorageResourceCreateMode.Overwrite, + overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, completeLength: completeLength, options: options, cancellationToken: _cancellationToken).ConfigureAwait(false); ReportBytesWritten(completeLength); - await OnTransferStatusChanged(StorageTransferStatus.Completed).ConfigureAwait(false); + await OnTransferStatusChanged(DataTransferStatus.Completed).ConfigureAwait(false); } catch (RequestFailedException exception) - when (_createMode == StorageResourceCreateMode.Skip + when (_createMode == StorageResourceCreationPreference.SkipIfExists && exception.ErrorCode == "BlobAlreadyExists") { await InvokeSkippedArg().ConfigureAwait(false); @@ -238,7 +238,7 @@ internal async Task CreateDestinationResource(long length, long blockSize) await GetCopyFromUriOptionsAsync(_cancellationToken).ConfigureAwait(false); await _destinationResource.CopyBlockFromUriAsync( sourceResource: _sourceResource, - overwrite: _createMode == StorageResourceCreateMode.Overwrite, + overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, range: new HttpRange(0, blockSize), completeLength: length, options: options, @@ -255,7 +255,7 @@ await _destinationResource.CopyBlockFromUriAsync( return true; } catch (RequestFailedException exception) - when (_createMode == StorageResourceCreateMode.Skip + when (_createMode == StorageResourceCreationPreference.SkipIfExists && exception.ErrorCode == "BlobAlreadyExists") { await InvokeSkippedArg().ConfigureAwait(false); @@ -272,7 +272,7 @@ internal CommitChunkHandler GetCommitController( long expectedLength, long blockSize, ServiceToServiceJobPart jobPart, - TransferType transferType) + DataTransferOrder transferType) => new CommitChunkHandler( expectedLength, blockSize, @@ -300,14 +300,14 @@ internal async Task CompleteTransferAsync() { // Apply necessary transfer completions on the destination. await _destinationResource.CompleteTransferAsync( - overwrite: _createMode == StorageResourceCreateMode.Overwrite, + overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, cancellationToken: _cancellationToken).ConfigureAwait(false); // Dispose the handlers await DisposeHandlers().ConfigureAwait(false); // Set completion status to completed - await OnTransferStatusChanged(StorageTransferStatus.Completed).ConfigureAwait(false); + await OnTransferStatusChanged(DataTransferStatus.Completed).ConfigureAwait(false); } catch (Exception ex) { @@ -351,7 +351,7 @@ internal async Task PutBlockFromUri( await GetCopyFromUriOptionsAsync(_cancellationToken).ConfigureAwait(false); await _destinationResource.CopyBlockFromUriAsync( sourceResource: _sourceResource, - overwrite: _createMode == StorageResourceCreateMode.Overwrite, + overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, range: new HttpRange(offset, blockLength), completeLength: expectedLength, options: options, @@ -368,12 +368,12 @@ await _commitBlockHandler.InvokeEvent( cancellationToken: _cancellationToken)).ConfigureAwait(false); } catch (RequestFailedException ex) - when (_createMode == StorageResourceCreateMode.Overwrite + when (_createMode == StorageResourceCreationPreference.OverwriteIfExists && ex.ErrorCode == "BlobAlreadyExists") { // For Block Blobs this is a one off case because we don't create the blob // before uploading to it. - if (_createMode == StorageResourceCreateMode.Fail) + if (_createMode == StorageResourceCreationPreference.FailIfExists) { await InvokeFailedArg(ex).ConfigureAwait(false); } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/ServiceToServiceTransferJob.cs b/sdk/storage/Azure.Storage.DataMovement/src/ServiceToServiceTransferJob.cs index b821aeb40e1fd..ea5af0ae23746 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/ServiceToServiceTransferJob.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/ServiceToServiceTransferJob.cs @@ -18,12 +18,12 @@ internal class ServiceToServiceTransferJob : TransferJobInternal /// internal ServiceToServiceTransferJob( DataTransfer dataTransfer, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, - TransferOptions transferOptions, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, + DataTransferOptions transferOptions, QueueChunkTaskInternal queueChunkTask, TransferCheckpointer CheckPointFolderPath, - ErrorHandlingBehavior errorHandling, + DataTransferErrorMode errorHandling, ArrayPool arrayPool, ClientDiagnostics clientDiagnostics) : base(dataTransfer, @@ -45,10 +45,10 @@ internal ServiceToServiceTransferJob( DataTransfer dataTransfer, StorageResourceContainer sourceResource, StorageResourceContainer destinationResource, - TransferOptions transferOptions, + DataTransferOptions transferOptions, QueueChunkTaskInternal queueChunkTask, TransferCheckpointer checkpointer, - ErrorHandlingBehavior errorHandling, + DataTransferErrorMode errorHandling, ArrayPool arrayPool, ClientDiagnostics clientDiagnostics) : base(dataTransfer, @@ -69,7 +69,7 @@ internal ServiceToServiceTransferJob( /// An IEnumerable that contains the job parts public override async IAsyncEnumerable ProcessJobToJobPartAsync() { - await OnJobStatusChangedAsync(StorageTransferStatus.InProgress).ConfigureAwait(false); + await OnJobStatusChangedAsync(DataTransferStatus.InProgress).ConfigureAwait(false); int partNumber = 0; if (_jobParts.Count == 0) @@ -108,9 +108,9 @@ public override async IAsyncEnumerable ProcessJobToJobPartAsync bool isFinalPartFound = false; foreach (JobPartInternal part in _jobParts) { - if (part.JobPartStatus != StorageTransferStatus.Completed) + if (part.JobPartStatus != DataTransferStatus.Completed) { - part.JobPartStatus = StorageTransferStatus.Queued; + part.JobPartStatus = DataTransferStatus.Queued; yield return part; if (part.IsFinalPart) @@ -192,8 +192,8 @@ private async IAsyncEnumerable GetStorageResourcesAsync() part = await ServiceToServiceJobPart.CreateJobPartAsync( job: this, partNumber: partNumber, - sourceResource: (StorageResourceSingle)lastResource, - destinationResource: _destinationResourceContainer.GetChildStorageResource(sourceName), + sourceResource: (StorageResourceItem)lastResource, + destinationResource: _destinationResourceContainer.GetStorageResourceReference(sourceName), isFinalPart: false).ConfigureAwait(false); AppendJobPart(part); } @@ -224,8 +224,8 @@ private async IAsyncEnumerable GetStorageResourcesAsync() lastPart = await ServiceToServiceJobPart.CreateJobPartAsync( job: this, partNumber: partNumber, - sourceResource: (StorageResourceSingle)lastResource, - destinationResource: _destinationResourceContainer.GetChildStorageResource(lastSourceName), + sourceResource: (StorageResourceItem)lastResource, + destinationResource: _destinationResourceContainer.GetStorageResourceReference(lastSourceName), isFinalPart: true).ConfigureAwait(false); AppendJobPart(lastPart); } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/CheckpointerExtensions.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/CheckpointerExtensions.cs index 6a87242f13b33..247530390d023 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/CheckpointerExtensions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/CheckpointerExtensions.cs @@ -5,7 +5,7 @@ namespace Azure.Storage.DataMovement { internal static class CheckpointerExtensions { - public static TransferCheckpointer GetCheckpointer(this TransferCheckpointerOptions options) + public static TransferCheckpointer GetCheckpointer(this TransferCheckpointStoreOptions options) { if (!string.IsNullOrEmpty(options?.CheckpointerPath)) { diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataMovementExtensions.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataMovementExtensions.cs index cac74acb85a01..79db0b2bde3f0 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataMovementExtensions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataMovementExtensions.cs @@ -22,14 +22,14 @@ internal static StorageResourceProperties ToStorageResourceProperties(this FileI public static async Task ToJobPartAsync( this StreamToUriTransferJob baseJob, Stream planFileStream, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource) + StorageResourceItem sourceResource, + StorageResourceItem destinationResource) { // Convert stream to job plan header JobPartPlanHeader header = JobPartPlanHeader.Deserialize(planFileStream); // Apply credentials to the saved transfer job path - StorageTransferStatus jobPartStatus = header.AtomicJobStatus; + DataTransferStatus jobPartStatus = header.AtomicJobStatus; StreamToUriJobPart jobPart = await StreamToUriJobPart.CreateJobPartAsync( job: baseJob, partNumber: Convert.ToInt32(header.PartNumber), @@ -48,14 +48,14 @@ public static async Task ToJobPartAsync( public static async Task ToJobPartAsync( this ServiceToServiceTransferJob baseJob, Stream planFileStream, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource) + StorageResourceItem sourceResource, + StorageResourceItem destinationResource) { // Convert stream to job plan header JobPartPlanHeader header = JobPartPlanHeader.Deserialize(planFileStream); // Apply credentials to the saved transfer job path - StorageTransferStatus jobPartStatus = header.AtomicJobStatus; + DataTransferStatus jobPartStatus = header.AtomicJobStatus; ServiceToServiceJobPart jobPart = await ServiceToServiceJobPart.CreateJobPartAsync( job: baseJob, partNumber: Convert.ToInt32(header.PartNumber), @@ -74,14 +74,14 @@ public static async Task ToJobPartAsync( public static async Task ToJobPartAsync( this UriToStreamTransferJob baseJob, Stream planFileStream, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource) + StorageResourceItem sourceResource, + StorageResourceItem destinationResource) { // Convert stream to job plan header JobPartPlanHeader header = JobPartPlanHeader.Deserialize(planFileStream); // Apply credentials to the saved transfer job path - StorageTransferStatus jobPartStatus = header.AtomicJobStatus; + DataTransferStatus jobPartStatus = header.AtomicJobStatus; UriToStreamJobPart jobPart = await UriToStreamJobPart.CreateJobPartAsync( job: baseJob, partNumber: Convert.ToInt32(header.PartNumber), @@ -111,13 +111,13 @@ public static async Task ToJobPartAsync( string childSourceName = childSourcePath.Substring(sourceResource.Path.Length + 1); string childDestinationPath = header.DestinationPath; string childDestinationName = childDestinationPath.Substring(destinationResource.Uri.AbsoluteUri.Length + 1); - StorageTransferStatus jobPartStatus = header.AtomicJobStatus; + DataTransferStatus jobPartStatus = header.AtomicJobStatus; StreamToUriJobPart jobPart = await StreamToUriJobPart.CreateJobPartAsync( job: baseJob, partNumber: Convert.ToInt32(header.PartNumber), jobPartStatus: jobPartStatus, - sourceResource: sourceResource.GetChildStorageResource(childSourceName), - destinationResource: destinationResource.GetChildStorageResource(childDestinationName), + sourceResource: sourceResource.GetStorageResourceReference(childSourceName), + destinationResource: destinationResource.GetStorageResourceReference(childDestinationName), partPlanFileExists: true, isFinalPart: header.IsFinalPart).ConfigureAwait(false); @@ -139,13 +139,13 @@ public static async Task ToJobPartAsync( // Apply credentials to the saved transfer job path string childSourcePath = header.SourcePath; string childDestinationPath = header.DestinationPath; - StorageTransferStatus jobPartStatus = header.AtomicJobStatus; + DataTransferStatus jobPartStatus = header.AtomicJobStatus; ServiceToServiceJobPart jobPart = await ServiceToServiceJobPart.CreateJobPartAsync( job: baseJob, partNumber: Convert.ToInt32(header.PartNumber), jobPartStatus: jobPartStatus, - sourceResource: sourceResource.GetChildStorageResource(childSourcePath.Substring(sourceResource.Uri.AbsoluteUri.Length + 1)), - destinationResource: destinationResource.GetChildStorageResource(childDestinationPath.Substring(destinationResource.Uri.AbsoluteUri.Length + 1)), + sourceResource: sourceResource.GetStorageResourceReference(childSourcePath.Substring(sourceResource.Uri.AbsoluteUri.Length + 1)), + destinationResource: destinationResource.GetStorageResourceReference(childDestinationPath.Substring(destinationResource.Uri.AbsoluteUri.Length + 1)), partPlanFileExists: true, isFinalPart: header.IsFinalPart).ConfigureAwait(false); @@ -169,13 +169,13 @@ public static async Task ToJobPartAsync( string childSourceName = childSourcePath.Substring(sourceResource.Uri.AbsoluteUri.Length + 1); string childDestinationPath = header.DestinationPath; string childDestinationName = childDestinationPath.Substring(destinationResource.Path.Length + 1); - StorageTransferStatus jobPartStatus = header.AtomicJobStatus; + DataTransferStatus jobPartStatus = header.AtomicJobStatus; UriToStreamJobPart jobPart = await UriToStreamJobPart.CreateJobPartAsync( job: baseJob, partNumber: Convert.ToInt32(header.PartNumber), jobPartStatus: jobPartStatus, - sourceResource: sourceResource.GetChildStorageResource(childSourceName), - destinationResource: destinationResource.GetChildStorageResource(childDestinationName), + sourceResource: sourceResource.GetStorageResourceReference(childSourceName), + destinationResource: destinationResource.GetStorageResourceReference(childDestinationName), partPlanFileExists: true, isFinalPart: header.IsFinalPart).ConfigureAwait(false); @@ -189,7 +189,7 @@ public static async Task ToJobPartAsync( /// Translate the initial job part header to a job plan format file /// internal static JobPartPlanHeader ToJobPartPlanHeader(this JobPartInternal jobPart, - StorageTransferStatus jobStatus, + DataTransferStatus jobStatus, bool isFinalPart) { JobPartPlanDestinationBlob dstBlobData = new JobPartPlanDestinationBlob( @@ -252,7 +252,7 @@ internal static JobPartPlanHeader ToJobPartPlanHeader(this JobPartInternal jobPa destinationPath: destinationPath, destinationExtraQuery: "", // TODO: convert options to string isFinalPart: isFinalPart, - forceWrite: jobPart._createMode == StorageResourceCreateMode.Overwrite, // TODO: change to enum value + forceWrite: jobPart._createMode == StorageResourceCreationPreference.OverwriteIfExists, // TODO: change to enum value forceIfReadOnly: false, // TODO: revisit for Azure Files autoDecompress: false, // TODO: revisit if we want to support this feature priority: 0, // TODO: add priority feature @@ -330,8 +330,8 @@ internal static void VerifyJobPartPlanHeader(this JobPartInternal jobPart, JobPa } // Check CreateMode / Overwrite - if ((header.ForceWrite && jobPart._createMode != StorageResourceCreateMode.Overwrite) || - (!header.ForceWrite && jobPart._createMode == StorageResourceCreateMode.Overwrite)) + if ((header.ForceWrite && jobPart._createMode != StorageResourceCreationPreference.OverwriteIfExists) || + (!header.ForceWrite && jobPart._createMode == StorageResourceCreationPreference.OverwriteIfExists)) { throw Errors.MismatchResumeCreateMode(header.ForceWrite, jobPart._createMode); } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransfer.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransfer.cs index 0aab393cb562c..f1f6becbe1bca 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransfer.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransfer.cs @@ -21,7 +21,7 @@ public class DataTransfer /// /// Defines the current Transfer Status of the Data Transfer. /// - public StorageTransferStatus TransferStatus => _state.Status; + public DataTransferStatus TransferStatus => _state.Status; /// /// DataTransfer Identification. @@ -50,11 +50,11 @@ internal DataTransfer() /// /// The transfer ID of the transfer object. /// Reference to the transfer manager running this transfer. - /// The Transfer Status of the Transfer. See . + /// The Transfer Status of the Transfer. See . internal DataTransfer( string id, TransferManager transferManager, - StorageTransferStatus status = StorageTransferStatus.Queued) + DataTransferStatus status = DataTransferStatus.Queued) { Argument.AssertNotNullOrEmpty(id, nameof(id)); Argument.AssertNotNull(transferManager, nameof(transferManager)); @@ -65,7 +65,7 @@ internal DataTransfer( /// /// Ensures completion of the DataTransfer and attempts to get result /// - public void EnsureCompleted(CancellationToken cancellationToken = default) + public void WaitForCompletion(CancellationToken cancellationToken = default) { #pragma warning disable AZC0102 // Do not use GetAwaiter().GetResult(). Use the TaskExtensions.EnsureCompleted() extension method instead. WaitForCompletionAsync(cancellationToken).GetAwaiter().GetResult(); @@ -90,7 +90,7 @@ public async Task WaitForCompletionAsync(CancellationToken cancellationToken = d /// /// Will return true if the pause has taken place. /// - public virtual async Task PauseIfRunningAsync(CancellationToken cancellationToken = default) + public virtual async Task PauseAsync(CancellationToken cancellationToken = default) { await _state.PauseIfRunningAsync(cancellationToken).ConfigureAwait(false); } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/ErrorHandlingBehavior.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransferErrorMode.cs similarity index 92% rename from sdk/storage/Azure.Storage.DataMovement/src/Shared/ErrorHandlingBehavior.cs rename to sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransferErrorMode.cs index b53c1df4884d1..f446b25175551 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/ErrorHandlingBehavior.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransferErrorMode.cs @@ -9,7 +9,7 @@ namespace Azure.Storage.DataMovement /// Defines the Error Handling Path to take when a failure or error occurs. /// [Flags] - public enum ErrorHandlingBehavior + public enum DataTransferErrorMode { /// /// If set all the transfer jobs will ignore failures @@ -25,6 +25,6 @@ public enum ErrorHandlingBehavior /// quickly on encountering failures from the storage service /// and filesystem failures. /// - StopOnAllFailures = 0, + StopOnAnyFailure = 0, } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferType.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransferOrder.cs similarity index 76% rename from sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferType.cs rename to sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransferOrder.cs index f39b96b847c39..0fe6d5a846329 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferType.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransferOrder.cs @@ -8,14 +8,14 @@ namespace Azure.Storage.DataMovement { /// - /// Defines the recommended Transfer Type of the . + /// Defines the recommended Transfer Type of the . /// - public enum TransferType + public enum DataTransferOrder { /// - /// Recommended Transfer type is concurrent transfer for each chunk. + /// Recommended Transfer type is unordered transfer for each chunk. /// - Concurrent = 0, + Unordered = 0, /// /// Recommended Transfer type is sequential transfer for each chunk. diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransferState.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransferState.cs index 26e41665195b0..d96830068f369 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransferState.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataTransferState.cs @@ -16,31 +16,31 @@ internal class DataTransferState { private readonly object _statusLock = new object(); private string _id; - private StorageTransferStatus _status; + private DataTransferStatus _status; - public TaskCompletionSource CompletionSource; + public TaskCompletionSource CompletionSource; public CancellationTokenSource CancellationTokenSource { get; internal set; } - public StorageTransferStatus Status => _status; + public DataTransferStatus Status => _status; /// /// Constructor to resume current jobs /// /// The transfer ID of the transfer object. - /// The Transfer Status of the Transfer. See . + /// The Transfer Status of the Transfer. See . public DataTransferState( string id = default, - StorageTransferStatus status = StorageTransferStatus.Queued) + DataTransferStatus status = DataTransferStatus.Queued) { _id = string.IsNullOrEmpty(id) ? Guid.NewGuid().ToString() : id; _status = status; - CompletionSource = new TaskCompletionSource( + CompletionSource = new TaskCompletionSource( _status, TaskCreationOptions.RunContinuationsAsynchronously); - if (StorageTransferStatus.Completed == status || - StorageTransferStatus.CompletedWithSkippedTransfers == status || - StorageTransferStatus.CompletedWithFailedTransfers == status) + if (DataTransferStatus.Completed == status || + DataTransferStatus.CompletedWithSkippedTransfers == status || + DataTransferStatus.CompletedWithFailedTransfers == status) { CompletionSource.TrySetResult(status); } @@ -62,9 +62,9 @@ internal set { } public bool HasCompleted { get { - return (StorageTransferStatus.Completed == _status || - StorageTransferStatus.CompletedWithSkippedTransfers == _status || - StorageTransferStatus.CompletedWithFailedTransfers == _status); + return (DataTransferStatus.Completed == _status || + DataTransferStatus.CompletedWithSkippedTransfers == _status || + DataTransferStatus.CompletedWithFailedTransfers == _status); } internal set { } } @@ -82,7 +82,7 @@ public void SetId(string id) /// Gets the status of the transfer /// /// - public StorageTransferStatus GetTransferStatus() + public DataTransferStatus GetTransferStatus() { lock (_statusLock) { @@ -95,17 +95,17 @@ public StorageTransferStatus GetTransferStatus() /// /// /// Returns whether or not the status has been changed/set - public bool TrySetTransferStatus(StorageTransferStatus status) + public bool TrySetTransferStatus(DataTransferStatus status) { lock (_statusLock) { if (_status != status) { _status = status; - if (StorageTransferStatus.Paused == status || - StorageTransferStatus.Completed == status || - StorageTransferStatus.CompletedWithSkippedTransfers == status || - StorageTransferStatus.CompletedWithFailedTransfers == status) + if (DataTransferStatus.Paused == status || + DataTransferStatus.Completed == status || + DataTransferStatus.CompletedWithSkippedTransfers == status || + DataTransferStatus.CompletedWithFailedTransfers == status) { // If the _completionSource has been cancelled or the exception // has been set, we don't need to check if TrySetResult returns false @@ -119,7 +119,7 @@ public bool TrySetTransferStatus(StorageTransferStatus status) } internal bool CanPause() - => _status == StorageTransferStatus.InProgress; + => _status == DataTransferStatus.InProgress; public async Task PauseIfRunningAsync(CancellationToken cancellationToken) { @@ -129,7 +129,7 @@ public async Task PauseIfRunningAsync(CancellationToken cancellationToken) } CancellationHelper.ThrowIfCancellationRequested(cancellationToken); // Call the inner cancellation token to stop the transfer job - TrySetTransferStatus(StorageTransferStatus.PauseInProgress); + TrySetTransferStatus(DataTransferStatus.PauseInProgress); if (TriggerCancellation()) { // Wait until full pause has completed. diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/Errors.DataMovement.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/Errors.DataMovement.cs index 98c732c7740c6..b5bb0ef921d51 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/Errors.DataMovement.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/Errors.DataMovement.cs @@ -81,7 +81,7 @@ public static ArgumentException MismatchResumeTransferArguments(string elementNa $"Checkpointer Value: {checkpointerValue}\n" + $"New Value: {passedValue}"); - public static ArgumentException MismatchResumeCreateMode(bool checkpointerValue, StorageResourceCreateMode passedValue) + public static ArgumentException MismatchResumeCreateMode(bool checkpointerValue, StorageResourceCreationPreference passedValue) => new ArgumentException($"Mismatch Value to Resume Job: The value to overwrite / create files when they exist does not match the stored value in the transfer checkpointer. Please ensure the value passed to resume the transfer matches the value in order to prevent overwriting or failing files.\n" + $"Checkpointer Value to overwrite was set to {checkpointerValue.ToString()}.\n" + $"The value passed in was {passedValue.ToString()}"); diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/JobPlan/JobPartPlanHeader.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/JobPlan/JobPartPlanHeader.cs index 6356909443d96..b9a822ae348bd 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/JobPlan/JobPartPlanHeader.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/JobPlan/JobPartPlanHeader.cs @@ -209,9 +209,9 @@ internal class JobPartPlanHeader // jobStatus_doNotUse represents the current status of JobPartPlan // jobStatus_doNotUse is a private member whose value can be accessed by Status and SetJobStatus // jobStatus_doNotUse should not be directly accessed anywhere except by the Status and SetJobStatus - public StorageTransferStatus AtomicJobStatus; + public DataTransferStatus AtomicJobStatus; - public StorageTransferStatus AtomicPartStatus; + public DataTransferStatus AtomicPartStatus; internal JobPartPlanHeader( string version, @@ -244,8 +244,8 @@ internal JobPartPlanHeader( JobPartDeleteSnapshotsOption deleteSnapshotsOption, JobPartPermanentDeleteOption permanentDeleteOption, JobPartPlanRehydratePriorityType rehydratePriorityType, - StorageTransferStatus atomicJobStatus, - StorageTransferStatus atomicPartStatus) + DataTransferStatus atomicJobStatus, + DataTransferStatus atomicPartStatus) { // Version String size verification Argument.AssertNotNullOrEmpty(version, nameof(version)); @@ -822,11 +822,11 @@ public static JobPartPlanHeader Deserialize(Stream stream) // AtomicJobStatus byte atomicJobStatusByte = reader.ReadByte(); - StorageTransferStatus atomicJobStatus = (StorageTransferStatus)atomicJobStatusByte; + DataTransferStatus atomicJobStatus = (DataTransferStatus)atomicJobStatusByte; // AtomicPartStatus byte atomicPartStatusByte = reader.ReadByte(); - StorageTransferStatus atomicPartStatus = (StorageTransferStatus)atomicPartStatusByte; + DataTransferStatus atomicPartStatus = (DataTransferStatus)atomicPartStatusByte; JobPartPlanDestinationBlob dstBlobData = new JobPartPlanDestinationBlob( blobType: blobType, diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/LocalTransferCheckpointer.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/LocalTransferCheckpointer.cs index 03f55c18a1e13..ae7a5c992c2c5 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/LocalTransferCheckpointer.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/LocalTransferCheckpointer.cs @@ -302,7 +302,7 @@ public override Task> GetStoredTransfersAsync(CancellationToken can /// public override async Task SetJobTransferStatusAsync( string transferId, - StorageTransferStatus status, + DataTransferStatus status, CancellationToken cancellationToken = default) { long length = DataMovementConstants.PlanFile.OneByte; @@ -345,7 +345,7 @@ public override async Task SetJobTransferStatusAsync( public override async Task SetJobPartTransferStatusAsync( string transferId, int partNumber, - StorageTransferStatus status, + DataTransferStatus status, CancellationToken cancellationToken = default) { long length = DataMovementConstants.PlanFile.OneByte; diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/StorageManagerTransferStatus.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/StorageManagerTransferStatus.cs deleted file mode 100644 index 212a6e697fb0e..0000000000000 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/StorageManagerTransferStatus.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -using System; -using System.Collections.Generic; -using System.Text; - -namespace Azure.Storage.DataMovement -{ - /// - /// Defines the status of the StorageTransferManager. - /// - internal enum StorageManagerTransferStatus - { - /// - /// No Jobs are in progress - /// - Idle, - - /// - /// Jobs are in progress - /// - InProgress, - - /// - /// In progress of pausing transfers. Which means we have received the - /// command to PauseTransfers but we have not stopped all the running Tasks yet. - /// - /// During this time we are writing to the plan files to keep track of the progress - /// and waiting for the Tasks in flight to exit properly. Also updating all log files - /// as well. - /// - /// In this state no other transfers can be resumed until all the jobs have been - /// paused, finished or cancelled. - /// - Pausing, - - /// - /// In progress of cancelling transfers. Which means that we received the cancel command - /// but we have not stopped all the transfers and tasks running. - /// - /// During this time we are deleting all the plan files and updating the log files properly. - /// - /// In this state no other transfers can be resumed until all the jobs have been - /// paused, finished or cancelled. - /// - Cancelling, - - /// - /// In progress of cleaning up all the plan and log files. In this state no transfers can - /// occur. - /// - /// In this state no other jobs can be kicked off. - /// - Cleaning - }; -} diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/StorageResourceCreateMode.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/StorageResourceCreationPreference.cs similarity index 79% rename from sdk/storage/Azure.Storage.DataMovement/src/Shared/StorageResourceCreateMode.cs rename to sdk/storage/Azure.Storage.DataMovement/src/Shared/StorageResourceCreationPreference.cs index 277f51567f459..e77230b529dea 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/StorageResourceCreateMode.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/StorageResourceCreationPreference.cs @@ -10,18 +10,8 @@ namespace Azure.Storage.DataMovement /// Defines how creating a transfer file resource should go /// if the resource already exists or does not exist. /// - public enum StorageResourceCreateMode + public enum StorageResourceCreationPreference { - /// - /// Default. If specified to this value, it will default to . - /// - None = default, - - /// - /// Overwrites the file if it already exists. No error will be thrown. - /// - Overwrite = 1, - /// /// If the file/blob already exists in the destination path, a failure will be thrown. /// All parallel downloads in progress will finish, but no further @@ -30,15 +20,20 @@ public enum StorageResourceCreateMode /// If ErrorHandlingOptions.ContinueOnFailure is enabled, then this will get overrided /// and the transfer will complete regardless of failure. /// - Fail = 2, + FailIfExists = 0, + + /// + /// Overwrites the file if it already exists. No error will be thrown. + /// + OverwriteIfExists = 1, /// /// If the file/blob already exists in the destination path, no failure will be thrown. /// The file will simply be skipped over and other parallel downloads in progress /// will finish and the rest of the files in the directory to download will continue. /// - /// If ErrorHandlingOptions.StopOnAllFailures is set, the download will still be skipped. + /// If ErrorHandlingOptions.StopOnAnyFailures is set, the download will still be skipped. /// - Skip = 3, + SkipIfExists = 2, } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferCheckpointer.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferCheckpointer.cs index b6fdd1f284e4f..ebd52aa5c4cad 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferCheckpointer.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferCheckpointer.cs @@ -128,14 +128,14 @@ public abstract Task WriteToCheckpointAsync( /// Sets the Job Transfer Status in the Job Part Plan files. /// /// The transfer ID. - /// The of the job. + /// The of the job. /// /// Optional to propagate /// notifications that the operation should be canceled. /// public abstract Task SetJobTransferStatusAsync( string transferId, - StorageTransferStatus status, + DataTransferStatus status, CancellationToken cancellationToken = default); /// @@ -143,7 +143,7 @@ public abstract Task SetJobTransferStatusAsync( /// /// The transfer ID. /// The job part number. - /// The of the job part. + /// The of the job part. /// /// Optional to propagate /// notifications that the operation should be canceled. @@ -151,7 +151,7 @@ public abstract Task SetJobTransferStatusAsync( public abstract Task SetJobPartTransferStatusAsync( string transferId, int partNumber, - StorageTransferStatus status, + DataTransferStatus status, CancellationToken cancellationToken = default); /// diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferManager.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferManager.cs index c5e67b1fcdf6c..3bff5e88f7f5c 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferManager.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferManager.cs @@ -67,15 +67,15 @@ public class TransferManager : IAsyncDisposable /// If unspecified will default to LocalTransferCheckpointer at {currentpath}/.azstoragedml /// internal TransferCheckpointer _checkpointer; - private TransferCheckpointerOptions _checkpointerOptions; + private TransferCheckpointStoreOptions _checkpointerOptions; /// /// Defines the error handling method to follow when an error is seen. Defaults to - /// . + /// . /// - /// See . + /// See . /// - internal ErrorHandlingBehavior _errorHandling; + internal DataTransferErrorMode _errorHandling; /// /// Cancels the channels operations when disposing. @@ -125,11 +125,11 @@ public TransferManager(TransferManagerOptions options = default) _currentTaskIsProcessingJobPart = Task.Run(() => NotifyOfPendingJobPartProcessing()); _currentTaskIsProcessingJobChunk = Task.Run(() => NotifyOfPendingJobChunkProcessing()); _maxJobChunkTasks = options?.MaximumConcurrency ?? DataMovementConstants.MaxJobChunkTasks; - _checkpointerOptions = options?.CheckpointerOptions != default ? new TransferCheckpointerOptions(options.CheckpointerOptions) : default; + _checkpointerOptions = options?.CheckpointerOptions != default ? new TransferCheckpointStoreOptions(options.CheckpointerOptions) : default; _checkpointer = _checkpointerOptions != default ? _checkpointerOptions.GetCheckpointer() : CreateDefaultCheckpointer(); _dataTransfers = new Dictionary(); _arrayPool = ArrayPool.Shared; - _errorHandling = options?.ErrorHandling != default ? options.ErrorHandling : ErrorHandlingBehavior.StopOnAllFailures; + _errorHandling = options?.ErrorHandling != default ? options.ErrorHandling : DataTransferErrorMode.StopOnAnyFailure; ClientDiagnostics = new ClientDiagnostics(options?.ClientOptions ?? ClientOptions.Default); } @@ -247,7 +247,7 @@ public virtual async Task PauseTransferIfRunningAsync(string transferId, Cancell { throw Errors.InvalidTransferId(nameof(PauseTransferIfRunningAsync), transferId); } - await transfer.PauseIfRunningAsync(cancellationToken: cancellationToken).ConfigureAwait(false); + await transfer.PauseAsync(cancellationToken: cancellationToken).ConfigureAwait(false); } /// @@ -257,12 +257,12 @@ public virtual async Task PauseTransferIfRunningAsync(string transferId, Cancell /// If specified, the returned list of transfers will have only have the transfers /// of which match the status specified. /// - /// If not specified or specified to , + /// If not specified or specified to , /// all transfers will be returned regardless of status. /// /// public virtual async IAsyncEnumerable GetTransfersAsync( - params StorageTransferStatus[] filterByStatus) + params DataTransferStatus[] filterByStatus) { await SetDataTransfers().ConfigureAwait(false); IEnumerable totalTransfers; @@ -294,13 +294,13 @@ public virtual async IAsyncEnumerable GetResumableTransf List storedTransfers = await _checkpointer.GetStoredTransfersAsync().ConfigureAwait(false); foreach (string transferId in storedTransfers) { - StorageTransferStatus jobStatus = (StorageTransferStatus) await _checkpointer.GetByteValue( + DataTransferStatus jobStatus = (DataTransferStatus) await _checkpointer.GetByteValue( transferId, DataMovementConstants.PlanFile.AtomicJobStatusIndex, _cancellationToken).ConfigureAwait(false); // Transfers marked as fully completed are not resumable - if (jobStatus == StorageTransferStatus.Completed) + if (jobStatus == DataTransferStatus.Completed) { continue; } @@ -345,7 +345,7 @@ public virtual async Task ResumeTransferAsync( string transferId, StorageResource sourceResource, StorageResource destinationResource, - TransferOptions transferOptions = default, + DataTransferOptions transferOptions = default, CancellationToken cancellationToken = default) { CancellationHelper.ThrowIfCancellationRequested(cancellationToken); @@ -353,7 +353,7 @@ public virtual async Task ResumeTransferAsync( Argument.AssertNotNull(sourceResource, nameof(sourceResource)); Argument.AssertNotNull(destinationResource, nameof(destinationResource)); - transferOptions ??= new TransferOptions(); + transferOptions ??= new DataTransferOptions(); if (_dataTransfers.ContainsKey(transferId)) { @@ -382,7 +382,7 @@ internal virtual async Task PauseAllRunningTransfersAsync(CancellationToken canc { await Task.WhenAll(_dataTransfers.Values .Where(transfer => transfer.CanPause()) - .Select(transfer => transfer.PauseIfRunningAsync(cancellationToken))) + .Select(transfer => transfer.PauseAsync(cancellationToken))) .ConfigureAwait(false); } @@ -413,14 +413,14 @@ internal virtual Task TryRemoveTransferAsync(string id) public virtual async Task StartTransferAsync( StorageResource sourceResource, StorageResource destinationResource, - TransferOptions transferOptions = default, + DataTransferOptions transferOptions = default, CancellationToken cancellationToken = default) { CancellationHelper.ThrowIfCancellationRequested(cancellationToken); Argument.AssertNotNull(sourceResource, nameof(sourceResource)); Argument.AssertNotNull(destinationResource, nameof(destinationResource)); - transferOptions ??= new TransferOptions(); + transferOptions ??= new DataTransferOptions(); string transferId = Guid.NewGuid().ToString(); await _checkpointer.AddNewJobAsync(transferId, _cancellationToken).ConfigureAwait(false); @@ -439,7 +439,7 @@ public virtual async Task StartTransferAsync( private async Task BuildAndAddTransferJobAsync( StorageResource sourceResource, StorageResource destinationResource, - TransferOptions transferOptions, + DataTransferOptions transferOptions, string transferId, bool resumeJob, CancellationToken cancellationToken) @@ -450,12 +450,12 @@ private async Task BuildAndAddTransferJobAsync( TransferJobInternal transferJobInternal; // Single transfer - if (sourceResource is StorageResourceSingle && - destinationResource is StorageResourceSingle) + if (sourceResource is StorageResourceItem && + destinationResource is StorageResourceItem) { transferJobInternal = await BuildSingleTransferJob( - (StorageResourceSingle)sourceResource, - (StorageResourceSingle)destinationResource, + (StorageResourceItem)sourceResource, + (StorageResourceItem)destinationResource, transferOptions, dataTransfer, resumeJob).ConfigureAwait(false); @@ -483,9 +483,9 @@ private async Task BuildAndAddTransferJobAsync( } private async Task BuildSingleTransferJob( - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, - TransferOptions transferOptions, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, + DataTransferOptions transferOptions, DataTransfer dataTransfer, bool resumeJob) { @@ -604,7 +604,7 @@ await uriToStreamJob.ToJobPartAsync( private async Task BuildContainerTransferJob( StorageResourceContainer sourceResource, StorageResourceContainer destinationResource, - TransferOptions transferOptions, + DataTransferOptions transferOptions, DataTransfer dataTransfer, bool resumeJob) { diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferStatusEventArgs.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferStatusEventArgs.cs index 7e5d867e98d81..dd534f19803fd 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferStatusEventArgs.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/TransferStatusEventArgs.cs @@ -7,12 +7,12 @@ namespace Azure.Storage.DataMovement /// /// Event Argument for a change in the Transfer Status /// - public class TransferStatusEventArgs : StorageTransferEventArgs + public class TransferStatusEventArgs : DataTransferEventArgs { /// - /// Gets the of the job. + /// Gets the of the job. /// - public StorageTransferStatus StorageTransferStatus { get; } + public DataTransferStatus StorageTransferStatus { get; } /// /// Initializes a new instance of the . @@ -23,7 +23,7 @@ public class TransferStatusEventArgs : StorageTransferEventArgs /// public TransferStatusEventArgs( string transferId, - StorageTransferStatus transferStatus, + DataTransferStatus transferStatus, bool isRunningSynchronously, CancellationToken cancellationToken) : base (transferId, isRunningSynchronously, cancellationToken) diff --git a/sdk/storage/Azure.Storage.DataMovement/src/StageChunkEventArgs.cs b/sdk/storage/Azure.Storage.DataMovement/src/StageChunkEventArgs.cs index ab36fa175261e..ed996c6e8642c 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/StageChunkEventArgs.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/StageChunkEventArgs.cs @@ -17,7 +17,7 @@ namespace Azure.Storage.DataMovement /// will end up using this internal event argument to track the success /// and the bytes transferred to ensure the correct amount of bytes are tranferred. /// - internal class StageChunkEventArgs : StorageTransferEventArgs + internal class StageChunkEventArgs : DataTransferEventArgs { public bool Success { get; } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceContainer.cs b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceContainer.cs index 41531b934b99d..1503623a4d605 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceContainer.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceContainer.cs @@ -26,7 +26,7 @@ protected internal abstract IAsyncEnumerable GetStorageResource /// Returns storage resources from the parent resource container /// /// - protected internal abstract StorageResourceSingle GetChildStorageResource(string path); + protected internal abstract StorageResourceItem GetStorageResourceReference(string path); /// /// Storage Resource is a container. diff --git a/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceCopyFromUriOptions.cs b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceCopyFromUriOptions.cs index 314d8833dc59a..e2ddb71c28926 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceCopyFromUriOptions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceCopyFromUriOptions.cs @@ -7,7 +7,7 @@ namespace Azure.Storage.DataMovement { /// - /// Options for + /// Options for /// public class StorageResourceCopyFromUriOptions { diff --git a/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceSingle.cs b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceItem.cs similarity index 94% rename from sdk/storage/Azure.Storage.DataMovement/src/StorageResourceSingle.cs rename to sdk/storage/Azure.Storage.DataMovement/src/StorageResourceItem.cs index 141ec2f4c24f4..1bbc9f69feec7 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceSingle.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceItem.cs @@ -10,12 +10,12 @@ namespace Azure.Storage.DataMovement /// /// Abstract class for a single storage resource. /// - public abstract class StorageResourceSingle : StorageResource + public abstract class StorageResourceItem : StorageResource { /// /// For Mocking. /// - protected StorageResourceSingle() { } + protected StorageResourceItem() { } /// /// The identifier for the type of storage resource. @@ -25,7 +25,7 @@ protected StorageResourceSingle() { } /// /// Defines the transfer type of the storage resource. /// - protected internal abstract TransferType TransferType { get; } + protected internal abstract DataTransferOrder TransferType { get; } /// /// Defines the maximum chunk size for the storage resource. @@ -58,7 +58,7 @@ protected StorageResourceSingle() { } /// notifications that the operation should be cancelled. /// /// - protected internal abstract Task ReadStreamAsync( + protected internal abstract Task ReadStreamAsync( long position = 0, long? length = default, CancellationToken cancellationToken = default); @@ -85,7 +85,7 @@ protected internal abstract Task ReadStreamAsyn /// notifications that the operation should be cancelled. /// /// - protected internal abstract Task WriteFromStreamAsync( + protected internal abstract Task CopyFromStreamAsync( Stream stream, long streamLength, bool overwrite, @@ -111,7 +111,7 @@ protected internal abstract Task WriteFromStreamAsync( /// /// protected internal abstract Task CopyFromUriAsync( - StorageResourceSingle sourceResource, + StorageResourceItem sourceResource, bool overwrite, long completeLength, StorageResourceCopyFromUriOptions options = default, @@ -135,7 +135,7 @@ protected internal abstract Task CopyFromUriAsync( /// /// protected internal abstract Task CopyBlockFromUriAsync( - StorageResourceSingle sourceResource, + StorageResourceItem sourceResource, HttpRange range, bool overwrite, long completeLength = 0, diff --git a/sdk/storage/Azure.Storage.DataMovement/src/ReadStreamStorageResourceResult.cs b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceReadStreamResult.cs similarity index 87% rename from sdk/storage/Azure.Storage.DataMovement/src/ReadStreamStorageResourceResult.cs rename to sdk/storage/Azure.Storage.DataMovement/src/StorageResourceReadStreamResult.cs index ef3b882efdec1..378c281888fa3 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/ReadStreamStorageResourceResult.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceReadStreamResult.cs @@ -8,12 +8,12 @@ namespace Azure.Storage.DataMovement /// /// The properties and content returned from downloading a storage resource /// - public class ReadStreamStorageResourceResult + public class StorageResourceReadStreamResult { /// /// Content /// - internal Stream Content { get; } + public readonly Stream Content; /// /// Indicates the range of bytes returned if the client requested a subset of the storage resource by setting the Range request header. @@ -24,18 +24,18 @@ public class ReadStreamStorageResourceResult /// /// The [end] value will be the inclusive last byte (e.g. header "bytes 0-7/8" is the entire 8-byte storage resource). /// - internal string ContentRange { get; } + public readonly string ContentRange; /// /// Indicates that the service supports requests for partial storage resource content. /// - internal string AcceptRanges { get; } + public readonly string AcceptRanges; /// /// If the storage resource has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned with the value of the whole storage resource's MD5 value. This value may or may not be equal to the value returned in Content-MD5 header, with the latter calculated from the requested range. /// #pragma warning disable CA1819 // Properties should not return arrays - internal byte[] RangeContentHash { get; } + public readonly byte[] RangeContentHash; #pragma warning restore CA1819 // Properties should not return arrays /// @@ -43,7 +43,7 @@ public class ReadStreamStorageResourceResult /// internal StorageResourceProperties Properties { get; set; } - internal ReadStreamStorageResourceResult() { } + internal StorageResourceReadStreamResult() { } /// /// Constructor for ReadStreamStorageResourceInfo @@ -53,7 +53,7 @@ internal ReadStreamStorageResourceResult() { } /// /// /// - public ReadStreamStorageResourceResult( + public StorageResourceReadStreamResult( Stream content, string contentRange, string acceptRanges, @@ -71,7 +71,7 @@ public ReadStreamStorageResourceResult( /// Constructor for ReadStreamStorageResourceInfo /// /// - public ReadStreamStorageResourceResult( + internal StorageResourceReadStreamResult( Stream content) { Content = content; diff --git a/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceWriteToOffsetOptions.cs b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceWriteToOffsetOptions.cs index 0ce5e3dcefe8f..12717964c7814 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceWriteToOffsetOptions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceWriteToOffsetOptions.cs @@ -7,7 +7,7 @@ namespace Azure.Storage.DataMovement { /// - /// Options for + /// Options for /// public class StorageResourceWriteToOffsetOptions { diff --git a/sdk/storage/Azure.Storage.DataMovement/src/StreamToUriJobPart.cs b/sdk/storage/Azure.Storage.DataMovement/src/StreamToUriJobPart.cs index f96246f1627fc..9055e4f601b27 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/StreamToUriJobPart.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/StreamToUriJobPart.cs @@ -33,8 +33,8 @@ private StreamToUriJobPart( destinationResource: job._destinationResource, maximumTransferChunkSize: job._maximumTransferChunkSize, initialTransferSize: job._initialTransferSize, - errorHandling: job._errorHandling, - createMode: job._createMode, + errorHandling: job._errorMode, + createMode: job._creationPreference, checkpointer: job._checkpointer, progressTracker: job._progressTracker, arrayPool: job.UploadArrayPool, @@ -43,7 +43,7 @@ private StreamToUriJobPart( statusEventHandler: job.TransferStatusEventHandler, failedEventHandler: job.TransferFailedEventHandler, skippedEventHandler: job.TransferSkippedEventHandler, - singleTransferEventHandler: job.SingleTransferCompletedEventHandler, + singleTransferEventHandler: job.TransferItemCompletedEventHandler, clientDiagnostics: job.ClientDiagnostics, cancellationToken: job._cancellationToken) { @@ -55,10 +55,10 @@ private StreamToUriJobPart( private StreamToUriJobPart( StreamToUriTransferJob job, int partNumber, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, bool isFinalPart, - StorageTransferStatus jobPartStatus = StorageTransferStatus.Queued, + DataTransferStatus jobPartStatus = DataTransferStatus.Queued, long? length = default) : base(dataTransfer: job._dataTransfer, partNumber: partNumber, @@ -66,8 +66,8 @@ private StreamToUriJobPart( destinationResource: destinationResource, maximumTransferChunkSize: job._maximumTransferChunkSize, initialTransferSize: job._initialTransferSize, - errorHandling: job._errorHandling, - createMode: job._createMode, + errorHandling: job._errorMode, + createMode: job._creationPreference, checkpointer: job._checkpointer, progressTracker: job._progressTracker, arrayPool: job.UploadArrayPool, @@ -76,7 +76,7 @@ private StreamToUriJobPart( statusEventHandler: job.TransferStatusEventHandler, failedEventHandler: job.TransferFailedEventHandler, skippedEventHandler: job.TransferSkippedEventHandler, - singleTransferEventHandler: job.SingleTransferCompletedEventHandler, + singleTransferEventHandler: job.TransferItemCompletedEventHandler, clientDiagnostics: job.ClientDiagnostics, cancellationToken: job._cancellationToken, jobPartStatus: jobPartStatus, @@ -108,10 +108,10 @@ await part.AddJobPartToCheckpointerAsync( public static async Task CreateJobPartAsync( StreamToUriTransferJob job, int partNumber, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, bool isFinalPart, - StorageTransferStatus jobPartStatus = default, + DataTransferStatus jobPartStatus = default, long? length = default, bool partPlanFileExists = false) { @@ -142,7 +142,7 @@ public override async Task ProcessPartToChunkAsync() // Attempt to get the length, it's possible the file could // not be accesible (or does not exist). string operationName = $"{nameof(TransferManager.StartTransferAsync)}"; - await OnTransferStatusChanged(StorageTransferStatus.InProgress).ConfigureAwait(false); + await OnTransferStatusChanged(DataTransferStatus.InProgress).ConfigureAwait(false); long? fileLength = default; try { @@ -176,7 +176,7 @@ await CreateDestinationResource( { // If we cannot upload in one shot, initiate the parallel block uploader List<(long Offset, long Length)> rangeList = GetRangeList(blockSize, length); - if (_destinationResource.TransferType == TransferType.Concurrent) + if (_destinationResource.TransferType == DataTransferOrder.Unordered) { await QueueStageBlockRequests(rangeList, length).ConfigureAwait(false); } @@ -216,7 +216,7 @@ private async Task CreateDestinationResource(long blockSize, long length, return !singleCall; } catch (RequestFailedException exception) - when (_createMode == StorageResourceCreateMode.Skip + when (_createMode == StorageResourceCreationPreference.SkipIfExists && exception.ErrorCode == "BlobAlreadyExists") { await InvokeSkippedArg().ConfigureAwait(false); @@ -235,13 +235,13 @@ private async Task InitialUploadCall(long blockSize, long expectedLength, bool s { if (singleCall) { - ReadStreamStorageResourceResult result = await _sourceResource.ReadStreamAsync( + StorageResourceReadStreamResult result = await _sourceResource.ReadStreamAsync( cancellationToken: _cancellationToken).ConfigureAwait(false); using Stream stream = result.Content; - await _destinationResource.WriteFromStreamAsync( + await _destinationResource.CopyFromStreamAsync( stream: stream, - overwrite: _createMode == StorageResourceCreateMode.Overwrite, + overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, position: 0, streamLength: blockSize, completeLength: expectedLength, @@ -252,12 +252,12 @@ await _destinationResource.WriteFromStreamAsync( ReportBytesWritten(blockSize); // Set completion status to completed - await OnTransferStatusChanged(StorageTransferStatus.Completed).ConfigureAwait(false); + await OnTransferStatusChanged(DataTransferStatus.Completed).ConfigureAwait(false); } else { Stream slicedStream = Stream.Null; - ReadStreamStorageResourceResult result = await _sourceResource.ReadStreamAsync( + StorageResourceReadStreamResult result = await _sourceResource.ReadStreamAsync( position: 0, length: blockSize, cancellationToken: _cancellationToken).ConfigureAwait(false); @@ -269,10 +269,10 @@ await _destinationResource.WriteFromStreamAsync( blockSize, UploadArrayPool, _cancellationToken).ConfigureAwait(false); - await _destinationResource.WriteFromStreamAsync( + await _destinationResource.CopyFromStreamAsync( stream: slicedStream, streamLength: blockSize, - overwrite: _createMode == StorageResourceCreateMode.Overwrite, + overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, position: 0, completeLength: expectedLength, default, @@ -283,7 +283,7 @@ await _destinationResource.WriteFromStreamAsync( } } catch (RequestFailedException ex) - when (ex.ErrorCode == "BlobAlreadyExists" && _createMode == StorageResourceCreateMode.Skip) + when (ex.ErrorCode == "BlobAlreadyExists" && _createMode == StorageResourceCreationPreference.SkipIfExists) { await InvokeSkippedArg().ConfigureAwait(false); } @@ -298,7 +298,7 @@ internal CommitChunkHandler GetCommitController( long expectedLength, long blockSize, StreamToUriJobPart jobPart, - TransferType transferType) + DataTransferOrder transferType) => new CommitChunkHandler( expectedLength, blockSize, @@ -329,7 +329,7 @@ internal async Task StageBlockInternal( try { Stream slicedStream = Stream.Null; - ReadStreamStorageResourceResult result = await _sourceResource.ReadStreamAsync( + StorageResourceReadStreamResult result = await _sourceResource.ReadStreamAsync( position: offset, length: blockLength, cancellationToken: _cancellationToken).ConfigureAwait(false); @@ -341,10 +341,10 @@ internal async Task StageBlockInternal( blockLength, UploadArrayPool, _cancellationToken).ConfigureAwait(false); - await _destinationResource.WriteFromStreamAsync( + await _destinationResource.CopyFromStreamAsync( stream: slicedStream, streamLength: blockLength, - overwrite: _createMode == StorageResourceCreateMode.Overwrite, + overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, position: offset, completeLength: completeLength, default, @@ -390,14 +390,14 @@ internal async Task CompleteTransferAsync() // Apply necessary transfer completions on the destination. await _destinationResource.CompleteTransferAsync( - overwrite: _createMode == StorageResourceCreateMode.Overwrite, + overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, cancellationToken: _cancellationToken).ConfigureAwait(false); // Dispose the handlers await DisposeHandlers().ConfigureAwait(false); // Set completion status to completed - await OnTransferStatusChanged(StorageTransferStatus.Completed).ConfigureAwait(false); + await OnTransferStatusChanged(DataTransferStatus.Completed).ConfigureAwait(false); } private async Task QueueStageBlockRequests(List<(long Offset, long Size)> rangeList, long completeLength) diff --git a/sdk/storage/Azure.Storage.DataMovement/src/StreamToUriTransferJob.cs b/sdk/storage/Azure.Storage.DataMovement/src/StreamToUriTransferJob.cs index b4add4c663076..429e7478bfef5 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/StreamToUriTransferJob.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/StreamToUriTransferJob.cs @@ -16,12 +16,12 @@ internal class StreamToUriTransferJob : TransferJobInternal /// internal StreamToUriTransferJob( DataTransfer dataTransfer, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, - TransferOptions transferOptions, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, + DataTransferOptions transferOptions, QueueChunkTaskInternal queueChunkTask, TransferCheckpointer checkpointer, - ErrorHandlingBehavior errorHandling, + DataTransferErrorMode errorHandling, ArrayPool arrayPool, ClientDiagnostics clientDiagnostics) : base(dataTransfer, @@ -43,10 +43,10 @@ internal StreamToUriTransferJob( DataTransfer dataTransfer, StorageResourceContainer sourceResource, StorageResourceContainer destinationResource, - TransferOptions transferOptions, + DataTransferOptions transferOptions, QueueChunkTaskInternal queueChunkTask, TransferCheckpointer checkpointer, - ErrorHandlingBehavior errorHandling, + DataTransferErrorMode errorHandling, ArrayPool arrayPool, ClientDiagnostics clientDiagnostics) : base(dataTransfer, @@ -67,7 +67,7 @@ internal StreamToUriTransferJob( /// An IEnumerable that contains the job parts public override async IAsyncEnumerable ProcessJobToJobPartAsync() { - await OnJobStatusChangedAsync(StorageTransferStatus.InProgress).ConfigureAwait(false); + await OnJobStatusChangedAsync(DataTransferStatus.InProgress).ConfigureAwait(false); int partNumber = 0; if (_jobParts.Count == 0) @@ -106,9 +106,9 @@ public override async IAsyncEnumerable ProcessJobToJobPartAsync bool isFinalPartFound = false; foreach (JobPartInternal part in _jobParts) { - if (part.JobPartStatus != StorageTransferStatus.Completed) + if (part.JobPartStatus != DataTransferStatus.Completed) { - part.JobPartStatus = StorageTransferStatus.Queued; + part.JobPartStatus = DataTransferStatus.Queued; yield return part; if (part.IsFinalPart) @@ -190,8 +190,8 @@ private async IAsyncEnumerable GetStorageResourcesAsync() part = await StreamToUriJobPart.CreateJobPartAsync( job: this, partNumber: partNumber, - sourceResource: (StorageResourceSingle)lastResource, - destinationResource: _destinationResourceContainer.GetChildStorageResource(sourceName), + sourceResource: (StorageResourceItem)lastResource, + destinationResource: _destinationResourceContainer.GetStorageResourceReference(sourceName), isFinalPart: false).ConfigureAwait(false); AppendJobPart(part); } @@ -222,8 +222,8 @@ private async IAsyncEnumerable GetStorageResourcesAsync() lastPart = await StreamToUriJobPart.CreateJobPartAsync( job: this, partNumber: partNumber, - sourceResource: (StorageResourceSingle)lastResource, - destinationResource: _destinationResourceContainer.GetChildStorageResource(lastSourceName), + sourceResource: (StorageResourceItem)lastResource, + destinationResource: _destinationResourceContainer.GetStorageResourceReference(lastSourceName), isFinalPart: true).ConfigureAwait(false); AppendJobPart(lastPart); } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferCheckpointerOptions.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferCheckpointStoreOptions.cs similarity index 77% rename from sdk/storage/Azure.Storage.DataMovement/src/TransferCheckpointerOptions.cs rename to sdk/storage/Azure.Storage.DataMovement/src/TransferCheckpointStoreOptions.cs index 731c4426b9d8d..84465289784f2 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferCheckpointerOptions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferCheckpointStoreOptions.cs @@ -7,7 +7,7 @@ namespace Azure.Storage.DataMovement /// Options for Checkpointer used for saving transfer state to allow for /// resuming a transfer. /// - public class TransferCheckpointerOptions + public class TransferCheckpointStoreOptions { /// /// The local folder where the checkpoint information will be stored. @@ -21,14 +21,14 @@ public class TransferCheckpointerOptions /// /// The local folder where the checkpoint information will be stored. /// - public TransferCheckpointerOptions(string localCheckpointerPath) + public TransferCheckpointStoreOptions(string localCheckpointerPath) { CheckpointerPath = localCheckpointerPath; } - internal TransferCheckpointerOptions(TransferCheckpointerOptions other) + internal TransferCheckpointStoreOptions(TransferCheckpointStoreOptions options) { - CheckpointerPath = other.CheckpointerPath; + CheckpointerPath = options.CheckpointerPath; } } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferEventsInternal.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferEventsInternal.cs index d86c1e004c50a..0bbc50fbdc4cb 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferEventsInternal.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferEventsInternal.cs @@ -16,8 +16,8 @@ internal class TransferEventsInternal /// /// If the transfer has any failed events that occur the event will get added to this handler. /// - public event SyncAsyncEventHandler TransferFailedEventHandler; + public event SyncAsyncEventHandler TransferFailedEventHandler; - internal SyncAsyncEventHandler GetFailed() => TransferFailedEventHandler; + internal SyncAsyncEventHandler GetFailed() => TransferFailedEventHandler; } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/SingleTransferCompletedEventArgs.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferItemCompletedEventArgs.cs similarity index 78% rename from sdk/storage/Azure.Storage.DataMovement/src/SingleTransferCompletedEventArgs.cs rename to sdk/storage/Azure.Storage.DataMovement/src/TransferItemCompletedEventArgs.cs index 3c24d9fbda09b..e16f08ea9509a 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/SingleTransferCompletedEventArgs.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferItemCompletedEventArgs.cs @@ -8,20 +8,20 @@ namespace Azure.Storage.DataMovement /// /// Event Argument for a change in the Transfer Status /// - public class SingleTransferCompletedEventArgs : StorageTransferEventArgs + public class TransferItemCompletedEventArgs : DataTransferEventArgs { /// - /// Gets the that was the source resource for the transfer. + /// Gets the that was the source resource for the transfer. /// - public StorageResourceSingle SourceResource { get; } + public StorageResourceItem SourceResource { get; } /// - /// Gets the that was the destination resource for the transfer. + /// Gets the that was the destination resource for the transfer. /// - public StorageResourceSingle DestinationResource { get; } + public StorageResourceItem DestinationResource { get; } /// - /// Initializes a new instance of the . + /// Initializes a new instance of the . /// /// /// @@ -43,10 +43,10 @@ public class SingleTransferCompletedEventArgs : StorageTransferEventArgs /// Thrown if is empty or null. /// Thrown if is empty or null. /// - public SingleTransferCompletedEventArgs( + public TransferItemCompletedEventArgs( string transferId, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, bool isRunningSynchronously, CancellationToken cancellationToken) : base(transferId, isRunningSynchronously, cancellationToken) diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferFailedEventArgs.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferItemFailedEventArgs.cs similarity index 81% rename from sdk/storage/Azure.Storage.DataMovement/src/TransferFailedEventArgs.cs rename to sdk/storage/Azure.Storage.DataMovement/src/TransferItemFailedEventArgs.cs index 2a1869e0023fe..b7761982841bb 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferFailedEventArgs.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferItemFailedEventArgs.cs @@ -9,17 +9,17 @@ namespace Azure.Storage.DataMovement /// /// Event Argument for Failed Single Blob Upload Transfers /// - public class TransferFailedEventArgs : StorageTransferEventArgs + public class TransferItemFailedEventArgs : DataTransferEventArgs { /// - /// Gets the that was the source resource for the transfer. + /// Gets the that was the source resource for the transfer. /// - public StorageResourceSingle SourceResource { get; } + public StorageResourceItem SourceResource { get; } /// - /// Gets the that was the destination resource for the transfer. + /// Gets the that was the destination resource for the transfer. /// - public StorageResourceSingle DestinationResource { get; } + public StorageResourceItem DestinationResource { get; } /// /// Gets the that was thrown during the job. @@ -27,7 +27,7 @@ public class TransferFailedEventArgs : StorageTransferEventArgs public Exception Exception { get; } /// - /// Initializes a new instance of the . + /// Initializes a new instance of the . /// /// /// @@ -50,10 +50,10 @@ public class TransferFailedEventArgs : StorageTransferEventArgs /// Thrown if is empty or null. /// Thrown if is empty or null. /// - public TransferFailedEventArgs( + public TransferItemFailedEventArgs( string transferId, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, Exception exception, bool isRunningSynchronously, CancellationToken cancellationToken) diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferSkippedEventArgs.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferItemSkippedEventArgs.cs similarity index 78% rename from sdk/storage/Azure.Storage.DataMovement/src/TransferSkippedEventArgs.cs rename to sdk/storage/Azure.Storage.DataMovement/src/TransferItemSkippedEventArgs.cs index 11be24d98602e..75e90c62f6c50 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferSkippedEventArgs.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferItemSkippedEventArgs.cs @@ -9,20 +9,20 @@ namespace Azure.Storage.DataMovement /// /// Event Argument for a change in the Transfer Status /// - public class TransferSkippedEventArgs : StorageTransferEventArgs + public class TransferItemSkippedEventArgs : DataTransferEventArgs { /// - /// Gets the that was the source resource for the transfer. + /// Gets the that was the source resource for the transfer. /// - public StorageResourceSingle SourceResource { get; } + public StorageResourceItem SourceResource { get; } /// - /// Gets the that was the destination resource for the transfer. + /// Gets the that was the destination resource for the transfer. /// - public StorageResourceSingle DestinationResource { get; } + public StorageResourceItem DestinationResource { get; } /// - /// Initializes a new instance of the . + /// Initializes a new instance of the . /// /// /// @@ -44,10 +44,10 @@ public class TransferSkippedEventArgs : StorageTransferEventArgs /// Thrown if is empty or null. /// Thrown if is empty or null. /// - public TransferSkippedEventArgs( + public TransferItemSkippedEventArgs( string transferId, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, bool isRunningSynchronously, CancellationToken cancellationToken) : base(transferId, isRunningSynchronously, cancellationToken) diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs index e5a12cf415b38..935aeeaa66666 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs @@ -36,12 +36,12 @@ internal abstract class TransferJobInternal : IDisposable /// /// Source resource /// - internal StorageResourceSingle _sourceResource; + internal StorageResourceItem _sourceResource; /// /// Destination Resource /// - internal StorageResourceSingle _destinationResource; + internal StorageResourceItem _destinationResource; /// /// Source resource @@ -80,12 +80,12 @@ internal abstract class TransferJobInternal : IDisposable /// /// The error handling options /// - internal ErrorHandlingBehavior _errorHandling; + internal DataTransferErrorMode _errorMode; /// /// Determines how files are created or if they should be overwritten if they already exists /// - internal StorageResourceCreateMode _createMode; + internal StorageResourceCreationPreference _creationPreference; private object _statusLock = new object(); @@ -110,19 +110,19 @@ internal abstract class TransferJobInternal : IDisposable /// /// If the transfer has any failed events that occur the event will get added to this handler. /// - public SyncAsyncEventHandler TransferFailedEventHandler { get; internal set; } + public SyncAsyncEventHandler TransferFailedEventHandler { get; internal set; } /// /// Number of single transfers skipped during Transfer due to no overwrite allowed as specified in - /// + /// /// - public SyncAsyncEventHandler TransferSkippedEventHandler { get; internal set; } + public SyncAsyncEventHandler TransferSkippedEventHandler { get; internal set; } /// /// If a single transfer within the resource container gets transferred successfully the event /// will get added to this handler /// - public SyncAsyncEventHandler SingleTransferCompletedEventHandler { get; internal set; } + public SyncAsyncEventHandler TransferItemCompletedEventHandler { get; internal set; } internal ClientDiagnostics ClientDiagnostics { get; } @@ -152,22 +152,22 @@ private TransferJobInternal( DataTransfer dataTransfer, QueueChunkTaskInternal queueChunkTask, TransferCheckpointer checkPointer, - ErrorHandlingBehavior errorHandling, - StorageResourceCreateMode createMode, + DataTransferErrorMode errorHandling, + StorageResourceCreationPreference creationPreference, ArrayPool arrayPool, SyncAsyncEventHandler statusEventHandler, - SyncAsyncEventHandler failedEventHandler, - SyncAsyncEventHandler skippedEventHandler, - SyncAsyncEventHandler singleTransferEventHandler, + SyncAsyncEventHandler failedEventHandler, + SyncAsyncEventHandler skippedEventHandler, + SyncAsyncEventHandler singleTransferEventHandler, ClientDiagnostics clientDiagnostics) { Argument.AssertNotNull(clientDiagnostics, nameof(clientDiagnostics)); _dataTransfer = dataTransfer ?? throw Errors.ArgumentNull(nameof(dataTransfer)); - _dataTransfer._state.TrySetTransferStatus(StorageTransferStatus.Queued); - _errorHandling = errorHandling; - _createMode = createMode == StorageResourceCreateMode.None ? StorageResourceCreateMode.Fail : createMode; + _dataTransfer._state.TrySetTransferStatus(DataTransferStatus.Queued); + _errorMode = errorHandling; _checkpointer = checkPointer; + _creationPreference = creationPreference; QueueChunkTask = queueChunkTask; _hasFailures = false; _hasSkipped = false; @@ -181,7 +181,7 @@ private TransferJobInternal( TransferStatusEventHandler = statusEventHandler; TransferFailedEventHandler = failedEventHandler; TransferSkippedEventHandler = skippedEventHandler; - SingleTransferCompletedEventHandler = singleTransferEventHandler; + TransferItemCompletedEventHandler = singleTransferEventHandler; ClientDiagnostics = clientDiagnostics; } @@ -190,19 +190,19 @@ private TransferJobInternal( /// internal TransferJobInternal( DataTransfer dataTransfer, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, - TransferOptions transferOptions, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, + DataTransferOptions transferOptions, QueueChunkTaskInternal queueChunkTask, TransferCheckpointer checkpointer, - ErrorHandlingBehavior errorHandling, + DataTransferErrorMode errorHandling, ArrayPool arrayPool, ClientDiagnostics clientDiagnostics) : this(dataTransfer, queueChunkTask, checkpointer, errorHandling, - transferOptions.CreateMode, + transferOptions.CreationPreference, arrayPool, transferOptions.GetTransferStatus(), transferOptions.GetFailed(), @@ -225,17 +225,17 @@ internal TransferJobInternal( DataTransfer dataTransfer, StorageResourceContainer sourceResource, StorageResourceContainer destinationResource, - TransferOptions transferOptions, + DataTransferOptions transferOptions, QueueChunkTaskInternal queueChunkTask, TransferCheckpointer checkpointer, - ErrorHandlingBehavior errorHandling, + DataTransferErrorMode errorHandling, ArrayPool arrayPool, ClientDiagnostics clientDiagnostics) : this(dataTransfer, queueChunkTask, checkpointer, errorHandling, - transferOptions.CreateMode, + transferOptions.CreationPreference, arrayPool, transferOptions.GetTransferStatus(), transferOptions.GetFailed(), @@ -273,20 +273,20 @@ public void DisposeHandlers() /// /// Triggers the cancellation for the Job Part. /// - /// If the status is set to - /// and any chunks is still processing to be cancelled is will be set to - /// until the chunks finish then it will be set to . + /// If the status is set to + /// and any chunks is still processing to be cancelled is will be set to + /// until the chunks finish then it will be set to . /// - /// If the status is set to - /// and any chunks is still processing to be cancelled is will be set to - /// until the chunks finish then it will be set to . + /// If the status is set to + /// and any chunks is still processing to be cancelled is will be set to + /// until the chunks finish then it will be set to . /// /// The task to wait until the cancellation has been triggered. public async Task TriggerJobCancellationAsync() { if (!_dataTransfer._state.CancellationTokenSource.IsCancellationRequested) { - await OnJobStatusChangedAsync(StorageTransferStatus.CancellationInProgress).ConfigureAwait(false); + await OnJobStatusChangedAsync(DataTransferStatus.CancellationInProgress).ConfigureAwait(false); _dataTransfer._state.TriggerCancellation(); } } @@ -304,7 +304,7 @@ public async virtual Task InvokeFailedArgAsync(Exception ex) { // TODO: change to RaiseAsync await TransferFailedEventHandler.RaiseAsync( - new TransferFailedEventArgs( + new TransferItemFailedEventArgs( _dataTransfer.Id, _sourceResource, _destinationResource, @@ -332,43 +332,43 @@ await TransferFailedEventHandler.RaiseAsync( /// public async Task JobPartEvent(TransferStatusEventArgs args) { - StorageTransferStatus jobPartStatus = args.StorageTransferStatus; - StorageTransferStatus jobStatus = _dataTransfer._state.GetTransferStatus(); + DataTransferStatus jobPartStatus = args.StorageTransferStatus; + DataTransferStatus jobStatus = _dataTransfer._state.GetTransferStatus(); // Keep track of paused, failed, and skipped which we will use to determine final job status - if (jobPartStatus == StorageTransferStatus.Paused) + if (jobPartStatus == DataTransferStatus.Paused) { _jobPartPaused = true; } - else if (jobPartStatus == StorageTransferStatus.CompletedWithFailedTransfers) + else if (jobPartStatus == DataTransferStatus.CompletedWithFailedTransfers) { _jobPartFailed = true; } - else if (jobPartStatus == StorageTransferStatus.CompletedWithSkippedTransfers) + else if (jobPartStatus == DataTransferStatus.CompletedWithSkippedTransfers) { _jobPartSkipped = true; } // Cancel the entire job if one job part fails and StopOnFailure is set - if (_errorHandling == ErrorHandlingBehavior.StopOnAllFailures && - jobPartStatus == StorageTransferStatus.CompletedWithFailedTransfers && - jobStatus != StorageTransferStatus.CancellationInProgress && - jobStatus != StorageTransferStatus.CompletedWithFailedTransfers && - jobStatus != StorageTransferStatus.CompletedWithSkippedTransfers && - jobStatus != StorageTransferStatus.Completed) + if (_errorMode == DataTransferErrorMode.StopOnAnyFailure && + jobPartStatus == DataTransferStatus.CompletedWithFailedTransfers && + jobStatus != DataTransferStatus.CancellationInProgress && + jobStatus != DataTransferStatus.CompletedWithFailedTransfers && + jobStatus != DataTransferStatus.CompletedWithSkippedTransfers && + jobStatus != DataTransferStatus.Completed) { await TriggerJobCancellationAsync().ConfigureAwait(false); jobStatus = _dataTransfer._state.GetTransferStatus(); } - if ((jobPartStatus == StorageTransferStatus.Paused || - jobPartStatus == StorageTransferStatus.Completed || - jobPartStatus == StorageTransferStatus.CompletedWithSkippedTransfers || - jobPartStatus == StorageTransferStatus.CompletedWithFailedTransfers) - && (jobStatus == StorageTransferStatus.Queued || - jobStatus == StorageTransferStatus.InProgress || - jobStatus == StorageTransferStatus.PauseInProgress || - jobStatus == StorageTransferStatus.CancellationInProgress)) + if ((jobPartStatus == DataTransferStatus.Paused || + jobPartStatus == DataTransferStatus.Completed || + jobPartStatus == DataTransferStatus.CompletedWithSkippedTransfers || + jobPartStatus == DataTransferStatus.CompletedWithFailedTransfers) + && (jobStatus == DataTransferStatus.Queued || + jobStatus == DataTransferStatus.InProgress || + jobStatus == DataTransferStatus.PauseInProgress || + jobStatus == DataTransferStatus.CancellationInProgress)) { Interlocked.Decrement(ref _pendingJobParts); @@ -379,7 +379,7 @@ public async Task JobPartEvent(TransferStatusEventArgs args) } } - public async Task OnJobStatusChangedAsync(StorageTransferStatus status) + public async Task OnJobStatusChangedAsync(DataTransferStatus status) { bool statusChanged = false; lock (_statusLock) @@ -389,10 +389,10 @@ public async Task OnJobStatusChangedAsync(StorageTransferStatus status) if (statusChanged) { // If we are in a final state, dispose the JobPartEvent handlers - if (status == StorageTransferStatus.Completed || - status == StorageTransferStatus.CompletedWithSkippedTransfers || - status == StorageTransferStatus.CompletedWithFailedTransfers || - status == StorageTransferStatus.Paused) + if (status == DataTransferStatus.Completed || + status == DataTransferStatus.CompletedWithSkippedTransfers || + status == DataTransferStatus.CompletedWithFailedTransfers || + status == DataTransferStatus.Paused) { DisposeHandlers(); } @@ -413,7 +413,7 @@ await TransferStatusEventHandler.RaiseAsync( } } - public async Task OnJobPartStatusChangedAsync(StorageTransferStatus status) + public async Task OnJobPartStatusChangedAsync(DataTransferStatus status) { //TODO: change to RaiseAsync after implementing ClientDiagnostics for TransferManager await JobPartStatusEvents.RaiseAsync( @@ -428,7 +428,7 @@ await JobPartStatusEvents.RaiseAsync( .ConfigureAwait(false); } - internal async virtual Task SetCheckpointerStatus(StorageTransferStatus status) + internal async virtual Task SetCheckpointerStatus(DataTransferStatus status) { await _checkpointer.SetJobTransferStatusAsync( transferId: _dataTransfer.Id, @@ -439,24 +439,24 @@ internal async Task OnEnumerationComplete() { // If there were no job parts enumerated and we haven't already aborted/completed the job. if (_jobParts.Count == 0 && - _dataTransfer.TransferStatus != StorageTransferStatus.Paused && - _dataTransfer.TransferStatus != StorageTransferStatus.CompletedWithSkippedTransfers && - _dataTransfer.TransferStatus != StorageTransferStatus.CompletedWithFailedTransfers && - _dataTransfer.TransferStatus != StorageTransferStatus.Completed) + _dataTransfer.TransferStatus != DataTransferStatus.Paused && + _dataTransfer.TransferStatus != DataTransferStatus.CompletedWithSkippedTransfers && + _dataTransfer.TransferStatus != DataTransferStatus.CompletedWithFailedTransfers && + _dataTransfer.TransferStatus != DataTransferStatus.Completed) { - if (_dataTransfer.TransferStatus == StorageTransferStatus.PauseInProgress) + if (_dataTransfer.TransferStatus == DataTransferStatus.PauseInProgress) { // If we paused before we were able to list, set the status properly. - await OnJobStatusChangedAsync(StorageTransferStatus.Paused).ConfigureAwait(false); + await OnJobStatusChangedAsync(DataTransferStatus.Paused).ConfigureAwait(false); } - else if (_dataTransfer.TransferStatus == StorageTransferStatus.CancellationInProgress) + else if (_dataTransfer.TransferStatus == DataTransferStatus.CancellationInProgress) { // If we aborted before we were able to list, set the status properly. - await OnJobStatusChangedAsync(StorageTransferStatus.CompletedWithFailedTransfers).ConfigureAwait(false); + await OnJobStatusChangedAsync(DataTransferStatus.CompletedWithFailedTransfers).ConfigureAwait(false); } else { - await OnJobStatusChangedAsync(StorageTransferStatus.Completed).ConfigureAwait(false); + await OnJobStatusChangedAsync(DataTransferStatus.Completed).ConfigureAwait(false); } } await CheckAndUpdateStatusAsync().ConfigureAwait(false); @@ -468,13 +468,13 @@ internal async Task CheckAndUpdateStatusAsync() // This is in the case that we weren't able to begin listing any job parts yet. if (_jobParts.Count == 0) { - if (_dataTransfer.TransferStatus == StorageTransferStatus.PauseInProgress) + if (_dataTransfer.TransferStatus == DataTransferStatus.PauseInProgress) { - await OnJobStatusChangedAsync(StorageTransferStatus.Paused).ConfigureAwait(false); + await OnJobStatusChangedAsync(DataTransferStatus.Paused).ConfigureAwait(false); } - else if (_dataTransfer.TransferStatus == StorageTransferStatus.CancellationInProgress) + else if (_dataTransfer.TransferStatus == DataTransferStatus.CancellationInProgress) { - await OnJobStatusChangedAsync(StorageTransferStatus.CompletedWithFailedTransfers).ConfigureAwait(false); + await OnJobStatusChangedAsync(DataTransferStatus.CompletedWithFailedTransfers).ConfigureAwait(false); } return; } @@ -484,19 +484,19 @@ internal async Task CheckAndUpdateStatusAsync() { if (_jobPartPaused) { - await OnJobStatusChangedAsync(StorageTransferStatus.Paused).ConfigureAwait(false); + await OnJobStatusChangedAsync(DataTransferStatus.Paused).ConfigureAwait(false); } else if (_jobPartFailed) { - await OnJobStatusChangedAsync(StorageTransferStatus.CompletedWithFailedTransfers).ConfigureAwait(false); + await OnJobStatusChangedAsync(DataTransferStatus.CompletedWithFailedTransfers).ConfigureAwait(false); } else if (_jobPartSkipped) { - await OnJobStatusChangedAsync(StorageTransferStatus.CompletedWithSkippedTransfers).ConfigureAwait(false); + await OnJobStatusChangedAsync(DataTransferStatus.CompletedWithSkippedTransfers).ConfigureAwait(false); } else { - await OnJobStatusChangedAsync(StorageTransferStatus.Completed).ConfigureAwait(false); + await OnJobStatusChangedAsync(DataTransferStatus.Completed).ConfigureAwait(false); } } } @@ -506,10 +506,10 @@ public void AppendJobPart(JobPartInternal jobPart) _jobParts.Add(jobPart); // Job parts can come from resuming a transfer and therefore may already be complete - StorageTransferStatus status = jobPart.JobPartStatus; - if (status != StorageTransferStatus.CompletedWithSkippedTransfers && - status != StorageTransferStatus.CompletedWithFailedTransfers && - status != StorageTransferStatus.Completed) + DataTransferStatus status = jobPart.JobPartStatus; + if (status != DataTransferStatus.CompletedWithSkippedTransfers && + status != DataTransferStatus.CompletedWithFailedTransfers && + status != DataTransferStatus.Completed) { Interlocked.Increment(ref _pendingJobParts); } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferManagerOptions.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferManagerOptions.cs index 94838568e4e65..6a63e58a6fc1b 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferManagerOptions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferManagerOptions.cs @@ -20,9 +20,9 @@ internal class TransferManagerClientOptions : ClientOptions /// /// Optional. Sets the way errors during a transfer will be handled. - /// Default is . + /// Default is . /// - public ErrorHandlingBehavior ErrorHandling { get; set; } + public DataTransferErrorMode ErrorHandling { get; set; } /// /// The maximum number of workers that may be used in a parallel transfer. @@ -33,7 +33,7 @@ internal class TransferManagerClientOptions : ClientOptions /// Optional. Defines the options for creating a checkpointer which is used for saving /// transfer state so transfers can be resumed. /// - public TransferCheckpointerOptions CheckpointerOptions { get; set; } + public TransferCheckpointStoreOptions CheckpointerOptions { get; set; } internal TransferManagerClientOptions ClientOptions { get; } = new(); diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferProgressTracker.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferProgressTracker.cs index a43e88e7f0480..cd41937b2aee6 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferProgressTracker.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferProgressTracker.cs @@ -12,7 +12,7 @@ namespace Azure.Storage.DataMovement /// internal class TransferProgressTracker { - private readonly IProgress _progressHandler; + private readonly IProgress _progressHandler; private readonly ProgressHandlerOptions _options; private long _completedCount = 0; @@ -23,7 +23,7 @@ internal class TransferProgressTracker private long _bytesTransferred = 0; private object _bytesTransferredLock = new(); - public TransferProgressTracker(IProgress progressHandler, ProgressHandlerOptions options) + public TransferProgressTracker(IProgress progressHandler, ProgressHandlerOptions options) { _progressHandler = progressHandler; _options = options ?? new ProgressHandlerOptions(); @@ -94,9 +94,9 @@ public void IncrementBytesTransferred(long bytesTransferred) } } - private StorageTransferProgress GetTransferProgress() + private DataTransferProgress GetTransferProgress() { - return new StorageTransferProgress() + return new DataTransferProgress() { CompletedCount = _completedCount, SkippedCount = _skippedCount, diff --git a/sdk/storage/Azure.Storage.DataMovement/src/UriToStreamJobPart.cs b/sdk/storage/Azure.Storage.DataMovement/src/UriToStreamJobPart.cs index b8479fd4751a0..747b830145d07 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/UriToStreamJobPart.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/UriToStreamJobPart.cs @@ -34,8 +34,8 @@ private UriToStreamJobPart( destinationResource: job._destinationResource, maximumTransferChunkSize: job._maximumTransferChunkSize, initialTransferSize: job._initialTransferSize, - errorHandling: job._errorHandling, - createMode: job._createMode, + errorHandling: job._errorMode, + createMode: job._creationPreference, checkpointer: job._checkpointer, progressTracker: job._progressTracker, arrayPool: job.UploadArrayPool, @@ -44,7 +44,7 @@ private UriToStreamJobPart( statusEventHandler: job.TransferStatusEventHandler, failedEventHandler: job.TransferFailedEventHandler, skippedEventHandler: job.TransferSkippedEventHandler, - singleTransferEventHandler: job.SingleTransferCompletedEventHandler, + singleTransferEventHandler: job.TransferItemCompletedEventHandler, clientDiagnostics: job.ClientDiagnostics, cancellationToken: job._cancellationToken) { } @@ -55,10 +55,10 @@ private UriToStreamJobPart( private UriToStreamJobPart( UriToStreamTransferJob job, int partNumber, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, bool isFinalPart, - StorageTransferStatus jobPartStatus = StorageTransferStatus.Queued, + DataTransferStatus jobPartStatus = DataTransferStatus.Queued, long? length = default) : base(dataTransfer: job._dataTransfer, partNumber: partNumber, @@ -66,8 +66,8 @@ private UriToStreamJobPart( destinationResource: destinationResource, maximumTransferChunkSize: job._maximumTransferChunkSize, initialTransferSize: job._initialTransferSize, - errorHandling: job._errorHandling, - createMode: job._createMode, + errorHandling: job._errorMode, + createMode: job._creationPreference, checkpointer: job._checkpointer, progressTracker: job._progressTracker, arrayPool: job.UploadArrayPool, @@ -76,7 +76,7 @@ private UriToStreamJobPart( statusEventHandler: job.TransferStatusEventHandler, failedEventHandler: job.TransferFailedEventHandler, skippedEventHandler: job.TransferSkippedEventHandler, - singleTransferEventHandler: job.SingleTransferCompletedEventHandler, + singleTransferEventHandler: job.TransferItemCompletedEventHandler, clientDiagnostics: job.ClientDiagnostics, cancellationToken: job._cancellationToken, jobPartStatus: jobPartStatus, @@ -102,10 +102,10 @@ await part.AddJobPartToCheckpointerAsync( public static async Task CreateJobPartAsync( UriToStreamTransferJob job, int partNumber, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, bool isFinalPart, - StorageTransferStatus jobPartStatus = default, + DataTransferStatus jobPartStatus = default, long? length = default, bool partPlanFileExists = false) { @@ -147,7 +147,7 @@ public override async Task ProcessPartToChunkAsync() { // we can default the length to 0 because we know the destination is local and // does not require a length to be created. - await OnTransferStatusChanged(StorageTransferStatus.InProgress).ConfigureAwait(false); + await OnTransferStatusChanged(DataTransferStatus.InProgress).ConfigureAwait(false); try { @@ -169,14 +169,14 @@ public override async Task ProcessPartToChunkAsync() internal async Task UnknownDownloadInternal() { - Task initialTask = _sourceResource.ReadStreamAsync( + Task initialTask = _sourceResource.ReadStreamAsync( position: 0, length: _initialTransferSize, _cancellationToken); try { - ReadStreamStorageResourceResult initialResult = default; + StorageResourceReadStreamResult initialResult = default; try { initialResult = await initialTask.ConfigureAwait(false); @@ -268,7 +268,7 @@ internal async Task LengthKnownDownloadInternal() { // To prevent requesting a range that is invalid when // we already know the length we can just make one get blob request. - ReadStreamStorageResourceResult result = await _sourceResource. + StorageResourceReadStreamResult result = await _sourceResource. ReadStreamAsync(cancellationToken: _cancellationToken) .ConfigureAwait(false); @@ -333,14 +333,14 @@ internal async Task CompleteFileDownload() // Apply necessary transfer completions on the destination. await _destinationResource.CompleteTransferAsync( - overwrite: _createMode == StorageResourceCreateMode.Overwrite, + overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, cancellationToken: _cancellationToken).ConfigureAwait(false); // Dispose the handlers await DisposeHandlers().ConfigureAwait(false); // Update the transfer status - await OnTransferStatusChanged(StorageTransferStatus.Completed).ConfigureAwait(false); + await OnTransferStatusChanged(DataTransferStatus.Completed).ConfigureAwait(false); } catch (Exception ex) { @@ -352,7 +352,7 @@ internal async Task DownloadStreamingInternal(HttpRange range) { try { - ReadStreamStorageResourceResult result = await _sourceResource.ReadStreamAsync( + StorageResourceReadStreamResult result = await _sourceResource.ReadStreamAsync( range.Offset, (long)range.Length, _cancellationToken).ConfigureAwait(false); @@ -401,9 +401,9 @@ public async Task CopyToStreamInternal( try { // TODO: change to custom offset based on chunk offset - await _destinationResource.WriteFromStreamAsync( + await _destinationResource.CopyFromStreamAsync( stream: source, - overwrite: _createMode == StorageResourceCreateMode.Overwrite, + overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, position: offset, streamLength: sourceLength, completeLength: expectedLength, @@ -412,7 +412,7 @@ await _destinationResource.WriteFromStreamAsync( return true; } catch (IOException ex) - when (_createMode == StorageResourceCreateMode.Skip && + when (_createMode == StorageResourceCreationPreference.SkipIfExists && ex.Message.Contains("Cannot overwrite file.")) { // Skip file that already exists on the destination. diff --git a/sdk/storage/Azure.Storage.DataMovement/src/UriToStreamTransferJob.cs b/sdk/storage/Azure.Storage.DataMovement/src/UriToStreamTransferJob.cs index dec94e9250bf8..88cc9bccab057 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/UriToStreamTransferJob.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/UriToStreamTransferJob.cs @@ -16,12 +16,12 @@ internal class UriToStreamTransferJob : TransferJobInternal /// internal UriToStreamTransferJob( DataTransfer dataTransfer, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, - TransferOptions transferOptions, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, + DataTransferOptions transferOptions, QueueChunkTaskInternal queueChunkTask, TransferCheckpointer checkpointer, - ErrorHandlingBehavior errorHandling, + DataTransferErrorMode errorHandling, ArrayPool arrayPool, ClientDiagnostics clientDiagnostics) : base(dataTransfer, @@ -43,10 +43,10 @@ internal UriToStreamTransferJob( DataTransfer dataTransfer, StorageResourceContainer sourceResource, StorageResourceContainer destinationResource, - TransferOptions transferOptions, + DataTransferOptions transferOptions, QueueChunkTaskInternal queueChunkTask, TransferCheckpointer checkpointer, - ErrorHandlingBehavior errorHandling, + DataTransferErrorMode errorHandling, ArrayPool arrayPool, ClientDiagnostics clientDiagnostics) : base(dataTransfer, @@ -67,7 +67,7 @@ internal UriToStreamTransferJob( /// An IEnumerable that contains the job parts public override async IAsyncEnumerable ProcessJobToJobPartAsync() { - await OnJobStatusChangedAsync(StorageTransferStatus.InProgress).ConfigureAwait(false); + await OnJobStatusChangedAsync(DataTransferStatus.InProgress).ConfigureAwait(false); int partNumber = 0; if (_jobParts.Count == 0) @@ -106,9 +106,9 @@ public override async IAsyncEnumerable ProcessJobToJobPartAsync bool isFinalPartFound = false; foreach (JobPartInternal part in _jobParts) { - if (part.JobPartStatus != StorageTransferStatus.Completed) + if (part.JobPartStatus != DataTransferStatus.Completed) { - part.JobPartStatus = StorageTransferStatus.Queued; + part.JobPartStatus = DataTransferStatus.Queued; yield return part; if (part.IsFinalPart) @@ -190,8 +190,8 @@ private async IAsyncEnumerable GetStorageResourcesAsync() part = await UriToStreamJobPart.CreateJobPartAsync( job: this, partNumber: partNumber, - sourceResource: (StorageResourceSingle)lastResource, - destinationResource: _destinationResourceContainer.GetChildStorageResource(sourceName), + sourceResource: (StorageResourceItem)lastResource, + destinationResource: _destinationResourceContainer.GetStorageResourceReference(sourceName), isFinalPart: false).ConfigureAwait(false); AppendJobPart(part); } @@ -222,8 +222,8 @@ private async IAsyncEnumerable GetStorageResourcesAsync() lastPart = await UriToStreamJobPart.CreateJobPartAsync( job: this, partNumber: partNumber, - sourceResource: (StorageResourceSingle) lastResource, - destinationResource: _destinationResourceContainer.GetChildStorageResource(lastSourceName), + sourceResource: (StorageResourceItem) lastResource, + destinationResource: _destinationResourceContainer.GetStorageResourceReference(lastSourceName), isFinalPart: true).ConfigureAwait(false); AppendJobPart(lastPart); } diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/AppendBlobStorageResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/AppendBlobStorageResourceTests.cs index a16962e3a8c27..2f2c752151d3a 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/AppendBlobStorageResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/AppendBlobStorageResourceTests.cs @@ -55,7 +55,7 @@ public async Task ReadStreamAsync() AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient); // Act - ReadStreamStorageResourceResult result = await storageResource.ReadStreamAsync(); + StorageResourceReadStreamResult result = await storageResource.ReadStreamAsync(); // Assert Assert.NotNull(result); @@ -81,7 +81,7 @@ public async Task ReadStreamAsync_Position() AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient); // Act - ReadStreamStorageResourceResult result = await storageResource.ReadStreamAsync(position: readPosition); + StorageResourceReadStreamResult result = await storageResource.ReadStreamAsync(position: readPosition); // Assert Assert.NotNull(result); @@ -125,7 +125,7 @@ public async Task ReadStreamAsync_Partial() } // Act - ReadStreamStorageResourceResult result = + StorageResourceReadStreamResult result = await storageResource.ReadStreamAsync(position: 0, length: Constants.KB); // Assert @@ -146,7 +146,7 @@ public async Task WriteFromStreamAsync() using (var stream = new MemoryStream(data)) { // Act - await storageResource.WriteFromStreamAsync(stream, length, false); + await storageResource.CopyFromStreamAsync(stream, length, false); } BlobDownloadStreamingResult result = await blobClient.DownloadStreamingAsync(); @@ -175,7 +175,7 @@ public async Task WriteFromStreamAsync_Position() using (var stream = new MemoryStream(data)) { // Act - await storageResource.WriteFromStreamAsync( + await storageResource.CopyFromStreamAsync( stream: stream, streamLength: length, overwrite: false, @@ -212,7 +212,7 @@ public async Task WriteFromStreamAsync_Error() { // Act await TestHelper.AssertExpectedExceptionAsync( - storageResource.WriteFromStreamAsync(stream, streamLength: length, false, position: position), + storageResource.CopyFromStreamAsync(stream, streamLength: length, false, position: position), e => { Assert.AreEqual(e.ErrorCode, "BlobAlreadyExists"); @@ -612,7 +612,7 @@ public async Task CompleteTransferAsync() var data = GetRandomBuffer(length); using (var stream = new MemoryStream(data)) { - await storageResource.WriteFromStreamAsync( + await storageResource.CopyFromStreamAsync( stream: stream, streamLength: length, overwrite: false, diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/BlobContainerClientExtensionsTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/BlobContainerClientExtensionsTests.cs index 225ee68d12352..3113c30490faa 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/BlobContainerClientExtensionsTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/BlobContainerClientExtensionsTests.cs @@ -45,7 +45,7 @@ public async Task VerifyStartUploadDirectoryAsync([Values] bool addBlobDirectory var directoryPath = Path.GetTempPath(); - var options = addTransferOptions ? new TransferOptions() : (TransferOptions)null; + var options = addTransferOptions ? new DataTransferOptions() : (DataTransferOptions)null; var assertionComplete = false; @@ -65,7 +65,7 @@ public async Task VerifyStartUploadDirectoryAsync([Values] bool addBlobDirectory { await client.StartUploadDirectoryAsync(directoryPath, new BlobContainerClientTransferOptions { - BlobContainerOptions = new() { DirectoryPrefix = blobDirectoryPrefix }, + BlobContainerOptions = new() { BlobDirectoryPrefix = blobDirectoryPrefix }, TransferOptions = options }); } @@ -90,7 +90,7 @@ public async Task VerifyStartDownloadToDirectoryAsync([Values] bool addBlobDirec var directoryPath = Path.GetTempPath(); - var options = addTransferOptions ? new TransferOptions() : (TransferOptions)null; + var options = addTransferOptions ? new DataTransferOptions() : (DataTransferOptions)null; var expSourceResourceType = addBlobDirectoryPath ? typeof(BlobStorageResourceContainer) : typeof(BlobStorageResourceContainer); @@ -112,7 +112,7 @@ public async Task VerifyStartDownloadToDirectoryAsync([Values] bool addBlobDirec { await client.StartDownloadToDirectoryAsync(directoryPath, new BlobContainerClientTransferOptions { - BlobContainerOptions = new() { DirectoryPrefix = blobDirectoryPrefix }, + BlobContainerOptions = new() { BlobDirectoryPrefix = blobDirectoryPrefix }, TransferOptions = options }); } @@ -132,9 +132,9 @@ private class MockTransferManager : TransferManager { public MockTransferManager() { } - public Action OnStartTransferContainerAsync { get; set; } + public Action OnStartTransferContainerAsync { get; set; } - public override Task StartTransferAsync(StorageResource sourceResource, StorageResource destinationResource, TransferOptions transferOptions = null, CancellationToken cancellationToken = default) + public override Task StartTransferAsync(StorageResource sourceResource, StorageResource destinationResource, DataTransferOptions transferOptions = null, CancellationToken cancellationToken = default) { if (OnStartTransferContainerAsync != null) { diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/BlobStorageResourceContainerTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/BlobStorageResourceContainerTests.cs index f4483dbb825ad..0638d2fc39bee 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/BlobStorageResourceContainerTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/BlobStorageResourceContainerTests.cs @@ -65,7 +65,7 @@ public void Ctor_PublicUri() string directoryName = "directoryName"; BlobContainerClient blobContainerClient = new BlobContainerClient(uri); BlobStorageResourceContainer storageResource = - new BlobStorageResourceContainer(blobContainerClient, new() { DirectoryPrefix = "directoryName" }); + new BlobStorageResourceContainer(blobContainerClient, new() { BlobDirectoryPrefix = "directoryName" }); // Assert Assert.AreEqual(uri, storageResource.Uri); @@ -82,7 +82,7 @@ public async Task GetStorageResourcesAsync() string folderName = "foo"; BlobStorageResourceContainer storageResourceContainer = - new BlobStorageResourceContainer(test.Container, new() { DirectoryPrefix = folderName }); + new BlobStorageResourceContainer(test.Container, new() { BlobDirectoryPrefix = folderName }); var resources = new List(); @@ -104,9 +104,9 @@ public async Task GetChildStorageResourceAsync() string prefix = "foo"; StorageResourceContainer containerResource = - new BlobStorageResourceContainer(test.Container, new() { DirectoryPrefix = prefix }); + new BlobStorageResourceContainer(test.Container, new() { BlobDirectoryPrefix = prefix }); - StorageResourceSingle resource = containerResource.GetChildStorageResource("bar"); + StorageResourceItem resource = containerResource.GetStorageResourceReference("bar"); // Assert StorageResourceProperties properties = await resource.GetPropertiesAsync(); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/BlockBlobStorageResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/BlockBlobStorageResourceTests.cs index 8e71e96ab4660..56bce91bd4e6b 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/BlockBlobStorageResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/BlockBlobStorageResourceTests.cs @@ -53,7 +53,7 @@ public async Task ReadStreamAsync() BlockBlobStorageResource storageResource = new BlockBlobStorageResource(blobClient); // Act - ReadStreamStorageResourceResult result = await storageResource.ReadStreamAsync(); + StorageResourceReadStreamResult result = await storageResource.ReadStreamAsync(); // Assert Assert.NotNull(result); @@ -78,7 +78,7 @@ await blobClient.UploadAsync( BlockBlobStorageResource storageResource = new BlockBlobStorageResource(blobClient); // Act - ReadStreamStorageResourceResult result = await storageResource.ReadStreamAsync(position: position); + StorageResourceReadStreamResult result = await storageResource.ReadStreamAsync(position: position); // Assert Assert.NotNull(result); @@ -121,7 +121,7 @@ await blobClient.UploadAsync( } // Act - ReadStreamStorageResourceResult result = + StorageResourceReadStreamResult result = await storageResource.ReadStreamAsync(position: 0, length: Constants.KB); // Assert @@ -142,7 +142,7 @@ public async Task WriteFromStreamAsync() using (var stream = new MemoryStream(data)) { // Act - await storageResource.WriteFromStreamAsync( + await storageResource.CopyFromStreamAsync( stream: stream, streamLength: length, completeLength: length, @@ -169,7 +169,7 @@ public async Task WriteFromStreamAsync_Position() using (var stream = new MemoryStream(data)) { // Act - await storageResource.WriteFromStreamAsync( + await storageResource.CopyFromStreamAsync( stream: stream, streamLength: length, overwrite: false, @@ -200,7 +200,7 @@ public async Task WriteFromStreamAsync_Error() var data = GetRandomBuffer(length); using (var stream = new MemoryStream(data)) { - await storageResource.WriteFromStreamAsync( + await storageResource.CopyFromStreamAsync( stream: stream, streamLength: length, overwrite: false, @@ -210,7 +210,7 @@ await storageResource.WriteFromStreamAsync( { // Act await TestHelper.AssertExpectedExceptionAsync( - storageResource.WriteFromStreamAsync( + storageResource.CopyFromStreamAsync( stream: stream, streamLength: length, overwrite: false, @@ -605,7 +605,7 @@ public async Task CompleteTransferAsync() var data = GetRandomBuffer(length); using (var stream = new MemoryStream(data)) { - await storageResource.WriteFromStreamAsync( + await storageResource.CopyFromStreamAsync( stream: stream, streamLength: length, overwrite: false, @@ -641,7 +641,7 @@ public async Task CompleteTransferAsync_Overwrite() var newData = GetRandomBuffer(length); using (var stream = new MemoryStream(newData)) { - await storageResource.WriteFromStreamAsync( + await storageResource.CopyFromStreamAsync( stream: stream, streamLength: length, overwrite: overwrite, diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/CommitChunkHandlerTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/CommitChunkHandlerTests.cs index b4d68ed2ba1db..dfd780566fdbb 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/CommitChunkHandlerTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/CommitChunkHandlerTests.cs @@ -159,7 +159,7 @@ public async Task OneChunkTransfer(long blockSize) ReportProgressInBytes = mockCommitChunkBehaviors.ReportProgressInBytesTask.Object, InvokeFailedHandler = mockCommitChunkBehaviors.InvokeFailedEventHandlerTask.Object, }, - TransferType.Concurrent, + DataTransferOrder.Unordered, ClientDiagnostics, CancellationToken.None); @@ -201,7 +201,7 @@ public async Task ParallelChunkTransfer(long blockSize) ReportProgressInBytes = mockCommitChunkBehaviors.ReportProgressInBytesTask.Object, InvokeFailedHandler = mockCommitChunkBehaviors.InvokeFailedEventHandlerTask.Object, }, - TransferType.Concurrent, + DataTransferOrder.Unordered, ClientDiagnostics, CancellationToken.None); @@ -263,7 +263,7 @@ public async Task ParallelChunkTransfer_ExceedError(long blockSize) ReportProgressInBytes = mockCommitChunkBehaviors.ReportProgressInBytesTask.Object, InvokeFailedHandler = mockCommitChunkBehaviors.InvokeFailedEventHandlerTask.Object, }, - TransferType.Concurrent, + DataTransferOrder.Unordered, ClientDiagnostics, CancellationToken.None); @@ -308,7 +308,7 @@ public async Task ParallelChunkTransfer_MultipleProcesses(long blockSize, int ta ReportProgressInBytes = mockCommitChunkBehaviors.ReportProgressInBytesTask.Object, InvokeFailedHandler = mockCommitChunkBehaviors.InvokeFailedEventHandlerTask.Object, }, - TransferType.Concurrent, + DataTransferOrder.Unordered, ClientDiagnostics, CancellationToken.None); @@ -360,7 +360,7 @@ public async Task SequentialChunkTransfer(long blockSize) ReportProgressInBytes = mockCommitChunkBehaviors.ReportProgressInBytesTask.Object, InvokeFailedHandler = mockCommitChunkBehaviors.InvokeFailedEventHandlerTask.Object, }, - TransferType.Sequential, + DataTransferOrder.Sequential, ClientDiagnostics, CancellationToken.None); @@ -422,7 +422,7 @@ public async Task SequentialChunkTransfer_ExceedError(long blockSize) ReportProgressInBytes = mockCommitChunkBehaviors.ReportProgressInBytesTask.Object, InvokeFailedHandler = mockCommitChunkBehaviors.InvokeFailedEventHandlerTask.Object, }, - TransferType.Sequential, + DataTransferOrder.Sequential, ClientDiagnostics, CancellationToken.None); @@ -466,7 +466,7 @@ public async Task GetPutBlockTask_ExpectedFailure() ReportProgressInBytes = mockCommitChunkBehaviors.ReportProgressInBytesTask.Object, InvokeFailedHandler = mockCommitChunkBehaviors.InvokeFailedEventHandlerTask.Object, }, - transferType: TransferType.Sequential, + transferOrder: DataTransferOrder.Sequential, ClientDiagnostics, CancellationToken.None); @@ -508,7 +508,7 @@ public async Task GetCommitBlockTask_ExpectedFailure() ReportProgressInBytes = mockCommitChunkBehaviors.ReportProgressInBytesTask.Object, InvokeFailedHandler = mockCommitChunkBehaviors.InvokeFailedEventHandlerTask.Object, }, - transferType: TransferType.Concurrent, + transferOrder: DataTransferOrder.Unordered, ClientDiagnostics, CancellationToken.None); @@ -549,7 +549,7 @@ public async Task DisposedEventHandler() ReportProgressInBytes = mockCommitChunkBehaviors.ReportProgressInBytesTask.Object, InvokeFailedHandler = mockCommitChunkBehaviors.InvokeFailedEventHandlerTask.Object, }, - transferType: TransferType.Concurrent, + transferOrder: DataTransferOrder.Unordered, ClientDiagnostics, CancellationToken.None); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/DataTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/DataTransferTests.cs index 22b30cc44e859..879586d0c8b6d 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/DataTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/DataTransferTests.cs @@ -30,13 +30,13 @@ public void Ctor_Default() } [Test] - [TestCase(StorageTransferStatus.None)] - [TestCase(StorageTransferStatus.Queued)] - [TestCase(StorageTransferStatus.InProgress)] - [TestCase(StorageTransferStatus.PauseInProgress)] - [TestCase(StorageTransferStatus.CancellationInProgress)] - [TestCase(StorageTransferStatus.Paused)] - public void HasCompleted_False(StorageTransferStatus status) + [TestCase(DataTransferStatus.None)] + [TestCase(DataTransferStatus.Queued)] + [TestCase(DataTransferStatus.InProgress)] + [TestCase(DataTransferStatus.PauseInProgress)] + [TestCase(DataTransferStatus.CancellationInProgress)] + [TestCase(DataTransferStatus.Paused)] + public void HasCompleted_False(DataTransferStatus status) { // Arrange string transferId = GetNewTransferId(); @@ -55,10 +55,10 @@ public void HasCompleted_False(StorageTransferStatus status) } [Test] - [TestCase(StorageTransferStatus.Completed)] - [TestCase(StorageTransferStatus.CompletedWithSkippedTransfers)] - [TestCase(StorageTransferStatus.CompletedWithFailedTransfers)] - public void HasCompleted_True(StorageTransferStatus status) + [TestCase(DataTransferStatus.Completed)] + [TestCase(DataTransferStatus.CompletedWithSkippedTransfers)] + [TestCase(DataTransferStatus.CompletedWithFailedTransfers)] + public void HasCompleted_True(DataTransferStatus status) { // Arrange string transferId = GetNewTransferId(); @@ -86,10 +86,10 @@ public void EnsureCompleted() DataTransfer transfer = new DataTransfer( id: transferId, transferManager: transferManager, - status: StorageTransferStatus.Completed); + status: DataTransferStatus.Completed); // Act - transfer.EnsureCompleted(); + transfer.WaitForCompletion(); // Assert Assert.AreEqual(transferId, transfer.Id); @@ -106,12 +106,12 @@ public void EnsureCompleted_CancellationToken() DataTransfer transfer = new DataTransfer( id: transferId, transferManager: new(), - status: StorageTransferStatus.Queued); + status: DataTransferStatus.Queued); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(1)); // Act TestHelper.AssertExpectedException( - () => transfer.EnsureCompleted(cancellationTokenSource.Token), + () => transfer.WaitForCompletion(cancellationTokenSource.Token), new OperationCanceledException("The operation was canceled.")); } @@ -125,7 +125,7 @@ public async Task AwaitCompletion() DataTransfer transfer = new DataTransfer( id: transferId, transferManager: transferManager, - status: StorageTransferStatus.Completed); + status: DataTransferStatus.Completed); // Act await transfer.WaitForCompletionAsync(); @@ -145,7 +145,7 @@ public void AwaitCompletion_CancellationToken() DataTransfer transfer = new DataTransfer( id: transferId, transferManager: new(), - status: StorageTransferStatus.Queued); + status: DataTransferStatus.Queued); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(1)); Assert.CatchAsync( @@ -162,31 +162,31 @@ public async Task TryPauseAsync() DataTransfer transfer = new DataTransfer( id: transferId, transferManager: new(), - status: StorageTransferStatus.InProgress); + status: DataTransferStatus.InProgress); // Act - Task pauseTask = transfer.PauseIfRunningAsync(); + Task pauseTask = transfer.PauseAsync(); - Assert.AreEqual(StorageTransferStatus.PauseInProgress, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.PauseInProgress, transfer.TransferStatus); // Assert - if (!transfer._state.TrySetTransferStatus(StorageTransferStatus.Paused)) + if (!transfer._state.TrySetTransferStatus(DataTransferStatus.Paused)) { Assert.Fail("Unable to set the transfer status internally to the DataTransfer."); } await pauseTask; - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); Assert.IsFalse(transfer.HasCompleted); } [Test] - [TestCase(StorageTransferStatus.Paused)] - [TestCase(StorageTransferStatus.Completed)] - [TestCase(StorageTransferStatus.CompletedWithSkippedTransfers)] - [TestCase(StorageTransferStatus.CompletedWithFailedTransfers)] - public async Task TryPauseAsync_AlreadyPaused(StorageTransferStatus status) + [TestCase(DataTransferStatus.Paused)] + [TestCase(DataTransferStatus.Completed)] + [TestCase(DataTransferStatus.CompletedWithSkippedTransfers)] + [TestCase(DataTransferStatus.CompletedWithFailedTransfers)] + public async Task TryPauseAsync_AlreadyPaused(DataTransferStatus status) { // Arrange string transferId = GetNewTransferId(); @@ -197,7 +197,7 @@ public async Task TryPauseAsync_AlreadyPaused(StorageTransferStatus status) status: status); Assert.AreEqual(status, transfer.TransferStatus); - await transfer.PauseIfRunningAsync(); + await transfer.PauseAsync(); Assert.AreEqual(status, transfer.TransferStatus); } @@ -210,18 +210,18 @@ public async Task TryPauseAsync_CancellationToken() DataTransfer transfer = new DataTransfer( id: transferId, transferManager: new(), - status: StorageTransferStatus.InProgress); + status: DataTransferStatus.InProgress); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(1)); try { - await transfer.PauseIfRunningAsync(cancellationTokenSource.Token); + await transfer.PauseAsync(cancellationTokenSource.Token); } catch (OperationCanceledException exception) { Assert.AreEqual(exception.Message, "The operation was canceled."); } - Assert.AreEqual(StorageTransferStatus.PauseInProgress, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.PauseInProgress, transfer.TransferStatus); Assert.IsFalse(transfer.HasCompleted); } } diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/GetTransfersTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/GetTransfersTests.cs index 095deee7c7b30..06939c2fd71f1 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/GetTransfersTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/GetTransfersTests.cs @@ -10,14 +10,14 @@ namespace Azure.Storage.DataMovement.Tests { /// - /// These tests aim to test the . + /// These tests aim to test the . /// public class GetTransfersTests { private TransferManagerOptions GetDefaultManagerOptions(string checkpointerPath) => new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(checkpointerPath) + CheckpointerOptions = new TransferCheckpointStoreOptions(checkpointerPath) }; private void AssertListTransfersEquals(IList expected, IList actual) @@ -38,7 +38,7 @@ private void AssertListTransfersEquals(IList expected, IList storedTransfers = new List { - GetNewDataTransfer(StorageTransferStatus.Queued), - GetNewDataTransfer(StorageTransferStatus.Queued), - GetNewDataTransfer(StorageTransferStatus.Queued), - GetNewDataTransfer(StorageTransferStatus.Queued), - GetNewDataTransfer(StorageTransferStatus.InProgress), - GetNewDataTransfer(StorageTransferStatus.InProgress), - GetNewDataTransfer(StorageTransferStatus.Paused), - GetNewDataTransfer(StorageTransferStatus.Paused), - GetNewDataTransfer(StorageTransferStatus.CompletedWithFailedTransfers), - GetNewDataTransfer(StorageTransferStatus.CompletedWithFailedTransfers), - GetNewDataTransfer(StorageTransferStatus.CompletedWithFailedTransfers), - GetNewDataTransfer(StorageTransferStatus.Completed), - GetNewDataTransfer(StorageTransferStatus.Completed), + GetNewDataTransfer(DataTransferStatus.Queued), + GetNewDataTransfer(DataTransferStatus.Queued), + GetNewDataTransfer(DataTransferStatus.Queued), + GetNewDataTransfer(DataTransferStatus.Queued), + GetNewDataTransfer(DataTransferStatus.InProgress), + GetNewDataTransfer(DataTransferStatus.InProgress), + GetNewDataTransfer(DataTransferStatus.Paused), + GetNewDataTransfer(DataTransferStatus.Paused), + GetNewDataTransfer(DataTransferStatus.CompletedWithFailedTransfers), + GetNewDataTransfer(DataTransferStatus.CompletedWithFailedTransfers), + GetNewDataTransfer(DataTransferStatus.CompletedWithFailedTransfers), + GetNewDataTransfer(DataTransferStatus.Completed), + GetNewDataTransfer(DataTransferStatus.Completed), }; TransferManagerFactory factory = new TransferManagerFactory(GetDefaultManagerOptions(testDirectory.DirectoryPath)); TransferManager manager = factory.BuildTransferManager(storedTransfers); // Act - StorageTransferStatus[] statuses = new StorageTransferStatus[] { status }; + DataTransferStatus[] statuses = new DataTransferStatus[] { status }; IList result = await manager.GetTransfersAsync(statuses).ToListAsync(); // Assert @@ -127,30 +127,30 @@ public async Task GetTransfers_FilterMultipleStatuses() // Arrange - Set up transfer manager with multiple transfers List storedTransfers = new List { - GetNewDataTransfer(StorageTransferStatus.Queued), - GetNewDataTransfer(StorageTransferStatus.Queued), - GetNewDataTransfer(StorageTransferStatus.Queued), - GetNewDataTransfer(StorageTransferStatus.Queued), - GetNewDataTransfer(StorageTransferStatus.InProgress), - GetNewDataTransfer(StorageTransferStatus.InProgress), - GetNewDataTransfer(StorageTransferStatus.Paused), - GetNewDataTransfer(StorageTransferStatus.Paused), - GetNewDataTransfer(StorageTransferStatus.CompletedWithFailedTransfers), - GetNewDataTransfer(StorageTransferStatus.CompletedWithFailedTransfers), - GetNewDataTransfer(StorageTransferStatus.CompletedWithFailedTransfers), - GetNewDataTransfer(StorageTransferStatus.Completed), - GetNewDataTransfer(StorageTransferStatus.Completed), - GetNewDataTransfer(StorageTransferStatus.CompletedWithSkippedTransfers) + GetNewDataTransfer(DataTransferStatus.Queued), + GetNewDataTransfer(DataTransferStatus.Queued), + GetNewDataTransfer(DataTransferStatus.Queued), + GetNewDataTransfer(DataTransferStatus.Queued), + GetNewDataTransfer(DataTransferStatus.InProgress), + GetNewDataTransfer(DataTransferStatus.InProgress), + GetNewDataTransfer(DataTransferStatus.Paused), + GetNewDataTransfer(DataTransferStatus.Paused), + GetNewDataTransfer(DataTransferStatus.CompletedWithFailedTransfers), + GetNewDataTransfer(DataTransferStatus.CompletedWithFailedTransfers), + GetNewDataTransfer(DataTransferStatus.CompletedWithFailedTransfers), + GetNewDataTransfer(DataTransferStatus.Completed), + GetNewDataTransfer(DataTransferStatus.Completed), + GetNewDataTransfer(DataTransferStatus.CompletedWithSkippedTransfers) }; TransferManagerFactory factory = new TransferManagerFactory(GetDefaultManagerOptions(testDirectory.DirectoryPath)); TransferManager manager = factory.BuildTransferManager(storedTransfers); // Act - StorageTransferStatus[] statuses = new StorageTransferStatus[] { - StorageTransferStatus.Completed, - StorageTransferStatus.CompletedWithFailedTransfers, - StorageTransferStatus.CompletedWithSkippedTransfers }; + DataTransferStatus[] statuses = new DataTransferStatus[] { + DataTransferStatus.Completed, + DataTransferStatus.CompletedWithFailedTransfers, + DataTransferStatus.CompletedWithSkippedTransfers }; IList result = await manager.GetTransfersAsync(statuses).ToListAsync(); // Assert @@ -164,26 +164,26 @@ public async Task GetTransfers_Filtered_Empty() // Arrange - Set up transfer manager with multiple transfers List storedTransfers = new List { - GetNewDataTransfer(StorageTransferStatus.Queued), - GetNewDataTransfer(StorageTransferStatus.Queued), - GetNewDataTransfer(StorageTransferStatus.Queued), - GetNewDataTransfer(StorageTransferStatus.Queued), - GetNewDataTransfer(StorageTransferStatus.InProgress), - GetNewDataTransfer(StorageTransferStatus.InProgress), - GetNewDataTransfer(StorageTransferStatus.Paused), - GetNewDataTransfer(StorageTransferStatus.Paused), - GetNewDataTransfer(StorageTransferStatus.CompletedWithFailedTransfers), - GetNewDataTransfer(StorageTransferStatus.CompletedWithFailedTransfers), - GetNewDataTransfer(StorageTransferStatus.CompletedWithFailedTransfers), - GetNewDataTransfer(StorageTransferStatus.Completed), - GetNewDataTransfer(StorageTransferStatus.Completed), + GetNewDataTransfer(DataTransferStatus.Queued), + GetNewDataTransfer(DataTransferStatus.Queued), + GetNewDataTransfer(DataTransferStatus.Queued), + GetNewDataTransfer(DataTransferStatus.Queued), + GetNewDataTransfer(DataTransferStatus.InProgress), + GetNewDataTransfer(DataTransferStatus.InProgress), + GetNewDataTransfer(DataTransferStatus.Paused), + GetNewDataTransfer(DataTransferStatus.Paused), + GetNewDataTransfer(DataTransferStatus.CompletedWithFailedTransfers), + GetNewDataTransfer(DataTransferStatus.CompletedWithFailedTransfers), + GetNewDataTransfer(DataTransferStatus.CompletedWithFailedTransfers), + GetNewDataTransfer(DataTransferStatus.Completed), + GetNewDataTransfer(DataTransferStatus.Completed), }; TransferManagerFactory factory = new TransferManagerFactory(GetDefaultManagerOptions(testDirectory.DirectoryPath)); TransferManager manager = factory.BuildTransferManager(storedTransfers); // Act - With a transfer status not in the above stored transfers - StorageTransferStatus[] statuses = new StorageTransferStatus[] { StorageTransferStatus.CancellationInProgress }; + DataTransferStatus[] statuses = new DataTransferStatus[] { DataTransferStatus.CancellationInProgress }; IList result = await manager.GetTransfersAsync(statuses).ToListAsync(); // Assert @@ -206,7 +206,7 @@ public async Task GetTransfers_LocalCheckpointer() // Build TransferManager with the stored transfers TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(test.DirectoryPath) + CheckpointerOptions = new TransferCheckpointStoreOptions(test.DirectoryPath) }; TransferManager manager = new TransferManager(options); @@ -247,7 +247,7 @@ public async Task GetResumableTransfers_LocalCheckpointer() // Build TransferManager with the stored transfers TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(test.DirectoryPath) + CheckpointerOptions = new TransferCheckpointStoreOptions(test.DirectoryPath) }; TransferManager manager = new TransferManager(options); @@ -274,19 +274,19 @@ public async Task GetResumableTransfers_IgnoresCompleted() test.DirectoryPath, transferId1, 3 /* jobPartCount */, - StorageTransferStatus.Completed); + DataTransferStatus.Completed); string transferId2 = Guid.NewGuid().ToString(); factory.CreateStubJobPartPlanFilesAsync( test.DirectoryPath, transferId2, 3 /* jobPartCount */, - StorageTransferStatus.Queued); + DataTransferStatus.Queued); // Build TransferManager with the stored transfers TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(test.DirectoryPath) + CheckpointerOptions = new TransferCheckpointStoreOptions(test.DirectoryPath) }; TransferManager manager = new TransferManager(options); @@ -326,7 +326,7 @@ private void AddTransferFromDataTransferProperties( checkpointerPath, properties.TransferId, numParts, /* jobPartCount */ - StorageTransferStatus.InProgress, + DataTransferStatus.InProgress, sourcePaths, destinationPaths, sourceResourceId: properties.SourceTypeId, @@ -338,7 +338,7 @@ private void AddTransferFromDataTransferProperties( checkpointerPath, properties.TransferId, 1, /* jobPartCount */ - StorageTransferStatus.InProgress, + DataTransferStatus.InProgress, new List { properties.SourcePath }, new List { properties.DestinationPath }, sourceResourceId: properties.SourceTypeId, diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/LocalDirectoryStorageResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/LocalDirectoryStorageResourceTests.cs index 5006a7d0675af..ec4f590114e50 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/LocalDirectoryStorageResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/LocalDirectoryStorageResourceTests.cs @@ -95,7 +95,7 @@ public async Task GetChildStorageResourceAsync() StorageResourceContainer containerResource = new LocalDirectoryStorageResourceContainer(folderPath); foreach (string fileName in fileNames) { - StorageResourceSingle resource = containerResource.GetChildStorageResource(fileName); + StorageResourceItem resource = containerResource.GetStorageResourceReference(fileName); // Assert await resource.GetPropertiesAsync().ConfigureAwait(false); } @@ -127,7 +127,7 @@ public async Task GetChildStorageResourceAsync_SubDir() StorageResourceContainer containerResource = new LocalDirectoryStorageResourceContainer(folderPath); foreach (string fileName in fileNames) { - StorageResourceSingle resource = containerResource.GetChildStorageResource(fileName); + StorageResourceItem resource = containerResource.GetStorageResourceReference(fileName); // Assert await resource.GetPropertiesAsync().ConfigureAwait(false); } diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/LocalFileStorageResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/LocalFileStorageResourceTests.cs index 7acdb373b2f16..8f55986a03fe4 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/LocalFileStorageResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/LocalFileStorageResourceTests.cs @@ -98,7 +98,7 @@ public async Task ReadStreamAsync() // Act LocalFileStorageResource storageResource = new LocalFileStorageResource(path); - ReadStreamStorageResourceResult result = await storageResource.ReadStreamAsync(); + StorageResourceReadStreamResult result = await storageResource.ReadStreamAsync(); using Stream content = result.Content; // Assert @@ -120,7 +120,7 @@ public async Task ReadStreamAsync_Position() // Act var readPosition = 5; LocalFileStorageResource storageResource = new LocalFileStorageResource(path); - ReadStreamStorageResourceResult result = await storageResource.ReadStreamAsync(position: readPosition); + StorageResourceReadStreamResult result = await storageResource.ReadStreamAsync(position: readPosition); using Stream content = result.Content; // Assert @@ -163,7 +163,7 @@ public async Task WriteStreamAsync() using (var stream = new MemoryStream(data)) { // Act - await storageResource.WriteFromStreamAsync( + await storageResource.CopyFromStreamAsync( stream, streamLength: length, false, @@ -192,7 +192,7 @@ public async Task WriteStreamAsync_Position() using (var stream = new MemoryStream(data)) { // Act - await storageResource.WriteFromStreamAsync( + await storageResource.CopyFromStreamAsync( stream, streamLength: length, overwrite: false, @@ -220,7 +220,7 @@ public async Task WriteStreamAsync_Error() { using (var stream = new MemoryStream(data)) { - await storageResource.WriteFromStreamAsync(stream, length, false); + await storageResource.CopyFromStreamAsync(stream, length, false); } } catch (IOException ex) diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/LocalTransferCheckpointerFactory.cs b/sdk/storage/Azure.Storage.DataMovement/tests/LocalTransferCheckpointerFactory.cs index 43a5c22d98d24..255123d43b732 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/LocalTransferCheckpointerFactory.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/LocalTransferCheckpointerFactory.cs @@ -43,8 +43,8 @@ internal static readonly DateTimeOffset _testStartTime internal const JobPartDeleteSnapshotsOption _testDeleteSnapshotsOption = JobPartDeleteSnapshotsOption.None; internal const JobPartPermanentDeleteOption _testPermanentDeleteOption = JobPartPermanentDeleteOption.None; internal const JobPartPlanRehydratePriorityType _testRehydratePriorityType = JobPartPlanRehydratePriorityType.None; - internal const StorageTransferStatus _testJobStatus = StorageTransferStatus.Queued; - internal const StorageTransferStatus _testPartStatus = StorageTransferStatus.Queued; + internal const DataTransferStatus _testJobStatus = DataTransferStatus.Queued; + internal const DataTransferStatus _testPartStatus = DataTransferStatus.Queued; private string _checkpointerPath; @@ -89,7 +89,7 @@ internal void CreateStubJobPartPlanFilesAsync( string checkpointerPath, string transferId, int jobPartCount, - StorageTransferStatus status = StorageTransferStatus.Queued, + DataTransferStatus status = DataTransferStatus.Queued, List sourcePaths = default, List destinationPaths = default, string sourceResourceId = "LocalFile", @@ -185,8 +185,8 @@ internal JobPartPlanHeader CreateDefaultJobPartHeader( JobPartDeleteSnapshotsOption deleteSnapshotsOption = _testDeleteSnapshotsOption, JobPartPermanentDeleteOption permanentDeleteOption = _testPermanentDeleteOption, JobPartPlanRehydratePriorityType rehydratePriorityType = _testRehydratePriorityType, - StorageTransferStatus atomicJobStatus = _testJobStatus, - StorageTransferStatus atomicPartStatus = _testPartStatus) + DataTransferStatus atomicJobStatus = _testJobStatus, + DataTransferStatus atomicPartStatus = _testPartStatus) { if (startTime == default) { diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/LocalTransferCheckpointerTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/LocalTransferCheckpointerTests.cs index 9c32af576bd16..3c74cb43e158e 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/LocalTransferCheckpointerTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/LocalTransferCheckpointerTests.cs @@ -906,7 +906,7 @@ public async Task SetJobTransferStatusAsync() string transferId = GetNewTransferId(); int partNumber = 0; int chunksTotal = 1; - StorageTransferStatus newStatus = StorageTransferStatus.Completed; + DataTransferStatus newStatus = DataTransferStatus.Completed; JobPartPlanHeader header = CheckpointerTesting.CreateDefaultJobPartHeader( transferId: transferId, partNumber: partNumber); @@ -948,7 +948,7 @@ public async Task SetJobTransferStatusAsync_MultipleParts() // Arrange string transferId = GetNewTransferId(); int chunksTotal = 1; - StorageTransferStatus newStatus = StorageTransferStatus.Completed; + DataTransferStatus newStatus = DataTransferStatus.Completed; JobPartPlanHeader header1 = CheckpointerTesting.CreateDefaultJobPartHeader( transferId: transferId, partNumber: 0); @@ -1057,7 +1057,7 @@ public void SetJobTransferStatusAsync_Error() // Arrange string transferId = GetNewTransferId(); int partNumber = 0; - StorageTransferStatus newStatus = StorageTransferStatus.Completed; + DataTransferStatus newStatus = DataTransferStatus.Completed; JobPartPlanHeader header = CheckpointerTesting.CreateDefaultJobPartHeader( transferId: transferId, partNumber: partNumber); @@ -1079,7 +1079,7 @@ public async Task SetJobPartTransferStatusAsync() int partNumber = 0; int chunksTotal = 1; // originally the default is set to Queued - StorageTransferStatus newStatus = StorageTransferStatus.Completed; + DataTransferStatus newStatus = DataTransferStatus.Completed; JobPartPlanHeader header = CheckpointerTesting.CreateDefaultJobPartHeader( transferId: transferId, partNumber: partNumber); @@ -1122,7 +1122,7 @@ public void SetJobPartTransferStatusAsync_Error() string transferId = GetNewTransferId(); int partNumber = 0; // originally the default is set to Queued - StorageTransferStatus newStatus = StorageTransferStatus.Completed; + DataTransferStatus newStatus = DataTransferStatus.Completed; JobPartPlanHeader header = CheckpointerTesting.CreateDefaultJobPartHeader( transferId: transferId, partNumber: partNumber); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/MockStorageResource.cs b/sdk/storage/Azure.Storage.DataMovement/tests/MockStorageResource.cs index f9ed45d3c0e0b..09911de1f596d 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/MockStorageResource.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/MockStorageResource.cs @@ -9,13 +9,13 @@ namespace Azure.Storage.DataMovement.Tests { - internal class MockStorageResource : StorageResourceSingle + internal class MockStorageResource : StorageResourceItem { private readonly Stream _readStream; protected internal override string ResourceId => "Mock"; - protected internal override TransferType TransferType => TransferType.Sequential; + protected internal override DataTransferOrder TransferType => DataTransferOrder.Sequential; private readonly long _maxChunkSize; protected internal override long MaxChunkSize => _maxChunkSize; @@ -55,12 +55,12 @@ protected internal override Task CompleteTransferAsync(bool overwrite, Cancellat return Task.CompletedTask; } - protected internal override Task CopyBlockFromUriAsync(StorageResourceSingle sourceResource, HttpRange range, bool overwrite, long completeLength = 0, StorageResourceCopyFromUriOptions options = null, CancellationToken cancellationToken = default) + protected internal override Task CopyBlockFromUriAsync(StorageResourceItem sourceResource, HttpRange range, bool overwrite, long completeLength = 0, StorageResourceCopyFromUriOptions options = null, CancellationToken cancellationToken = default) { return Task.CompletedTask; } - protected internal override Task CopyFromUriAsync(StorageResourceSingle sourceResource, bool overwrite, long completeLength, StorageResourceCopyFromUriOptions options = null, CancellationToken cancellationToken = default) + protected internal override Task CopyFromUriAsync(StorageResourceItem sourceResource, bool overwrite, long completeLength, StorageResourceCopyFromUriOptions options = null, CancellationToken cancellationToken = default) { return Task.CompletedTask; } @@ -84,13 +84,13 @@ protected internal override Task GetCopyAuthorizationHeaderAs return Task.FromResult(default); } - protected internal override Task ReadStreamAsync(long position = 0, long? length = null, CancellationToken cancellationToken = default) + protected internal override Task ReadStreamAsync(long position = 0, long? length = null, CancellationToken cancellationToken = default) { _readStream.Position = 0; - return Task.FromResult(new ReadStreamStorageResourceResult(_readStream)); + return Task.FromResult(new StorageResourceReadStreamResult(_readStream)); } - protected internal override async Task WriteFromStreamAsync(Stream stream, long streamLength, bool overwrite, long position = 0, long completeLength = 0, StorageResourceWriteToOffsetOptions options = null, CancellationToken cancellationToken = default) + protected internal override async Task CopyFromStreamAsync(Stream stream, long streamLength, bool overwrite, long position = 0, long completeLength = 0, StorageResourceWriteToOffsetOptions options = null, CancellationToken cancellationToken = default) { await stream.CopyToAsync(Stream.Null); } diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/PageBlobStorageResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/PageBlobStorageResourceTests.cs index 677acd5c1bd65..3f5443ac0d974 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/PageBlobStorageResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/PageBlobStorageResourceTests.cs @@ -57,7 +57,7 @@ await blobClient.UploadPagesAsync( PageBlobStorageResource storageResource = new PageBlobStorageResource(blobClient); // Act - ReadStreamStorageResourceResult result = await storageResource.ReadStreamAsync(); + StorageResourceReadStreamResult result = await storageResource.ReadStreamAsync(); // Assert Assert.NotNull(result); @@ -85,7 +85,7 @@ await blobClient.UploadPagesAsync( PageBlobStorageResource storageResource = new PageBlobStorageResource(blobClient); // Act - ReadStreamStorageResourceResult result = await storageResource.ReadStreamAsync(position: readPosition); + StorageResourceReadStreamResult result = await storageResource.ReadStreamAsync(position: readPosition); // Assert Assert.NotNull(result); @@ -131,7 +131,7 @@ await blobClient.UploadPagesAsync( } // Act - ReadStreamStorageResourceResult result = + StorageResourceReadStreamResult result = await storageResource.ReadStreamAsync(position: 0, length: Constants.KB); // Assert @@ -152,7 +152,7 @@ public async Task WriteFromStreamAsync() using (var stream = new MemoryStream(data)) { // Act - await storageResource.WriteFromStreamAsync( + await storageResource.CopyFromStreamAsync( stream: stream, streamLength: length, completeLength: length, @@ -185,7 +185,7 @@ public async Task WriteFromStreamAsync_Position() using (var stream = new MemoryStream(data)) { // Act - await storageResource.WriteFromStreamAsync( + await storageResource.CopyFromStreamAsync( stream: stream, streamLength: length, overwrite: false, @@ -222,7 +222,7 @@ public async Task WriteFromStreamAsync_Error() { // Act await TestHelper.AssertExpectedExceptionAsync( - storageResource.WriteFromStreamAsync( + storageResource.CopyFromStreamAsync( stream: stream, overwrite: false, position: position, @@ -643,7 +643,7 @@ public async Task CompleteTransferAsync() var data = GetRandomBuffer(length); using (var stream = new MemoryStream(data)) { - await storageResource.WriteFromStreamAsync( + await storageResource.CopyFromStreamAsync( stream: stream, streamLength: length, completeLength: length, diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/PauseResumeTransferTests.cs index 91ea53299d76f..ac86813f8634f 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/PauseResumeTransferTests.cs @@ -37,18 +37,18 @@ private async Task AssertDirectorySourceAndDestinationAsync( BlobContainerClient sourceContainer, BlobContainerClient destinationContainer) { - await foreach (StorageResourceSingle childSourceResource in sourceResource.GetStorageResourcesAsync()) + await foreach (StorageResourceItem childSourceResource in sourceResource.GetStorageResourcesAsync()) { - StorageResourceSingle childDestinationResource; + StorageResourceItem childDestinationResource; if (transferType == TransferDirection.Upload) { string destinationChildName = childSourceResource.Path.Substring(sourceResource.Path.Length + 1); - childDestinationResource = destinationResource.GetChildStorageResource(destinationChildName); + childDestinationResource = destinationResource.GetStorageResourceReference(destinationChildName); } else { string destinationChildName = childSourceResource.Uri.AbsoluteUri.Substring(sourceResource.Uri.AbsoluteUri.Length + 1); - childDestinationResource = destinationResource.GetChildStorageResource(destinationChildName); + childDestinationResource = destinationResource.GetStorageResourceReference(destinationChildName); } await AssertSourceAndDestinationAsync( transferType: transferType, @@ -61,8 +61,8 @@ await AssertSourceAndDestinationAsync( private async Task AssertSourceAndDestinationAsync( TransferDirection transferType, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, BlobContainerClient sourceContainer, BlobContainerClient destinationContainer) { @@ -139,7 +139,7 @@ private BlockBlobStorageResource CreateBlobDestinationResource( return new BlockBlobStorageResource(destinationClient, options); } - private async Task<(StorageResourceSingle SourceResource, StorageResourceSingle DestinationResource)> CreateStorageResourcesAsync( + private async Task<(StorageResourceItem SourceResource, StorageResourceItem DestinationResource)> CreateStorageResourcesAsync( TransferDirection transferType, long size, string localDirectory, @@ -149,8 +149,8 @@ private BlockBlobStorageResource CreateBlobDestinationResource( { storagePath ??= GetNewBlobName(); - StorageResourceSingle SourceResource = default; - StorageResourceSingle DestinationResource = default; + StorageResourceItem SourceResource = default; + StorageResourceItem DestinationResource = default; if (transferType == TransferDirection.Download) { Argument.AssertNotNull(sourceContainer, nameof(sourceContainer)); @@ -188,15 +188,15 @@ private async Task CreateSingleLongTransferAsync( string localDirectory = default, BlobContainerClient sourceContainer = default, BlobContainerClient destinationContainer = default, - StorageResourceSingle sourceResource = default, - StorageResourceSingle destinationResource = default, - TransferOptions transferOptions = default, + StorageResourceItem sourceResource = default, + StorageResourceItem destinationResource = default, + DataTransferOptions transferOptions = default, long size = Constants.KB * 100) { Argument.AssertNotNull(manager, nameof(manager)); if (sourceResource == default && destinationResource == default) { - (StorageResourceSingle source, StorageResourceSingle dest) = await CreateStorageResourcesAsync( + (StorageResourceItem source, StorageResourceItem dest) = await CreateStorageResourcesAsync( transferType: transferType, size: size, localDirectory: localDirectory, @@ -230,11 +230,11 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(checkpointerDirectory.DirectoryPath), - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + CheckpointerOptions = new TransferCheckpointStoreOptions(checkpointerDirectory.DirectoryPath), + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, }; TransferManager transferManager = new TransferManager(options); - TransferOptions transferOptions = new TransferOptions(); + DataTransferOptions transferOptions = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); // Add long-running job to pause, if the job is not big enough @@ -254,7 +254,7 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) // Assert await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); // Check if Job Plan File exists in checkpointer path. JobPartPlanFileName fileName = new JobPartPlanFileName( @@ -278,10 +278,10 @@ public async Task TryPauseTransferAsync_DataTransfer(TransferDirection transferT await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(checkpointerDirectory.DirectoryPath), - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + CheckpointerOptions = new TransferCheckpointStoreOptions(checkpointerDirectory.DirectoryPath), + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; - TransferOptions transferOptions = new TransferOptions(); + DataTransferOptions transferOptions = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); TransferManager transferManager = new TransferManager(options); @@ -302,7 +302,7 @@ public async Task TryPauseTransferAsync_DataTransfer(TransferDirection transferT // Assert await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); // Check if Job Plan File exists in checkpointer path. JobPartPlanFileName fileName = new JobPartPlanFileName( @@ -319,8 +319,8 @@ public void TryPauseTransferAsync_Error() using DisposingLocalDirectory checkpointerDirectory = DisposingLocalDirectory.GetTestDirectory(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(checkpointerDirectory.DirectoryPath), - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + CheckpointerOptions = new TransferCheckpointStoreOptions(checkpointerDirectory.DirectoryPath), + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; TransferManager transferManager = new TransferManager(options); @@ -342,10 +342,10 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(checkpointerDirectory.DirectoryPath), - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + CheckpointerOptions = new TransferCheckpointStoreOptions(checkpointerDirectory.DirectoryPath), + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; - TransferOptions transferOptions = new TransferOptions(); + DataTransferOptions transferOptions = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); TransferManager transferManager = new TransferManager(options); @@ -366,12 +366,12 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer // Assert await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource2.Token); - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); // Check if Job Plan File exists in checkpointer path. JobPartPlanFileName fileName = new JobPartPlanFileName( @@ -396,22 +396,22 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(checkpointerDirectory.DirectoryPath), - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + CheckpointerOptions = new TransferCheckpointStoreOptions(checkpointerDirectory.DirectoryPath), + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; - TransferOptions transferOptions = new TransferOptions(); + DataTransferOptions transferOptions = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); TransferManager transferManager = new TransferManager(options); long size = Constants.KB * 100; - (StorageResourceSingle sResource, StorageResourceSingle dResource) = await CreateStorageResourcesAsync( + (StorageResourceItem sResource, StorageResourceItem dResource) = await CreateStorageResourcesAsync( transferType: transferType, size: size, localDirectory: localDirectory.DirectoryPath, sourceContainer: sourceContainer.Container, destinationContainer: destinationContainer.Container); - StorageResourceSingle sourceResource = sResource; - StorageResourceSingle destinationResource = dResource; + StorageResourceItem sourceResource = sResource; + StorageResourceItem destinationResource = dResource; // Add long-running job to pause, if the job is not big enough // then the job might finish before we can pause it. @@ -426,11 +426,11 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); await testEventsRaised.AssertPausedCheck(); // Act - Resume Job - TransferOptions resumeOptions = new TransferOptions(); + DataTransferOptions resumeOptions = new DataTransferOptions(); TestEventsRaised testEventRaised2 = new TestEventsRaised(resumeOptions); DataTransfer resumeTransfer = await transferManager.ResumeTransferAsync( transferId: transfer.Id, @@ -443,7 +443,7 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) // Assert await testEventRaised2.AssertSingleCompletedCheck(); - Assert.AreEqual(StorageTransferStatus.Completed, resumeTransfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, resumeTransfer.TransferStatus); Assert.IsTrue(resumeTransfer.HasCompleted); // Verify transfer @@ -470,15 +470,15 @@ public async Task ResumeTransferAsync(TransferDirection transferType) TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(checkpointerDirectory.DirectoryPath), - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + CheckpointerOptions = new TransferCheckpointStoreOptions(checkpointerDirectory.DirectoryPath), + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; - TransferOptions transferOptions = new TransferOptions(); + DataTransferOptions transferOptions = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); TransferManager transferManager = new TransferManager(options); long size = Constants.KB * 100; - (StorageResourceSingle sResource, StorageResourceSingle dResource) = await CreateStorageResourcesAsync( + (StorageResourceItem sResource, StorageResourceItem dResource) = await CreateStorageResourcesAsync( transferType: transferType, size: size, localDirectory: localDirectory.DirectoryPath, @@ -498,11 +498,11 @@ public async Task ResumeTransferAsync(TransferDirection transferType) await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); await testEventsRaised.AssertPausedCheck(); // Act - Resume Job - TransferOptions resumeOptions = new(); + DataTransferOptions resumeOptions = new(); TestEventsRaised testEventRaised2 = new TestEventsRaised(resumeOptions); DataTransfer resumeTransfer = await transferManager.ResumeTransferAsync( transfer.Id, @@ -515,7 +515,7 @@ public async Task ResumeTransferAsync(TransferDirection transferType) // Assert await testEventRaised2.AssertSingleCompletedCheck(); - Assert.AreEqual(StorageTransferStatus.Completed, resumeTransfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, resumeTransfer.TransferStatus); Assert.IsTrue(resumeTransfer.HasCompleted); // Verify transfer @@ -547,7 +547,7 @@ private async Task CreateBlobDirectorySourceResour } } options ??= new(); - options.DirectoryPrefix = directoryPath; + options.BlobDirectoryPrefix = directoryPath; return new BlobStorageResourceContainer(container, options); } @@ -591,7 +591,7 @@ private async Task CreateLocalDirectoryS Argument.AssertNotNull(destinationContainer, nameof(destinationContainer)); BlobStorageResourceContainerOptions options = new BlobStorageResourceContainerOptions() { - DirectoryPrefix = GetNewBlobDirectoryName(), + BlobDirectoryPrefix = GetNewBlobDirectoryName(), }; SourceResource ??= await CreateBlobDirectorySourceResourceAsync( size: size, @@ -612,7 +612,7 @@ private async Task CreateLocalDirectoryS BlobStorageResourceContainerOptions options = new() { - DirectoryPrefix = GetNewBlobDirectoryName() + BlobDirectoryPrefix = GetNewBlobDirectoryName() }; DestinationResource ??= new BlobStorageResourceContainer(destinationContainer, options); } @@ -634,7 +634,7 @@ private async Task CreateDirectoryLongTransferAsync( BlobContainerClient destinationContainer = default, StorageResourceContainer sourceResource = default, StorageResourceContainer destinationResource = default, - TransferOptions transferOptions = default, + DataTransferOptions transferOptions = default, int transferCount = 100, long size = Constants.MB) { @@ -678,11 +678,11 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(checkpointerDirectory.DirectoryPath), - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + CheckpointerOptions = new TransferCheckpointStoreOptions(checkpointerDirectory.DirectoryPath), + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, }; TransferManager transferManager = new TransferManager(options); - TransferOptions transferOptions = new TransferOptions(); + DataTransferOptions transferOptions = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); // Add long-running job to pause, if the job is not big enough @@ -705,7 +705,7 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT // Assert await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); } [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] @@ -723,11 +723,11 @@ public async Task TryPauseTransferAsync_DataTransfer_Directory(TransferDirection await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(checkpointerDirectory.DirectoryPath), - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + CheckpointerOptions = new TransferCheckpointStoreOptions(checkpointerDirectory.DirectoryPath), + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, }; TransferManager transferManager = new TransferManager(options); - TransferOptions transferOptions = new TransferOptions(); + DataTransferOptions transferOptions = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); // Add long-running job to pause, if the job is not big enough @@ -750,7 +750,7 @@ public async Task TryPauseTransferAsync_DataTransfer_Directory(TransferDirection // Assert await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); } [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] @@ -768,11 +768,11 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(checkpointerDirectory.DirectoryPath), - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + CheckpointerOptions = new TransferCheckpointStoreOptions(checkpointerDirectory.DirectoryPath), + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, }; TransferManager transferManager = new TransferManager(options); - TransferOptions transferOptions = new TransferOptions(); + DataTransferOptions transferOptions = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); // Add long-running job to pause, if the job is not big enough @@ -795,13 +795,13 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio // Assert await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(10)); await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource2.Token); await testEventsRaised.AssertPausedCheck(); - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); } [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] @@ -819,11 +819,11 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(checkpointerDirectory.DirectoryPath), - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + CheckpointerOptions = new TransferCheckpointStoreOptions(checkpointerDirectory.DirectoryPath), + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, }; TransferManager transferManager = new TransferManager(options); - TransferOptions transferOptions = new TransferOptions(); + DataTransferOptions transferOptions = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); long size = Constants.KB * 4; int partCount = 4; @@ -852,11 +852,11 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); await testEventsRaised.AssertPausedCheck(); // Act - Resume Job - TransferOptions resumeOptions = new TransferOptions(); + DataTransferOptions resumeOptions = new DataTransferOptions(); TestEventsRaised testEventRaised2 = new TestEventsRaised(resumeOptions); DataTransfer resumeTransfer = await transferManager.ResumeTransferAsync( transferId: transfer.Id, @@ -869,7 +869,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans // Assert await testEventRaised2.AssertContainerCompletedCheck(partCount); - Assert.AreEqual(StorageTransferStatus.Completed, resumeTransfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, resumeTransfer.TransferStatus); Assert.IsTrue(resumeTransfer.HasCompleted); // Verify transfer @@ -896,11 +896,11 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) await using DisposingBlobContainer destinationContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(checkpointerDirectory.DirectoryPath), - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + CheckpointerOptions = new TransferCheckpointStoreOptions(checkpointerDirectory.DirectoryPath), + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, }; TransferManager transferManager = new TransferManager(options); - TransferOptions transferOptions = new TransferOptions(); + DataTransferOptions transferOptions = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(transferOptions); long size = Constants.KB * 4; int partCount = 4; @@ -929,11 +929,11 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); await testEventsRaised.AssertPausedCheck(); // Act - Resume Job - TransferOptions resumeOptions = new(); + DataTransferOptions resumeOptions = new(); TestEventsRaised testEventsRaised2 = new TestEventsRaised(resumeOptions); DataTransfer resumeTransfer = await transferManager.ResumeTransferAsync( transfer.Id, @@ -946,7 +946,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) // Assert await testEventsRaised2.AssertContainerCompletedCheck(partCount); - Assert.AreEqual(StorageTransferStatus.Completed, resumeTransfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, resumeTransfer.TransferStatus); Assert.IsTrue(resumeTransfer.HasCompleted); // Verify transfer @@ -964,15 +964,15 @@ public async Task PauseAllTriggersCorrectPauses() List> pausable = new(); List> unpausable = new(); TransferManager manager = new(); - foreach (StorageTransferStatus state in Enum.GetValues(typeof(StorageTransferStatus)).Cast()) + foreach (DataTransferStatus state in Enum.GetValues(typeof(DataTransferStatus)).Cast()) { - bool canPause = state == StorageTransferStatus.InProgress; + bool canPause = state == DataTransferStatus.InProgress; Mock transfer = new(MockBehavior.Loose) { CallBase = true, }; transfer.Setup(t => t.CanPause()).Returns(canPause); - transfer.Setup(t => t.PauseIfRunningAsync(_mockingToken)).Returns(Task.CompletedTask); + transfer.Setup(t => t.PauseAsync(_mockingToken)).Returns(Task.CompletedTask); if (canPause) { pausable.Add(transfer); @@ -988,7 +988,7 @@ public async Task PauseAllTriggersCorrectPauses() foreach (Mock transfer in pausable) { - transfer.Verify(t => t.PauseIfRunningAsync(_mockingToken), Times.Once()); + transfer.Verify(t => t.PauseAsync(_mockingToken), Times.Once()); } foreach (Mock transfer in pausable.Concat(unpausable)) { diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/ProgressHandlerAsserts.cs b/sdk/storage/Azure.Storage.DataMovement/tests/ProgressHandlerAsserts.cs index 553ccf9e261f2..388e7beef562c 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/ProgressHandlerAsserts.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/ProgressHandlerAsserts.cs @@ -11,7 +11,7 @@ namespace Azure.Storage.DataMovement.Tests internal static class ProgressHandlerAsserts { public static void AssertFileProgress( - IEnumerable updates, + IEnumerable updates, long fileCount, long skippedCount = 0, long failedCount = 0, @@ -32,23 +32,23 @@ public static void AssertFileProgress( continue; } - IEnumerable before = updates.Take(index); + IEnumerable before = updates.Take(index); AssertProgressUpdates(before, fileCount); - StorageTransferProgress lastBeforePause = before.Last(); + DataTransferProgress lastBeforePause = before.Last(); completed += lastBeforePause.CompletedCount; skipped += lastBeforePause.SkippedCount; failed += lastBeforePause.FailedCount; } // Grab the final set of updates (all the updates if there were no pauses) - IEnumerable finalUpdates = + IEnumerable finalUpdates = pauseIndexes.Length > 0 ? updates.Skip(pauseIndexes.Last()) : updates; AssertProgressUpdates(finalUpdates, fileCount); // Check final update for goal state - StorageTransferProgress final = finalUpdates.Last(); + DataTransferProgress final = finalUpdates.Last(); completed += final.CompletedCount; skipped += final.SkippedCount; failed += final.FailedCount; @@ -61,7 +61,7 @@ public static void AssertFileProgress( } public static void AssertBytesTransferred( - IEnumerable updates, + IEnumerable updates, long[] expectedUpdates) { IEnumerable bytesUpdates = updates.Select(x => x.BytesTransferred); @@ -77,12 +77,12 @@ public static void AssertBytesTransferred( CollectionAssert.AreEqual(expectedUpdates, actualUpdates); } - private static void AssertProgressUpdates(IEnumerable updates, long fileCount) + private static void AssertProgressUpdates(IEnumerable updates, long fileCount) { long completed = 0; long skipped = 0; long failed = 0; - foreach (StorageTransferProgress update in updates) + foreach (DataTransferProgress update in updates) { // Queued/InProgress should never be below zero or above total Assert.GreaterOrEqual(update.QueuedCount, 0); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/ProgressHandlerTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/ProgressHandlerTests.cs index 8e46b8fa267e2..a2bea0c44de33 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/ProgressHandlerTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/ProgressHandlerTests.cs @@ -114,26 +114,26 @@ private async Task TransferAndAssertProgress( int skippedCount = 0, int failedCount = 0, TransferManagerOptions transferManagerOptions = default, - TransferOptions transferOptions = default, + DataTransferOptions transferOptions = default, ProgressHandlerOptions progressHandlerOptions = default, - StorageResourceCreateMode createMode = StorageResourceCreateMode.Overwrite, + StorageResourceCreationPreference createMode = StorageResourceCreationPreference.OverwriteIfExists, int waitTime = 30) { transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; TransferManager transferManager = new TransferManager(transferManagerOptions); TestProgressHandler progressHandler = new TestProgressHandler(); - transferOptions ??= new TransferOptions(); + transferOptions ??= new DataTransferOptions(); transferOptions.ProgressHandler = progressHandler; transferOptions.ProgressHandlerOptions = progressHandlerOptions ?? new ProgressHandlerOptions() { TrackBytesTransferred = true }; - transferOptions.CreateMode = createMode; + transferOptions.CreationPreference = createMode; DataTransfer transfer = await transferManager.StartTransferAsync(source, destination, transferOptions); CancellationTokenSource tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(waitTime)); @@ -214,9 +214,9 @@ await TransferAndAssertProgress( [Test] [LiveOnly] // https://github.com/Azure/azure-sdk-for-net/issues/33082 - [TestCase(StorageResourceCreateMode.Skip)] - [TestCase(StorageResourceCreateMode.Fail)] - public async Task ProgressHandler_Conflict(StorageResourceCreateMode createMode) + [TestCase(StorageResourceCreationPreference.SkipIfExists)] + [TestCase(StorageResourceCreationPreference.FailIfExists)] + public async Task ProgressHandler_Conflict(StorageResourceCreationPreference createMode) { // Arrange using DisposingLocalDirectory source = DisposingLocalDirectory.GetTestDirectory(); @@ -239,8 +239,8 @@ await TransferAndAssertProgress( destinationResource, _expectedBytesTransferred.Take(_expectedBytesTransferred.Length - 2).ToArray(), fileCount: 5, - skippedCount: createMode == StorageResourceCreateMode.Skip ? 2 : 0, - failedCount: createMode == StorageResourceCreateMode.Fail ? 2 : 0, + skippedCount: createMode == StorageResourceCreationPreference.SkipIfExists ? 2 : 0, + failedCount: createMode == StorageResourceCreationPreference.FailIfExists ? 2 : 0, createMode: createMode); } @@ -284,10 +284,10 @@ public async Task ProgressHandler_Chunks(TransferDirection transferType) TransferManagerOptions transferManagerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.StopOnAllFailures, + ErrorHandling = DataTransferErrorMode.StopOnAnyFailure, MaximumConcurrency = 3 }; - TransferOptions transferOptions = new TransferOptions() + DataTransferOptions transferOptions = new DataTransferOptions() { InitialTransferSize = chunkSize, MaximumTransferChunkSize = chunkSize @@ -325,7 +325,7 @@ public async Task ProgressHandler_PauseResume(int delayInMs) TransferManager transferManager = new TransferManager(); TestProgressHandler progressHandler = new TestProgressHandler(); - TransferOptions transferOptions = new TransferOptions() + DataTransferOptions transferOptions = new DataTransferOptions() { ProgressHandler = progressHandler, ProgressHandlerOptions = new ProgressHandlerOptions() @@ -344,7 +344,7 @@ public async Task ProgressHandler_PauseResume(int delayInMs) // Pause transfer CancellationTokenSource tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); await transferManager.PauseTransferIfRunningAsync(transfer.Id, tokenSource.Token); - Assert.AreEqual(StorageTransferStatus.Paused, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Paused, transfer.TransferStatus); // Record the current number of progress updates to use during assertions int pause = progressHandler.Updates.Count; @@ -360,7 +360,7 @@ public async Task ProgressHandler_PauseResume(int delayInMs) await resumeTransfer.WaitForCompletionAsync(tokenSource.Token); // Assert - Assert.AreEqual(StorageTransferStatus.Completed, resumeTransfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, resumeTransfer.TransferStatus); ProgressHandlerAsserts.AssertFileProgress(progressHandler.Updates, 5, pauseIndexes: pause); ProgressHandlerAsserts.AssertBytesTransferred(progressHandler.Updates, _expectedBytesTransferred); } diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/RehydrateStorageResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/RehydrateStorageResourceTests.cs index 2239cf8bfdf94..6b29e052140da 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/RehydrateStorageResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/RehydrateStorageResourceTests.cs @@ -65,7 +65,7 @@ private static Mock GetProperties( { var mock = new Mock(MockBehavior.Strict); mock.Setup(p => p.TransferId).Returns(transferId); - mock.Setup(p => p.Checkpointer).Returns(new TransferCheckpointerOptions(checkpointerPath)); + mock.Setup(p => p.Checkpointer).Returns(new TransferCheckpointStoreOptions(checkpointerPath)); mock.Setup(p => p.SourcePath).Returns(sourcePath); mock.Setup(p => p.DestinationPath).Returns(destinationPath); mock.Setup(p => p.SourceTypeId).Returns(sourceResourceId); @@ -154,7 +154,7 @@ private StorageResource LocalStorageResourcesInlineTryGet(DataTransferProperties { return null; } - return getSource ? sourceProvider.MakeResource() : destinationProvider.MakeResource(); + return getSource ? sourceProvider.CreateResource() : destinationProvider.CreateResource(); } [Test] @@ -194,7 +194,7 @@ await AddJobPartToCheckpointer( { RehydrateApi.ResourceStaticApi => LocalFileStorageResource.RehydrateResource(transferProperties, isSource), RehydrateApi.ProviderInstance => (LocalFileStorageResource)new LocalStorageResourceProvider( - transferProperties, isSource, isFolder: false).MakeResource(), + transferProperties, isSource, isFolder: false).CreateResource(), RehydrateApi.PublicStaticApi => (LocalFileStorageResource)LocalStorageResourcesInlineTryGet( transferProperties, isSource), _ => throw new ArgumentException("Unrecognized test parameter"), @@ -250,7 +250,7 @@ await AddJobPartToCheckpointer( { RehydrateApi.ResourceStaticApi => LocalDirectoryStorageResourceContainer.RehydrateResource(transferProperties, isSource), RehydrateApi.ProviderInstance => (LocalDirectoryStorageResourceContainer)new LocalStorageResourceProvider( - transferProperties, isSource, isFolder: true).MakeResource(), + transferProperties, isSource, isFolder: true).CreateResource(), RehydrateApi.PublicStaticApi => (LocalDirectoryStorageResourceContainer)LocalStorageResourcesInlineTryGet( transferProperties, isSource), _ => throw new ArgumentException("Unrecognized test parameter"), diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/CheckpointerTesting.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/CheckpointerTesting.cs index 354677c3d6b8c..0e28efccc35d2 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/CheckpointerTesting.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/CheckpointerTesting.cs @@ -43,8 +43,8 @@ internal static readonly DateTimeOffset DefaultStartTime internal const JobPartDeleteSnapshotsOption DefaultDeleteSnapshotsOption = JobPartDeleteSnapshotsOption.None; internal const JobPartPermanentDeleteOption DefaultPermanentDeleteOption = JobPartPermanentDeleteOption.None; internal const JobPartPlanRehydratePriorityType DefaultRehydratePriorityType = JobPartPlanRehydratePriorityType.None; - internal const StorageTransferStatus DefaultJobStatus = StorageTransferStatus.Queued; - internal const StorageTransferStatus DefaultPartStatus = StorageTransferStatus.Queued; + internal const DataTransferStatus DefaultJobStatus = DataTransferStatus.Queued; + internal const DataTransferStatus DefaultPartStatus = DataTransferStatus.Queued; internal static JobPartPlanHeader CreateDefaultJobPartHeader( string version = DataMovementConstants.PlanFile.SchemaVersion, @@ -92,8 +92,8 @@ internal static JobPartPlanHeader CreateDefaultJobPartHeader( JobPartDeleteSnapshotsOption deleteSnapshotsOption = DefaultDeleteSnapshotsOption, JobPartPermanentDeleteOption permanentDeleteOption = DefaultPermanentDeleteOption, JobPartPlanRehydratePriorityType rehydratePriorityType = DefaultRehydratePriorityType, - StorageTransferStatus atomicJobStatus = DefaultJobStatus, - StorageTransferStatus atomicPartStatus = DefaultPartStatus) + DataTransferStatus atomicJobStatus = DefaultJobStatus, + DataTransferStatus atomicPartStatus = DefaultPartStatus) { if (startTime == default) { diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferCheckpointerTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferCheckpointerTests.cs index 8660ede55becb..108e47e04b5d9 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferCheckpointerTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferCheckpointerTests.cs @@ -66,18 +66,18 @@ public async Task CheckpointerWithSasAsync() .GetBlobContainerClient(containerName) .GetBlockBlobClient(destinationBlobName)); - StorageResourceSingle sourceResource = new BlockBlobStorageResource(sasSourceBlob); - StorageResourceSingle destinationResource = new BlockBlobStorageResource(sasDestinationBlob); + StorageResourceItem sourceResource = new BlockBlobStorageResource(sasSourceBlob); + StorageResourceItem destinationResource = new BlockBlobStorageResource(sasDestinationBlob); TransferManagerOptions managerOptions = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(disposingLocalDirectory.DirectoryPath) + CheckpointerOptions = new TransferCheckpointStoreOptions(disposingLocalDirectory.DirectoryPath) }; TransferManager transferManager = new TransferManager(managerOptions); - TransferOptions transferOptions = new TransferOptions() + DataTransferOptions transferOptions = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; // Start transfer and await for completion. This transfer will fail @@ -126,18 +126,18 @@ public async Task CheckpointerMismatch_Source() string destinationBlobName = GetNewBlobName(); BlockBlobClient destinationBlob = await CreateBlockBlob(test.Container, Path.GetTempFileName(), destinationBlobName, Constants.KB * 4); - StorageResourceSingle sourceResource = new BlockBlobStorageResource(sourceBlob); - StorageResourceSingle destinationResource = new BlockBlobStorageResource(destinationBlob); + StorageResourceItem sourceResource = new BlockBlobStorageResource(sourceBlob); + StorageResourceItem destinationResource = new BlockBlobStorageResource(destinationBlob); TransferManagerOptions managerOptions = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(disposingLocalDirectory.DirectoryPath) + CheckpointerOptions = new TransferCheckpointStoreOptions(disposingLocalDirectory.DirectoryPath) }; TransferManager transferManager = new TransferManager(managerOptions); - TransferOptions transferOptions = new TransferOptions() + DataTransferOptions transferOptions = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; // Start transfer and await for completion. @@ -151,7 +151,7 @@ public async Task CheckpointerMismatch_Source() // Act/Assert - resume transfer with wrong source resource. BlockBlobClient newSourceBlob = test.Container.GetBlockBlobClient(GetNewBlobName()); - StorageResourceSingle wrongSourceResource = new BlockBlobStorageResource(newSourceBlob); + StorageResourceItem wrongSourceResource = new BlockBlobStorageResource(newSourceBlob); Assert.CatchAsync( async () => await transferManager.ResumeTransferAsync( @@ -180,18 +180,18 @@ public async Task CheckpointerMismatch_Destination() string destinationBlobName = GetNewBlobName(); BlockBlobClient destinationBlob = await CreateBlockBlob(test.Container, Path.GetTempFileName(), destinationBlobName, Constants.KB * 4); - StorageResourceSingle sourceResource = new BlockBlobStorageResource(sourceBlob); - StorageResourceSingle destinationResource = new BlockBlobStorageResource(destinationBlob); + StorageResourceItem sourceResource = new BlockBlobStorageResource(sourceBlob); + StorageResourceItem destinationResource = new BlockBlobStorageResource(destinationBlob); TransferManagerOptions managerOptions = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(disposingLocalDirectory.DirectoryPath) + CheckpointerOptions = new TransferCheckpointStoreOptions(disposingLocalDirectory.DirectoryPath) }; TransferManager transferManager = new TransferManager(managerOptions); - TransferOptions transferOptions = new TransferOptions() + DataTransferOptions transferOptions = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; // Start transfer and await for completion. @@ -205,7 +205,7 @@ public async Task CheckpointerMismatch_Destination() // Act/Assert - resume transfer with wrong destination resource. BlockBlobClient newDestinationBlob = test.Container.GetBlockBlobClient(GetNewBlobName()); - StorageResourceSingle wrongDestinationResource = new BlockBlobStorageResource(newDestinationBlob); + StorageResourceItem wrongDestinationResource = new BlockBlobStorageResource(newDestinationBlob); Assert.CatchAsync( async () => await transferManager.ResumeTransferAsync( @@ -234,18 +234,18 @@ public async Task CheckpointerMismatch_CreateMode_Overwrite() string destinationBlobName = GetNewBlobName(); BlockBlobClient destinationBlob = await CreateBlockBlob(test.Container, Path.GetTempFileName(), destinationBlobName, Constants.KB * 4); - StorageResourceSingle sourceResource = new BlockBlobStorageResource(sourceBlob); - StorageResourceSingle destinationResource = new BlockBlobStorageResource(destinationBlob); + StorageResourceItem sourceResource = new BlockBlobStorageResource(sourceBlob); + StorageResourceItem destinationResource = new BlockBlobStorageResource(destinationBlob); TransferManagerOptions managerOptions = new TransferManagerOptions() { - CheckpointerOptions = new TransferCheckpointerOptions(disposingLocalDirectory.DirectoryPath) + CheckpointerOptions = new TransferCheckpointStoreOptions(disposingLocalDirectory.DirectoryPath) }; TransferManager transferManager = new TransferManager(managerOptions); - TransferOptions transferOptions = new TransferOptions() + DataTransferOptions transferOptions = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; // Start transfer and await for completion. @@ -258,9 +258,9 @@ public async Task CheckpointerMismatch_CreateMode_Overwrite() await transfer.WaitForCompletionAsync(cancellationTokenSource.Token).ConfigureAwait(false); // Act/Assert - resume transfer with wrong CreateMode Resource - TransferOptions resumeTransferOptions = new TransferOptions() + DataTransferOptions resumeTransferOptions = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; Assert.CatchAsync( @@ -271,7 +271,7 @@ public async Task CheckpointerMismatch_CreateMode_Overwrite() resumeTransferOptions), Errors.MismatchResumeCreateMode( false, - StorageResourceCreateMode.Overwrite).Message); + StorageResourceCreationPreference.OverwriteIfExists).Message); } } } diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferDownloadDirectoryTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferDownloadDirectoryTests.cs index bec270bd110c8..e3c7b3212169e 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferDownloadDirectoryTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferDownloadDirectoryTests.cs @@ -48,22 +48,22 @@ private async Task DownloadBlobDirectoryAndVerify( string destinationLocalPath, int waitTimeInSec = 30, TransferManagerOptions transferManagerOptions = default, - TransferOptions options = default) + DataTransferOptions options = default) { // Set transfer options - options ??= new TransferOptions(); + options ??= new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; // Initialize transferManager TransferManager transferManager = new TransferManager(transferManagerOptions); StorageResourceContainer sourceResource = - new BlobStorageResourceContainer(sourceContainer, new() { DirectoryPrefix = sourceBlobPrefix }); + new BlobStorageResourceContainer(sourceContainer, new() { BlobDirectoryPrefix = sourceBlobPrefix }); StorageResourceContainer destinationResource = new LocalDirectoryStorageResourceContainer(destinationLocalPath); @@ -75,7 +75,7 @@ private async Task DownloadBlobDirectoryAndVerify( await testEventsRaised.AssertContainerCompletedCheck(sourceFiles.Count); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); // List all files in source blob folder path List blobNames = new List(); @@ -208,11 +208,11 @@ public async Task DownloadDirectoryAsync_Empty() // Initialize transferManager TransferManager transferManager = new TransferManager(); - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised testEventRaised = new TestEventsRaised(options); StorageResourceContainer sourceResource = - new BlobStorageResourceContainer(test.Container, new() { DirectoryPrefix = sourceBlobDirectoryName }); + new BlobStorageResourceContainer(test.Container, new() { BlobDirectoryPrefix = sourceBlobDirectoryName }); StorageResourceContainer destinationResource = new LocalDirectoryStorageResourceContainer(destinationFolder); @@ -221,7 +221,7 @@ public async Task DownloadDirectoryAsync_Empty() await transfer.WaitForCompletionAsync(cancellationTokenSource.Token); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); List localItemsAfterDownload = Directory.GetFiles(destinationFolder, "*", SearchOption.AllDirectories).ToList(); @@ -382,10 +382,10 @@ public async Task DownloadDirectoryAsync_SmallChunks_ManyFiles() TransferManagerOptions transferManagerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.StopOnAllFailures, + ErrorHandling = DataTransferErrorMode.StopOnAnyFailure, MaximumConcurrency = 3 }; - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = 512, MaximumTransferChunkSize = 512 @@ -464,7 +464,7 @@ private async Task CreateStartTransfer( BlobContainerClient containerClient, string destinationFolder, int concurrency, - TransferOptions options = default, + DataTransferOptions options = default, int size = Constants.KB) { // Arrange @@ -473,7 +473,7 @@ private async Task CreateStartTransfer( await CreateBlobDirectoryTree(containerClient, sourceFolderPath, sourceBlobPrefix, size); // Create storage resources - StorageResourceContainer sourceResource = new BlobStorageResourceContainer(containerClient, new() { DirectoryPrefix = sourceBlobPrefix }); + StorageResourceContainer sourceResource = new BlobStorageResourceContainer(containerClient, new() { BlobDirectoryPrefix = sourceBlobPrefix }); StorageResourceContainer destinationResource = new LocalDirectoryStorageResourceContainer(destinationFolder); // Create Transfer Manager with single threaded operation @@ -500,7 +500,7 @@ public async Task StartTransfer_AwaitCompletion() string destinationFolder = CreateRandomDirectory(testDirectory.DirectoryPath); // Create transfer to do a AwaitCompletion - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); DataTransfer transfer = await CreateStartTransfer( test.Container, @@ -515,7 +515,7 @@ public async Task StartTransfer_AwaitCompletion() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); await testEventsRaised.AssertContainerCompletedCheck(4); } @@ -528,9 +528,9 @@ public async Task StartTransfer_AwaitCompletion_Failed() using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); string destinationFolder = CreateRandomDirectory(testDirectory.DirectoryPath); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -551,7 +551,7 @@ public async Task StartTransfer_AwaitCompletion_Failed() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("Cannot overwrite file.")); await testEventsRaised.AssertContainerCompletedWithFailedCheck(1); } @@ -566,9 +566,9 @@ public async Task StartTransfer_AwaitCompletion_Skipped() string destinationFolder = CreateRandomDirectory(testDirectory.DirectoryPath); // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip + CreationPreference = StorageResourceCreationPreference.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -589,7 +589,7 @@ public async Task StartTransfer_AwaitCompletion_Skipped() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); await testEventsRaised.AssertContainerCompletedWithSkippedCheck(1); } @@ -603,7 +603,7 @@ public async Task StartTransfer_EnsureCompleted() string destinationFolder = CreateRandomDirectory(testDirectory.DirectoryPath); // Create transfer to do a EnsureCompleted - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); DataTransfer transfer = await CreateStartTransfer( @@ -614,12 +614,12 @@ public async Task StartTransfer_EnsureCompleted() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); await testEventsRaised.AssertContainerCompletedCheck(4); } @@ -632,9 +632,9 @@ public async Task StartTransfer_EnsureCompleted_Failed() using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); string destinationFolder = CreateRandomDirectory(testDirectory.DirectoryPath); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -650,12 +650,12 @@ public async Task StartTransfer_EnsureCompleted_Failed() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("Cannot overwrite file.")); await testEventsRaised.AssertContainerCompletedWithFailedCheck(1); } @@ -670,9 +670,9 @@ public async Task StartTransfer_EnsureCompleted_Skipped() string destinationFolder = CreateRandomDirectory(testDirectory.DirectoryPath); // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip + CreationPreference = StorageResourceCreationPreference.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -688,12 +688,12 @@ public async Task StartTransfer_EnsureCompleted_Skipped() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); await testEventsRaised.AssertContainerCompletedWithSkippedCheck(1); } @@ -706,9 +706,9 @@ public async Task StartTransfer_EnsureCompleted_Failed_SmallChunks() using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); string destinationFolder = CreateRandomDirectory(testDirectory.DirectoryPath); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail, + CreationPreference = StorageResourceCreationPreference.FailIfExists, InitialTransferSize = 512, MaximumTransferChunkSize = 512 }; @@ -727,12 +727,12 @@ public async Task StartTransfer_EnsureCompleted_Failed_SmallChunks() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("Cannot overwrite file.")); await testEventsRaised.AssertContainerCompletedWithFailedCheck(1); } diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferDownloadTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferDownloadTests.cs index 2787ab92d2baa..ee0478b07accf 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferDownloadTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferDownloadTests.cs @@ -73,7 +73,7 @@ private async Task DownloadBlockBlobsAndVerify( int blobCount = 1, TransferManagerOptions transferManagerOptions = default, List blobNames = default, - List options = default) + List options = default) { using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); // Populate blobNames list for number of blobs to be created @@ -96,7 +96,7 @@ private async Task DownloadBlockBlobsAndVerify( transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; List downloadedBlobInfo = new List(blobCount); @@ -114,10 +114,10 @@ private async Task DownloadBlockBlobsAndVerify( await CreateBlockBlob(container, localSourceFile, blobNames[i], size); // Set up event handler for the respective blob - options[i].TransferStatus += (TransferStatusEventArgs args) => + options[i].TransferStatusChanged += (TransferStatusEventArgs args) => { // Assert - if (args.StorageTransferStatus == StorageTransferStatus.Completed) + if (args.StorageTransferStatus == DataTransferStatus.Completed) { completed = true; } @@ -147,8 +147,8 @@ private async Task DownloadBlockBlobsAndVerify( BlobName = blobNames[i] }; BlockBlobClient sourceBlobClient = InstrumentClient(new BlockBlobClient(blobUriBuilder.ToUri(), credential, GetOptions(true))); - StorageResourceSingle sourceResource = new BlockBlobStorageResource(sourceBlobClient); - StorageResourceSingle destinationResource = new LocalFileStorageResource(downloadedBlobInfo[i].DestinationLocalPath); + StorageResourceItem sourceResource = new BlockBlobStorageResource(sourceBlobClient); + StorageResourceItem destinationResource = new LocalFileStorageResource(downloadedBlobInfo[i].DestinationLocalPath); // Act DataTransfer transfer = await transferManager.StartTransferAsync( @@ -169,7 +169,7 @@ private async Task DownloadBlockBlobsAndVerify( // Verify Download await downloadedBlobInfo[i].EventsRaised.AssertSingleCompletedCheck(); - Assert.AreEqual(StorageTransferStatus.Completed, downloadedBlobInfo[i].DataTransfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, downloadedBlobInfo[i].DataTransfer.TransferStatus); CheckDownloadFile(downloadedBlobInfo[i].SourceLocalPath, downloadedBlobInfo[i].DestinationLocalPath); }; } @@ -204,11 +204,11 @@ public async Task BlockBlobToLocal_Overwrite_Exists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List { options }; + List optionsList = new List { options }; await DownloadBlockBlobsAndVerify( testContainer.Container, waitTimeInSec: 10, @@ -226,11 +226,11 @@ public async Task BlockBlobToLocal_Overwrite_NotExists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List { options }; + List optionsList = new List { options }; await DownloadBlockBlobsAndVerify( testContainer.Container, waitTimeInSec: 10, @@ -258,11 +258,11 @@ public async Task BlockBlobToLocal_Skip_Exists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip, + CreationPreference = StorageResourceCreationPreference.SkipIfExists, }; - options.TransferSkipped += (TransferSkippedEventArgs args) => + options.ItemTransferSkipped += (TransferItemSkippedEventArgs args) => { if (args.SourceResource != null && args.DestinationResource != null && @@ -285,7 +285,7 @@ public async Task BlockBlobToLocal_Skip_Exists() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); Assert.IsTrue(skippedSeen); FileInfo destFileInfo = new FileInfo(destFile); Assert.IsTrue(destFileInfo.Length == 0); @@ -307,13 +307,13 @@ public async Task BlockBlobToLocal_Failure_Exists() // Act // Create options bag to fail and keep track of the failure. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail, + CreationPreference = StorageResourceCreationPreference.FailIfExists, }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); - StorageResourceSingle sourceResource = new BlockBlobStorageResource(sourceClient); - StorageResourceSingle destinationResource = new LocalFileStorageResource(destFile); + StorageResourceItem sourceResource = new BlockBlobStorageResource(sourceClient); + StorageResourceItem destinationResource = new LocalFileStorageResource(destFile); TransferManager transferManager = new TransferManager(); // Start transfer and await for completion. @@ -327,7 +327,7 @@ public async Task BlockBlobToLocal_Failure_Exists() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); await testEventsRaised.AssertSingleFailedCheck(); FileInfo destFileInfo = new FileInfo(destFile); Assert.IsTrue(destFileInfo.Length == 0); @@ -340,7 +340,7 @@ public async Task BlockBlobToLocal_SmallChunk() { long size = Constants.KB; int waitTimeInSec = 25; - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = 100, MaximumTransferChunkSize = 200, @@ -349,7 +349,7 @@ public async Task BlockBlobToLocal_SmallChunk() // Arrange await using DisposingBlobContainer testContainer = await GetTestContainerAsync(); - List optionsList = new List() { options }; + List optionsList = new List() { options }; await DownloadBlockBlobsAndVerify( testContainer.Container, waitTimeInSec: waitTimeInSec, @@ -435,19 +435,19 @@ public async Task BlockBlobToLocal_SmallConcurrency(int concurrency, int size, i { TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; // Arrange await using DisposingBlobContainer testContainer = await GetTestContainerAsync(); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = 512, MaximumTransferChunkSize = 512, }; - List optionsList = new List() { options }; + List optionsList = new List() { options }; await DownloadBlockBlobsAndVerify( testContainer.Container, @@ -468,7 +468,7 @@ public async Task BlockBlobToLocal_LargeConcurrency(int concurrency, int size, i { TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; @@ -500,7 +500,7 @@ private async Task DownloadAppendBlobsAndVerify( int blobCount = 1, TransferManagerOptions transferManagerOptions = default, List blobNames = default, - List options = default) + List options = default) { using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); @@ -524,7 +524,7 @@ private async Task DownloadAppendBlobsAndVerify( transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; List downloadedBlobInfo = new List(blobCount); @@ -565,8 +565,8 @@ private async Task DownloadAppendBlobsAndVerify( BlobName = blobNames[i] }; AppendBlobClient sourceBlobClient = InstrumentClient(new AppendBlobClient(blobUriBuilder.ToUri(), credential, GetOptions(true))); - StorageResourceSingle sourceResource = new AppendBlobStorageResource(sourceBlobClient); - StorageResourceSingle destinationResource = new LocalFileStorageResource(downloadedBlobInfo[i].DestinationLocalPath); + StorageResourceItem sourceResource = new AppendBlobStorageResource(sourceBlobClient); + StorageResourceItem destinationResource = new LocalFileStorageResource(downloadedBlobInfo[i].DestinationLocalPath); // Act DataTransfer transfer = await transferManager.StartTransferAsync( @@ -621,11 +621,11 @@ public async Task AppendBlobToLocal_Overwrite_Exists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List { options }; + List optionsList = new List { options }; await DownloadAppendBlobsAndVerify( testContainer.Container, waitTimeInSec: 10, @@ -643,11 +643,11 @@ public async Task AppendBlobToLocal_Overwrite_NotExists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List { options }; + List optionsList = new List { options }; await DownloadAppendBlobsAndVerify( testContainer.Container, waitTimeInSec: 10, @@ -674,9 +674,9 @@ public async Task AppendBlobToLocal_Skip_Exists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip, + CreationPreference = StorageResourceCreationPreference.SkipIfExists, }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); TransferManager transferManager = new TransferManager(); @@ -692,7 +692,7 @@ public async Task AppendBlobToLocal_Skip_Exists() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); await testEventsRaised.AssertSingleSkippedCheck(); FileInfo destFileInfo = new FileInfo(destFile); Assert.IsTrue(destFileInfo.Length == 0); @@ -715,13 +715,13 @@ public async Task AppendBlobToLocal_Failure_Exists() // Act // Create options bag to fail and keep track of the failure. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail, + CreationPreference = StorageResourceCreationPreference.FailIfExists, }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); - StorageResourceSingle sourceResource = new AppendBlobStorageResource(sourceClient); - StorageResourceSingle destinationResource = new LocalFileStorageResource(destFile); + StorageResourceItem sourceResource = new AppendBlobStorageResource(sourceClient); + StorageResourceItem destinationResource = new LocalFileStorageResource(destFile); TransferManager transferManager = new TransferManager(); // Start transfer and await for completion. @@ -735,7 +735,7 @@ public async Task AppendBlobToLocal_Failure_Exists() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); await testEventsRaised.AssertSingleFailedCheck(); FileInfo destFileInfo = new FileInfo(destFile); Assert.IsTrue(destFileInfo.Length == 0); @@ -763,14 +763,14 @@ public async Task AppendBlobToLocal_FailedEvent() // Act - Attempt a transfer even though the destination already exists. TransferManager transferManager = new TransferManager(); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail, + CreationPreference = StorageResourceCreationPreference.FailIfExists, }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); - StorageResourceSingle sourceResource = new AppendBlobStorageResource(sourceClient); - StorageResourceSingle destinationResource = new LocalFileStorageResource(destFile); + StorageResourceItem sourceResource = new AppendBlobStorageResource(sourceClient); + StorageResourceItem destinationResource = new LocalFileStorageResource(destFile); DataTransfer transfer = await transferManager.StartTransferAsync( sourceResource, @@ -792,9 +792,9 @@ public async Task AppendBlobToLocal_SmallSize(long size, int waitTimeInSec) // Arrange await using DisposingBlobContainer testContainer = await GetTestContainerAsync(); - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); - List optionsList = new List() { options }; + List optionsList = new List() { options }; await DownloadAppendBlobsAndVerify( testContainer.Container, size: size, @@ -817,9 +817,9 @@ public async Task AppendBlobToLocal_LargeSize(long size, int waitTimeInSec) await using DisposingBlobContainer testContainer = await GetTestContainerAsync(); string exceptionMessage = default; - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); - List optionsList = new List() { options }; + List optionsList = new List() { options }; await DownloadAppendBlobsAndVerify( testContainer.Container, size: size, @@ -879,7 +879,7 @@ public async Task AppendBlobToLocal_SmallChunk() // and run through. long size = Constants.KB; int waitTimeInSec = 25; - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = 100, MaximumTransferChunkSize = 200, @@ -888,7 +888,7 @@ public async Task AppendBlobToLocal_SmallChunk() // Arrange await using DisposingBlobContainer testContainer = await GetTestContainerAsync(); - List optionsList = new List() { options }; + List optionsList = new List() { options }; await DownloadBlockBlobsAndVerify( testContainer.Container, waitTimeInSec: waitTimeInSec, @@ -907,7 +907,7 @@ public async Task AppendBlobToLocal_SmallConcurrency(int concurrency, int size, { TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; @@ -934,7 +934,7 @@ public async Task AppendBlobToLocal_LargeConcurrency(int concurrency, int size, { TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; @@ -966,7 +966,7 @@ private async Task DownloadPageBlobsAndVerify( int blobCount = 1, TransferManagerOptions transferManagerOptions = default, List blobNames = default, - List options = default) + List options = default) { using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); // Populate blobNames list for number of blobs to be created @@ -989,7 +989,7 @@ private async Task DownloadPageBlobsAndVerify( transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; List downloadedBlobInfo = new List(blobCount); @@ -1029,8 +1029,8 @@ private async Task DownloadPageBlobsAndVerify( BlobName = blobNames[i] }; PageBlobClient sourceBlobClient = InstrumentClient(new PageBlobClient(blobUriBuilder.ToUri(), credential, GetOptions(true))); - StorageResourceSingle sourceResource = new PageBlobStorageResource(sourceBlobClient); - StorageResourceSingle destinationResource = new LocalFileStorageResource(downloadedBlobInfo[i].DestinationLocalPath); + StorageResourceItem sourceResource = new PageBlobStorageResource(sourceBlobClient); + StorageResourceItem destinationResource = new LocalFileStorageResource(downloadedBlobInfo[i].DestinationLocalPath); // Act DataTransfer transfer = await TransferManager.StartTransferAsync( @@ -1080,11 +1080,11 @@ public async Task PageBlobToLocal_Overwrite_Exists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List { options }; + List optionsList = new List { options }; await DownloadPageBlobsAndVerify( testContainer.Container, waitTimeInSec: 10, @@ -1102,11 +1102,11 @@ public async Task PageBlobToLocal_Overwrite_NotExists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List { options }; + List optionsList = new List { options }; await DownloadPageBlobsAndVerify( testContainer.Container, waitTimeInSec: 10, @@ -1134,9 +1134,9 @@ public async Task PageBlobToLocal_Skip_Exists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip, + CreationPreference = StorageResourceCreationPreference.SkipIfExists, }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); TransferManager transferManager = new TransferManager(); @@ -1152,7 +1152,7 @@ public async Task PageBlobToLocal_Skip_Exists() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); await testEventsRaised.AssertSingleSkippedCheck(); FileInfo destFileInfo = new FileInfo(destFile); Assert.IsTrue(destFileInfo.Length == 0); @@ -1175,13 +1175,13 @@ public async Task PageBlobToLocal_Failure_Exists() // Act // Create options bag to fail and keep track of the failure. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail, + CreationPreference = StorageResourceCreationPreference.FailIfExists, }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); - StorageResourceSingle sourceResource = new PageBlobStorageResource(sourceClient); - StorageResourceSingle destinationResource = new LocalFileStorageResource(destFile); + StorageResourceItem sourceResource = new PageBlobStorageResource(sourceClient); + StorageResourceItem destinationResource = new LocalFileStorageResource(destFile); TransferManager transferManager = new TransferManager(); // Start transfer and await for completion. @@ -1195,7 +1195,7 @@ public async Task PageBlobToLocal_Failure_Exists() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); await testEventsRaised.AssertSingleFailedCheck(); FileInfo destFileInfo = new FileInfo(destFile); Assert.IsTrue(destFileInfo.Length == 0); @@ -1208,7 +1208,7 @@ public async Task PageBlobToLocal_SmallChunk() { long size = 12 * Constants.KB; int waitTimeInSec = 25; - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = Constants.KB, MaximumTransferChunkSize = Constants.KB, @@ -1217,7 +1217,7 @@ public async Task PageBlobToLocal_SmallChunk() // Arrange await using DisposingBlobContainer testContainer = await GetTestContainerAsync(); - List optionsList = new List() { options }; + List optionsList = new List() { options }; await DownloadPageBlobsAndVerify( testContainer.Container, waitTimeInSec: waitTimeInSec, @@ -1302,16 +1302,16 @@ public async Task PageBlobToLocal_SmallConcurrency(int concurrency, int size, in { TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = 512, MaximumTransferChunkSize = 512, }; - List optionsList = new List() { options }; + List optionsList = new List() { options }; // Arrange await using DisposingBlobContainer testContainer = await GetTestContainerAsync(); @@ -1335,7 +1335,7 @@ public async Task PageBlobToLocal_LargeConcurrency(int concurrency, int size, in { TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; @@ -1355,7 +1355,7 @@ private async Task CreateStartTransfer( string localDirectoryPath, int concurrency, bool createFailedCondition = false, - TransferOptions options = default, + DataTransferOptions options = default, int size = Constants.KB) { // Arrange @@ -1374,8 +1374,8 @@ private async Task CreateStartTransfer( // Create new source block blob. string newSourceFile = Path.Combine(localDirectoryPath, sourceBlobName); BlockBlobClient blockBlobClient = await CreateBlockBlob(containerClient, newSourceFile, sourceBlobName, size); - StorageResourceSingle sourceResource = new BlockBlobStorageResource(blockBlobClient); - StorageResourceSingle destinationResource = new LocalFileStorageResource(destFile); + StorageResourceItem sourceResource = new BlockBlobStorageResource(blockBlobClient); + StorageResourceItem destinationResource = new LocalFileStorageResource(destFile); // Create Transfer Manager with single threaded operation TransferManagerOptions managerOptions = new TransferManagerOptions() @@ -1399,7 +1399,7 @@ public async Task StartTransfer_AwaitCompletion() using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); // Create transfer to do a AwaitCompletion - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised failureTransferHolder = new TestEventsRaised(options); DataTransfer transfer = await CreateStartTransfer( containerClient: test.Container, @@ -1415,7 +1415,7 @@ public async Task StartTransfer_AwaitCompletion() failureTransferHolder.AssertUnexpectedFailureCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); } [RecordedTest] @@ -1425,9 +1425,9 @@ public async Task StartTransfer_AwaitCompletion_Failed() await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: Storage.Blobs.Models.PublicAccessType.BlobContainer); using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventRaised = new TestEventsRaised(options); @@ -1446,7 +1446,7 @@ public async Task StartTransfer_AwaitCompletion_Failed() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); await testEventRaised.AssertSingleFailedCheck(); Assert.AreEqual(1, testEventRaised.FailedEvents.Count); Assert.IsTrue(testEventRaised.FailedEvents.First().Exception.Message.Contains("Cannot overwrite file.")); @@ -1460,9 +1460,9 @@ public async Task StartTransfer_AwaitCompletion_Skipped() using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip + CreationPreference = StorageResourceCreationPreference.SkipIfExists }; TestEventsRaised testEventRaised = new TestEventsRaised(options); @@ -1481,7 +1481,7 @@ public async Task StartTransfer_AwaitCompletion_Skipped() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); await testEventRaised.AssertSingleSkippedCheck(); } @@ -1493,9 +1493,9 @@ public async Task StartTransfer_EnsureCompleted() using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); // Create transfer to do a EnsureCompleted - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventRaised = new TestEventsRaised(options); @@ -1508,13 +1508,13 @@ public async Task StartTransfer_EnsureCompleted() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert testEventRaised.AssertUnexpectedFailureCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); } [RecordedTest] @@ -1524,9 +1524,9 @@ public async Task StartTransfer_EnsureCompleted_Failed() await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: Storage.Blobs.Models.PublicAccessType.BlobContainer); using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -1540,12 +1540,12 @@ public async Task StartTransfer_EnsureCompleted_Failed() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); await testEventsRaised.AssertSingleFailedCheck(); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("Cannot overwrite file.")); } @@ -1558,9 +1558,9 @@ public async Task StartTransfer_EnsureCompleted_Skipped() using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip + CreationPreference = StorageResourceCreationPreference.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -1574,13 +1574,13 @@ public async Task StartTransfer_EnsureCompleted_Skipped() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert await testEventsRaised.AssertSingleSkippedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); } #endregion } diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferSyncCopyDirectoryTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferSyncCopyDirectoryTests.cs index fbbfd6ba15af8..56e367a2cd120 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferSyncCopyDirectoryTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferSyncCopyDirectoryTests.cs @@ -47,27 +47,27 @@ private async Task CopyBlobDirectoryAndVerify( List sourceFiles, int waitTimeInSec = 30, TransferManagerOptions transferManagerOptions = default, - TransferOptions options = default) + DataTransferOptions options = default) { // Set transfer options - options ??= new TransferOptions(); + options ??= new DataTransferOptions(); TestEventsRaised testEventFailed = new TestEventsRaised(options); transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; // Initialize transferManager TransferManager transferManager = new TransferManager(transferManagerOptions); StorageResourceContainer sourceResource = - new BlobStorageResourceContainer(container, new() { DirectoryPrefix = sourceBlobPrefix }); + new BlobStorageResourceContainer(container, new() { BlobDirectoryPrefix = sourceBlobPrefix }); StorageResourceContainer destinationResource = new BlobStorageResourceContainer(container, new BlobStorageResourceContainerOptions() { - DirectoryPrefix = destinationBlobPrefix, + BlobDirectoryPrefix = destinationBlobPrefix, }); DataTransfer transfer = await transferManager.StartTransferAsync(sourceResource, destinationResource, options); @@ -78,7 +78,7 @@ private async Task CopyBlobDirectoryAndVerify( await testEventFailed.AssertContainerCompletedCheck(sourceFiles.Count); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); // List all files in source blob folder path List sourceblobNames = new List(); @@ -223,20 +223,20 @@ public async Task BlockBlobDirectoryToDirectory_EmptyFolder() string folder = CreateRandomDirectory(testDirectory.DirectoryPath); // Set up destination client - StorageResourceContainer destinationResource = new BlobStorageResourceContainer(test.Container, new() { DirectoryPrefix = dirName }); + StorageResourceContainer destinationResource = new BlobStorageResourceContainer(test.Container, new() { BlobDirectoryPrefix = dirName }); StorageResourceContainer sourceResource = new BlobStorageResourceContainer(test.Container, new BlobStorageResourceContainerOptions() { - DirectoryPrefix = dirName2, + BlobDirectoryPrefix = dirName2, }); TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = 1, }; TransferManager transferManager = new TransferManager(managerOptions); - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); // Act @@ -245,7 +245,7 @@ public async Task BlockBlobDirectoryToDirectory_EmptyFolder() CancellationTokenSource tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); await transfer.WaitForCompletionAsync(tokenSource.Token); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); // Assert List blobs = ((List)await test.Container.GetBlobsAsync().ToListAsync()) @@ -384,9 +384,9 @@ public async Task BlockBlobDirectoryToDirectory_OverwriteTrue() await CreateBlockBlobAndSourceFile(test.Container, testDirectory.DirectoryPath, blobName4, size); blobNames.Add(blobName4); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists }; string destinationFolder = "destFolder"; @@ -433,9 +433,9 @@ public async Task BlockBlobDirectoryToDirectory_OverwriteFalse() await CreateBlockBlobAndSourceFile(test.Container, testDirectory.DirectoryPath, blobName4, size); blobNames.Add(blobName4); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists }; string destinationFolder = "destFolder"; @@ -526,7 +526,7 @@ private async Task CreateStartTransfer( BlobContainerClient containerClient, int concurrency, bool createFailedCondition = false, - TransferOptions options = default, + DataTransferOptions options = default, int size = Constants.KB) { using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); @@ -538,11 +538,11 @@ private async Task CreateStartTransfer( await CreateBlobDirectoryTree(containerClient, sourceFolderPath, sourceBlobPrefix, size); // Create new source block blob. - StorageResourceContainer sourceResource = new BlobStorageResourceContainer(containerClient, new() { DirectoryPrefix = sourceBlobPrefix }); + StorageResourceContainer sourceResource = new BlobStorageResourceContainer(containerClient, new() { BlobDirectoryPrefix = sourceBlobPrefix }); StorageResourceContainer destinationResource = new BlobStorageResourceContainer(containerClient, new BlobStorageResourceContainerOptions() { - DirectoryPrefix = destBlobPrefix, + BlobDirectoryPrefix = destBlobPrefix, }); // If we want a failure condition to happen @@ -574,7 +574,7 @@ public async Task StartTransfer_AwaitCompletion() await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); // Create transfer to do a AwaitCompletion - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); DataTransfer transfer = await CreateStartTransfer(test.Container, 1, options: options); @@ -586,7 +586,7 @@ public async Task StartTransfer_AwaitCompletion() testEventsRaised.AssertUnexpectedFailureCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); } [Test] @@ -596,9 +596,9 @@ public async Task StartTransfer_AwaitCompletion_Failed() // Arrange await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -616,7 +616,7 @@ public async Task StartTransfer_AwaitCompletion_Failed() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); await testEventsRaised.AssertContainerCompletedWithFailedCheck(1); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("BlobAlreadyExists")); } @@ -629,9 +629,9 @@ public async Task StartTransfer_AwaitCompletion_Skipped() await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip + CreationPreference = StorageResourceCreationPreference.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -649,7 +649,7 @@ public async Task StartTransfer_AwaitCompletion_Skipped() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); await testEventsRaised.AssertContainerCompletedWithSkippedCheck(1); } @@ -661,20 +661,20 @@ public async Task StartTransfer_EnsureCompleted() await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); // Create transfer to do a EnsureCompleted - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); DataTransfer transfer = await CreateStartTransfer(test.Container, 1, options: options); // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert testEventsRaised.AssertUnexpectedFailureCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); } [Test] @@ -684,9 +684,9 @@ public async Task StartTransfer_EnsureCompleted_Failed() // Arrange await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -699,12 +699,12 @@ public async Task StartTransfer_EnsureCompleted_Failed() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); await testEventsRaised.AssertContainerCompletedWithFailedCheck(1); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("BlobAlreadyExists")); } @@ -717,9 +717,9 @@ public async Task StartTransfer_EnsureCompleted_Skipped() await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip + CreationPreference = StorageResourceCreationPreference.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -732,13 +732,13 @@ public async Task StartTransfer_EnsureCompleted_Skipped() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert testEventsRaised.AssertUnexpectedFailureCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); } [Test] @@ -750,9 +750,9 @@ public async Task StartTransfer_EnsureCompleted_Failed_SmallChunks() using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); string destinationFolder = CreateRandomDirectory(testDirectory.DirectoryPath); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail, + CreationPreference = StorageResourceCreationPreference.FailIfExists, InitialTransferSize = 512, MaximumTransferChunkSize = 512 }; @@ -768,12 +768,12 @@ public async Task StartTransfer_EnsureCompleted_Failed_SmallChunks() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("BlobAlreadyExists")); await testEventsRaised.AssertContainerCompletedWithFailedCheck(1); } diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferSyncCopyTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferSyncCopyTests.cs index d072ef81b1d3e..307dd7c781de0 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferSyncCopyTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferSyncCopyTests.cs @@ -25,8 +25,8 @@ public StartTransferSyncCopyTests(bool async, BlobClientOptions.ServiceVersion s internal class VerifyBlockBlobCopyFromUriInfo { public readonly string SourceLocalPath; - public readonly StorageResourceSingle SourceResource; - public readonly StorageResourceSingle DestinationResource; + public readonly StorageResourceItem SourceResource; + public readonly StorageResourceItem DestinationResource; public readonly BlockBlobClient DestinationClient; public TestEventsRaised testEventsRaised; public DataTransfer DataTransfer; @@ -34,8 +34,8 @@ internal class VerifyBlockBlobCopyFromUriInfo public VerifyBlockBlobCopyFromUriInfo( string sourceLocalPath, - StorageResourceSingle sourceResource, - StorageResourceSingle destinationResource, + StorageResourceItem sourceResource, + StorageResourceItem destinationResource, BlockBlobClient destinationClient, TestEventsRaised eventsRaised, bool completed) @@ -69,7 +69,7 @@ private async Task CopyBlockBlobsAndVerify( TransferManagerOptions transferManagerOptions = default, List sourceBlobNames = default, List destinationBlobNames = default, - List options = default) + List options = default) { using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); // Populate blobNames list for number of blobs to be created @@ -107,7 +107,7 @@ private async Task CopyBlockBlobsAndVerify( transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; List copyBlobInfo = new List(blobCount); @@ -134,10 +134,10 @@ private async Task CopyBlockBlobsAndVerify( await originalBlob.UploadAsync(originalStream); } - StorageResourceSingle sourceResource = new BlockBlobStorageResource(originalBlob); + StorageResourceItem sourceResource = new BlockBlobStorageResource(originalBlob); // Set up destination client BlockBlobClient destClient = InstrumentClient(container.GetBlockBlobClient(string.Concat(destinationBlobNames[i]))); - StorageResourceSingle destinationResource = new BlockBlobStorageResource(destClient); + StorageResourceItem destinationResource = new BlockBlobStorageResource(destClient); copyBlobInfo.Add(new VerifyBlockBlobCopyFromUriInfo( localSourceFile, sourceResource, @@ -165,7 +165,7 @@ private async Task CopyBlockBlobsAndVerify( CancellationTokenSource tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(waitTimeInSec)); await copyBlobInfo[i].DataTransfer.WaitForCompletionAsync(tokenSource.Token); Assert.IsTrue(copyBlobInfo[i].DataTransfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, copyBlobInfo[i].DataTransfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, copyBlobInfo[i].DataTransfer.TransferStatus); // Verify Copy - using original source File and Copying the destination await copyBlobInfo[i].testEventsRaised.AssertSingleCompletedCheck(); @@ -192,7 +192,7 @@ public async Task BlockBlobToBlockBlob_SmallChunk() long size = Constants.KB; int waitTimeInSec = 25; - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = 100, MaximumTransferChunkSize = 200, @@ -201,7 +201,7 @@ public async Task BlockBlobToBlockBlob_SmallChunk() // Arrange await using DisposingBlobContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); - List optionsList = new List() { options }; + List optionsList = new List() { options }; await CopyBlockBlobsAndVerify( testContainer.Container, waitTimeInSec: waitTimeInSec, @@ -299,11 +299,11 @@ public async Task BlockBlobToBlockBlob_Overwrite_Exists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List() { options }; + List optionsList = new List() { options }; List blobNames = new List() { blobName }; // Start transfer and await for completion. @@ -324,11 +324,11 @@ public async Task BlockBlobToBlockBlob_Overwrite_NotExists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List() { options }; + List optionsList = new List() { options }; // Start transfer and await for completion. await CopyBlockBlobsAndVerify( @@ -356,9 +356,9 @@ public async Task BlockBlobToBlockBlob_Skip_Exists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip, + CreationPreference = StorageResourceCreationPreference.SkipIfExists, }; // Create new source block blob. @@ -368,8 +368,8 @@ public async Task BlockBlobToBlockBlob_Skip_Exists() newSourceFile, GetNewBlobName(), size); - StorageResourceSingle sourceResource = new BlockBlobStorageResource(blockBlobClient); - StorageResourceSingle destinationResource = new BlockBlobStorageResource(destinationClient); + StorageResourceItem sourceResource = new BlockBlobStorageResource(blockBlobClient); + StorageResourceItem destinationResource = new BlockBlobStorageResource(destinationClient); TestEventsRaised testEventsRaised = new TestEventsRaised(options); TransferManager transferManager = new TransferManager(); @@ -385,7 +385,7 @@ public async Task BlockBlobToBlockBlob_Skip_Exists() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); await testEventsRaised.AssertSingleSkippedCheck(); Assert.IsTrue(await destinationClient.ExistsAsync()); // Verify Upload - That we skipped over and didn't reupload something new. @@ -410,9 +410,9 @@ public async Task BlockBlobToBlockBlob_Failure_Exists() // Act // Create options bag to fail and keep track of the failure. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail, + CreationPreference = StorageResourceCreationPreference.FailIfExists, }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); // Create new source block blob. @@ -422,8 +422,8 @@ public async Task BlockBlobToBlockBlob_Failure_Exists() newSourceFile, GetNewBlobName(), size); - StorageResourceSingle sourceResource = new BlockBlobStorageResource(blockBlobClient); - StorageResourceSingle destinationResource = new BlockBlobStorageResource(destinationClient); + StorageResourceItem sourceResource = new BlockBlobStorageResource(blockBlobClient); + StorageResourceItem destinationResource = new BlockBlobStorageResource(destinationClient); TransferManager transferManager = new TransferManager(); // Start transfer and await for completion. @@ -437,7 +437,7 @@ public async Task BlockBlobToBlockBlob_Failure_Exists() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(await destinationClient.ExistsAsync()); await testEventsRaised.AssertSingleFailedCheck(); Assert.NotNull(testEventsRaised.FailedEvents.First().Exception, "Excepted failure: Overwrite failure was supposed to be raised during the test"); @@ -465,11 +465,11 @@ public async Task BlockBlobToBlockBlob_OAuth() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List() { options }; + List optionsList = new List() { options }; // Start transfer and await for completion. await CopyBlockBlobsAndVerify( @@ -489,9 +489,9 @@ public async Task AppendBlobToAppendBlob_Error() // Act // Create options bag to fail and keep track of the failure. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail, + CreationPreference = StorageResourceCreationPreference.FailIfExists, }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); // Create new source block blob. @@ -511,8 +511,8 @@ public async Task AppendBlobToAppendBlob_Error() blobName: destinationBlobName, size: size); - StorageResourceSingle sourceResource = new AppendBlobStorageResource(sourceBlob); - StorageResourceSingle destinationResource = new AppendBlobStorageResource(destinationBlob); + StorageResourceItem sourceResource = new AppendBlobStorageResource(sourceBlob); + StorageResourceItem destinationResource = new AppendBlobStorageResource(destinationBlob); TransferManager transferManager = new TransferManager(); // Start transfer and await for completion. @@ -526,7 +526,7 @@ public async Task AppendBlobToAppendBlob_Error() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); await testEventsRaised.AssertSingleFailedCheck(); Assert.NotNull(testEventsRaised.FailedEvents.First().Exception, "Excepted failure: Failure was supposed to be raised during the test"); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("BlobAlreadyExists")); @@ -542,9 +542,9 @@ public async Task PageBlobToPageBlob_Error() // Act // Create options bag to fail and keep track of the failure. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail, + CreationPreference = StorageResourceCreationPreference.FailIfExists, }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); // Create new source block blob. @@ -564,8 +564,8 @@ public async Task PageBlobToPageBlob_Error() blobName: destinationBlobName, size: size); - StorageResourceSingle sourceResource = new PageBlobStorageResource(sourceClient); - StorageResourceSingle destinationResource = new PageBlobStorageResource(destinationClient); + StorageResourceItem sourceResource = new PageBlobStorageResource(sourceClient); + StorageResourceItem destinationResource = new PageBlobStorageResource(destinationClient); TransferManager transferManager = new TransferManager(); // Start transfer and await for completion. @@ -579,7 +579,7 @@ public async Task PageBlobToPageBlob_Error() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); await testEventsRaised.AssertSingleFailedCheck(); Assert.NotNull(testEventsRaised.FailedEvents.First().Exception, "Excepted failure: Failure was supposed to be raised during the test"); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("BlobAlreadyExists")); @@ -591,7 +591,7 @@ private async Task CreateStartTransfer( BlobContainerClient containerClient, int concurrency, bool createFailedCondition = false, - TransferOptions options = default, + DataTransferOptions options = default, int size = Constants.KB) { // Arrange @@ -612,8 +612,8 @@ private async Task CreateStartTransfer( // Create new source block blob. string newSourceFile = Path.Combine(testDirectory.DirectoryPath, sourceBlobName); BlockBlobClient blockBlobClient = await CreateBlockBlob(containerClient, newSourceFile, sourceBlobName, size); - StorageResourceSingle sourceResource = new BlockBlobStorageResource(blockBlobClient); - StorageResourceSingle destinationResource = new BlockBlobStorageResource(destinationClient); + StorageResourceItem sourceResource = new BlockBlobStorageResource(blockBlobClient); + StorageResourceItem destinationResource = new BlockBlobStorageResource(destinationClient); // Create Transfer Manager with single threaded operation TransferManagerOptions managerOptions = new TransferManagerOptions() @@ -635,7 +635,7 @@ public async Task StartTransfer_AwaitCompletion() // Arrange await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); // Create transfer to do a AwaitCompletion @@ -649,7 +649,7 @@ public async Task StartTransfer_AwaitCompletion() await testEventsRaised.AssertSingleCompletedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); } [RecordedTest] @@ -658,9 +658,9 @@ public async Task StartTransfer_AwaitCompletion_Failed() // Arrange await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -678,7 +678,7 @@ public async Task StartTransfer_AwaitCompletion_Failed() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); await testEventsRaised.AssertSingleFailedCheck(); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("BlobAlreadyExists")); } @@ -690,9 +690,9 @@ public async Task StartTransfer_AwaitCompletion_Skipped() await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip + CreationPreference = StorageResourceCreationPreference.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -711,7 +711,7 @@ public async Task StartTransfer_AwaitCompletion_Skipped() await testEventsRaised.AssertSingleSkippedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); } [RecordedTest] @@ -720,7 +720,7 @@ public async Task StartTransfer_EnsureCompleted() // Arrange await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); // Create transfer to do a EnsureCompleted @@ -728,13 +728,13 @@ public async Task StartTransfer_EnsureCompleted() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert await testEventsRaised.AssertSingleCompletedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); } [RecordedTest] @@ -743,9 +743,9 @@ public async Task StartTransfer_EnsureCompleted_Failed() // Arrange await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -758,13 +758,13 @@ public async Task StartTransfer_EnsureCompleted_Failed() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert await testEventsRaised.AssertSingleFailedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("BlobAlreadyExists")); } @@ -775,9 +775,9 @@ public async Task StartTransfer_EnsureCompleted_Skipped() await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip + CreationPreference = StorageResourceCreationPreference.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -790,13 +790,13 @@ public async Task StartTransfer_EnsureCompleted_Skipped() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert await testEventsRaised.AssertSingleSkippedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); } #endregion } diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferUploadDirectoryTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferUploadDirectoryTests.cs index 6e11ea01a9e68..3f0c961d57b2c 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferUploadDirectoryTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferUploadDirectoryTests.cs @@ -41,15 +41,15 @@ private async Task UploadBlobDirectoryAndVerify( string destinationPrefix = default, int waitTimeInSec = 30, TransferManagerOptions transferManagerOptions = default, - TransferOptions options = default) + DataTransferOptions options = default) { // Set transfer options - options ??= new TransferOptions(); + options ??= new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; destinationPrefix ??= "foo"; @@ -60,7 +60,7 @@ private async Task UploadBlobDirectoryAndVerify( StorageResourceContainer sourceResource = new LocalDirectoryStorageResourceContainer(localDirectoryPath); StorageResourceContainer destinationResource = - new BlobStorageResourceContainer(destinationContainer, new() { DirectoryPrefix = destinationPrefix }); + new BlobStorageResourceContainer(destinationContainer, new() { BlobDirectoryPrefix = destinationPrefix }); // Set up blob to upload DataTransfer transfer = await transferManager.StartTransferAsync(sourceResource, destinationResource, options); @@ -71,7 +71,7 @@ private async Task UploadBlobDirectoryAndVerify( await testEventsRaised.AssertContainerCompletedCheck(files.Count); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); // Assert - Check Response List blobs = ((List)await destinationContainer.GetBlobsAsync(prefix: destinationPrefix).ToListAsync()) @@ -100,7 +100,7 @@ private async Task UploadBlobDirectoryAndVerify( [TestCase(Constants.KB, 10)] public async Task LocalToBlockBlobDirectory_SmallSize(long blobSize, int waitTimeInSec) { - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); List files = new List(); using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); string localDirectory = CreateRandomDirectory(testDirectory.DirectoryPath); @@ -132,7 +132,7 @@ await UploadBlobDirectoryAndVerify( [TestCase(Constants.GB, 500)] public async Task LocalToBlockBlobDirectory_LargeSize(long blobSize, int waitTimeInSec) { - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); List files = new List(); using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); string localDirectory = CreateRandomDirectory(testDirectory.DirectoryPath); @@ -161,7 +161,7 @@ public async Task LocalToBlockBlobDirectory_SmallChunks() { long blobSize = Constants.KB; int waitTimeInSec = 25; - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = 100, MaximumTransferChunkSize = 200, @@ -197,10 +197,10 @@ public async Task LocalToBlockBlobDirectory_SmallChunks_ManyFiles() int waitTimeInSec = 25; TransferManagerOptions transferManagerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.StopOnAllFailures, + ErrorHandling = DataTransferErrorMode.StopOnAnyFailure, MaximumConcurrency = 3, }; - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = 512, MaximumTransferChunkSize = 512, @@ -248,16 +248,16 @@ public async Task DirectoryUpload_EmptyFolder() string localDirectory = CreateRandomDirectory(testDirectory.DirectoryPath); // Set up destination client - StorageResourceContainer destinationResource = new BlobStorageResourceContainer(test.Container, new() { DirectoryPrefix = dirName }); + StorageResourceContainer destinationResource = new BlobStorageResourceContainer(test.Container, new() { BlobDirectoryPrefix = dirName }); StorageResourceContainer sourceResource = new LocalDirectoryStorageResourceContainer(localDirectory); TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = 1, }; TransferManager transferManager = new TransferManager(managerOptions); - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); // Act @@ -281,7 +281,7 @@ public async Task DirectoryUpload_SingleFile() await using DisposingBlobContainer test = await GetTestContainerAsync(); string dirName = GetNewBlobName(); - StorageResourceContainer destinationResource = new BlobStorageResourceContainer(test.Container, new() { DirectoryPrefix = dirName }); + StorageResourceContainer destinationResource = new BlobStorageResourceContainer(test.Container, new() { BlobDirectoryPrefix = dirName }); List files = new List(); using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); @@ -437,9 +437,9 @@ public async Task DirectoryUpload_OverwriteTrue() string file4 = await CreateRandomFileAsync(lockedSubfolder); files.Add(file4); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists }; BlobClient blobClient = test.Container.GetBlobClient(dirName + "/" + file1.Substring(localDirectory.Length + 1).Replace('\\', '/')); await blobClient.UploadAsync(file1); @@ -478,9 +478,9 @@ public async Task DirectoryUpload_OverwriteFalse() string file4 = await CreateRandomFileAsync(lockedSubfolder); files.Add(file4); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists }; BlobClient blobClient = test.Container.GetBlobClient(dirName + "/" + file1.Substring(localDirectory.Length + 1).Replace('\\', '/')); await blobClient.UploadAsync(file1); @@ -519,13 +519,13 @@ public async Task DirectoryUpload_BlobType(BlobType blobType) BlobStorageResourceContainerOptions options = new BlobStorageResourceContainerOptions() { BlobType = blobType, - DirectoryPrefix = destinationPrefix, + BlobDirectoryPrefix = destinationPrefix, }; StorageResourceContainer destinationResource = new BlobStorageResourceContainer( test.Container, options); - TransferOptions containerOptions = new TransferOptions(); + DataTransferOptions containerOptions = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(containerOptions); // Act @@ -593,9 +593,9 @@ public async Task DirectoryUpload_Root() [Test] [LiveOnly] // https://github.com/Azure/azure-sdk-for-net/issues/33082 - [TestCase(ErrorHandlingBehavior.ContinueOnFailure)] - [TestCase(ErrorHandlingBehavior.StopOnAllFailures)] - public async Task DirectoryUpload_ErrorHandling(ErrorHandlingBehavior errorHandling) + [TestCase(DataTransferErrorMode.ContinueOnFailure)] + [TestCase(DataTransferErrorMode.StopOnAnyFailure)] + public async Task DirectoryUpload_ErrorHandling(DataTransferErrorMode errorHandling) { // Arrange using DisposingLocalDirectory source = DisposingLocalDirectory.GetTestDirectory(); @@ -618,9 +618,9 @@ await destination.Container.UploadBlobAsync( new BlobStorageResourceContainer(destination.Container); // Conflict should cause failure - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -634,7 +634,7 @@ await destination.Container.UploadBlobAsync( IEnumerable destinationFiles = (await destination.Container.GetBlobsAsync().ToEnumerableAsync()).Select(b => b.Name); - if (errorHandling == ErrorHandlingBehavior.ContinueOnFailure) + if (errorHandling == DataTransferErrorMode.ContinueOnFailure) { await testEventsRaised.AssertContainerCompletedWithFailedCheckContinue(1); @@ -644,7 +644,7 @@ await destination.Container.UploadBlobAsync( .OrderBy(f => f) .SequenceEqual(destinationFiles.OrderBy(f => f))); } - else if (errorHandling == ErrorHandlingBehavior.StopOnAllFailures) + else if (errorHandling == DataTransferErrorMode.StopOnAnyFailure) { await testEventsRaised.AssertContainerCompletedWithFailedCheck(1); @@ -673,7 +673,7 @@ private async Task CreateStartTransfer( BlobContainerClient containerClient, int concurrency, bool createFailedCondition = false, - TransferOptions options = default, + DataTransferOptions options = default, int size = Constants.KB) { // Arrange @@ -683,7 +683,7 @@ private async Task CreateStartTransfer( // Create storage resources StorageResourceContainer sourceResource = new LocalDirectoryStorageResourceContainer(sourceDirectoryPath); // Create destination folder - StorageResourceContainer destinationResource = new BlobStorageResourceContainer(containerClient, new() { DirectoryPrefix = destinationFolderName }); + StorageResourceContainer destinationResource = new BlobStorageResourceContainer(containerClient, new() { BlobDirectoryPrefix = destinationFolderName }); // Create Transfer Manager with single threaded operation TransferManagerOptions managerOptions = new TransferManagerOptions() @@ -717,7 +717,7 @@ public async Task StartTransfer_AwaitCompletion() // Arrange await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); // Create transfer to do a AwaitCompletion @@ -734,7 +734,7 @@ public async Task StartTransfer_AwaitCompletion() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); await testEventsRaised.AssertContainerCompletedCheck(4); } @@ -746,9 +746,9 @@ public async Task StartTransfer_AwaitCompletion_Failed() await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -768,7 +768,7 @@ public async Task StartTransfer_AwaitCompletion_Failed() await testEventsRaised.AssertContainerCompletedWithFailedCheck(1); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("BlobAlreadyExists")); } @@ -781,9 +781,9 @@ public async Task StartTransfer_AwaitCompletion_Skipped() using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip + CreationPreference = StorageResourceCreationPreference.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -803,7 +803,7 @@ public async Task StartTransfer_AwaitCompletion_Skipped() await testEventsRaised.AssertContainerCompletedWithSkippedCheck(1); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); } [Test] @@ -814,7 +814,7 @@ public async Task StartTransfer_EnsureCompleted() await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); // Create transfer to do a EnsureCompleted @@ -826,13 +826,13 @@ public async Task StartTransfer_EnsureCompleted() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert await testEventsRaised.AssertContainerCompletedCheck(4); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); } [Test] @@ -843,9 +843,9 @@ public async Task StartTransfer_EnsureCompleted_Failed() await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -859,13 +859,13 @@ public async Task StartTransfer_EnsureCompleted_Failed() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert await testEventsRaised.AssertContainerCompletedWithFailedCheck(1); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("BlobAlreadyExists")); } @@ -878,9 +878,9 @@ public async Task StartTransfer_EnsureCompleted_Skipped() using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip + CreationPreference = StorageResourceCreationPreference.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -894,13 +894,13 @@ public async Task StartTransfer_EnsureCompleted_Skipped() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert await testEventsRaised.AssertContainerCompletedWithSkippedCheck(1); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); } [Test] @@ -912,9 +912,9 @@ public async Task StartTransfer_EnsureCompleted_Failed_SmallChunks() using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); string destinationFolder = CreateRandomDirectory(testDirectory.DirectoryPath); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail, + CreationPreference = StorageResourceCreationPreference.FailIfExists, InitialTransferSize = 512, MaximumTransferChunkSize = 512 }; @@ -930,12 +930,12 @@ public async Task StartTransfer_EnsureCompleted_Failed_SmallChunks() size: Constants.KB * 4); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("BlobAlreadyExists")); await testEventsRaised.AssertContainerCompletedWithFailedCheck(1); } diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferUploadTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferUploadTests.cs index 10118190f1d90..b25ac03a1414e 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferUploadTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferUploadTests.cs @@ -42,9 +42,9 @@ public VerifyUploadBlobContentInfo( } }; - internal TransferOptions CopySingleUploadOptions(TransferOptions options) + internal DataTransferOptions CopySingleUploadOptions(DataTransferOptions options) { - TransferOptions newOptions = new TransferOptions() + DataTransferOptions newOptions = new DataTransferOptions() { MaximumTransferChunkSize = options.MaximumTransferChunkSize, InitialTransferSize = options.InitialTransferSize, @@ -70,7 +70,7 @@ private async Task UploadBlockBlobsAndVerify( TransferManagerOptions transferManagerOptions = default, int blobCount = 1, List blobNames = default, - List options = default) + List options = default) { using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); @@ -94,7 +94,7 @@ private async Task UploadBlockBlobsAndVerify( transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; List uploadedBlobInfo = new List(blobCount); @@ -116,10 +116,10 @@ private async Task UploadBlockBlobsAndVerify( // Set up destination client BlockBlobClient destClient = container.GetBlockBlobClient(blobNames[i]); - StorageResourceSingle destinationResource = new BlockBlobStorageResource(destClient); + StorageResourceItem destinationResource = new BlockBlobStorageResource(destClient); // Act - StorageResourceSingle sourceResource = new LocalFileStorageResource(localSourceFile); + StorageResourceItem sourceResource = new LocalFileStorageResource(localSourceFile); DataTransfer transfer = await transferManager.StartTransferAsync(sourceResource, destinationResource, options[i]); uploadedBlobInfo.Add(new VerifyUploadBlobContentInfo( @@ -162,11 +162,11 @@ public async Task LocalToBlockBlob_EventHandler() AutoResetEvent InProgressWait = new AutoResetEvent(false); bool progressSeen = false; - TransferOptions options = new TransferOptions(); - options.TransferStatus += (TransferStatusEventArgs args) => + DataTransferOptions options = new DataTransferOptions(); + options.TransferStatusChanged += (TransferStatusEventArgs args) => { // Assert - if (args.StorageTransferStatus == StorageTransferStatus.InProgress) + if (args.StorageTransferStatus == DataTransferStatus.InProgress) { progressSeen = true; } @@ -176,7 +176,7 @@ public async Task LocalToBlockBlob_EventHandler() // Arrange await using DisposingBlobContainer testContainer = await GetTestContainerAsync(); - List optionsList = new List() { options }; + List optionsList = new List() { options }; await UploadBlockBlobsAndVerify( container: testContainer.Container, blobCount: optionsList.Count, @@ -191,7 +191,7 @@ public async Task LocalToBlockBlobSize_SmallChunk() { long fileSize = Constants.KB; int waitTimeInSec = 25; - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = 100, MaximumTransferChunkSize = 200, @@ -199,7 +199,7 @@ public async Task LocalToBlockBlobSize_SmallChunk() // Arrange await using DisposingBlobContainer testContainer = await GetTestContainerAsync(); - List optionsList = new List() { options }; + List optionsList = new List() { options }; await UploadBlockBlobsAndVerify( size: fileSize, @@ -223,11 +223,11 @@ public async Task LocalToBlockBlob_Overwrite_Exists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List() { options }; + List optionsList = new List() { options }; List blobNames = new List() { blobName }; // Start transfer and await for completion. @@ -250,11 +250,11 @@ public async Task LocalToBlockBlob_Overwrite_NotExists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List() { options }; + List optionsList = new List() { options }; // Start transfer and await for completion. await UploadBlockBlobsAndVerify( @@ -280,12 +280,12 @@ public async Task LocalToBlockBlob_Skip_Exists() // Create new source file string newSourceFile = await CreateRandomFileAsync(Path.GetTempPath(), size:size); // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip, + CreationPreference = StorageResourceCreationPreference.SkipIfExists, }; - StorageResourceSingle sourceResource = new LocalFileStorageResource(newSourceFile); - StorageResourceSingle destinationResource = new BlockBlobStorageResource(destinationClient); + StorageResourceItem sourceResource = new LocalFileStorageResource(newSourceFile); + StorageResourceItem destinationResource = new BlockBlobStorageResource(destinationClient); TestEventsRaised testEventsRaised = new TestEventsRaised(options); TransferManager transferManager = new TransferManager(); @@ -302,7 +302,7 @@ public async Task LocalToBlockBlob_Skip_Exists() await testEventsRaised.AssertSingleSkippedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); Assert.IsTrue(await destinationClient.ExistsAsync()); // Verify Upload - That we skipped over and didn't reupload something new. using (FileStream fileStream = File.OpenRead(originalSourceFile)) @@ -329,13 +329,13 @@ public async Task LocalToBlockBlob_Failure_Exists() // Act // Create options bag to fail and keep track of the failure. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail, + CreationPreference = StorageResourceCreationPreference.FailIfExists, }; TestEventsRaised testEventRaised = new TestEventsRaised(options); - StorageResourceSingle sourceResource = new LocalFileStorageResource(newSourceFile); - StorageResourceSingle destinationResource = new BlockBlobStorageResource(destinationClient); + StorageResourceItem sourceResource = new LocalFileStorageResource(newSourceFile); + StorageResourceItem destinationResource = new BlockBlobStorageResource(destinationClient); TransferManager transferManager = new TransferManager(); // Start transfer and await for completion. @@ -349,7 +349,7 @@ public async Task LocalToBlockBlob_Failure_Exists() // Assert Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(await destinationClient.ExistsAsync()); await testEventRaised.AssertSingleFailedCheck(); Assert.NotNull(testEventRaised.FailedEvents.First().Exception, "Excepted failure: Overwrite failure was supposed to be raised during the test"); @@ -408,16 +408,16 @@ public async Task LocalToBlockBlob_SmallConcurrency(int concurrency, long size, TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = 512, MaximumTransferChunkSize = 512, }; - List optionsList = new List { options }; + List optionsList = new List { options }; await UploadBlockBlobsAndVerify( container: testContainer.Container, @@ -442,7 +442,7 @@ public async Task LocalToBlockBlob_LargeConcurrency(int concurrency, int size, i TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; @@ -512,7 +512,7 @@ private async Task UploadPageBlobsAndVerify( int blobCount = 1, TransferManagerOptions transferManagerOptions = default, List blobNames = default, - List options = default) + List options = default) { using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); @@ -536,7 +536,7 @@ private async Task UploadPageBlobsAndVerify( transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; List uploadedBlobInfo = new List(blobCount); @@ -558,10 +558,10 @@ private async Task UploadPageBlobsAndVerify( // Set up destination client PageBlobClient destClient = container.GetPageBlobClient(blobNames[i]); - StorageResourceSingle destinationResource = new PageBlobStorageResource(destClient); + StorageResourceItem destinationResource = new PageBlobStorageResource(destClient); // Act - StorageResourceSingle sourceResource = new LocalFileStorageResource(localSourceFile); + StorageResourceItem sourceResource = new LocalFileStorageResource(localSourceFile); DataTransfer transfer = await blobDataController.StartTransferAsync(sourceResource, destinationResource, options[i]); uploadedBlobInfo.Add(new VerifyUploadBlobContentInfo( @@ -578,7 +578,7 @@ private async Task UploadPageBlobsAndVerify( CancellationTokenSource tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(waitTimeInSec)); await uploadedBlobInfo[i].DataTransfer.WaitForCompletionAsync(tokenSource.Token); Assert.IsTrue(uploadedBlobInfo[i].DataTransfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, uploadedBlobInfo[i].DataTransfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, uploadedBlobInfo[i].DataTransfer.TransferStatus); // Verify Upload await uploadedBlobInfo[i].EventsRaised.AssertSingleCompletedCheck(); @@ -612,11 +612,11 @@ public async Task LocalToPageBlob_Overwrite_Exists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List() { options }; + List optionsList = new List() { options }; List blobNames = new List() { blobName }; TransferManager transferManager = new TransferManager(); @@ -640,11 +640,11 @@ public async Task LocalToPageBlob_Overwrite_NotExists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List() { options }; + List optionsList = new List() { options }; TransferManager transferManager = new TransferManager(); // Start transfer and await for completion. @@ -670,12 +670,12 @@ public async Task LocalToPageBlob_Skip_Exists() // Create new source file string newSourceFile = await CreateRandomFileAsync(Path.GetTempPath(), size: size); // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip, + CreationPreference = StorageResourceCreationPreference.SkipIfExists, }; - StorageResourceSingle sourceResource = new LocalFileStorageResource(newSourceFile); - StorageResourceSingle destinationResource = new PageBlobStorageResource(destinationClient); + StorageResourceItem sourceResource = new LocalFileStorageResource(newSourceFile); + StorageResourceItem destinationResource = new PageBlobStorageResource(destinationClient); TestEventsRaised testEventsRaised = new TestEventsRaised(options); TransferManager transferManager = new TransferManager(); @@ -692,7 +692,7 @@ public async Task LocalToPageBlob_Skip_Exists() await testEventsRaised.AssertSingleSkippedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); Assert.IsTrue(await destinationClient.ExistsAsync()); // Verify Upload - That we skipped over and didn't reupload something new. using (FileStream fileStream = File.OpenRead(originalSourceFile)) @@ -718,13 +718,13 @@ public async Task LocalToPageBlob_Failure_Exists() // Act // Create options bag to fail and keep track of the failure. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail, + CreationPreference = StorageResourceCreationPreference.FailIfExists, }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); - StorageResourceSingle sourceResource = new LocalFileStorageResource(newSourceFile); - StorageResourceSingle destinationResource = new PageBlobStorageResource(destinationClient); + StorageResourceItem sourceResource = new LocalFileStorageResource(newSourceFile); + StorageResourceItem destinationResource = new PageBlobStorageResource(destinationClient); TransferManager transferManager = new TransferManager(); // Start transfer and await for completion. @@ -739,7 +739,7 @@ public async Task LocalToPageBlob_Failure_Exists() await testEventsRaised.AssertSingleFailedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(await destinationClient.ExistsAsync()); Assert.NotNull(testEventsRaised.FailedEvents.First().Exception, "Excepted failure: Overwrite failure was supposed to be raised during the test"); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("The specified blob already exists.")); @@ -757,7 +757,7 @@ public async Task LocalToPageBlob_Failure_Exists() [TestCase(5 * Constants.KB, 60)] public async Task LocalToPageBlob_SmallSize(long fileSize, int waitTimeInSec) { - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); // Arrange var blobName = GetNewBlobName(); @@ -779,7 +779,7 @@ await UploadPageBlobsAndVerify( [TestCase(Constants.GB, 1500)] public async Task LocalToPageBlob_LargeSize(long fileSize, int waitTimeInSec) { - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); // Arrange var blobName = GetNewBlobName(); @@ -805,16 +805,16 @@ public async Task LocalToPageBlob_SmallConcurrency(int concurrency, int size, in TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = 512, MaximumTransferChunkSize = 512, }; - List optionsList = new List { options }; + List optionsList = new List { options }; await UploadPageBlobsAndVerify( size: size, @@ -841,7 +841,7 @@ public async Task LocalToPageBlob_LargeConcurrency(int concurrency, int size, in TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; @@ -895,7 +895,7 @@ await UploadPageBlobsAndVerify( public async Task LocalToPageBlob_SmallChunks() { long size = 12 * Constants.KB; - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = Constants.KB, MaximumTransferChunkSize = Constants.KB @@ -904,7 +904,7 @@ public async Task LocalToPageBlob_SmallChunks() // Arrange await using DisposingBlobContainer testContainer = await GetTestContainerAsync(); - List optionsList = new List() { options }; + List optionsList = new List() { options }; await UploadPageBlobsAndVerify( container: testContainer.Container, size: size, @@ -931,7 +931,7 @@ private async Task UploadAppendBlobsAndVerify( int blobCount = 1, TransferManagerOptions transferManagerOptions = default, List blobNames = default, - List options = default) + List options = default) { using DisposingLocalDirectory testDirectory = DisposingLocalDirectory.GetTestDirectory(); @@ -955,7 +955,7 @@ private async Task UploadAppendBlobsAndVerify( transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure + ErrorHandling = DataTransferErrorMode.ContinueOnFailure }; List uploadedBlobInfo = new List(blobCount); @@ -977,10 +977,10 @@ private async Task UploadAppendBlobsAndVerify( // Set up destination client AppendBlobClient destClient = container.GetAppendBlobClient(blobNames[i]); - StorageResourceSingle destinationResource = new AppendBlobStorageResource(destClient); + StorageResourceItem destinationResource = new AppendBlobStorageResource(destClient); // Act - StorageResourceSingle sourceResource = new LocalFileStorageResource(localSourceFile); + StorageResourceItem sourceResource = new LocalFileStorageResource(localSourceFile); DataTransfer transfer = await blobDataController.StartTransferAsync(sourceResource, destinationResource, options[i]); uploadedBlobInfo.Add(new VerifyUploadBlobContentInfo( @@ -997,7 +997,7 @@ private async Task UploadAppendBlobsAndVerify( CancellationTokenSource tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(waitTimeInSec)); await uploadedBlobInfo[i].DataTransfer.WaitForCompletionAsync(tokenSource.Token); Assert.IsTrue(uploadedBlobInfo[i].DataTransfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, uploadedBlobInfo[i].DataTransfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, uploadedBlobInfo[i].DataTransfer.TransferStatus); // Verify Upload await uploadedBlobInfo[i].EventsRaised.AssertSingleCompletedCheck(); @@ -1023,7 +1023,7 @@ public async Task LocalToAppend_SmallChunk() long size = Constants.KB; int waitTimeInSec = 25; - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = 100, MaximumTransferChunkSize = 500, @@ -1032,7 +1032,7 @@ public async Task LocalToAppend_SmallChunk() // Arrange await using DisposingBlobContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); - List optionsList = new List() { options }; + List optionsList = new List() { options }; await UploadAppendBlobsAndVerify( testContainer.Container, waitTimeInSec: waitTimeInSec, @@ -1055,11 +1055,11 @@ public async Task LocalToAppendBlob_Overwrite_Exists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List() { options }; + List optionsList = new List() { options }; List blobNames = new List() { blobName }; // Start transfer and await for completion. @@ -1082,11 +1082,11 @@ public async Task LocalToAppendBlob_Overwrite_NotExists() // Act // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Overwrite, + CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, }; - List optionsList = new List() { options }; + List optionsList = new List() { options }; // Start transfer and await for completion. await UploadAppendBlobsAndVerify( @@ -1111,12 +1111,12 @@ public async Task LocalToAppendBlob_Skip_Exists() // Create new source file string newSourceFile = await CreateRandomFileAsync(Path.GetTempPath(), size: size); // Create options bag to overwrite any existing destination. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip, + CreationPreference = StorageResourceCreationPreference.SkipIfExists, }; - StorageResourceSingle sourceResource = new LocalFileStorageResource(newSourceFile); - StorageResourceSingle destinationResource = new AppendBlobStorageResource(destinationClient); + StorageResourceItem sourceResource = new LocalFileStorageResource(newSourceFile); + StorageResourceItem destinationResource = new AppendBlobStorageResource(destinationClient); TestEventsRaised testEventsRaised = new TestEventsRaised(options); TransferManager transferManager = new TransferManager(); @@ -1133,7 +1133,7 @@ public async Task LocalToAppendBlob_Skip_Exists() await testEventsRaised.AssertSingleSkippedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); Assert.IsTrue(await destinationClient.ExistsAsync()); // Verify Upload - That we skipped over and didn't reupload something new. using (FileStream fileStream = File.OpenRead(originalSourceFile)) @@ -1159,13 +1159,13 @@ public async Task LocalToAppendBlob_Failure_Exists() // Act // Create options bag to fail and keep track of the failure. - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail, + CreationPreference = StorageResourceCreationPreference.FailIfExists, }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); - StorageResourceSingle sourceResource = new LocalFileStorageResource(newSourceFile); - StorageResourceSingle destinationResource = new AppendBlobStorageResource(destinationClient); + StorageResourceItem sourceResource = new LocalFileStorageResource(newSourceFile); + StorageResourceItem destinationResource = new AppendBlobStorageResource(destinationClient); TransferManager transferManager = new TransferManager(); // Start transfer and await for completion. @@ -1180,7 +1180,7 @@ public async Task LocalToAppendBlob_Failure_Exists() await testEventsRaised.AssertSingleFailedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(await destinationClient.ExistsAsync()); Assert.NotNull(testEventsRaised.FailedEvents.First().Exception, "Excepted failure: Overwrite failure was supposed to be raised during the test"); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("The specified blob already exists.")); @@ -1243,18 +1243,18 @@ public async Task LocalToAppendBlob_SmallConcurrency(int concurrency, int size, await using DisposingBlobContainer testContainer = await GetTestContainerAsync(); AppendBlobClient destClient = testContainer.Container.GetAppendBlobClient(blobName); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { InitialTransferSize = 512, MaximumTransferChunkSize = 512 }; - List optionsList = new List { options }; + List optionsList = new List { options }; List blobNames = new List() { blobName }; TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; @@ -1285,7 +1285,7 @@ public async Task LocalToAppendBlob_LargeConcurrency(int concurrency, int size, TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = ErrorHandlingBehavior.ContinueOnFailure, + ErrorHandling = DataTransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; @@ -1349,7 +1349,7 @@ private async Task CreateStartTransfer( BlobContainerClient containerClient, int concurrency, bool createFailedCondition = false, - TransferOptions options = default, + DataTransferOptions options = default, int size = Constants.KB) { // Arrange @@ -1364,7 +1364,7 @@ private async Task CreateStartTransfer( { destinationClient = containerClient.GetBlockBlobClient(destinationBlobName); } - StorageResourceSingle destinationResource = new BlockBlobStorageResource(destinationClient); + StorageResourceItem destinationResource = new BlockBlobStorageResource(destinationClient); // Create new source file using Stream originalStream = await CreateLimitedMemoryStream(size); @@ -1375,7 +1375,7 @@ private async Task CreateStartTransfer( { await originalStream.CopyToAsync(fileStream); } - StorageResourceSingle sourceResource = new LocalFileStorageResource(localSourceFile); + StorageResourceItem sourceResource = new LocalFileStorageResource(localSourceFile); // Create Transfer Manager with single threaded operation TransferManagerOptions managerOptions = new TransferManagerOptions() @@ -1397,7 +1397,7 @@ public async Task StartTransfer_AwaitCompletion() // Arrange await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: Storage.Blobs.Models.PublicAccessType.BlobContainer); - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); // Create transfer to do a AwaitCompletion @@ -1411,7 +1411,7 @@ public async Task StartTransfer_AwaitCompletion() await testEventsRaised.AssertSingleCompletedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); } [RecordedTest] @@ -1420,9 +1420,9 @@ public async Task StartTransfer_AwaitCompletion_Failed() // Arrange await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: Storage.Blobs.Models.PublicAccessType.BlobContainer); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -1441,7 +1441,7 @@ public async Task StartTransfer_AwaitCompletion_Failed() await testEventsRaised.AssertSingleFailedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("BlobAlreadyExists")); } @@ -1452,9 +1452,9 @@ public async Task StartTransfer_AwaitCompletion_Skipped() await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: Storage.Blobs.Models.PublicAccessType.BlobContainer); // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip + CreationPreference = StorageResourceCreationPreference.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -1473,7 +1473,7 @@ public async Task StartTransfer_AwaitCompletion_Skipped() await testEventsRaised.AssertSingleSkippedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); } [RecordedTest] @@ -1482,7 +1482,7 @@ public async Task StartTransfer_EnsureCompleted() // Arrange await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: Storage.Blobs.Models.PublicAccessType.BlobContainer); - TransferOptions options = new TransferOptions(); + DataTransferOptions options = new DataTransferOptions(); TestEventsRaised testEventsRaised = new TestEventsRaised(options); // Create transfer to do a EnsureCompleted @@ -1490,13 +1490,13 @@ public async Task StartTransfer_EnsureCompleted() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert await testEventsRaised.AssertSingleCompletedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.Completed, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.Completed, transfer.TransferStatus); } [RecordedTest] @@ -1505,9 +1505,9 @@ public async Task StartTransfer_EnsureCompleted_Failed() // Arrange await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: Storage.Blobs.Models.PublicAccessType.BlobContainer); - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Fail + CreationPreference = StorageResourceCreationPreference.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -1520,13 +1520,13 @@ public async Task StartTransfer_EnsureCompleted_Failed() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert await testEventsRaised.AssertSingleFailedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithFailedTransfers, transfer.TransferStatus); Assert.IsTrue(testEventsRaised.FailedEvents.First().Exception.Message.Contains("BlobAlreadyExists")); } @@ -1537,9 +1537,9 @@ public async Task StartTransfer_EnsureCompleted_Skipped() await using DisposingBlobContainer test = await GetTestContainerAsync(publicAccessType: Storage.Blobs.Models.PublicAccessType.BlobContainer); // Create transfer options with Skipping available - TransferOptions options = new TransferOptions() + DataTransferOptions options = new DataTransferOptions() { - CreateMode = StorageResourceCreateMode.Skip + CreationPreference = StorageResourceCreationPreference.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -1552,13 +1552,13 @@ public async Task StartTransfer_EnsureCompleted_Skipped() // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5)); - transfer.EnsureCompleted(cancellationTokenSource.Token); + transfer.WaitForCompletion(cancellationTokenSource.Token); // Assert await testEventsRaised.AssertSingleSkippedCheck(); Assert.NotNull(transfer); Assert.IsTrue(transfer.HasCompleted); - Assert.AreEqual(StorageTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); + Assert.AreEqual(DataTransferStatus.CompletedWithSkippedTransfers, transfer.TransferStatus); } #endregion @@ -1567,11 +1567,11 @@ public async Task SupportsLongFiles() { long fileSize = 5L * Constants.GB; - StorageResourceSingle srcResource = MockStorageResource.MakeSourceResource(fileSize, false, maxChunkSize: Constants.GB); - StorageResourceSingle dstResource = MockStorageResource.MakeDestinationResource(true, maxChunkSize: Constants.GB); + StorageResourceItem srcResource = MockStorageResource.MakeSourceResource(fileSize, false, maxChunkSize: Constants.GB); + StorageResourceItem dstResource = MockStorageResource.MakeDestinationResource(true, maxChunkSize: Constants.GB); TransferManager transferManager = new TransferManager(); - TransferOptions options = new(); + DataTransferOptions options = new(); TestEventsRaised events = new(options); DataTransfer transfer = await transferManager.StartTransferAsync(srcResource, dstResource, options); await transfer.WaitForCompletionAsync(); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/TestEventsRaised.cs b/sdk/storage/Azure.Storage.DataMovement/tests/TestEventsRaised.cs index 36b2bc118e1e3..15e47868ca365 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/TestEventsRaised.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/TestEventsRaised.cs @@ -20,61 +20,61 @@ namespace Azure.Storage.DataMovement.Tests /// an Assert.Failure in the middle of an event. /// /// Also if there's multiple failures then we will catch all of them. - /// (Which would mainly occur during + /// (Which would mainly occur during /// internal class TestEventsRaised : IDisposable { - public List FailedEvents { get; internal set; } + public List FailedEvents { get; internal set; } public List StatusEvents { get; internal set; } - public List SkippedEvents { get; internal set; } - public ConcurrentBag SingleCompletedEvents { get; internal set; } + public List SkippedEvents { get; internal set; } + public ConcurrentBag SingleCompletedEvents { get; internal set; } - private List _options; + private List _options; private TestEventsRaised() { - FailedEvents = new List(); + FailedEvents = new List(); StatusEvents = new List(); - SkippedEvents = new List(); - SingleCompletedEvents = new ConcurrentBag(); + SkippedEvents = new List(); + SingleCompletedEvents = new ConcurrentBag(); } - public TestEventsRaised(TransferOptions options) + public TestEventsRaised(DataTransferOptions options) : this() { - options.TransferFailed += AppendFailedArg; - options.TransferStatus += AppendStatusArg; - options.TransferSkipped += AppendSkippedArg; - options.SingleTransferCompleted += AppendSingleTransferCompleted; - _options = new List { options }; + options.ItemTransferFailed += AppendFailedArg; + options.TransferStatusChanged += AppendStatusArg; + options.ItemTransferSkipped += AppendSkippedArg; + options.ItemTransferCompleted += AppendSingleTransferCompleted; + _options = new List { options }; } - public TestEventsRaised(List optionsList) + public TestEventsRaised(List optionsList) : this() { - _options = new List(); - foreach (TransferOptions options in optionsList) + _options = new List(); + foreach (DataTransferOptions options in optionsList) { - options.TransferFailed += AppendFailedArg; - options.TransferStatus += AppendStatusArg; - options.TransferSkipped += AppendSkippedArg; - options.SingleTransferCompleted += AppendSingleTransferCompleted; + options.ItemTransferFailed += AppendFailedArg; + options.TransferStatusChanged += AppendStatusArg; + options.ItemTransferSkipped += AppendSkippedArg; + options.ItemTransferCompleted += AppendSingleTransferCompleted; _options.Add(options); } } public void Dispose() { - foreach (TransferOptions options in _options) + foreach (DataTransferOptions options in _options) { - options.TransferFailed -= AppendFailedArg; - options.TransferStatus -= AppendStatusArg; - options.TransferSkipped -= AppendSkippedArg; - options.SingleTransferCompleted -= AppendSingleTransferCompleted; + options.ItemTransferFailed -= AppendFailedArg; + options.TransferStatusChanged -= AppendStatusArg; + options.ItemTransferSkipped -= AppendSkippedArg; + options.ItemTransferCompleted -= AppendSingleTransferCompleted; } } - private Task AppendFailedArg(TransferFailedEventArgs args) + private Task AppendFailedArg(TransferItemFailedEventArgs args) { FailedEvents.Add(args); return Task.CompletedTask; @@ -86,13 +86,13 @@ private Task AppendStatusArg(TransferStatusEventArgs args) return Task.CompletedTask; } - private Task AppendSkippedArg(TransferSkippedEventArgs args) + private Task AppendSkippedArg(TransferItemSkippedEventArgs args) { SkippedEvents.Add(args); return Task.CompletedTask; } - private Task AppendSingleTransferCompleted(SingleTransferCompletedEventArgs args) + private Task AppendSingleTransferCompleted(TransferItemCompletedEventArgs args) { SingleCompletedEvents.Add(args); return Task.CompletedTask; @@ -102,7 +102,7 @@ public void AssertUnexpectedFailureCheck() { Assert.Multiple(() => { - foreach (TransferFailedEventArgs failure in FailedEvents) + foreach (TransferItemFailedEventArgs failure in FailedEvents) { Assert.Fail( $"Failure occurred at Transfer id: {failure.TransferId}.\n" + @@ -116,7 +116,7 @@ public void AssertUnexpectedFailureCheck() /// /// This asserts that the expected events occurred during a single transfer that is expected - /// to have a at the end without any skips + /// to have a at the end without any skips /// or failures. /// public async Task AssertSingleCompletedCheck() @@ -127,15 +127,15 @@ public async Task AssertSingleCompletedCheck() await WaitForStatusEventsAsync().ConfigureAwait(false); CollectionAssert.AreEqual( - new StorageTransferStatus[] { - StorageTransferStatus.InProgress, - StorageTransferStatus.Completed }, + new DataTransferStatus[] { + DataTransferStatus.InProgress, + DataTransferStatus.Completed }, StatusEvents.Select(e => e.StorageTransferStatus)); } /// /// This asserts that the expected events occurred during a single transfer that is expected - /// to have a at the end without any + /// to have a at the end without any /// or failures. /// public async Task AssertSingleSkippedCheck() @@ -148,15 +148,15 @@ public async Task AssertSingleSkippedCheck() await WaitForStatusEventsAsync().ConfigureAwait(false); CollectionAssert.AreEqual( - new StorageTransferStatus[] { - StorageTransferStatus.InProgress, - StorageTransferStatus.CompletedWithSkippedTransfers }, + new DataTransferStatus[] { + DataTransferStatus.InProgress, + DataTransferStatus.CompletedWithSkippedTransfers }, StatusEvents.Select(e => e.StorageTransferStatus)); } /// /// This asserts that the expected events occurred during a single transfer that is expected - /// to have a at the end without any skips. + /// to have a at the end without any skips. /// public async Task AssertSingleFailedCheck() { @@ -169,16 +169,16 @@ public async Task AssertSingleFailedCheck() await WaitForStatusEventsAsync().ConfigureAwait(false); CollectionAssert.AreEqual( - new StorageTransferStatus[] { - StorageTransferStatus.InProgress, - StorageTransferStatus.CancellationInProgress, - StorageTransferStatus.CompletedWithFailedTransfers }, + new DataTransferStatus[] { + DataTransferStatus.InProgress, + DataTransferStatus.CancellationInProgress, + DataTransferStatus.CompletedWithFailedTransfers }, StatusEvents.Select(e => e.StorageTransferStatus)); } /// /// This asserts that the expected events occurred during a container transfer that is expected - /// to have a at the end without any skips + /// to have a at the end without any skips /// or failures. /// /// @@ -192,16 +192,16 @@ public async Task AssertContainerCompletedCheck(int transferCount) await WaitForStatusEventsAsync().ConfigureAwait(false); CollectionAssert.AreEqual( - new StorageTransferStatus[] { - StorageTransferStatus.InProgress, - StorageTransferStatus.Completed }, + new DataTransferStatus[] { + DataTransferStatus.InProgress, + DataTransferStatus.Completed }, StatusEvents.Select(e => e.StorageTransferStatus)); } /// /// This asserts that the expected events occurred during a container transfer that is expected - /// to have a at the end without any skips. - /// Assuming was set. + /// to have a at the end without any skips. + /// Assuming was set. /// /// /// Expected amount of failure single transfers to occur within the container transfers. @@ -222,17 +222,17 @@ public async Task AssertContainerCompletedWithFailedCheck(int expectedFailureCou await WaitForStatusEventsAsync().ConfigureAwait(false); CollectionAssert.AreEqual( - new StorageTransferStatus[] { - StorageTransferStatus.InProgress, - StorageTransferStatus.CancellationInProgress, - StorageTransferStatus.CompletedWithFailedTransfers }, + new DataTransferStatus[] { + DataTransferStatus.InProgress, + DataTransferStatus.CancellationInProgress, + DataTransferStatus.CompletedWithFailedTransfers }, StatusEvents.Select(e => e.StorageTransferStatus)); } /// /// This asserts that the expected events occurred during a container transfer that is expected - /// to have a at the end without any skips. - /// Assuming was set. + /// to have a at the end without any skips. + /// Assuming was set. /// /// /// Expected amount of failure single transfers to occur within the container transfers. @@ -253,15 +253,15 @@ public async Task AssertContainerCompletedWithFailedCheckContinue(int expectedFa await WaitForStatusEventsAsync().ConfigureAwait(false); CollectionAssert.AreEqual( - new StorageTransferStatus[] { - StorageTransferStatus.InProgress, - StorageTransferStatus.CompletedWithFailedTransfers }, + new DataTransferStatus[] { + DataTransferStatus.InProgress, + DataTransferStatus.CompletedWithFailedTransfers }, StatusEvents.Select(e => e.StorageTransferStatus)); } /// /// This asserts that the expected events occurred during a container transfer that is expected - /// to have a at the end without any failures. + /// to have a at the end without any failures. /// /// /// Expected amount of skipped single transfers to occur within the container transfers. @@ -273,9 +273,9 @@ public async Task AssertContainerCompletedWithSkippedCheck(int expectedSkipCount await WaitForStatusEventsAsync().ConfigureAwait(false); CollectionAssert.AreEqual( - new StorageTransferStatus[] { - StorageTransferStatus.InProgress, - StorageTransferStatus.CompletedWithSkippedTransfers }, + new DataTransferStatus[] { + DataTransferStatus.InProgress, + DataTransferStatus.CompletedWithSkippedTransfers }, StatusEvents.Select(e => e.StorageTransferStatus)); } @@ -286,9 +286,9 @@ public async Task AssertPausedCheck() await WaitForStatusEventsAsync().ConfigureAwait(false); CollectionAssert.AreEqual( - new StorageTransferStatus[] { - StorageTransferStatus.InProgress, - StorageTransferStatus.Paused }, + new DataTransferStatus[] { + DataTransferStatus.InProgress, + DataTransferStatus.Paused }, StatusEvents.Select(e => e.StorageTransferStatus)); } @@ -300,15 +300,15 @@ public async Task AssertPausedCheck() /// The options bag reference. If there are existing options, use the existing options, /// if not default options will be created so event args can be added to the event handlers /// A respective list of Events Raised coordinating with the options given. - internal static List PopulateTestOptions(int transferCount, ref List listOptions) + internal static List PopulateTestOptions(int transferCount, ref List listOptions) { List eventRaisedList = new List(transferCount); if (listOptions == default || listOptions?.Count == 0) { - listOptions ??= new List(transferCount); + listOptions ??= new List(transferCount); for (int i = 0; i < transferCount; i++) { - TransferOptions currentOptions = new TransferOptions(); + DataTransferOptions currentOptions = new DataTransferOptions(); TestEventsRaised testEventRaisedCurrent = new TestEventsRaised(currentOptions); listOptions.Add(currentOptions); eventRaisedList.Add(testEventRaisedCurrent); @@ -319,7 +319,7 @@ internal static List PopulateTestOptions(int transferCount, re // If blobNames is populated make sure these number of blobs match Assert.AreEqual(transferCount, listOptions.Count); // Add TestEventRaised to each option - foreach (TransferOptions currentOptions in listOptions) + foreach (DataTransferOptions currentOptions in listOptions) { TestEventsRaised testEventRaisedCurrent = new TestEventsRaised(currentOptions); eventRaisedList.Add(testEventRaisedCurrent); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/TestProgressHandler.cs b/sdk/storage/Azure.Storage.DataMovement/tests/TestProgressHandler.cs index e5a188f979dfa..4877cf33bf83f 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/TestProgressHandler.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/TestProgressHandler.cs @@ -6,11 +6,11 @@ namespace Azure.Storage.DataMovement.Tests { - internal class TestProgressHandler : IProgress + internal class TestProgressHandler : IProgress { - public List Updates { get; private set; } = new List(); + public List Updates { get; private set; } = new List(); - public void Report(StorageTransferProgress progress) + public void Report(DataTransferProgress progress) { Updates.Add(progress); }