Exemple #1
0
 /// <summary>
 /// Task execution override
 /// </summary>
 protected override void DoExecute()
 {
     // prepare the restore plugin for the session
      // and mark it as in-progress
      using (var txn = new TransactionScope(TransactionScopeOption.Required, TimeSpan.MaxValue))
      {
     this.restore = this.Archive.PrepareRestore(this.Session);
     if (this.Session.State == SkyFloe.Restore.SessionState.Pending)
     {
        this.Session.State = SkyFloe.Restore.SessionState.InProgress;
        this.Archive.RestoreIndex.UpdateSession(this.Session);
     }
     txn.Complete();
      }
      this.limiter = new IO.RateLimiter(this.Session.RateLimit);
      this.copier = new IO.StreamCopier();
      for (; ; )
      {
     this.Canceler.ThrowIfCancellationRequested();
     // fetch and restore the next pending entry
     var entry = this.Archive.RestoreIndex.LookupNextEntry(this.Session);
     if (entry == null)
        break;
     RestoreEntry(entry);
      }
      // there are no more pending restore entries, so complete the session
      this.Session.State = SkyFloe.Restore.SessionState.Completed;
      this.Archive.RestoreIndex.UpdateSession(this.Session);
 }
Exemple #2
0
 /// <summary>
 /// Initializes a new restore instance
 /// </summary>
 /// <param name="archive">
 /// The SkyFloe archive for the restore
 /// </param>
 /// <param name="session">
 /// The restore session being processed
 /// </param>
 public GlacierRestore(GlacierArchive archive, Restore.Session session)
 {
     this.archive = archive;
      if (session.State == SkyFloe.Restore.SessionState.Pending)
     ScheduleRetrievals(session);
      this.downloader = new GlacierDownloader(
     this.archive.Glacier,
     this.archive.Vault
      );
      this.retrievalLimiter = new IO.RateLimiter(
     Math.Min(session.RateLimit, MaxRetrievalRate)
      );
 }
Exemple #3
0
 /// <summary>
 /// Task execution override
 /// </summary>
 protected override void DoExecute()
 {
     // prepare the backup plugin for the session
      // and mark it as in-progress
      this.backup = this.Archive.PrepareBackup(this.Session);
      if (this.Session.State == SkyFloe.Backup.SessionState.Pending)
      {
     this.Session.State = SkyFloe.Backup.SessionState.InProgress;
     this.Archive.BackupIndex.UpdateSession(this.Session);
     Checkpoint();
      }
      try
      {
     this.limiter = new IO.RateLimiter(this.Session.RateLimit);
     var checkpointSize = 0L;
     for (; ; )
     {
        this.Canceler.ThrowIfCancellationRequested();
        // fetch the next pending backup entry and
        // send it to the archive
        var entry = this.Archive.BackupIndex.LookupNextEntry(this.Session);
        if (entry == null)
           break;
        BackupEntry(entry);
        // if we have reached the configured checkpoint
        // size, then force a checkpoint
        checkpointSize += entry.Length;
        if (checkpointSize > this.Session.CheckpointLength)
        {
           checkpointSize = 0;
           Checkpoint();
        }
     }
     // there are no more pending backup entries, so complete the session
     this.Session.State = SkyFloe.Backup.SessionState.Completed;
     this.Archive.BackupIndex.UpdateSession(this.Session);
     Checkpoint();
      }
      catch (OperationCanceledException)
      {
     // if the client requested cancellation, attempt to
     // checkpoint the backup to save our progress
     Checkpoint();
     throw;
      }
 }