Exemplo n.º 1
0
 public InstancePlacement Merge(InstancePlacement subsequentPlacement)
 {
     Debug.Assert(IsAdjacent(subsequentPlacement));
     return(new InstancePlacement(
                MergeTenancy(this.Tenancy, subsequentPlacement.Tenancy),
                this.ServerId ?? subsequentPlacement.ServerId,
                this.From,
                subsequentPlacement.To));
 }
Exemplo n.º 2
0
        private void AddPlacement(InstancePlacement placement)
        {
            if (this.placements.Any())
            {
                var subsequentPlacement = this.placements.First();
                if (placement.IsAdjacent(subsequentPlacement))
                {
                    // Placement are right adjacent -> merge.
                    placement = placement.Merge(subsequentPlacement);
                    this.placements.RemoveFirst();
                }
            }

            this.placements.AddFirst(placement);
        }
Exemplo n.º 3
0
        public bool IsAdjacent(InstancePlacement subsequentPlacement)
        {
            Debug.Assert(this.To <= subsequentPlacement.To);
            Debug.Assert(this.From <= subsequentPlacement.From);

            if (Math.Abs((this.To - subsequentPlacement.From).TotalSeconds) < 60)
            {
                // These two placements are so close to another that one of them
                // probably isn't right.
                if (this.ServerId != null && subsequentPlacement.ServerId != null)
                {
                    return(this.ServerId == subsequentPlacement.ServerId);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                // There is substantial space between these placements.
                return(false);
            }
        }