private static Binding GetWebServiceBinding(EnhancedTimeSpan timeout)
 {
     if (GetQueueDigestWebServiceImpl.webServiceBinding == null)
     {
         GetQueueDigestWebServiceImpl.webServiceBinding = new NetTcpBinding
         {
             Security =
             {
                 Transport                =
                 {
                     ProtectionLevel      = ProtectionLevel.EncryptAndSign,
                     ClientCredentialType = TcpClientCredentialType.Windows
                 },
                 Message                  =
                 {
                     ClientCredentialType = MessageCredentialType.Windows
                 }
             },
             MaxReceivedMessageSize = (long)((int)ByteQuantifiedSize.FromMB(5UL).ToBytes()),
             OpenTimeout            = timeout,
             CloseTimeout           = timeout,
             SendTimeout            = timeout,
             ReceiveTimeout         = timeout
         };
     }
     return(GetQueueDigestWebServiceImpl.webServiceBinding);
 }
Esempio n. 2
0
 internal override void StampPersistableDefaultValues()
 {
     if (!base.IsModified(MailboxDatabaseSchema.ProhibitSendReceiveQuota))
     {
         this.ProhibitSendReceiveQuota = new Unlimited <ByteQuantifiedSize>(ByteQuantifiedSize.FromMB(2355UL));
     }
     if (!base.IsModified(MailboxDatabaseSchema.ProhibitSendQuota))
     {
         this.ProhibitSendQuota = new Unlimited <ByteQuantifiedSize>(ByteQuantifiedSize.FromGB(2UL));
     }
     if (!base.IsModified(MailboxDatabaseSchema.RecoverableItemsWarningQuota))
     {
         this.RecoverableItemsWarningQuota = new Unlimited <ByteQuantifiedSize>(ByteQuantifiedSize.FromGB(20UL));
     }
     if (!base.IsModified(MailboxDatabaseSchema.RecoverableItemsQuota))
     {
         this.RecoverableItemsQuota = new Unlimited <ByteQuantifiedSize>(ByteQuantifiedSize.FromGB(30UL));
     }
     if (!base.IsModified(MailboxDatabaseSchema.CalendarLoggingQuota))
     {
         this.CalendarLoggingQuota = new Unlimited <ByteQuantifiedSize>(ByteQuantifiedSize.FromGB(6UL));
     }
     this.ReservedFlag = true;
     base.StampPersistableDefaultValues();
 }
Esempio n. 3
0
        protected override IConfigurable PrepareDataObject()
        {
            SmtpSendConnectorConfig smtpSendConnectorConfig = (SmtpSendConnectorConfig)base.PrepareDataObject();

            try
            {
                this.localServer = ((ITopologyConfigurationSession)base.DataSession).ReadLocalServer();
            }
            catch (TransientException exception)
            {
                base.WriteError(exception, ErrorCategory.ResourceUnavailable, this.DataObject);
            }
            this.isHubTransportServer = (this.localServer != null && this.localServer.IsHubTransportServer);
            bool isEdgeConnector = this.localServer != null && this.localServer.IsEdgeServer;

            if (this.SourceTransportServers != null)
            {
                smtpSendConnectorConfig.SourceTransportServers = base.ResolveIdParameterCollection <ServerIdParameter, Server, ADObjectId>(this.SourceTransportServers, base.DataSession, this.RootId, null, (ExchangeErrorCategory)0, new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotFound), new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotUnique), null, delegate(IConfigurable configObject)
                {
                    Server server    = (Server)configObject;
                    isEdgeConnector |= server.IsEdgeServer;
                    return(server);
                });
            }
            MultiValuedProperty <ADObjectId> multiValuedProperty = this.DataObject.SourceTransportServers;

            if (this.localServer != null && this.localServer.IsHubTransportServer && (multiValuedProperty == null || multiValuedProperty.Count == 0))
            {
                multiValuedProperty = new MultiValuedProperty <ADObjectId>(false, SendConnectorSchema.SourceTransportServers, new ADObjectId[]
                {
                    this.localServer.Id
                });
                this.DataObject.SourceTransportServers = multiValuedProperty;
            }
            if (multiValuedProperty != null && multiValuedProperty.Count > 0)
            {
                ManageSendConnectors.SetConnectorHomeMta(this.DataObject, (IConfigurationSession)base.DataSession);
            }
            if (!this.DataObject.IsModified(SendConnectorSchema.MaxMessageSize))
            {
                if (this.IsUsageSet && this.usage == NewSendConnector.UsageType.Internal)
                {
                    this.MaxMessageSize = Unlimited <ByteQuantifiedSize> .UnlimitedValue;
                }
                else
                {
                    this.MaxMessageSize = ByteQuantifiedSize.FromMB(35UL);
                }
            }
            if (!this.DataObject.IsModified(SmtpSendConnectorConfigSchema.UseExternalDNSServersEnabled) && isEdgeConnector)
            {
                this.UseExternalDNSServersEnabled = true;
            }
            ManageSendConnectors.SetConnectorId(smtpSendConnectorConfig, ((ITopologyConfigurationSession)base.DataSession).GetRoutingGroupId());
            return(smtpSendConnectorConfig);
        }
