/// <summary> /// Initializes a new instance of the <see cref="TransferContext" /> class. /// </summary> /// <param name="checkpoint">An <see cref="TransferCheckpoint"/> object representing the last checkpoint from which the transfer continues on.</param> public TransferContext(TransferCheckpoint checkpoint) { if (checkpoint == null) { this.Checkpoint = new TransferCheckpoint(); } else { this.Checkpoint = checkpoint.Copy(); } }
/// <summary> /// Initializes a new instance of the <see cref="TransferCheckpoint"/> class. /// </summary> /// <param name="other">Another TransferCheckpoint object. </param> internal TransferCheckpoint(TransferCheckpoint other) { if (null == other) { this.TransferCollection = new TransferCollection(); } else { this.TransferCollection = other.TransferCollection.Copy(); } }
/// <summary> /// Initializes a new instance of the <see cref="TransferContext" /> class. /// </summary> /// <param name="checkpoint">An <see cref="TransferCheckpoint"/> object representing the last checkpoint from which the transfer continues on.</param> public TransferContext(TransferCheckpoint checkpoint) { if (checkpoint == null) { this.Checkpoint = new TransferCheckpoint(); } else { this.Checkpoint = checkpoint.Copy(); } }
/// <summary> /// Initializes a new instance of the <see cref="TransferContext" /> class. /// </summary> /// <param name="checkpoint">An <see cref="TransferCheckpoint"/> object representing the last checkpoint from which the transfer continues on.</param> public TransferContext(TransferCheckpoint checkpoint) { if (checkpoint == null) { #if BINARY_SERIALIZATION this.Checkpoint = new TransferCheckpoint(); #else this.Checkpoint = new TransferCheckpoint(null); #endif } else { this.Checkpoint = checkpoint.Copy(); } }
/// <summary> /// Gets a static snapshot of this transfer checkpoint /// </summary> /// <returns>A snapshot of current transfer checkpoint</returns> internal TransferCheckpoint Copy() { TransferCheckpoint copyObj = new TransferCheckpoint(); foreach (var kvPair in this.transfers) { SingleObjectTransfer transfer = kvPair.Value as SingleObjectTransfer; if (transfer != null) { copyObj.AddTransfer(transfer.Copy()); } } return(copyObj); }
/// <summary> /// Initializes a new instance of the <see cref="TransferContext" /> class. /// </summary> /// <param name="checkpoint">An <see cref="TransferCheckpoint"/> object representing the last checkpoint from which the transfer continues on.</param> protected TransferContext(TransferCheckpoint checkpoint) { this.LogLevel = OperationContext.DefaultLogLevel; if (checkpoint == null) { #if BINARY_SERIALIZATION this.Checkpoint = new TransferCheckpoint(); #else this.Checkpoint = new TransferCheckpoint(other: null); #endif } else { this.Checkpoint = checkpoint.Copy(); } }
/// <summary> /// Initializes a new instance of the <see cref="TransferContext" /> class. /// </summary> /// <param name="checkpoint">An <see cref="TransferCheckpoint"/> object representing the last checkpoint from which the transfer continues on.</param> public TransferContext(TransferCheckpoint checkpoint) { if (checkpoint == null) { this.Checkpoint = new TransferCheckpoint(); } else { this.Checkpoint = checkpoint.Copy(); } this.OverallProgressTracker = new TransferProgressTracker(); foreach (Transfer transfer in this.Checkpoint.AllTransfers) { this.OverallProgressTracker.AddBytesTransferred(transfer.ProgressTracker.BytesTransferred); this.OverallProgressTracker.AddNumberOfFilesTransferred(transfer.ProgressTracker.NumberOfFilesTransferred); this.OverallProgressTracker.AddNumberOfFilesSkipped(transfer.ProgressTracker.NumberOfFilesSkipped); this.OverallProgressTracker.AddNumberOfFilesFailed(transfer.ProgressTracker.NumberOfFilesFailed); } }
/// <summary> /// Initializes a new instance of the <see cref="TransferContext" /> class. /// </summary> /// <param name="checkpoint">An <see cref="TransferCheckpoint"/> object representing the last checkpoint from which the transfer continues on.</param> public TransferContext(TransferCheckpoint checkpoint) { if (checkpoint == null) { this.Checkpoint = new TransferCheckpoint(); } else { this.Checkpoint = checkpoint.Copy(); } this.OverallProgressTracker = new TransferProgressTracker(); foreach(Transfer transfer in this.Checkpoint.AllTransfers) { this.OverallProgressTracker.AddBytesTransferred(transfer.ProgressTracker.BytesTransferred); this.OverallProgressTracker.AddNumberOfFilesTransferred(transfer.ProgressTracker.NumberOfFilesTransferred); this.OverallProgressTracker.AddNumberOfFilesSkipped(transfer.ProgressTracker.NumberOfFilesSkipped); this.OverallProgressTracker.AddNumberOfFilesFailed(transfer.ProgressTracker.NumberOfFilesFailed); } }
public static TransferCheckpoint SaveAndReloadCheckpoint(TransferCheckpoint checkpoint) { //return checkpoint; Test.Info("Save and reload checkpoint"); IFormatter formatter = new BinaryFormatter(); TransferCheckpoint reloadedCheckpoint; string tempFileName = Guid.NewGuid().ToString(); using (var stream = new FileStream(tempFileName, FileMode.Create, FileAccess.Write, FileShare.None)) { formatter.Serialize(stream, checkpoint); } using (var stream = new FileStream(tempFileName, FileMode.Open, FileAccess.Read, FileShare.None)) { reloadedCheckpoint = formatter.Deserialize(stream) as TransferCheckpoint; } File.Delete(tempFileName); return reloadedCheckpoint; }
private async static Task CopyDirectoryAsync(string jobId, CloudBlobDirectory sourceDirectory, CloudBlobDirectory destinationDirectory, CopyDirectoryOptions copyDirectoryOptions, TransferContext transferContext, TransferCheckpoint transferCheckpoint, CancellationTokenSource cancellationTokenSource) { // Start the transfer try { await TransferManager.CopyDirectoryAsync( sourceBlobDir: sourceDirectory, destBlobDir: destinationDirectory, isServiceCopy: false, options: copyDirectoryOptions, context: transferContext, cancellationToken: cancellationTokenSource.Token); // Store the transfer checkpoint to record the completed copy operation transferCheckpoint = transferContext.LastCheckpoint; } catch(TransferException) { // Swallow all transfer exceptions here. Files skipped in the OverwriteCallback throw an exception here // even in an Incremental copy where the source is skipped because it and destination are identical // Instead all exceptions from transfers are handled in the FileFailed event handler. } catch (Exception ex) { // Fatal or other exceptions resulting in the transfer being cancelled will still appear here // Save a Checkpoint so we can restart the transfer transferCheckpoint = transferContext.LastCheckpoint; SaveTransferCheckpoint(jobId, transferCheckpoint); throw new Exception("Error in CopyDirectoryAsync(): " + ex.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="TransferCheckpoint"/> class. /// </summary> /// <param name="other">Another TransferCheckpoint object. </param> private TransferCheckpoint(TransferCheckpoint other) { this.TransferCollection = other.TransferCollection.Copy(); }
/// <summary> /// Initializes a new instance of the <see cref="SingleTransferContext" /> class. /// </summary> /// <param name="checkpoint">An <see cref="TransferCheckpoint"/> object representing the last checkpoint from which the transfer continues on.</param> public SingleTransferContext(TransferCheckpoint checkpoint) : base(checkpoint) { }
/// <summary> /// Gets a static snapshot of this transfer checkpoint /// </summary> /// <returns>A snapshot of current transfer checkpoint</returns> internal TransferCheckpoint Copy() { TransferCheckpoint copyObj = new TransferCheckpoint(); foreach (var kvPair in this.transfers) { SingleObjectTransfer transfer = kvPair.Value as SingleObjectTransfer; if (transfer != null) { copyObj.AddTransfer(transfer.Copy()); } } return copyObj; }
public static TransferCheckpoint RandomReloadCheckpoint(TransferCheckpoint checkpoint) { if (Helper.RandomBoolean()) { Test.Info("Save and reload checkpoint"); return DMLibTestHelper.SaveAndReloadCheckpoint(checkpoint); } return checkpoint; }
/// <summary> /// Initializes a new instance of the <see cref="DirectoryTransferContext" /> class. /// </summary> /// <param name="checkpoint">An <see cref="TransferCheckpoint"/> object representing the last checkpoint from which the transfer continues on.</param> public DirectoryTransferContext(TransferCheckpoint checkpoint) : base(checkpoint) { }
private async static void SaveTransferCheckpoint(string jobId, TransferCheckpoint transferCheckpoint) { try { // Get reference to storage account we are using for Web Jobs Storage CloudBlobDirectory directory = await GetCheckpointStorage(); CloudBlockBlob blob = directory.GetBlockBlobReference(jobId); await blob.DeleteIfExistsAsync(DeleteSnapshotsOption.None, null, _blobRequestOptions, _opContext); using (var stream = new MemoryStream()) { IFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, transferCheckpoint); stream.Position = 0; await blob.UploadFromStreamAsync(stream, null, _blobRequestOptions, _opContext); } } catch(Exception ex) { throw new Exception("Error in SaveTransferCheckpoint(): " + ex.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="TransferCheckpoint"/> class. /// </summary> /// <param name="other">Another TransferCheckpoint object. </param> private TransferCheckpoint(TransferCheckpoint other) { this.TransferCollection = other.TransferCollection.Copy(); }