public static string ToAppropriateUnitFormatString(this ByteQuantifiedSize size, string valueFormat) { if (size.ToTB() > 0UL) { return(string.Format(OwaOptionStrings.MailboxUsageUnitTB, string.Format(CultureInfo.InvariantCulture, valueFormat, new object[] { size.ToBytes() / 1099511627776.0 }))); } if (size.ToGB() > 0UL) { return(string.Format(OwaOptionStrings.MailboxUsageUnitGB, string.Format(CultureInfo.InvariantCulture, valueFormat, new object[] { size.ToBytes() / 1073741824.0 }))); } if (size.ToMB() > 0UL) { return(string.Format(OwaOptionStrings.MailboxUsageUnitMB, string.Format(CultureInfo.InvariantCulture, valueFormat, new object[] { size.ToBytes() / 1048576.0 }))); } if (size.ToKB() > 0UL) { return(string.Format(OwaOptionStrings.MailboxUsageUnitKB, string.Format(CultureInfo.InvariantCulture, valueFormat, new object[] { size.ToBytes() / 1024.0 }))); } return(string.Format(CultureInfo.InvariantCulture, OwaOptionStrings.MailboxUsageUnitB, new object[] { size.ToBytes() })); }
private static void Initialize(ExDateTime serviceStartTime, string logFilePath, TimeSpan maxRetentionPeriond, ByteQuantifiedSize directorySizeQuota, ByteQuantifiedSize perFileSizeQuota, bool applyHourPrecision) { int registryInt; using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess\\Parameters")) { GLSLogger.Enabled = GLSLogger.GetRegistryBool(registryKey, "ProtocolLoggingEnabled", true); registryInt = GLSLogger.GetRegistryInt(registryKey, "LogBufferSize", 65536); } if (GLSLogger.registryWatcher == null) { GLSLogger.registryWatcher = new RegistryWatcher("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess\\Parameters", false); } if (GLSLogger.timer == null) { GLSLogger.timer = new Timer(new TimerCallback(GLSLogger.UpdateConfigIfChanged), null, 0, 300000); } if (GLSLogger.Enabled) { GLSLogger.log = new Log(GLSLogger.logFilePrefix, new LogHeaderFormatter(GLSLogger.schema, LogHeaderCsvOption.CsvCompatible), "GLSLogs"); GLSLogger.log.Configure(logFilePath, maxRetentionPeriond, (long)directorySizeQuota.ToBytes(), (long)perFileSizeQuota.ToBytes(), applyHourPrecision, registryInt, GLSLogger.defaultFlushInterval); AppDomain.CurrentDomain.ProcessExit += GLSLogger.CurrentDomain_ProcessExit; } GLSLogger.Initialized = true; }
private void Initialize(ExDateTime serviceStartTime, string logFilePath, TimeSpan maxRetentionPeriod, ByteQuantifiedSize directorySizeQuota, ByteQuantifiedSize perFileSizeQuota, bool applyHourPrecision) { int registryInt; using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess\\Parameters")) { this.enabled = ServiceTopologyLog.GetRegistryBool(registryKey, "ServiceTopologyLoggingEnabled", false); registryInt = ServiceTopologyLog.GetRegistryInt(registryKey, "LogBufferSize", 524288); int registryInt2 = ServiceTopologyLog.GetRegistryInt(registryKey, "FlushIntervalInMinutes", 15); if (registryInt2 > 0) { ServiceTopologyLog.FlushInterval = TimeSpan.FromMinutes((double)registryInt2); } } if (this.registryWatcher == null) { this.registryWatcher = new RegistryWatcher("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess\\Parameters", false); } if (this.timer == null) { this.timer = new Timer(new TimerCallback(this.UpdateConfigIfChanged), null, 0, 300000); } this.log = new Log(ServiceTopologyLog.LogFilePrefix, new LogHeaderFormatter(ServiceTopologyLog.Schema, LogHeaderCsvOption.CsvCompatible), "ServiceTopologyLogs"); this.log.Configure(logFilePath, maxRetentionPeriod, (long)directorySizeQuota.ToBytes(), (long)perFileSizeQuota.ToBytes(), applyHourPrecision, registryInt, ServiceTopologyLog.FlushInterval, LogFileRollOver.Hourly); AppDomain.CurrentDomain.ProcessExit += this.CurrentDomain_ProcessExit; this.initialized = true; }
public virtual long GetUnitsForSize(ByteQuantifiedSize size) { if (!this.IsSize) { throw new InvalidOperationException("Cannot get units for size on a non-size metric."); } return((long)size.ToBytes()); }
public LoadContainer ToLoadContainer() { DatabaseSizeInfo size = this.GetSize(); LoadContainer loadContainer = new LoadContainer(this, ContainerType.Database); loadContainer.RelativeLoadWeight = this.RelativeLoadCapacity; loadContainer.CanAcceptRegularLoad = (!this.IsExcludedFromProvisioning && size.CurrentPhysicalSize < this.MaximumSize); loadContainer.CanAcceptBalancingLoad = (!this.IsExcludedFromInitialProvisioning && loadContainer.CanAcceptRegularLoad); loadContainer.MaximumLoad[PhysicalSize.Instance] = (long)this.MaximumSize.ToBytes(); loadContainer.MaximumLoad[LogicalSize.Instance] = (long)this.MaximumSize.ToBytes(); loadContainer.ReusableCapacity[LogicalSize.Instance] = (long)size.AvailableWhitespace.ToBytes(); loadContainer.ReusableCapacity[PhysicalSize.Instance] = (long)size.AvailableWhitespace.ToBytes(); ByteQuantifiedSize byteQuantifiedSize = size.CurrentPhysicalSize - size.AvailableWhitespace; loadContainer.ConsumedLoad[LogicalSize.Instance] = (long)byteQuantifiedSize.ToBytes(); loadContainer.ConsumedLoad[PhysicalSize.Instance] = (long)byteQuantifiedSize.ToBytes(); return(loadContainer); }
protected void Initialize(ExDateTime serviceStartTime, string logFilePath, TimeSpan maxRetentionPeriond, ByteQuantifiedSize directorySizeQuota, ByteQuantifiedSize perFileSizeQuota, bool applyHourPrecision, string logComponent) { if (this.Initialized) { throw new NotSupportedException("Protocol Log is already initialized"); } BaseDirectoryProtocolLog.InitializeGlobalConfigIfRequired(); if (this.log == null) { this.log = new Log(BaseDirectoryProtocolLog.logFilePrefix, new LogHeaderFormatter(this.Schema, LogHeaderCsvOption.CsvCompatible), logComponent); AppDomain.CurrentDomain.ProcessExit += this.CurrentDomainProcessExit; } if (BaseDirectoryProtocolLog.loggingEnabled.Value) { this.log.Configure(logFilePath, maxRetentionPeriond, (long)directorySizeQuota.ToBytes(), (long)perFileSizeQuota.ToBytes(), applyHourPrecision, BaseDirectoryProtocolLog.bufferSize, BaseDirectoryProtocolLog.DefaultFlushInterval, LogFileRollOver.Hourly); } BaseDirectoryProtocolLog.callsBacks = (TimerCallback)Delegate.Combine(BaseDirectoryProtocolLog.callsBacks, new TimerCallback(this.UpdateConfigIfChanged)); this.Initialized = true; }
public static string ToMB(this ByteQuantifiedSize size, int precision) { return(Math.Round(size.ToBytes() / 1048576.0, precision).ToString()); }
// 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); }
internal static void Initialize(ExDateTime serviceStartTime, string logFilePath, TimeSpan maxRetentionPeriond, ByteQuantifiedSize directorySizeQuota, ByteQuantifiedSize perFileSizeQuota, bool applyHourPrecision) { ProtocolLog.log = new Log(ProtocolLog.defaultLogFilePrefix, new LogHeaderFormatter(ProtocolLog.Schema), ProtocolLog.defaultLogComponent); ProtocolLog.log.Configure(logFilePath, maxRetentionPeriond, (long)directorySizeQuota.ToBytes(), (long)perFileSizeQuota.ToBytes(), applyHourPrecision); ProtocolLog.Enabled = true; }
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; } } } } } } }