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

            if (failoverPolicies.Count > 0)
            {
                for (int i = 0; i < failoverPolicies.Count; i++)
                {
                    Models.FailoverPolicyInner 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;
        }
Exemple #2
0
 public CosmosDBAccountImpl WithWriteReplication(Region region)
 {
     Models.FailoverPolicyInner failoverPolicyInner = new Models.FailoverPolicyInner();
     failoverPolicyInner.LocationName = region.Name;
     this.hasFailoverPolicyChanges    = true;
     this.failoverPolicies.Add(failoverPolicyInner);
     return(this);
 }
Exemple #3
0
 public CosmosDBAccountImpl WithReadReplication(Region region)
 {
     this.EnsureFailoverIsInitialized();
     Models.FailoverPolicyInner failoverPolicyInner = new Models.FailoverPolicyInner();
     failoverPolicyInner.LocationName     = region.Name;
     failoverPolicyInner.FailoverPriority = this.failoverPolicies.Count;
     this.hasFailoverPolicyChanges        = true;
     this.failoverPolicies.Add(failoverPolicyInner);
     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.FailoverPolicyInner> policyInners = new List <Models.FailoverPolicyInner>();

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

            await this.Manager.Inner.DatabaseAccounts.FailoverPriorityChangeAsync(groupName, accountName, policyInners);
        }
Exemple #5
0
        private void initializeFailover()
        {
            this.failoverPolicies.Clear();
            Models.FailoverPolicyInner[] policyInners = new Models.FailoverPolicyInner[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;
        }