Пример #1
0
        /// <summary>
        /// Shutdown this <see cref="KafkaStream"/> instance by signaling all the threads to stop, and then wait for them to join.
        /// This will block until all threads have stopped.
        /// </summary>
        private void Close()
        {
            if (!SetState(State.PENDING_SHUTDOWN))
            {
                // if transition failed, it means it was either in PENDING_SHUTDOWN
                // or NOT_RUNNING already; just check that all threads have been stopped
                logger.LogInformation($"{logPrefix}Already in the pending shutdown state, wait to complete shutdown");
            }
            else
            {
                RunMiddleware(true, false);

                foreach (var t in threads)
                {
                    t.Dispose();
                }

                if (globalStreamThread != null)
                {
                    globalStreamThread.Dispose();
                }

                RunMiddleware(false, false);
                metricsRegistry.RemoveClientSensors();
                SetState(State.NOT_RUNNING);
                logger.LogInformation($"{logPrefix}Streams client stopped completely");
            }
        }
Пример #2
0
        /// <summary>
        /// Shutdown this <see cref="KafkaStream"/> instance by signaling all the threads to stop, and then wait for them to join.
        /// This will block until all threads have stopped.
        /// </summary>
        public void Close()
        {
            if (!SetState(State.PENDING_SHUTDOWN))
            {
                // if transition failed, it means it was either in PENDING_SHUTDOWN
                // or NOT_RUNNING already; just check that all threads have been stopped
                logger.Info($"{logPrefix}Already in the pending shutdown state, wait to complete shutdown");
            }
            else
            {
                foreach (var t in threads)
                {
                    t.Dispose();
                }

                if (globalStreamThread != null)
                {
                    globalStreamThread.Dispose();
                }

                SetState(State.NOT_RUNNING);
                logger.Info($"{logPrefix}Streams client stopped completely");
            }
        }