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

Checkpointer use testing #47224

Merged
merged 12 commits into from
Dec 3, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ public override int GetHashCode()
return hashCode;
}

/// <inheritdoc/>
public override string ToString()
{
return $"{{{nameof(State)}:{State},{nameof(HasFailedItems)}:{HasFailedItems},{nameof(HasSkippedItems)}:{HasSkippedItems}}}";
}

/// <summary>
/// Performs a Deep Copy of the <see cref="DataTransferStatus"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ await TransferFailedEventHandler.RaiseAsync(
.ConfigureAwait(false);
}
}
_dataTransfer.TransferStatus.SetFailedItem();
jaschrep-msft marked this conversation as resolved.
Show resolved Hide resolved

try
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public JobPartPlanHeader Plan
}
}

private Dictionary<string, Job> Jobs { get; set; } = new();
public Dictionary<string, Job> Jobs { get; set; } = new();

public Task AddNewJobAsync(string transferId, StorageResource source, StorageResource destination, CancellationToken cancellationToken = default)
public virtual Task AddNewJobAsync(string transferId, StorageResource source, StorageResource destination, CancellationToken cancellationToken = default)
{
if (Jobs.ContainsKey(transferId))
{
Expand All @@ -68,12 +68,13 @@ public Task AddNewJobAsync(string transferId, StorageResource source, StorageRes
CreationTime = DateTimeOffset.Now,
Operation = JobPlanOperation.Upload, // TODO
Source = source,
Destination = destination
Destination = destination,
Status = new(DataTransferState.Queued, false, false),
};
return Task.CompletedTask;
}

public Task AddNewJobPartAsync(string transferId, int partNumber, JobPartPlanHeader header, CancellationToken cancellationToken = default)
public virtual Task AddNewJobPartAsync(string transferId, int partNumber, JobPartPlanHeader header, CancellationToken cancellationToken = default)
{
if (!Jobs.TryGetValue(transferId, out Job job))
{
Expand All @@ -86,16 +87,17 @@ public Task AddNewJobPartAsync(string transferId, int partNumber, JobPartPlanHea
job.Parts.Add(partNumber, new()
{
Plan = header,
Status = new(DataTransferState.Queued, false, false),
});
return Task.CompletedTask;
}

public Task<int> GetCurrentJobPartCountAsync(string transferId, CancellationToken cancellationToken = default)
public virtual Task<int> GetCurrentJobPartCountAsync(string transferId, CancellationToken cancellationToken = default)
{
return Task.FromResult(Jobs.TryGetValue(transferId, out Job job) ? job.Parts.Count : 0);
}

public Task<DataTransferProperties> GetDataTransferPropertiesAsync(string transferId, CancellationToken cancellationToken = default)
public virtual Task<DataTransferProperties> GetDataTransferPropertiesAsync(string transferId, CancellationToken cancellationToken = default)
{
if (!Jobs.TryGetValue(transferId, out Job job))
{
Expand All @@ -112,7 +114,7 @@ public Task<DataTransferProperties> GetDataTransferPropertiesAsync(string transf
});
}

public Task<JobPartPlanHeader> GetJobPartAsync(string transferId, int partNumber, CancellationToken cancellationToken = default)
public virtual Task<JobPartPlanHeader> GetJobPartAsync(string transferId, int partNumber, CancellationToken cancellationToken = default)
{
if (!Jobs.TryGetValue(transferId, out Job job))
{
Expand All @@ -125,7 +127,7 @@ public Task<JobPartPlanHeader> GetJobPartAsync(string transferId, int partNumber
return Task.FromResult(part.Plan);
}

public Task<DataTransferStatus> GetJobStatusAsync(string transferId, CancellationToken cancellationToken = default)
public virtual Task<DataTransferStatus> GetJobStatusAsync(string transferId, CancellationToken cancellationToken = default)
{
if (!Jobs.TryGetValue(transferId, out Job job))
{
Expand All @@ -134,17 +136,17 @@ public Task<DataTransferStatus> GetJobStatusAsync(string transferId, Cancellatio
return Task.FromResult(job.Status.DeepCopy());
}

public Task<List<string>> GetStoredTransfersAsync(CancellationToken cancellationToken = default)
public virtual Task<List<string>> GetStoredTransfersAsync(CancellationToken cancellationToken = default)
{
return Task.FromResult(Jobs.Keys.ToList());
}

public Task<bool> IsEnumerationCompleteAsync(string transferId, CancellationToken cancellationToken = default)
public virtual Task<bool> IsEnumerationCompleteAsync(string transferId, CancellationToken cancellationToken = default)
{
return Task.FromResult(Jobs.TryGetValue(transferId, out Job job) && job.EnumerationComplete);
}

public Task SetEnumerationCompleteAsync(string transferId, CancellationToken cancellationToken = default)
public virtual Task SetEnumerationCompleteAsync(string transferId, CancellationToken cancellationToken = default)
{
if (Jobs.TryGetValue(transferId, out Job job))
{
Expand All @@ -153,7 +155,7 @@ public Task SetEnumerationCompleteAsync(string transferId, CancellationToken can
return Task.CompletedTask;
}

public Task SetJobPartStatusAsync(string transferId, int partNumber, DataTransferStatus status, CancellationToken cancellationToken = default)
public virtual Task SetJobPartStatusAsync(string transferId, int partNumber, DataTransferStatus status, CancellationToken cancellationToken = default)
{
if (Jobs.TryGetValue(transferId, out Job job) && job.Parts.TryGetValue(partNumber, out JobPart part))
{
Expand All @@ -162,7 +164,7 @@ public Task SetJobPartStatusAsync(string transferId, int partNumber, DataTransfe
return Task.CompletedTask;
}

public Task SetJobStatusAsync(string transferId, DataTransferStatus status, CancellationToken cancellationToken = default)
public virtual Task SetJobStatusAsync(string transferId, DataTransferStatus status, CancellationToken cancellationToken = default)
{
if (Jobs.TryGetValue(transferId, out Job job))
{
Expand All @@ -171,7 +173,7 @@ public Task SetJobStatusAsync(string transferId, DataTransferStatus status, Canc
return Task.CompletedTask;
}

public Task<bool> TryRemoveStoredTransferAsync(string transferId, CancellationToken cancellationToken = default)
public virtual Task<bool> TryRemoveStoredTransferAsync(string transferId, CancellationToken cancellationToken = default)
{
return Task.FromResult(Jobs.Remove(transferId));
}
Expand Down
Loading
Loading