Esempio n. 4
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;
 }
Esempio n. 5
0
        public override EntitySelector GetSelector(LoadContainer container, string constraintSetIdentity, long units)
        {
            if (this.Profile == Band.BandProfile.CountBased)
            {
                return(new NumberOfEntitiesSelector(this, units, container, constraintSetIdentity));
            }
            double num = (double)units * this.MailboxSizeWeightFactor;

            return(new TotalSizeEntitySelector(this, ByteQuantifiedSize.FromMB((ulong)num), container, constraintSetIdentity));
        }
 internal override void StampPersistableDefaultValues()
 {
     if (!base.IsModified(LegacyMailboxDatabaseSchema.ProhibitSendReceiveQuota))
     {
         this.ProhibitSendReceiveQuota = new Unlimited <ByteQuantifiedSize>(ByteQuantifiedSize.FromMB(2355UL));
     }
     if (!base.IsModified(LegacyMailboxDatabaseSchema.ProhibitSendQuota))
     {
         this.ProhibitSendQuota = new Unlimited <ByteQuantifiedSize>(ByteQuantifiedSize.FromGB(2UL));
     }
     base.StampPersistableDefaultValues();
 }
Esempio n. 7
0
 internal static UnifiedAuditLoggerSettings Load()
 {
     return(new UnifiedAuditLoggerSettings
     {
         CacheSize = ByteQuantifiedSize.FromKB(128UL),
         DirectoryPath = "D:\\ComplianceAudit\\LocalQueue",
         FlushInterval = TimeSpan.FromMilliseconds(1000.0),
         FlushToDisk = true,
         MaxAge = TimeSpan.FromDays(3.0),
         MaxDirectorySize = ByteQuantifiedSize.FromMB(5000UL),
         MaxFileSize = ByteQuantifiedSize.FromMB(4UL)
     });
 }
Esempio n. 8
0
 internal override void StampPersistableDefaultValues()
 {
     if (!base.IsModified(LegacyDatabaseSchema.MaintenanceSchedule))
     {
         this.MaintenanceSchedule = Schedule.DailyFrom1AMTo5AM;
     }
     if (!base.IsModified(LegacyDatabaseSchema.QuotaNotificationSchedule))
     {
         this.QuotaNotificationSchedule = Schedule.Daily1AM;
     }
     if (!base.IsModified(LegacyDatabaseSchema.IssueWarningQuota))
     {
         this.IssueWarningQuota = new Unlimited <ByteQuantifiedSize>(ByteQuantifiedSize.FromMB(1945UL));
     }
     base.StampPersistableDefaultValues();
 }
