Esempio n. 1
0
        public void Close()
        {
            Enumerable
            .Range(0, PartitionCount)
            .SelectMany(PartitionTable)
            .OfType <DynamicRemoteStorage>()
            .ForEach(s =>
            {
                try
                {
                    int id = GetInstanceId(s.ReplicaInformation.Id);
                    using (var request = new StorageInformationWriter(MyPartitionId, m_nameservice.InstanceId))
                    { m_module.NotifyRemoteStorageOnLeaving(id, request); }
                }
                catch { }
            });

            m_cancelSrc.Cancel();

            m_backupctl.Dispose();
            m_taskexec.Dispose();
            m_partitioner.Dispose();
            m_healthmon.Dispose();
            m_cloudidx.Dispose();
            m_persistent_storage.Dispose();

            m_nameservice.Dispose();
            m_chunktable.Dispose();
            m_taskqueue.Dispose();
            m_healthmanager.Dispose();
            m_backupmgr.Dispose();
        }
        public void ClearAllMonitors()
        {
            _healthMonitor.SetHealthFunction(COMPONENT, () => HealthCheckResult.Unhealthy());
            _healthMonitor.Dispose();
            bool isComponentStillRegisteredToHealthCheck = HealthChecks.GetStatus().Results.Any(_ => _.Name == COMPONENT);

            isComponentStillRegisteredToHealthCheck.ShouldBeFalse();
        }
Esempio n. 3
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (healthMonitor != null)
         {
             healthMonitor.Dispose();
         }
     }
 }
Esempio n. 4
0
        private void CreatePool(string endPoints, ReachabilityChecker isReachableChecker = null)
        {
            _healthMonitor?.Dispose();
            _healthMonitor = new HealthMonitor();

            var unitTesting = new TestingKernel <LogSpy>(mockConfig: new Dictionary <string, string>  {
                { $"Discovery.Services.{SERVICE_NAME}.DelayMultiplier", "1" },
                { $"Discovery.Services.{SERVICE_NAME}.FirstAttemptDelaySeconds", "0.01" }
            });

            Log = (LogSpy)unitTesting.Get <ILog>();
            var factory = unitTesting.Get <IRemoteHostPoolFactory>();

            _discoverySourceMock = new DiscoverySourceMock(serviceContext, endPoints);

            Pool = factory.Create(
                new ServiceDeployment(SERVICE_NAME, "prod"),
                _discoverySourceMock,
                isReachableChecker ?? (rh => Task.FromResult(false)));
        }
 public void Dispose()
 {
     if (_disposed)
     {
         return;
     }
     try
     {
         _disposed = true;
         MetricsConfig.Dispose();
         HealthMonitor.Dispose();
     }
     catch (AggregateException ae)
     {
         // Ignore all TaskCanceledExceptions (unhandled by Metrics.NET for unknown reasons)
         ae.Handle(ex => ex is TaskCanceledException);
     }
 }