private RemoteHostPool GetRelevantPool() { lock (_locker) { bool shouldFallBack = MasterEnvironmentPool != null && !OriginatingEnvironmentPool.IsServiceDeploymentDefined; RemoteHostPool newActivePool = shouldFallBack ? MasterEnvironmentPool : OriginatingEnvironmentPool; if (newActivePool != _activePool) { Log.Info(x => x("Discovery host pool has changed", unencryptedTags: new { serviceName = _serviceName, previousPool = _activePool.ServiceDeployment.ToString(), newPool = newActivePool.ServiceDeployment.ToString() })); _activePool = newActivePool; FireEndPointChange(); if (shouldFallBack) { OriginatingEnvironmentPool.DeactivateMetrics(); } else { MasterEnvironmentPool?.DeactivateMetrics(); } } return(_activePool); } }
private void RemoveOriginatingPool() { if (_activePool == OriginatingEnvironmentPool) { _activePool = null; } OriginatingEnvironmentPool?.Dispose(); OriginatingEnvironmentPool = null; _originatingEnvironmentLinks.ForEach(x => x?.Dispose()); _originatingEnvironmentLinks = new List <IDisposable>(); }