Esempio n. 1
0
        private void AddLocationsForCreateUpdateParameters(Models.DatabaseAccountCreateUpdateParametersInner createUpdateParametersInner, IList <Microsoft.Azure.Management.CosmosDB.Fluent.Models.FailoverPolicy> failoverPolicies)
        {
            List <Models.Location> locations = new List <Models.Location>();

            if (failoverPolicies.Count > 0)
            {
                for (int i = 0; i < failoverPolicies.Count; i++)
                {
                    Models.FailoverPolicy policyInner = failoverPolicies[i];
                    Models.Location       location    = new Models.Location();
                    location.FailoverPriority = i;
                    location.LocationName     = policyInner.LocationName;
                    locations.Add(location);
                }
            }
            else
            {
                Models.Location location = new Models.Location();
                location.FailoverPriority = 0;
                location.LocationName     = createUpdateParametersInner.Location;
                locations.Add(location);
            }

            createUpdateParametersInner.Locations = locations;
        }
Esempio n. 2
0
 public CosmosDBAccountImpl WithWriteReplication(Region region)
 {
     Models.FailoverPolicy FailoverPolicy = new Models.FailoverPolicy();
     FailoverPolicy.LocationName   = region.Name;
     this.hasFailoverPolicyChanges = true;
     this.failoverPolicies.Add(FailoverPolicy);
     return(this);
 }
Esempio n. 3
0
 public CosmosDBAccountImpl WithReadReplication(Region region)
 {
     this.EnsureFailoverIsInitialized();
     Models.FailoverPolicy FailoverPolicy = new Models.FailoverPolicy();
     FailoverPolicy.LocationName     = region.Name;
     FailoverPolicy.FailoverPriority = this.failoverPolicies.Count;
     this.hasFailoverPolicyChanges   = true;
     this.failoverPolicies.Add(FailoverPolicy);
     return(this);
 }
        public async Task FailoverPriorityChangeAsync(string groupName, string accountName, IList <Microsoft.Azure.Management.CosmosDB.Fluent.Models.Location> failoverLocations, CancellationToken cancellationToken = default(CancellationToken))
        {
            List <Models.FailoverPolicy> policyInners = new List <Models.FailoverPolicy>();

            for (int i = 0; i < failoverLocations.Count(); i++)
            {
                Models.Location       location    = failoverLocations[i];
                Models.FailoverPolicy policyInner = new Models.FailoverPolicy();
                policyInner.LocationName     = location.LocationName;
                policyInner.FailoverPriority = i;
                policyInners.Add(policyInner);
            }

            await this.Manager.Inner.DatabaseAccounts.FailoverPriorityChangeAsync(groupName, accountName, policyInners);
        }
Esempio n. 5
0
        private void initializeFailover()
        {
            this.failoverPolicies.Clear();
            Models.FailoverPolicy[] policyInners = new Models.FailoverPolicy[this.Inner.FailoverPolicies.Count];
            for (var i = 0; i < policyInners.Length; i++)
            {
                policyInners[i] = this.Inner.FailoverPolicies[i];
            }

            Array.Sort(policyInners, (o1, o2) =>
            {
                return(o1.FailoverPriority.GetValueOrDefault().CompareTo(o2.FailoverPriority.GetValueOrDefault()));
            });

            for (int i = 0; i < policyInners.Length; i++)
            {
                this.failoverPolicies.Add(policyInners[i]);
            }

            this.hasFailoverPolicyChanges = true;
        }