Exemplo n.º 1
0
        /// <summary>
        /// This method communicates with policystorage service and gets the backupstorage details
        /// </summary>
        /// <param name="policy">Policy which is to be restored</param>
        /// <returns>BackupStorage details</returns>
        public async Task <BackupStorage> GetBackupStorageDetails(string policy)
        {
            IPolicyStorageService policyStorageClient = ServiceProxy.Create <IPolicyStorageService>(new Uri("fabric:/StandByApplication/PolicyStorageService"));
            BackupStorage         backupStorage       = await policyStorageClient.GetPolicyStorageDetails(policy);

            return(backupStorage);
        }
        public async Task ConfigureApplication(string application, List <PolicyStorageEntity> policyDetails, ClusterDetails primaryCluster, ClusterDetails secondaryCluster)
        {
            IPolicyStorageService policyStorageClient = ServiceProxy.Create <IPolicyStorageService>(new Uri("fabric:/SFAppDRTool/PolicyStorageService"));
            bool overwritePolicyDetails = false;
            bool stored = policyStorageClient.PostStorageDetails(policyDetails, primaryCluster.httpEndpoint, primaryCluster.certificateThumbprint, overwritePolicyDetails).GetAwaiter().GetResult();

            await MapPartitionsOfApplication(new Uri(application), primaryCluster, secondaryCluster, "partitionDictionary");

            IReliableDictionary <String, List <String> > configuredApplicationsDictionary = await this.StateManager.GetOrAddAsync <IReliableDictionary <String, List <String> > >("configuredApplicationsDictionary");

            using (var tx = this.StateManager.CreateTransaction())
            {
                String primarySecondaryJoin = Utility.getPrimarySecondaryClusterJoin(primaryCluster.address, secondaryCluster.address);
                ConditionalValue <List <String> > applicationsList = await configuredApplicationsDictionary.TryGetValueAsync(tx, primarySecondaryJoin);

                if (applicationsList.HasValue)
                {
                    List <String> configuredApplicationsList = applicationsList.Value;
                    configuredApplicationsList.Add(application);
                    var result = await configuredApplicationsDictionary.TryAddAsync(tx, primarySecondaryJoin, configuredApplicationsList);
                }
                else
                {
                    List <String> configuredApplicationsList = new List <String>();
                    configuredApplicationsList.Add(application);
                    var result = await configuredApplicationsDictionary.TryAddAsync(tx, primarySecondaryJoin, configuredApplicationsList);
                }

                await tx.CommitAsync();
            }
        }
        public async Task ConfigureService(String applicationName, String serviceName, List <PolicyStorageEntity> policyDetails, ClusterDetails primaryCluster, ClusterDetails secondaryCluster)
        {
            IPolicyStorageService policyStorageClient = ServiceProxy.Create <IPolicyStorageService>(new Uri("fabric:/SFAppDRTool/PolicyStorageService"));
            bool overwritePolicyDetails = false;
            bool stored = await policyStorageClient.PostStorageDetails(policyDetails, primaryCluster.httpEndpoint, primaryCluster.certificateThumbprint, overwritePolicyDetails);

            await MapPartitionsOfService(new Uri(applicationName), new Uri(serviceName), primaryCluster, secondaryCluster, "partitionDictionary");
        }
Exemplo n.º 4
0
        public async Task ConfigureService(String applicationName, String serviceName, List <PolicyStorageEntity> policyDetails, ClusterDetails primaryCluster, ClusterDetails secondaryCluster)
        {
            IReliableDictionary <Guid, PartitionWrapper> myDictionary = await this.StateManager.GetOrAddAsync <IReliableDictionary <Guid, PartitionWrapper> >("partitionDictionary");

            IPolicyStorageService policyStorageClient = ServiceProxy.Create <IPolicyStorageService>(new Uri("fabric:/SFAppDRTool/PolicyStorageService"));
            bool stored = await policyStorageClient.PostStorageDetails(policyDetails, primaryCluster.address + ':' + primaryCluster.httpEndpoint); //TODO CHECK ON THIS

            await MapPartitionsOfService(new Uri(applicationName), new Uri(serviceName), primaryCluster, secondaryCluster, "partitionDictionary"); //TODO Make sure correct Uri is being sent to serviceName
        }
