コード例 #1
0
        public async Task <IEnumerable <Tuple <ClusterDetails, ClusterDetails> > > GetClusterCombinations()
        {
            FabricClient         fabricClient  = new FabricClient();
            ServicePartitionList partitionList = fabricClient.QueryManager.GetPartitionListAsync(new Uri("fabric:/SFAppDRTool/RestoreService")).Result;

            List <Tuple <ClusterDetails, ClusterDetails> > allClusterCombinations = new List <Tuple <ClusterDetails, ClusterDetails> >();

            foreach (Partition partition in partitionList)
            {
                List <Tuple <ClusterDetails, ClusterDetails> > localClusterCombinations = new List <Tuple <ClusterDetails, ClusterDetails> >();
                var             int64PartitionInfo   = partition.PartitionInformation as Int64RangePartitionInformation;
                long            lowKey               = (long)int64PartitionInfo?.LowKey;
                IRestoreService restoreServiceClient = ServiceProxy.Create <IRestoreService>(new Uri("fabric:/SFAppDRTool/RestoreService"), new ServicePartitionKey(lowKey));
                try
                {
                    localClusterCombinations = await restoreServiceClient.GetClusterCombinations();

                    allClusterCombinations.AddRange(localClusterCombinations);
                }
                catch (Exception ex)
                {
                    ServiceEventSource.Current.Message("Web Service: Exception getting cluster combinations {0}", ex);
                    throw;
                }
            }

            return(allClusterCombinations);
        }
コード例 #2
0
ファイル: App.cs プロジェクト: uzbekdev1/AzureBackup
 public App(IBackupService backupService, IRestoreService restoreService, IConfigurationRoot config, ILogger <App> logger)
 {
     _backupService  = backupService;
     _restoreService = restoreService;
     _logger         = logger;
     _config         = config;
 }
コード例 #3
0
        public async Task <HashSet <String> > GetConfiguredApplications(String primarycs, String secondarycs)
        {
            FabricClient         fabricClient  = new FabricClient();
            ServicePartitionList partitionList = fabricClient.QueryManager.GetPartitionListAsync(new Uri("fabric:/SFAppDRTool/RestoreService")).Result;

            List <String> configuredApplicationNames = new List <String>();

            foreach (Partition partition in partitionList)
            {
                List <String>   configAppNames       = new List <String>();
                var             int64PartitionInfo   = partition.PartitionInformation as Int64RangePartitionInformation;
                long            lowKey               = (long)int64PartitionInfo?.LowKey;
                IRestoreService restoreServiceClient = ServiceProxy.Create <IRestoreService>(new Uri("fabric:/SFAppDRTool/RestoreService"), new ServicePartitionKey(lowKey));
                try
                {
                    configAppNames = await restoreServiceClient.GetConfiguredApplicationNames(primarycs, secondarycs);

                    configuredApplicationNames.AddRange(configAppNames);
                }
                catch (Exception ex)
                {
                    ServiceEventSource.Current.Message("Web Service: Exception getting all configured application names {0}", ex);
                    throw;
                }
            }

            return(new HashSet <String>(configuredApplicationNames));
        }
コード例 #4
0
        public async Task <IEnumerable <PartitionWrapper> > GetPartitionStatus()
        {
            FabricClient         fabricClient  = new FabricClient();
            ServicePartitionList partitionList = fabricClient.QueryManager.GetPartitionListAsync(new Uri("fabric:/SFAppDRTool/RestoreService")).Result;

            List <PartitionStatusModel> partitionStatusList = new List <PartitionStatusModel>();
            List <PartitionWrapper>     mappedPartitions    = new List <PartitionWrapper>();

            foreach (Partition partition in partitionList)
            {
                List <PartitionWrapper> servicePartitions = new List <PartitionWrapper>();
                var             int64PartitionInfo        = partition.PartitionInformation as Int64RangePartitionInformation;
                long            lowKey = (long)int64PartitionInfo?.LowKey;
                IRestoreService restoreServiceClient = ServiceProxy.Create <IRestoreService>(new Uri("fabric:/SFAppDRTool/RestoreService"), new ServicePartitionKey(lowKey));
                try
                {
                    servicePartitions = await restoreServiceClient.GetStatus();

                    mappedPartitions.AddRange(servicePartitions);
                }
                catch (Exception ex)
                {
                    ServiceEventSource.Current.Message("Web Service: Exception getting the status {0}", ex);
                    throw;
                }
            }

            //if (mappedPartitions.Count == 0) return null;
            return(mappedPartitions);
        }