Esempio n. 9
0
        public DiagnosticsAggregationServiceletConfig()
        {
            this.Enabled = AppConfigLoader.GetConfigBoolValue("DiagnosticsAggregationServiceletEnabled", true);
            this.TimeSpanForQueueDataBeingCurrent = AppConfigLoader.GetConfigTimeSpanValue("TimeSpanForQueueDataBeingCurrent", TimeSpan.FromMinutes(1.0), TimeSpan.FromHours(1.0), TimeSpan.FromMinutes(11.0));
            this.TimeSpanForQueueDataBeingStale   = AppConfigLoader.GetConfigTimeSpanValue("TimeSpanForQueueDataBeingStale", TimeSpan.FromMinutes(1.0), TimeSpan.FromHours(10.0), TimeSpan.FromHours(1.0));
            this.LoggingEnabled = AppConfigLoader.GetConfigBoolValue("DiagnosticsAggregationLoggingEnabled", false);
            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            string   path = Path.Combine(Directory.GetParent(Path.GetDirectoryName(executingAssembly.Location)).FullName, "TransportRoles\\Logs\\DiagnosticsAggregation\\");

            this.LogFileDirectoryPath = AppConfigLoader.GetConfigStringValue("DiagnosticsAggregationLogFileDirectoryPath", Path.GetFullPath(path));
            int configIntValue = AppConfigLoader.GetConfigIntValue("DiagnosticsAggregationLogFileMaxSizeInMB", 1, 10000, 2);

            this.LogFileMaxSize = ByteQuantifiedSize.FromMB((ulong)((long)configIntValue));
            int configIntValue2 = AppConfigLoader.GetConfigIntValue("DiagnosticsAggregationLogFileMaxDirectorySizeInMB", 1, 10000, 10);

            this.LogFileMaxDirectorySize = ByteQuantifiedSize.FromMB((ulong)((long)configIntValue2));
            this.LogFileMaxAge           = AppConfigLoader.GetConfigTimeSpanValue("DiagnosticsAggregationLogFileMaxAge", TimeSpan.FromMinutes(1.0), TimeSpan.FromDays(365.0), TimeSpan.FromDays(15.0));
        }
Esempio n. 10
0
 internal static NetTcpBinding GetTcpBinding()
 {
     return(new NetTcpBinding
     {
         MaxReceivedMessageSize = (long)((int)ByteQuantifiedSize.FromMB(10UL).ToBytes()),
         Security =
         {
             Transport                =
             {
                 ProtectionLevel      = ProtectionLevel.EncryptAndSign,
                 ClientCredentialType = TcpClientCredentialType.Windows
             },
             Message                  =
             {
                 ClientCredentialType = MessageCredentialType.Windows
             }
         }
     });
 }
 // Token: 0x0600254A RID: 9546 RVA: 0x000875BC File Offset: 0x000857BC
 public OwaServerTraceLogConfiguration()
 {
     this.IsLoggingEnabled           = AppConfigLoader.GetConfigBoolValue("OWAIsServerTraceLoggingEnabled", true);
     this.LogPath                    = AppConfigLoader.GetConfigStringValue("OWATraceLogPath", OwaServerTraceLogConfiguration.DefaultLogPath);
     this.MaxLogAge                  = AppConfigLoader.GetConfigTimeSpanValue("OWATraceMaxLogAge", TimeSpan.Zero, TimeSpan.MaxValue, TimeSpan.FromDays(5.0));
     this.MaxLogDirectorySizeInBytes = (long)OwaAppConfigLoader.GetConfigByteQuantifiedSizeValue("OWATraceMaxLogDirectorySize", ByteQuantifiedSize.FromGB(1UL)).ToBytes();
     this.MaxLogFileSizeInBytes      = (long)OwaAppConfigLoader.GetConfigByteQuantifiedSizeValue("OWATraceMaxLogFileSize", ByteQuantifiedSize.FromMB(10UL)).ToBytes();
     this.OwaTraceLoggingThreshold   = AppConfigLoader.GetConfigDoubleValue("OwaTraceLoggingThreshold", 0.0, 0.0, 0.0);
 }
