public IEnumerable <BandMailboxRebalanceData> BalanceForest(LoadContainer forest) { IEnumerable <BandMailboxRebalanceData> result; try { this.logger.Log(MigrationEventType.Information, "Starting a new load balancing procedure using the band algorithm.", new object[0]); this.results = new List <BandMailboxRebalanceData>(); this.logger.Log(MigrationEventType.Verbose, "Using {0} bands for balancing.", new object[] { this.bands.Count }); this.logger.Log(MigrationEventType.Verbose, "Calculating total database weight in the forest.", new object[0]); DatabaseWeightAggregator databaseWeightAggregator = new DatabaseWeightAggregator(); forest.Accept(databaseWeightAggregator); this.logger.Log(MigrationEventType.Verbose, "Forest has a '{0}' total database weight.", new object[] { databaseWeightAggregator.TotalWeight }); this.totalDataSelectedToMove = new ByteQuantifiedSize(0UL); foreach (Band band in this.bands) { BandDataAggregator bandDataAggregator = new BandDataAggregator(band); forest.Accept(bandDataAggregator); this.BalanceBand(band, (double)databaseWeightAggregator.TotalWeight, bandDataAggregator.BandData.ToArray <BandData>()); } ByteQuantifiedSize byteQuantifiedSize = ByteQuantifiedSize.FromGB((ulong)this.settings.MaximumBatchSizeGb); ByteQuantifiedSize totalBatchSize = this.GetTotalBatchSize(); if (totalBatchSize > byteQuantifiedSize) { this.logger.LogWarning("Total selected size is {0}, but we're only allowed to rebalance {1}. Reducing batch.", new object[] { totalBatchSize, byteQuantifiedSize }); IBatchSizeReducer batchSizeReducer = BatchSizeReducerFactory.Instance.GetBatchSizeReducer(byteQuantifiedSize, totalBatchSize, this.logger); result = batchSizeReducer.ReduceBatchSize(this.results); } else { result = this.results; } } finally { this.logger.Log(MigrationEventType.Information, "Finished load balancing procedure using the band algorithm. {0} rebalancing entries created.", new object[] { this.results.Count }); } return(result); }
protected override LoadContainer BuildTopology(TopologyExtractorFactoryContext topologyExtractorContext) { TopologyExtractorFactory loadBalancingLocalFactory = topologyExtractorContext.GetLoadBalancingLocalFactory(false); DirectoryServer localServer = base.ServiceContext.Directory.GetLocalServer(); TopologyExtractor extractor = loadBalancingLocalFactory.GetExtractor(localServer); LoadContainer loadContainer = extractor.ExtractTopology(); ExAssert.RetailAssert(loadContainer != null, "Extracted toplogy for server '{0}' should never be null.", new object[] { localServer }); DatabaseCollector databaseCollector = new DatabaseCollector(); loadContainer.Accept(databaseCollector); IOperationRetryManager operationRetryManager = LoadBalanceOperationRetryManager.Create(1, TimeSpan.Zero, base.ServiceContext.Logger); foreach (LoadContainer loadContainer2 in databaseCollector.Databases) { DirectoryDatabase directoryDatabase = loadContainer2.DirectoryObject as DirectoryDatabase; if (directoryDatabase != null) { DatabaseProcessor @object = new DatabaseProcessor(base.ServiceContext.Settings, base.ServiceContext.DrainControl, base.ServiceContext.Logger, directoryDatabase); operationRetryManager.TryRun(new Action(@object.ProcessDatabase)); } } return(loadContainer); }
public LoadContainer GetLocalServerData(Band[] bands) { return(base.CallService <LoadContainer>(delegate() { LoadContainer localServerData = this.Channel.GetLocalServerData(bands); localServerData.Accept(new DirectoryReconnectionVisitor(this.directory, this.Logger)); return localServerData; })); }