Exemplo n.º 5
0
        public async Task ConfigureApplication(string application, List <PolicyStorageEntity> policyDetails, ClusterDetails primaryCluster, ClusterDetails secondaryCluster)
        {
            IReliableDictionary <Guid, PartitionWrapper> myDictionary = await this.StateManager.GetOrAddAsync <IReliableDictionary <Guid, PartitionWrapper> >("partitionDictionary");

            IPolicyStorageService policyStorageClient = ServiceProxy.Create <IPolicyStorageService>(new Uri("fabric:/SFAppDRTool/PolicyStorageService"));
            bool stored = policyStorageClient.PostStorageDetails(policyDetails, primaryCluster.address + ':' + primaryCluster.httpEndpoint).GetAwaiter().GetResult();

            await MapPartitionsOfApplication(new Uri(application), primaryCluster, secondaryCluster, "partitionDictionary");
        }
Exemplo n.º 6
0
        // An interface method which is called by the webservice to configure the applications for stanby in secondary cluster
        // Takes in list of applications to be configured and corresponding policies and maps the partitions
        public async Task Configure(List <string> applications, List <PolicyStorageEntity> policyDeatils, ClusterDetails primaryCluster, ClusterDetails secondaryCluster)
        {
            IReliableDictionary <Guid, PartitionWrapper> myDictionary = await this.StateManager.GetOrAddAsync <IReliableDictionary <Guid, PartitionWrapper> >("partitionDictionary");

            IPolicyStorageService policyStorageClient = ServiceProxy.Create <IPolicyStorageService>(new Uri("fabric:/StandByApplication/PolicyStorageService"));
            bool stored = await policyStorageClient.PostStorageDetails(policyDeatils, primaryCluster.address + ':' + primaryCluster.httpEndpoint);

            foreach (string application in applications)
            {
                await MapPartitionsOfApplication(new Uri("fabric:/" + application), primaryCluster, secondaryCluster, "partitionDictionary");
            }
        }
        public async Task <List <String> > GetStoredPolicies()
        {
            FabricClient  fabricClient   = new FabricClient();
            List <String> storedPolicies = new List <String>();

            IPolicyStorageService policyStorageClient = ServiceProxy.Create <IPolicyStorageService>(new Uri("fabric:/SFAppDRTool/PolicyStorageService"));

            try
            {
                storedPolicies = await policyStorageClient.GetAllStoredPolicies();
            }
            catch (Exception ex)
            {
                ServiceEventSource.Current.Message("Web Service: Exception getting the stored polices {0}", ex);
                throw;
            }

            return(storedPolicies);
        }
        public void UpdatePolicy([FromBody] JObject content, string primaryHttpEndpointEncoded, string primaryClusterThumbprint)
        {
            string primaryClusterAddress = Utility.decodeHTTPString(primaryHttpEndpointEncoded);

            JArray policiesData = (JArray)content["PoliciesList"];
            List <PolicyStorageEntity> policicesList = JsonConvert.DeserializeObject <List <PolicyStorageEntity> >(policiesData.ToString());

            IPolicyStorageService policyStorageClient = ServiceProxy.Create <IPolicyStorageService>(new Uri("fabric:/SFAppDRTool/PolicyStorageService"));

            try
            {
                bool updateOverwritePolicy = true;
                policyStorageClient.PostStorageDetails(policicesList, primaryClusterAddress, primaryClusterThumbprint, updateOverwritePolicy);
            }
            catch (Exception ex)
            {
                ServiceEventSource.Current.Message("Web Service: Exception updating the stored polices {0}", ex);
                throw;
            }
        }