コード例 #5
0
        public async Task <string> Disconfigure(string applicationName)
        {
            bool                 successfullyRemoved = true;
            FabricClient         fabricClient        = new FabricClient();
            ServicePartitionList partitionList       = fabricClient.QueryManager.GetPartitionListAsync(new Uri("fabric:/SFAppDRTool/RestoreService")).Result;

            foreach (Partition partition in partitionList)
            {
                var             int64PartitionInfo   = partition.PartitionInformation as Int64RangePartitionInformation;
                long            lowKey               = (long)int64PartitionInfo?.LowKey;
                IRestoreService restoreServiceClient = ServiceProxy.Create <IRestoreService>(new Uri("fabric:/SFAppDRTool/RestoreService"), new ServicePartitionKey(lowKey));
                try
                {
                    string applicationRemoved = await restoreServiceClient.Disconfigure("fabric:/" + applicationName);

                    if (applicationRemoved == null)
                    {
                        successfullyRemoved = false;
                    }
                }
                catch (Exception ex)
                {
                    ServiceEventSource.Current.Message("Web Service: Exception Disconfiguring {0}", ex);
                    throw;
                }
            }
            if (successfullyRemoved)
            {
                return(applicationName);
            }
            return(null);
        }
コード例 #6
0
        public void Configure([FromBody] JObject content, string primaryClusterAddress, string secondaryClusterAddress, string primaryHttpEndpoint, string secondaryHttpEndpoint)
        {
            string primaryClientConnectionEndpoint   = GetClientConnectionEndpoint(primaryClusterAddress + ":" + primaryHttpEndpoint);
            string secondaryClientConnectionEndpoint = GetClientConnectionEndpoint(secondaryClusterAddress + ":" + secondaryHttpEndpoint);

            ClusterDetails primaryCluster   = new ClusterDetails(primaryClusterAddress, primaryHttpEndpoint, primaryClientConnectionEndpoint);
            ClusterDetails secondaryCluster = new ClusterDetails(secondaryClusterAddress, secondaryHttpEndpoint, secondaryClientConnectionEndpoint);

            JArray applicationsData = (JArray)content["ApplicationsList"];
            JArray policiesData     = (JArray)content["PoliciesList"];

            List <string> applicationsList           = JsonConvert.DeserializeObject <List <string> >(applicationsData.ToString());
            List <PolicyStorageEntity> policicesList = JsonConvert.DeserializeObject <List <PolicyStorageEntity> >(policiesData.ToString());

            FabricClient         fabricClient  = new FabricClient();
            ServicePartitionList partitionList = fabricClient.QueryManager.GetPartitionListAsync(new Uri("fabric:/SFAppDRTool/RestoreService")).Result;

            foreach (Partition partition in partitionList)
            {
                var             int64PartitionInfo   = partition.PartitionInformation as Int64RangePartitionInformation;
                long            lowKey               = (long)int64PartitionInfo?.LowKey;
                IRestoreService restoreServiceClient = ServiceProxy.Create <IRestoreService>(new Uri("fabric:/SFAppDRTool/RestoreService"), new ServicePartitionKey(lowKey));
                try
                {
                    restoreServiceClient.Configure(applicationsList, policicesList, primaryCluster, secondaryCluster);
                }
                catch (Exception ex)
                {
                    ServiceEventSource.Current.Message("Web Service: Exception configuring the application {0}", ex);
                    throw;
                }
            }
        }
コード例 #7
0
 public RestoreServiceTest(IAuthenticatorRepository authenticatorRepository,
                           IAuthenticatorCategoryRepository authenticatorCategoryRepository, ICategoryRepository categoryRepository,
                           ICustomIconRepository customIconRepository, IRestoreService restoreService, Backup backup)
     : base(authenticatorRepository, categoryRepository, authenticatorCategoryRepository, customIconRepository)
 {
     _restoreService = restoreService;
     _backup         = backup;
 }
コード例 #8
0
        public AutoBackupWorker(Context context, WorkerParameters workerParams) : base(context, workerParams)
        {
            _context             = context;
            _preferences         = new PreferenceWrapper(context);
            _shouldCloseDatabase = false;

            _database                        = Dependencies.Resolve <Database>();
            _restoreService                  = Dependencies.Resolve <IRestoreService>();
            _authenticatorRepository         = Dependencies.Resolve <IAuthenticatorRepository>();
            _categoryRepository              = Dependencies.Resolve <ICategoryRepository>();
            _authenticatorCategoryRepository = Dependencies.Resolve <IAuthenticatorCategoryRepository>();
            _customIconRepository            = Dependencies.Resolve <ICustomIconRepository>();

            _initTask = new Lazy <Task>(async delegate
            {
                if (!_database.IsOpen)
                {
                    var password = await SecureStorageWrapper.GetDatabasePassword();
                    await _database.Open(password);
                    _shouldCloseDatabase = true;
                }
            });
        }