Esempio n. 12
0
        public LogConfigurationBase()
        {
            this.enabled = new BoolAppSettingsEntry(this.Component + "Enabled", true, this.Tracer);
            StringAppSettingsEntry stringAppSettingsEntry = new StringAppSettingsEntry(this.Component + "Path", null, this.Tracer);

            this.logPath          = (stringAppSettingsEntry.Value ?? Path.Combine(ExchangeSetupContext.InstallPath, "Logging\\" + this.Component + "\\"));
            this.prefix           = this.Component + "_" + ApplicationName.Current.UniqueId + "_";
            this.maxDirectorySize = new ByteQuantifiedSizeAppSettingsEntry(this.Component + "MaxDirectorySize", ByteQuantifiedSize.FromMB(250UL), this.Tracer);
            this.maxFileSize      = new ByteQuantifiedSizeAppSettingsEntry(this.Component + "MaxFileSize", ByteQuantifiedSize.FromMB(10UL), this.Tracer);
            this.maxAge           = new TimeSpanAppSettingsEntry(this.Component + "MaxAge", TimeSpanUnit.Minutes, TimeSpan.FromDays(30.0), this.Tracer);
        }
        internal void CreateClassificationComparisonLogger()
        {
            ILogConfig config = new LogConfig(true, "InferenceClassificationComparisons", "InferenceClassificationComparisons", Path.Combine(ExchangeSetupContext.InstallPath, "Logging\\InferenceClassification\\Comparisons"), new ulong?(ByteQuantifiedSize.FromGB(2UL).ToBytes()), new ulong?(ByteQuantifiedSize.FromMB(10UL).ToBytes()), new TimeSpan?(TimeSpan.FromDays(30.0)), 4096);

            this.classificationComparisonLogger = new InferenceClassificationComparisonLogger(config);
        }
 public ClientExceptionLogConfiguration()
 {
     this.IsLoggingEnabled           = AppConfigLoader.GetConfigBoolValue("IsClientExceptionLoggingEnabled", true);
     this.LogPath                    = AppConfigLoader.GetConfigStringValue("ClientExceptionLogPath", ClientExceptionLogConfiguration.DefaultLogPath);
     this.MaxLogAge                  = AppConfigLoader.GetConfigTimeSpanValue("ClientExceptionMaxLogAge", TimeSpan.Zero, TimeSpan.MaxValue, TimeSpan.FromDays(30.0));
     this.MaxLogDirectorySizeInBytes = (long)ClientLogConfiguration.GetConfigByteQuantifiedSizeValue("ClientExceptionMaxLogDirectorySize", ByteQuantifiedSize.FromGB(1UL)).ToBytes();
     this.MaxLogFileSizeInBytes      = (long)ClientLogConfiguration.GetConfigByteQuantifiedSizeValue("ClientExceptionMaxLogFileSize", ByteQuantifiedSize.FromMB(10UL)).ToBytes();
 }
 protected override void ValidateWrite(List <ValidationError> errors)
 {
     base.ValidateWrite(errors);
     if (this.CalendarItemRetrievalOption == CalendarItemRetrievalOptions.Custom && this.OwaServerUrl == null)
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.ExArgumentNullException(PopImapAdConfigurationSchema.OwaServerUrl.Name), PopImapAdConfigurationSchema.OwaServerUrl, this.OwaServerUrl));
     }
     if (!string.IsNullOrEmpty(this.X509CertificateName) && !PopImapAdConfiguration.IsValidProtocolCertificate(this.X509CertificateName))
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.InvalidCertificateName(this.X509CertificateName), PopImapAdConfigurationSchema.X509CertificateName, this.X509CertificateName));
     }
     if (!this.LogPerFileSizeQuota.IsUnlimited && this.LogPerFileSizeQuota.Value > ByteQuantifiedSize.Zero && this.LogPerFileSizeQuota.Value < ByteQuantifiedSize.FromMB(1UL))
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.ExArgumentOutOfRangeException(PopImapAdConfigurationSchema.LogPerFileSizeQuota.Name, this.LogPerFileSizeQuota), PopImapAdConfigurationSchema.LogPerFileSizeQuota, this.LogPerFileSizeQuota));
     }
 }
