Example #1
0
        public override void Start()
        {
            Assert.IsFalse(IsRunning);
            Assert.IsNotNull(Synchronization);
            Assert.IsNotNull(Synchronization.StorageAccount);
            Assert.AreEqual(Models.EStorageAccountType.AmazonS3, Synchronization.StorageAccountType);

            AmazonS3AccountRepository dao = new AmazonS3AccountRepository();

            Models.AmazonS3Account s3account = dao.GetForReadOnly(Synchronization.StorageAccount.Id);

            //
            // Dispose and recycle previous objects, if needed.
            //
            if (TransferAgent != null)
            {
                TransferAgent.Dispose();
            }
            if (TransferListControl != null)
            {
                TransferListControl.ClearTransfers();
            }
            if (SyncAgent != null)
            {
                SyncAgent.Dispose();
            }

            //
            // Setup agents.
            //
            AWSCredentials       awsCredentials = new BasicAWSCredentials(s3account.AccessKey, s3account.SecretKey);
            TransferAgentOptions options        = new TransferAgentOptions
            {
                UploadChunkSizeInBytes = Teltec.Everest.Settings.Properties.Current.UploadChunkSize * 1024 * 1024,
            };

            TransferAgent = new S3TransferAgent(options, awsCredentials, s3account.BucketName, CancellationTokenSource.Token);
            TransferAgent.RemoteRootDir = TransferAgent.PathBuilder.CombineRemotePath("TELTEC_BKP", s3account.Hostname);

            RemoteObjects = new List <ListingObject>(4096);            // Avoid small resizes without compromising memory.
            SyncAgent     = new CustomSynchronizationAgent(TransferAgent);

            RegisterEventHandlers(Synchronization);

            Report.PlanType    = "synchronization";
            Report.PlanName    = "No plan";
            Report.BucketName  = s3account.BucketName;
            Report.HostName    = Synchronization.StorageAccount.Hostname;
            Report.SyncResults = SyncAgent.Results;

            //
            // Start the sync.
            //
            DoSynchronization(SyncAgent, Synchronization, Options);
        }
Example #2
0
        public override void Start()
        {
            Assert.IsFalse(IsRunning);
            Assert.IsNotNull(Restore);
            Assert.IsNotNull(Restore.RestorePlan.StorageAccount);
            Assert.AreEqual(Models.EStorageAccountType.AmazonS3, Restore.RestorePlan.StorageAccountType);

            AmazonS3AccountRepository dao = new AmazonS3AccountRepository();

            Models.AmazonS3Account s3account = dao.GetForReadOnly(Restore.RestorePlan.StorageAccount.Id);

            //
            // Dispose and recycle previous objects, if needed.
            //
            if (TransferAgent != null)
            {
                TransferAgent.Dispose();
            }
            if (TransferListControl != null)
            {
                TransferListControl.ClearTransfers();
            }
            if (RestoreAgent != null)
            {
                RestoreAgent.Dispose();
            }
            if (Versioner != null)
            {
                Versioner.Dispose();
            }

            //
            // Setup agents.
            //
            AWSCredentials       awsCredentials = new BasicAWSCredentials(s3account.AccessKey, s3account.SecretKey);
            TransferAgentOptions options        = new TransferAgentOptions
            {
                UploadChunkSizeInBytes = Teltec.Everest.Settings.Properties.Current.UploadChunkSize * 1024 * 1024,
            };

            TransferAgent = new S3TransferAgent(options, awsCredentials, s3account.BucketName, CancellationTokenSource.Token);
            TransferAgent.RemoteRootDir = TransferAgent.PathBuilder.CombineRemotePath("TELTEC_BKP",
                                                                                      Restore.RestorePlan.StorageAccount.Hostname);

            RestoreAgent = new CustomRestoreAgent(TransferAgent);
            RestoreAgent.Results.Monitor = TransferListControl;

            Versioner = new RestoreFileVersioner(CancellationTokenSource.Token);

            RegisterResultsEventHandlers(Restore, RestoreAgent.Results);

            Report.PlanType        = "restore";
            Report.PlanName        = Restore.RestorePlan.Name;
            Report.BucketName      = s3account.BucketName;
            Report.HostName        = Restore.RestorePlan.StorageAccount.Hostname;
            Report.TransferResults = RestoreAgent.Results;

            Helper = new BaseOperationHelper(Restore.RestorePlan);

            //
            // Start the restore.
            //
            DoRestore(RestoreAgent, Restore, Options);
        }