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 GetDatabaseData(Guid databaseGuid, bool includeMailboxes) { TopologyExtractorFactoryContext topologyExtractorFactoryContext = this.serviceContext.GetTopologyExtractorFactoryContext(); TopologyExtractorFactory topologyExtractorFactory = includeMailboxes ? topologyExtractorFactoryContext.GetEntitySelectorFactory() : topologyExtractorFactoryContext.GetLoadBalancingLocalFactory(false); DirectoryDatabase database = this.serviceContext.Directory.GetDatabase(databaseGuid); return(topologyExtractorFactory.GetExtractor(database).ExtractTopology()); }
public override LoadContainer GetLocalServerData(Band[] bands) { IList <Guid> nonMovableOrgsList = LoadBalanceUtils.GetNonMovableOrgsList(this.serviceContext.Settings); ILogger logger = this.serviceContext.Logger; TopologyExtractorFactoryContext context = this.serviceContext.TopologyExtractorFactoryContextPool.GetContext(this.serviceContext.ClientFactory, bands, nonMovableOrgsList, logger); TopologyExtractorFactory loadBalancingLocalFactory = context.GetLoadBalancingLocalFactory(true); return(loadBalancingLocalFactory.GetExtractor(base.TargetServer).ExtractTopology()); }
private HeatMapCapacityData GetDagCapacityDatum(DirectoryIdentity objectIdentity) { TopologyExtractorFactoryContext topologyExtractorFactoryContext = this.serviceContext.GetTopologyExtractorFactoryContext(); DirectoryDatabaseAvailabilityGroup directoryObject = (DirectoryDatabaseAvailabilityGroup)this.serviceContext.Directory.GetDirectoryObject(objectIdentity); TopologyExtractorFactory loadBalancingCentralFactory = topologyExtractorFactoryContext.GetLoadBalancingCentralFactory(); LoadContainer loadContainer = loadBalancingCentralFactory.GetExtractor(directoryObject).ExtractTopology(); return(loadContainer.ToCapacityData()); }
protected override LoadContainer BuildTopology(TopologyExtractorFactoryContext topologyExtractorContext) { TopologyExtractorFactory loadBalancingCentralFactory = topologyExtractorContext.GetLoadBalancingCentralFactory(); TopologyExtractor extractor = loadBalancingCentralFactory.GetExtractor(base.ServiceContext.Directory.GetLocalForest()); LoadContainer loadContainer = extractor.ExtractTopology(); ExAssert.RetailAssert(loadContainer != null, "Extracted toplogy for the forest should never be null."); return(loadContainer); }
protected override void ProcessRequest() { using (OperationTracker.Create(this.logger, "Rebalancing {0} from {1} to {2}.", new object[] { this.rebalanceData.RebalanceInformation, this.rebalanceData.SourceDatabase, this.rebalanceData.TargetDatabase })) { this.logger.Log(MigrationEventType.Information, "MOVE: Moving {0} from {1} to {2}.", new object[] { this.rebalanceData.RebalanceInformation, this.rebalanceData.SourceDatabase, this.rebalanceData.TargetDatabase }); Band[] bands = this.rebalanceData.RebalanceInformation.Metrics.OfType <Band>().ToArray <Band>(); TopologyExtractorFactory entitySelectorFactory = this.serviceContext.TopologyExtractorFactoryContextPool.GetContext(this.clientFactory, bands, this.nonMovableOrgs, this.logger).GetEntitySelectorFactory(); DirectoryDatabase database = this.directoryProvider.GetDatabase(this.rebalanceData.SourceDatabase.Guid); LoadContainer container = entitySelectorFactory.GetExtractor(database).ExtractTopology(); IOperationRetryManager operationRetryManager = LoadBalanceOperationRetryManager.Create(this.logger); foreach (LoadMetric loadMetric in this.rebalanceData.RebalanceInformation.Metrics) { EntitySelector selector = loadMetric.GetSelector(container, this.rebalanceData.ConstraintSetIdentity, this.rebalanceData.RebalanceInformation[loadMetric]); if (selector.IsEmpty) { this.logger.Log(MigrationEventType.Information, "Could not find any mailbox for metric {0} in database {1}.", new object[] { loadMetric, this.rebalanceData.SourceDatabase }); } else { this.logger.Log(MigrationEventType.Information, "Found mailboxes matching the metric {0} in database {1}. Requesting the injections.", new object[] { loadMetric, this.rebalanceData.SourceDatabase }); operationRetryManager.TryRun(delegate { DirectoryDatabase database2 = (DirectoryDatabase)this.directoryProvider.GetDirectoryObject(this.rebalanceData.TargetDatabase.DirectoryObjectIdentity); using (IInjectorService injectorClientForDatabase = this.clientFactory.GetInjectorClientForDatabase(database2)) { injectorClientForDatabase.InjectMoves(this.rebalanceData.TargetDatabase.Guid, this.rebalanceData.RebalanceBatchName, selector.GetEntities(this.rebalanceData.TargetDatabase)); } }); } } } }
public void InjectMoves(Guid targetDatabase, BatchName batchName, IList <LoadEntity> loadEntityList, bool throwIfNotValid = false) { this.logger.Log(MigrationEventType.Information, "Injecting {0} moves into database '{1}' with batch name '{2}'.", new object[] { loadEntityList.Count, targetDatabase, batchName }); TopologyExtractorFactoryContextPool topologyExtractorFactoryContextPool = this.serviceContext.TopologyExtractorFactoryContextPool; IList <Guid> nonMovableOrgsList = LoadBalanceUtils.GetNonMovableOrgsList(this.settings); TopologyExtractorFactoryContext context = topologyExtractorFactoryContextPool.GetContext(this.clientFactory, null, nonMovableOrgsList, this.logger); TopologyExtractorFactory entitySelectorFactory = context.GetEntitySelectorFactory(); LoadContainer database = entitySelectorFactory.GetExtractor(this.directoryProvider.GetDatabase(targetDatabase)).ExtractTopology(); this.InjectMoves(database, batchName, loadEntityList, throwIfNotValid); }
private HeatMapCapacityData GetDatabaseCapacityDatum(DirectoryIdentity objectIdentity, bool refreshData, DirectoryIdentity localServerIdentity) { DirectoryDatabase directoryDatabase = (DirectoryDatabase)this.serviceContext.Directory.GetDirectoryObject(objectIdentity); DirectoryServer directoryServer = directoryDatabase.ActivationOrder.FirstOrDefault <DirectoryServer>(); if (directoryServer == null || localServerIdentity.Equals(directoryServer.Identity)) { TopologyExtractorFactoryContext topologyExtractorFactoryContext = this.serviceContext.GetTopologyExtractorFactoryContext(); TopologyExtractorFactory loadBalancingLocalFactory = topologyExtractorFactoryContext.GetLoadBalancingLocalFactory(refreshData); LoadContainer loadContainer = loadBalancingLocalFactory.GetExtractor(directoryDatabase).ExtractTopology(); return(loadContainer.ToCapacityData()); } HeatMapCapacityData capacitySummary; using (ILoadBalanceService loadBalanceClientForDatabase = this.serviceContext.ClientFactory.GetLoadBalanceClientForDatabase(directoryDatabase)) { capacitySummary = loadBalanceClientForDatabase.GetCapacitySummary(objectIdentity, refreshData); } return(capacitySummary); }