Esempio n. 16
0
 public override ByteQuantifiedSize ToByteQuantifiedSize(long value)
 {
     return(ByteQuantifiedSize.FromMB((ulong)((double)value * this.MailboxSizeWeightFactor)));
 }
Esempio n. 17
0
        // Token: 0x0600144F RID: 5199 RVA: 0x00075368 File Offset: 0x00073568
        public Configuration()
        {
            bool               configBoolValue     = AppConfigLoader.GetConfigBoolValue("InferenceDataCollectionIsLoggingEnabled", true);
            LoggingLevel       configEnumValue     = AppConfigLoader.GetConfigEnumValue <LoggingLevel>("InferenceDataCollectionLoggingLevel", LoggingLevel.Debug);
            string             configStringValue   = AppConfigLoader.GetConfigStringValue("InferenceDataCollectionLogPath", Configuration.DefaultLogPath);
            TimeSpan           configTimeSpanValue = AppConfigLoader.GetConfigTimeSpanValue("InferenceDataCollectionMaxLogAge", TimeSpan.Zero, TimeSpan.MaxValue, TimeSpan.FromDays(30.0));
            ByteQuantifiedSize byteQuantifiedSize  = ConfigurationUtils.ReadByteQuantifiedSizeValue("InferenceDataCollectionMaxLogDirectorySize", ByteQuantifiedSize.FromGB(1UL));
            ByteQuantifiedSize byteQuantifiedSize2 = ConfigurationUtils.ReadByteQuantifiedSizeValue("InferenceDataCollectionMaxLogFileSize", ByteQuantifiedSize.FromMB(10UL));

            base.MetadataLogConfig                = new LogConfig(configBoolValue, "InferenceMetadata", "InferenceMetadata", Path.Combine(configStringValue, "Metadata"), new ulong?(byteQuantifiedSize.ToBytes()), new ulong?(byteQuantifiedSize2.ToBytes()), new TimeSpan?(configTimeSpanValue), 4096);
            base.DiagnosticLogConfig              = new DiagnosticLogConfig(configBoolValue, "InferenceDataCollection", "InferenceDataCollection", configStringValue, new ulong?(byteQuantifiedSize.ToBytes()), new ulong?(byteQuantifiedSize2.ToBytes()), new TimeSpan?(configTimeSpanValue), configEnumValue);
            base.MailboxReprocessAge              = AppConfigLoader.GetConfigTimeSpanValue("InferenceDataCollectionMailboxReprocessAge", TimeSpan.Zero, TimeSpan.MaxValue, TimeSpan.FromDays(30.0));
            base.ModuloNumberToRandomize          = AppConfigLoader.GetConfigIntValue("InferenceDataCollectionModuloNumberToRandomize", 1, int.MaxValue, 500);
            this.ModuloNumberToRandomizeForGroups = AppConfigLoader.GetConfigIntValue("InferenceDataCollectionModuloNumberToRandomizeForGroups", 1, int.MaxValue, 10);
            base.BlackListedFolders               = ConfigurationUtils.ReadCommaSeperatedStringValue("InferenceDataCollectionBlackListedFolders", null);
            base.WhiteListedFolders               = ConfigurationUtils.ReadCommaSeperatedStringValue("InferenceDataCollectionWhiteListedFolders", null);
            base.MinimumItemCountInMailbox        = AppConfigLoader.GetConfigIntValue("InferenceDataCollectionMinimumItemCountInMailbox", 0, int.MaxValue, 0);
            base.MinimumSentItemsCount            = AppConfigLoader.GetConfigIntValue("InferenceDataCollectionMinimumSentItemsCount", 0, int.MaxValue, 0);
            base.NumberOfItemsPerFolderToProcess  = AppConfigLoader.GetConfigIntValue("InferenceDataCollectionNumberOfItemsPerFolderToProcess", 0, int.MaxValue, int.MaxValue);
            base.MinimumSentItemsPercentage       = AppConfigLoader.GetConfigIntValue("InferenceDataCollectionMinimumSentItemsPercentage", 0, 100, 0);
            base.IsOutputSanitized                = AppConfigLoader.GetConfigBoolValue("InferenceDataCollectionIsOutputSanitized", true);
            base.QueryPageSize           = AppConfigLoader.GetConfigIntValue("InferenceDataCollectionQueryPageSize", 0, 32767, 100);
            base.CollectMessageBodyProps = AppConfigLoader.GetConfigBoolValue("InferenceDataCollectionCollectMessageBodyProps", false);
            base.ChunkSize           = AppConfigLoader.GetConfigIntValue("InferenceDataCollectionChunkSize", 1, int.MaxValue, 1000);
            base.ItemMaxAttemptCount = AppConfigLoader.GetConfigIntValue("InferenceDataCollectionItemMaxAttemptCount", 1, 10, 3);
        }