コード例 #9
0
        public void ConfigureService([FromBody] JObject content, string primaryClusterAddress, string primaryHttpEndpointEncoded, string primaryThumbprint, string primaryCommonName,
                                     string secondaryClusterAddress, string secondaryHttpEndpointEncoded, string secondaryThumbprint, string secondaryCommonName)
        {
            string[] primaryClusterDetails   = primaryClusterAddress.Split(':');
            string[] secondaryClusterDetails = secondaryClusterAddress.Split(':');

            string primaryHttpEndpoint   = Utility.decodeHTTPString(primaryHttpEndpointEncoded);
            string secondaryHttpEndpoint = Utility.decodeHTTPString(secondaryHttpEndpointEncoded);

            ClusterDetails primaryCluster   = new ClusterDetails(primaryClusterDetails[0], primaryHttpEndpoint, primaryClusterAddress, primaryThumbprint, primaryCommonName);
            ClusterDetails secondaryCluster = new ClusterDetails(secondaryClusterDetails[0], secondaryHttpEndpoint, secondaryClusterAddress, secondaryThumbprint, secondaryCommonName);

            JArray serviceData  = (JArray)content["ServiceList"];
            JArray policiesData = (JArray)content["PoliciesList"];

            List <string> serviceDataObj             = JsonConvert.DeserializeObject <List <string> >(serviceData.ToString());
            List <PolicyStorageEntity> policicesList = JsonConvert.DeserializeObject <List <PolicyStorageEntity> >(policiesData.ToString());

            FabricClient         fabricClient  = new FabricClient();
            ServicePartitionList partitionList = fabricClient.QueryManager.GetPartitionListAsync(new Uri("fabric:/SFAppDRTool/RestoreService")).Result;

            foreach (Partition partition in partitionList)
            {
                var             int64PartitionInfo   = partition.PartitionInformation as Int64RangePartitionInformation;
                long            lowKey               = (long)int64PartitionInfo?.LowKey;
                IRestoreService restoreServiceClient = ServiceProxy.Create <IRestoreService>(new Uri("fabric:/SFAppDRTool/RestoreService"), new ServicePartitionKey(lowKey));
                try
                {
                    restoreServiceClient.ConfigureService(serviceDataObj[0], serviceDataObj[1], policicesList, primaryCluster, secondaryCluster);
                }
                catch (Exception ex)
                {
                    ServiceEventSource.Current.Message("Web Service: Exception configuring the service {0}", ex);
                    throw;
                }
            }
        }
コード例 #10
0
        public async Task <string> DisconfigureService([FromBody] JObject content, String primaryCluster, String secondaryCluster)
        {
            bool successfullyRemoved = true;

            JArray        serviceData    = (JArray)content["ServiceList"];
            List <string> serviceDataObj = JsonConvert.DeserializeObject <List <string> >(serviceData.ToString());

            FabricClient         fabricClient  = new FabricClient();
            ServicePartitionList partitionList = fabricClient.QueryManager.GetPartitionListAsync(new Uri("fabric:/SFAppDRTool/RestoreService")).Result;

            foreach (Partition partition in partitionList)
            {
                var             int64PartitionInfo   = partition.PartitionInformation as Int64RangePartitionInformation;
                long            lowKey               = (long)int64PartitionInfo?.LowKey;
                IRestoreService restoreServiceClient = ServiceProxy.Create <IRestoreService>(new Uri("fabric:/SFAppDRTool/RestoreService"), new ServicePartitionKey(lowKey));
                try
                {
                    string serviceRemoved = await restoreServiceClient.DisconfigureService(serviceDataObj[0], primaryCluster, secondaryCluster);

                    if (serviceRemoved == null)
                    {
                        successfullyRemoved = false;
                    }
                }
                catch (Exception ex)
                {
                    ServiceEventSource.Current.Message("Web Service: Exception Disconfiguring Service {0}", ex);
                    throw;
                }
            }
            if (successfullyRemoved)
            {
                return(serviceDataObj[0]);
            }
            return(null);
        }
コード例 #11
0
 public RestoreController(IRestoreService restoreService)
 {
     _restoreService = restoreService;
 }
コード例 #12
0
 public ImportService(IRestoreService restoreService)
 {
     _restoreService = restoreService;
 }
コード例 #13
0
 public RestoreController(IRestoreService restoreService, IAuthService authService)
 {
     _restoreService = restoreService;
     _authService = authService;
 }