예제 #1
0
 private void CreateAndStartLoggerThread()
 {
     for (Int32 i = 0; i < Config.WorkThreadCount; ++i)
     {
         var thread = new NaiveLoopThread(Tick, Config.WorkThreadIntervalMS, e => ErrorCounter.RaiseError(e), $"{nameof(Tick)}:{i}");
         _loggerThreads.Add(thread);
         thread.Start();
     }
 }
예제 #2
0
        public void 데드락_유발_루프_안에서_Stop호출()
        {
            _naiveLoopThread = new NaiveLoopThread(Loop_2, 1000, Console.WriteLine, nameof(데드락_유발_루프_안에서_Stop호출));
            _naiveLoopThread.Start();

            while (_loopCount <= 0)
            {
                Console.WriteLine("wait for test...");
                Thread.Sleep(500);
            }

            Console.WriteLine("test ok.");
        }
예제 #3
0
        public Boolean CleanupAndWaitForAsyncSend(Int32 waitMS)
        {
            _thread?.Stop();

            while (_reportActions.IsEmpty() == false)
            {
                SendReportInQueue();
            }

            _thread        = null;
            _reportActions = null;

            return(_slackWebhook.WaitForAsyncSend(waitMS));
        }
예제 #4
0
        public void 데드락_유발_사용하는_쪽에서_Loop와_Stop에_락()
        {
            _naiveLoopThread = new NaiveLoopThread(Loop_1, 1000, Console.WriteLine, nameof(데드락_유발_사용하는_쪽에서_Loop와_Stop에_락));
            _naiveLoopThread.Start();
            Stop_1();

            while (_loopCount <= 0)
            {
                Console.WriteLine("wait for test...");
                Thread.Sleep(500);
            }

            Console.WriteLine("test ok.");
        }
예제 #5
0
        internal void Stop()
        {
            lock (_lock)
            {
                if (_thread == null)
                {
                    throw new LoggerException($"Fail {nameof(ThroughputController)}::{nameof(Stop)}");
                }

                _thread.Stop();
                _thread = null;

                Flush();
            }
        }
예제 #6
0
        internal void Start()
        {
            lock (_lock)
            {
                if (_thread != null)
                {
                    throw new LoggerException($"Fail {nameof(CompletePutNotifier)}::{nameof(Start)} ${nameof(_thread)} is not null");
                }

                _completePuts = new QueueMT <CompletePutNotice>();

                _thread = new NaiveLoopThread(HandleCompletePut, _config.CompletePutIntervalMS, e => _errorCounter.RaiseError(e), nameof(CompletePutNotifier));
                _thread.Start();
            }
        }
예제 #7
0
        internal void Start()
        {
            lock (_lock)
            {
                if (_mainThread != null || _recordLogQueueThread != null)
                {
                    throw new LoggerException($"Fail {nameof(Watcher)}::{nameof(Start)}");
                }

                _mainThread           = new NaiveLoopThread(() => Watching(DateTime.UtcNow), _logger.Config.Watchers.IntervalMS, e => _logger.ErrorCounter.RaiseError(e), $"{nameof(Watcher)}-Watching");
                _recordLogQueueThread = new NaiveLoopThread(RecordLogQueue, QUEUE_SIZE_RECORD_INTERVAL_MS, e => _logger.ErrorCounter.RaiseError(e), $"{nameof(Watcher)}-Record");

                _mainThread.Start();
                _recordLogQueueThread.Start();
            }
        }
예제 #8
0
        internal void Stop()
        {
            lock (_lock)
            {
                if (_mainThread == null || _recordLogQueueThread == null)
                {
                    throw new LoggerException($"Fail {nameof(Watcher)}::{nameof(Stop)}");
                }

                _mainThread.Stop();
                _recordLogQueueThread.Stop();

                _mainThread           = null;
                _recordLogQueueThread = null;
            }
        }
예제 #9
0
 internal void Initialize(Logger logger)
 {
     lock (_lock)
     {
         _temporalCounter.Clear();
         _logger               = logger;
         _mainThread           = null;
         _recordLogQueueThread = null;
         _lastWatchingTime     = DateTime.UtcNow;
         _pushLogCount         = 0;
         _requestPutLogCount   = 0;
         _pendingLogCount      = 0;
         _successLogCount      = 0;
         _failLogCount         = 0;
         LogTypeToCount        = new ConcurrentDictionary <String, Int32>();
         KinesisShardToCount   = new ConcurrentDictionary <String, Int32>();
     }
 }
예제 #10
0
        internal void Stop()
        {
            lock (_lock)
            {
                if (_thread == null)
                {
                    throw new LoggerException($"Fail {nameof(CompletePutNotifier)}::{nameof(Stop)}");
                }

                _thread.Stop();
                _thread = null;
            }

            // Stop이후에 미묘한 타이밍에 Push된 것은 손실될 수 있음을 감안한다.
            while (_completePuts.IsEmpty() == false)
            {
                PopAndNotice();
            }
        }
예제 #11
0
        public SlackReporter(ReportLevelType reportLevel,
                             String webhookURL,
                             String userName,
                             String channelDebug,
                             String channelInfo,
                             String channelWarn,
                             String channelError,
                             String channelFatal,
                             String iconEmoji          = null,
                             Int32 addUTCHour          = 0,
                             Boolean tryOrderingReport = false)
            : base(ReporterType.Slack, reportLevel)
        {
            if (String.IsNullOrEmpty(webhookURL))
            {
                _slackWebhook = null;
            }
            else
            {
                _channelDebug = channelDebug;
                _channelInfo  = channelInfo;
                _channelWarn  = channelWarn;
                _channelError = channelError;
                _channelFatal = channelFatal;

                _slackWebhook = new SlackWebhook(webhookURL, _channelDebug, userName, iconEmoji, addUTCHour);

                _tryOrderingReport = tryOrderingReport;

                if (_tryOrderingReport)
                {
                    _thread        = new NaiveLoopThread(SendReportInQueue, THREAD_INTERVAL_MS, null, nameof(SlackReporter));
                    _reportActions = new QueueMT <Action>();
                    _thread.Start();
                }
                else
                {
                    _thread        = null;
                    _reportActions = null;
                }
            }
        }
예제 #12
0
        internal void Start()
        {
            lock (_lock)
            {
                if (_thread != null)
                {
                    throw new LoggerException($"Fail {nameof(ThroughputController)}::{nameof(Start)} {nameof(_thread)} is not null");
                }

                _putLogs       = new QueueMT <PutLog>();
                _remainPutLogs = new List <PutLog>();

                _isThrottling = false;

                // 샤드가 최소 1개는 존재할 것이므로 1개 기준으로 초기화.
                _shardCount     = 1;
                _byteCapacity   = Const.BYTE_FOR_SECOND_PER_SHARD_BYTE;
                _recordCapacity = Const.RECORD_FOR_SECOND_PER_SHARD_COUNT;

                _thread = new NaiveLoopThread(() => ThroughputControl(DateTime.UtcNow), THROUGHPUT_CONTROL_MS, e => _errorCounter.RaiseError(e), nameof(ThroughputController));
                _thread.Start();
            }
        }