Esempio n. 18
0
        private static ByteQuantifiedSize GetMaxLogDirectorySizeOrDefault()
        {
            ulong value = RegistryReader.Instance.GetValue <ulong>(Registry.LocalMachine, "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\Inference\\ActivityLogging", "MaxLogDirectorySizeInMB", ActivityLoggingConfig.MaxLogDirectorySizeDefault.ToMB());

            return(ByteQuantifiedSize.FromMB(value));
        }
        static InferenceDiagnosticsLog()
        {
            InferenceDiagnosticsLog.Schema = new LogSchema("Microsoft Exchange", InferenceDiagnosticsLog.Version, "InferenceDiagnosticsLog", InferenceDiagnosticsLog.Columns);
            string fileNamePrefix = string.Format("{0}_{1}_{2}_", "InferenceDiagnosticsLog", InferenceDiagnosticsLog.ProcessName, InferenceDiagnosticsLog.ProcessId.ToString());

            InferenceDiagnosticsLog.Logger = new Log(fileNamePrefix, new LogHeaderFormatter(InferenceDiagnosticsLog.Schema), "InferenceDiagnosticsLog");
            InferenceDiagnosticsLog.Logger.Configure(InferenceDiagnosticsLog.LogPath, TimeSpan.FromDays(7.0), (long)ByteQuantifiedSize.FromGB(1UL).ToBytes(), (long)ByteQuantifiedSize.FromMB(10UL).ToBytes());
        }
 public virtual BatchCapacityDatum GetBatchCapacityForForest(int numberOfMailboxes)
 {
     return(this.GetBatchCapacityForForest(numberOfMailboxes, ByteQuantifiedSize.FromMB((ulong)((long)numberOfMailboxes * (long)this.AverageMailboxSize.ToMB()))));
 }
        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;
                                }
                            }
                        }
                    }
                }
            }
        }
        // Token: 0x06000038 RID: 56 RVA: 0x00003160 File Offset: 0x00001360
        public static void Start()
        {
            if (!ThrottlingAppConfig.LoggingEnabled)
            {
                return;
            }
            Assembly executingAssembly = Assembly.GetExecutingAssembly();

            ThrottlingServiceLog.throttlingServiceLogSchema = new LogSchema("Microsoft Exchange Server", executingAssembly.GetName().Version.ToString(), "Throttling Service Log", ThrottlingServiceLog.Fields);
            string logPath = ThrottlingAppConfig.LogPath;

            if (!string.IsNullOrEmpty(logPath))
            {
                ThrottlingServiceLog.log = new Log("TRTL", new LogHeaderFormatter(ThrottlingServiceLog.throttlingServiceLogSchema), "ThrottlingServiceLogs");
                ThrottlingServiceLog.log.Configure(logPath, ThrottlingAppConfig.LoggingMaxAge, (long)ThrottlingAppConfig.LoggingDirectorySize.ToBytes(), (long)ByteQuantifiedSize.FromMB(10UL).ToBytes(), 1048576, TimeSpan.FromSeconds(30.0));
                ThrottlingServiceLog.enabled = true;
            }
        }