Beispiel #1
0
 private async Task InitializeAsync(CancellationToken cancellationToken)
 {
     this.backupStore = new BackupStore(
         this.blobContainerEndpoint,
         this.storageCredentials,
         this.ServicePartition,
         this.testId,
         this.ServiceInitializationParameters);
     try
     {
         await this.backupStore.InitializeAsync(cancellationToken);
     }
     catch (Exception e)
     {
         ServiceEventSource.Current.ServiceMessage(this, "{0} {1}" + e.GetType() + e.Message);
     }
 }
Beispiel #2
0
        /// <summary>
        /// This method is used to create an instance of the AzureBlobBackupManager
        /// </summary>
        private void SetupBackupManager()
        {
            // change the logic here for your own partition scenario
            //
            string partitionId = this.Context.PartitionId.ToString("N");
            long   minKey      = ((Int64RangePartitionInformation)this.Partition.PartitionInfo).LowKey;
            long   maxKey      = ((Int64RangePartitionInformation)this.Partition.PartitionInfo).HighKey;

            if (this.Context.CodePackageActivationContext != null)
            {
                ICodePackageActivationContext codePackageContext =
                    this.Context.CodePackageActivationContext;

                ConfigurationPackage configPackage =
                    codePackageContext.GetConfigurationPackageObject("Config");

                // change the section name to match your service name
                ConfigurationSection configSection =
                    configPackage.Settings.Sections["Stateful1.Settings"];

                string backupSettingValue = configSection.Parameters["BackupMode"].Value;

                if (string.Equals(backupSettingValue, "none", StringComparison.InvariantCultureIgnoreCase))
                {
                    this.backupStorageType = BackupManagerType.None;
                }
                else if (string.Equals(backupSettingValue, "azure", StringComparison.InvariantCultureIgnoreCase))
                {
                    this.backupStorageType = BackupManagerType.Azure;

                    // change the section name to match your service name
                    ConfigurationSection azureBackupConfigSection =
                        configPackage.Settings.Sections["Stateful1.BackupSettings.Azure"];

                    this.backupManager = new AzureBlobBackupManager(azureBackupConfigSection,
                                                                    partitionId, minKey, maxKey, codePackageContext.TempDirectory);
                }
                else
                {
                    throw new ArgumentException("Unknown backup type");
                }

                ServiceEventSource.Current.ServiceMessage(this, "Backup Manager Set Up");
            }
        }
Beispiel #3
0
        private void SetupBackupManager()
        {
            string partitionId = this.Context.PartitionId.ToString("N");

            Debug.WriteLine("partitionId: " + partitionId);
            long minKey = ((Int64RangePartitionInformation)this.Partition.PartitionInfo).LowKey;
            long maxKey = ((Int64RangePartitionInformation)this.Partition.PartitionInfo).HighKey;

            if (this.Context.CodePackageActivationContext != null)
            {
                ICodePackageActivationContext codePackageContext = this.Context.CodePackageActivationContext;
                ConfigurationPackage          configPackage      = codePackageContext.GetConfigurationPackageObject("Config");

                this.backupStorageType = BackupManagerType.Minio;

                ConfigurationSection minioBackupConfigSection = configPackage.Settings.Sections["BackupSettings.Minio"];

                this.backupManager = new MinioBackupManager(minioBackupConfigSection, partitionId, minKey, maxKey, codePackageContext.TempDirectory);


                ServiceEventSource.Current.ServiceMessage(Context, "Backup Manager Set Up");
            }
        }
 private async Task InitializeAsync(CancellationToken cancellationToken)
 {
     this.backupStore = new BackupStore(
         this.blobContainerEndpoint,
         this.storageCredentials,
         this.ServicePartition,
         this.ServiceInitializationParameters);
     try
     {
         await this.backupStore.InitializeAsync(cancellationToken);
     }
     catch (Exception e)
     {
         ServiceEventSource.Current.ServiceMessage(this, "{0} {1}" + e.GetType() + e.Message);
     }
 }
        private void SetupBackupManager()
        {
            string partitionId = this.Context.PartitionId.ToString("N");
            long minKey = ((Int64RangePartitionInformation) this.Partition.PartitionInfo).LowKey;
            long maxKey = ((Int64RangePartitionInformation) this.Partition.PartitionInfo).HighKey;

            if (this.Context.CodePackageActivationContext != null)
            {
                ICodePackageActivationContext codePackageContext = this.Context.CodePackageActivationContext;
                ConfigurationPackage configPackage = codePackageContext.GetConfigurationPackageObject("Config");
                ConfigurationSection configSection = configPackage.Settings.Sections["Inventory.Service.Settings"];

                string backupSettingValue = configSection.Parameters["BackupMode"].Value;

                if (string.Equals(backupSettingValue, "none", StringComparison.InvariantCultureIgnoreCase))
                {
                    this.backupStorageType = BackupManagerType.None;
                }
                else if (string.Equals(backupSettingValue, "azure", StringComparison.InvariantCultureIgnoreCase))
                {
                    this.backupStorageType = BackupManagerType.Azure;

                    ConfigurationSection azureBackupConfigSection = configPackage.Settings.Sections["Inventory.Service.BackupSettings.Azure"];

                    this.backupManager = new AzureBlobBackupManager(azureBackupConfigSection, partitionId, minKey, maxKey, codePackageContext.TempDirectory);
                }
                else if (string.Equals(backupSettingValue, "local", StringComparison.InvariantCultureIgnoreCase))
                {
                    this.backupStorageType = BackupManagerType.Local;

                    ConfigurationSection localBackupConfigSection = configPackage.Settings.Sections["Inventory.Service.BackupSettings.Local"];

                    this.backupManager = new DiskBackupManager(localBackupConfigSection, partitionId, minKey, maxKey, codePackageContext.TempDirectory);
                }
                else
                {
                    throw new ArgumentException("Unknown backup type");
                }

                ServiceEventSource.Current.ServiceMessage(this, "Backup Manager Set Up");
            }
        }