コード例 #1
0
        /// <inheritdoc />
        public async Task ShutdownAsync(int timeoutMs = Timeout.Infinite)
        {
            if (!_initialized)
            {
                return;
            }
            var sessions = _connectedSessions.ClearAndGet();

            try
            {
                var task = Task.Run(() =>
                {
                    foreach (var s in sessions)
                    {
                        s.Dispose();
                    }
                }).WaitToCompleteAsync(timeoutMs);
                await task.ConfigureAwait(false);
            }
            catch (AggregateException ex)
            {
                if (ex.InnerExceptions.Count == 1)
                {
                    throw ex.InnerExceptions[0];
                }
                throw;
            }
            _metadata.ShutDown(timeoutMs);
            _controlConnection.Dispose();
            Configuration.Timer.Dispose();
            Configuration.Policies.SpeculativeExecutionPolicy.Dispose();
            _logger.Info("Cluster [" + _metadata.ClusterName + "] has been shut down.");
        }
コード例 #2
0
 public void Dispose()
 {
     if (_controlConnection != null)
     {
         _controlConnection.Dispose();
     }
 }
コード例 #3
0
        /// <summary>
        ///  Shutdown this cluster instance. This closes all connections from all the
        ///  sessions of this <code>* Cluster</code> instance and reclaim all resources
        ///  used by it. <p> This method has no effect if the cluster was already shutdown.</p>
        /// </summary>
        public void Shutdown()
        {
            List <Session> conccpy;

            lock (_connectedSessions)
            {
                conccpy            = new List <Session>(_connectedSessions);
                _connectedSessions = new List <Session>();
            }

            foreach (var ses in conccpy)
            {
                ses.Dispose();
            }
            lock (_controlConnectionGuard)
            {
                if (_controlConnection != null)
                {
                    string cluster_name = this.Metadata.GetClusterName();
                    try
                    {
                        Monitor.Exit(_controlConnectionGuard);
                        _controlConnection.Dispose();
                    }
                    finally
                    {
                        Monitor.Enter(_controlConnectionGuard);
                        _controlConnection = null;
                        _logger.Info("Cluster [" + cluster_name + "] has been shut down.");
                    }
                }
            }
        }
コード例 #4
0
        /// <inheritdoc />
        public void Shutdown(int timeoutMs = Timeout.Infinite)
        {
            if (!_initialized)
            {
                return;
            }
            Session session;

            while (_connectedSessions.TryTake(out session))
            {
                session.Dispose();
            }
            _metadata.ShutDown(timeoutMs);
            _controlConnection.Dispose();

            _logger.Info("Cluster [" + _metadata.ClusterName + "] has been shut down.");
        }
コード例 #5
0
        /// <inheritdoc />
        public void Shutdown(int timeoutMs = Timeout.Infinite)
        {
            if (!_initialized)
            {
                return;
            }
            Session session;

            while (_connectedSessions.TryTake(out session))
            {
                session.WaitForAllPendingActions(timeoutMs);
                session.Dispose();
            }
            _metadata.ShutDown(timeoutMs);
            _controlConnection.Dispose();
            Configuration.Timer.Dispose();
            Configuration.Policies.SpeculativeExecutionPolicy.Dispose();
            _logger.Info("Cluster [" + _metadata.ClusterName + "] has been shut down.");
        }