Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Storage] [DataMovement] Convert TransferStatus from enum to class #38374

Merged
merged 20 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public async Task UploadDirectory_EventHandler_SasAsync()
DataTransferOptions transferOptions = new DataTransferOptions();
transferOptions.TransferStatusChanged += (TransferStatusEventArgs args) =>
{
if (args.StorageTransferStatus == DataTransferStatus.Completed)
if (args.TransferStatus.HasCompletedSuccessfully)
{
using (StreamWriter logStream = File.AppendText(logFile))
{
Expand Down Expand Up @@ -659,7 +659,7 @@ public async Task CopySingle_ConnectionStringAsync()
#endregion

Assert.IsTrue(await destinationAppendBlobClient.ExistsAsync());
Assert.AreEqual(dataTransfer.TransferStatus, DataTransferStatus.Completed);
Assert.AreEqual(DataTransferStatus.TransferState.Completed, dataTransfer.TransferStatus.State);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@
<Compile Include="$(AzureStorageDataMovementSharedSources)CheckpointerExtensions.cs" LinkBase="Shared\DataMovement" />
<Compile Include="$(AzureStorageDataMovementSharedSources)Errors.DataMovement.cs" LinkBase="Shared\DataMovement" />
<Compile Include="$(AzureStorageDataMovementSharedSources)DataMovementConstants.cs" LinkBase="Shared\DataMovement" />
<Compile Include="$(AzureStorageDataMovementSharedSources)DataTransferStatusInternal.cs" LinkBase="Shared\DataMovement" />
<Compile Include="$(AzureStorageDataMovementSharedSources)JobPlanExtensions.cs" LinkBase="Shared\DataMovement" />
<Compile Include="$(AzureStorageDataMovementSharedSources)ResponseExtensions.cs" LinkBase="Shared\DataMovement" />
<Compile Include="$(AzureStorageDataMovementSharedSources)LocalTransferCheckpointer.cs" LinkBase="Shared\DataMovement" />
<Compile Include="$(AzureStorageDataMovementSharedSources)TransferCheckpointer.cs" LinkBase="Shared\DataMovement" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(AzureStorageDataMovementSharedSources)\JobPlan\*" LinkBase="Shared\DataMovement\JobPlan" />

</ItemGroup>
<ItemGroup>
<Compile Include="$(AzureStorageBlobsSharedSources)BlobErrors.cs" LinkBase="Shared\Blobs" />
Expand Down
4 changes: 3 additions & 1 deletion sdk/storage/Azure.Storage.DataMovement/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- [BREAKING CHANGE] Renamed `SingleTransferCompletedEventArgs` to `TransferItemCompletedEventArgs`
- [BREAKING CHANGE] Renamed `TransferItemFailedEventArgs` to `TransferItemFailedEventArgs`
- [BREAKING CHANGE] Renamed `TransferItemSkippedEventArgs` to `TransferItemSkippedEventArgs`
- [BREAKING CHANGE] Renamed `TransferStatusEventArgs.StorageTransferStatus` to `TransferStatus`
- [BREAKING CHANGE] Renamed `StorageResourceSingle` to `StorageResourceItem`
- [BREAKING CHANGE] Renamed `StorageResourceItem.WriteFromStreamAsync` to `CopyFromStreamAsync`
- [BREAKING CHANGE] Renamed `StorageResourceContainer.GetChildStorageResource` to `StorageResourceContainer.GetStorageResourceReference`
Expand All @@ -49,8 +50,9 @@
- [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 `DataTransferOrder.Concurrent` to `Unordered`
- [BREAKING CHANGE] Renamed `StorageTransferStatus` to `DataTransferStatus`
- [BREAKING CHANGE] Changed `DataTransferStatus` from `enum` to a `class`.
- [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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,25 @@ protected internal DataTransferProperties() { }
public virtual string SourceTypeId { get { throw null; } }
public virtual string TransferId { get { throw null; } }
}
public enum DataTransferStatus
{
None = 0,
Queued = 1,
InProgress = 2,
Paused = 3,
Completed = 4,
CompletedWithSkippedTransfers = 5,
CompletedWithFailedTransfers = 6,
PauseInProgress = 7,
CancellationInProgress = 8,
public partial class DataTransferStatus : System.IEquatable<Azure.Storage.DataMovement.DataTransferStatus>
{
protected internal DataTransferStatus() { }
protected internal DataTransferStatus(Azure.Storage.DataMovement.DataTransferStatus.TransferState state, bool hasFailureItems, bool hasSkippedItems) { }
public bool HasCompletedSuccessfully { get { throw null; } }
public bool HasFailedItems { get { throw null; } }
public bool HasSkippedItems { get { throw null; } }
public Azure.Storage.DataMovement.DataTransferStatus.TransferState State { get { throw null; } }
public bool Equals(Azure.Storage.DataMovement.DataTransferStatus other) { throw null; }
public enum TransferState
{
None = 0,
Queued = 1,
InProgress = 2,
Pausing = 3,
Stopping = 4,
Paused = 5,
Completed = 6,
}
}
public partial class LocalDirectoryStorageResourceContainer : Azure.Storage.DataMovement.StorageResourceContainer
{
Expand Down Expand Up @@ -237,6 +245,6 @@ public TransferManagerOptions() { }
public partial class TransferStatusEventArgs : Azure.Storage.DataMovement.DataTransferEventArgs
{
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; } }
public Azure.Storage.DataMovement.DataTransferStatus TransferStatus { get { throw null; } }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,25 @@ protected internal DataTransferProperties() { }
public virtual string SourceTypeId { get { throw null; } }
public virtual string TransferId { get { throw null; } }
}
public enum DataTransferStatus
{
None = 0,
Queued = 1,
InProgress = 2,
Paused = 3,
Completed = 4,
CompletedWithSkippedTransfers = 5,
CompletedWithFailedTransfers = 6,
PauseInProgress = 7,
CancellationInProgress = 8,
public partial class DataTransferStatus : System.IEquatable<Azure.Storage.DataMovement.DataTransferStatus>
{
protected internal DataTransferStatus() { }
protected internal DataTransferStatus(Azure.Storage.DataMovement.DataTransferStatus.TransferState state, bool hasFailureItems, bool hasSkippedItems) { }
public bool HasCompletedSuccessfully { get { throw null; } }
public bool HasFailedItems { get { throw null; } }
public bool HasSkippedItems { get { throw null; } }
public Azure.Storage.DataMovement.DataTransferStatus.TransferState State { get { throw null; } }
public bool Equals(Azure.Storage.DataMovement.DataTransferStatus other) { throw null; }
public enum TransferState
{
None = 0,
Queued = 1,
InProgress = 2,
Pausing = 3,
Stopping = 4,
Paused = 5,
Completed = 6,
}
}
public partial class LocalDirectoryStorageResourceContainer : Azure.Storage.DataMovement.StorageResourceContainer
{
Expand Down Expand Up @@ -237,6 +245,6 @@ public TransferManagerOptions() { }
public partial class TransferStatusEventArgs : Azure.Storage.DataMovement.DataTransferEventArgs
{
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; } }
public Azure.Storage.DataMovement.DataTransferStatus TransferStatus { get { throw null; } }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -13,13 +14,25 @@ internal static async Task<bool> IsResumableAsync(
string transferId,
CancellationToken cancellationToken)
{
DataTransferStatus jobStatus = (DataTransferStatus)await checkpointer.GetByteValue(
DataTransferStatus.TransferState transferState = (DataTransferStatus.TransferState) await checkpointer.GetByteValue(
transferId,
DataMovementConstants.JobPartPlanFile.AtomicJobStatusIndex,
DataMovementConstants.JobPartPlanFile.AtomicJobStatusStateIndex,
cancellationToken).ConfigureAwait(false);

byte hasFailedItemsByte = await checkpointer.GetByteValue(
transferId,
DataMovementConstants.JobPartPlanFile.AtomicJobStatusHasFailedIndex,
cancellationToken).ConfigureAwait(false);
bool hasFailedItems = Convert.ToBoolean(hasFailedItemsByte);

byte hasSkippedItemsByte = await checkpointer.GetByteValue(
transferId,
DataMovementConstants.JobPartPlanFile.AtomicJobStatusHasSkippedIndex,
cancellationToken).ConfigureAwait(false);
bool hasSkippedItems = Convert.ToBoolean(hasSkippedItemsByte);

// Transfers marked as fully completed are not resumable
return jobStatus != DataTransferStatus.Completed;
return transferState != DataTransferStatus.TransferState.Completed || hasFailedItems || hasSkippedItems;
}

internal static async Task<DataTransferProperties> GetDataTransferPropertiesAsync(
Expand Down
Loading
Loading