示例#1
0
 public BandDataAggregator(Band band)
 {
     this.band = band;
 }
        private void BalanceBand(Band band, double totalDatabaseWeight, BandData[] bandData)
        {
            this.logger.Log(MigrationEventType.Information, "Balancing band '{0}' with '{1}' data entries.", new object[]
            {
                band,
                bandData.Count <BandData>()
            });
            double             moveUnitsPerWeight = (double)bandData.Sum((BandData data) => data.TotalWeight) / totalDatabaseWeight;
            double             num                = (band.Profile == Band.BandProfile.SizeBased) ? band.MailboxSizeWeightFactor : 0.0;
            double             deviation          = (double)this.settings.WeightDeviationPercent / 100.0;
            ByteQuantifiedSize byteQuantifiedSize = ByteQuantifiedSize.FromGB((ulong)this.settings.MaximumAmountOfDataPerRoundGb);

            this.logger.Log(MigrationEventType.Verbose, "Moving with a deviation of '{0}', a minimum delta of '{1}' and a maximum of '{2}' per database.", new object[]
            {
                deviation,
                num,
                byteQuantifiedSize
            });
            List <BandData> list = (from data in bandData
                                    orderby this.GetBandDelta(moveUnitsPerWeight, deviation, data) descending
                                    select data).ToList <BandData>();

            foreach (BandData bandData2 in list)
            {
                double num2 = this.GetBandDelta(moveUnitsPerWeight, deviation, bandData2);
                this.logger.Log(MigrationEventType.Verbose, "Attempting to balance band {0} for database {1}, current delta is {2}.", new object[]
                {
                    band,
                    bandData2.Database,
                    num2
                });
                LoadMetric instance = PhysicalSize.Instance;
                if (num2 <= num)
                {
                    this.logger.Log(MigrationEventType.Information, "Not balancing band {0} for database {1} because delta {2} is either less than the minimum of {3} or database has no more available space ({4}). We're done.", new object[]
                    {
                        band,
                        bandData2.Database,
                        num2,
                        num,
                        bandData2.Database.AvailableCapacity.GetSizeMetric(instance)
                    });
                    break;
                }
                foreach (BandData bandData3 in from data in bandData
                         orderby data.TotalWeight
                         select data)
                {
                    if (!bandData3.Database.CanAcceptBalancingLoad)
                    {
                        this.logger.Log(MigrationEventType.Verbose, "Database {0} can not be used as target because it can't take LB load.", new object[]
                        {
                            bandData3.Database
                        });
                    }
                    else
                    {
                        double num3 = this.GetBandDelta(moveUnitsPerWeight, 0.0 - deviation, bandData3);
                        this.logger.Log(MigrationEventType.Verbose, "Trying to place weight into {0} (current delta: {1}).", new object[]
                        {
                            bandData3.Database,
                            num3
                        });
                        ByteQuantifiedSize sizeMetric = bandData3.Database.AvailableCapacity.GetSizeMetric(instance);
                        if (0.0 - num3 > sizeMetric.ToMB())
                        {
                            this.logger.Log(MigrationEventType.Verbose, "Target delta of {0} is larger than the {1} available space in the database, adjusting.", new object[]
                            {
                                num3,
                                sizeMetric
                            });
                            num3 = 0.0 - sizeMetric.ToMB();
                            this.logger.Log(MigrationEventType.Verbose, "New target delta is {0}.", new object[]
                            {
                                num3
                            });
                        }
                        if (num3 >= 0.0)
                        {
                            this.logger.Log(MigrationEventType.Verbose, "Target database is above the threshold, skipping as a target.", new object[0]);
                        }
                        else
                        {
                            ByteQuantifiedSize sizeMetric2 = bandData3.Database.CommittedLoad.GetSizeMetric(instance);
                            ByteQuantifiedSize byteQuantifiedSize2;
                            if (sizeMetric2 > byteQuantifiedSize)
                            {
                                byteQuantifiedSize2 = ByteQuantifiedSize.Zero;
                            }
                            else
                            {
                                byteQuantifiedSize2 = byteQuantifiedSize - sizeMetric2;
                            }
                            int num4 = (int)Math.Floor(byteQuantifiedSize2.ToMB() / band.MailboxSizeWeightFactor);
                            if (num4 <= 0)
                            {
                                this.logger.Log(MigrationEventType.Verbose, "Target database committed load is {0} which is over the limit of {1}, skipping as a target.", new object[]
                                {
                                    sizeMetric2,
                                    byteQuantifiedSize
                                });
                            }
                            else
                            {
                                int num5 = (int)Math.Min(Math.Round(Math.Min(Math.Abs(num2), Math.Abs(num3))), (double)num4);
                                this.logger.Log(MigrationEventType.Verbose, "Projected to move {0} units out of {1} and into {2}", new object[]
                                {
                                    num5,
                                    bandData2.Database,
                                    bandData3.Database
                                });
                                if (num5 > 0)
                                {
                                    ByteQuantifiedSize value             = ByteQuantifiedSize.FromMB((ulong)((double)num5 * band.MailboxSizeWeightFactor));
                                    LoadMetricStorage  loadMetricStorage = new LoadMetricStorage();
                                    loadMetricStorage[band] = (long)num5;
                                    BandMailboxRebalanceData item = new BandMailboxRebalanceData(bandData2.Database, bandData3.Database, loadMetricStorage);
                                    bandData3.TotalWeight += num5;
                                    LoadMetricStorage committedLoad;
                                    LoadMetric        metric;
                                    (committedLoad = bandData3.Database.CommittedLoad)[metric = instance] = committedLoad[metric] + (long)value.ToBytes();
                                    this.totalDataSelectedToMove += value;
                                    bandData2.TotalWeight        -= num5;
                                    this.results.Add(item);
                                    num2 -= (double)num5;
                                }
                                if (num2 <= num)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
示例#3
0
        private AnchorXmlSerializableObject <PersistedBandDefinition> GetBandPersistedMessage(Band band)
        {
            AnchorXmlSerializableObject <PersistedBandDefinition> anchorXmlSerializableObject = this.GetBandDefinitionXmlSerializable().FirstOrDefault((AnchorXmlSerializableObject <PersistedBandDefinition> persisted) => persisted.PersistedObject.Matches(band));

            if (anchorXmlSerializableObject == null)
            {
                throw new BandDefinitionNotFoundException(band.ToString());
            }
            return(anchorXmlSerializableObject);
        }
示例#4
0
 protected bool Equals(Band other)
 {
     return(this.MaxSize.Equals(other.MaxSize) && this.MinSize.Equals(other.MinSize) && this.Profile == other.Profile && Math.Abs(this.MailboxSizeWeightFactor - other.MailboxSizeWeightFactor) < 0.5 && this.IncludeOnlyPhysicalMailboxes == other.IncludeOnlyPhysicalMailboxes && object.Equals(this.MaxLastLogonAge, other.MaxLastLogonAge) && object.Equals(this.MinLastLogonAge, other.MinLastLogonAge));
 }
示例#5
0
 public bool IsOverlap(Band band)
 {
     return(!(this.MaxSize <= band.MinSize) && !(this.MinSize >= band.MaxSize) && !(this.MaxLastLogonAge <= band.MinLastLogonAge) && !(this.MinLastLogonAge >= band.MaxLastLogonAge));
 }
示例#6
0
 public Band(Band.BandProfile bandProfile, ulong minSizeMb, ulong maxSizeMb, double mailboxSizeWeightFactor, bool includeOnlyPhysicalMailboxes = false, TimeSpan?minLastLogonAge = null, TimeSpan?maxLastLogonAge = null) : base(Band.CreateBandName(bandProfile, minSizeMb, maxSizeMb, minLastLogonAge, maxLastLogonAge), true)
 {
     this.IncludeOnlyPhysicalMailboxes = includeOnlyPhysicalMailboxes;
     this.Profile = bandProfile;
     this.MailboxSizeWeightFactor = mailboxSizeWeightFactor;
     this.MaxSize         = ByteQuantifiedSize.FromMB(maxSizeMb);
     this.MinSize         = ByteQuantifiedSize.FromMB(minSizeMb);
     this.MinLastLogonAge = minLastLogonAge;
     this.MaxLastLogonAge = maxLastLogonAge;
 }