Exemple #1
0
        private void DoTraceNode(Object state)
        {
            var list = RedisNode.FindAllWithCache();

            foreach (var item in list)
            {
                if (item.Enable)
                {
                    // 捕获异常,不要影响后续操作
                    var key    = $"DoTraceNode:{item.Id}";
                    var errors = _cache.Get <Int64>(key);
                    if (errors < 5)
                    {
                        try
                        {
                            TraceNode(item);

                            _cache.Remove(key);
                        }
                        catch (Exception ex)
                        {
                            errors = _cache.Increment(key, 1);
                            if (errors <= 1)
                            {
                                _cache.SetExpire(key, TimeSpan.FromMinutes(10));
                            }

                            XTrace.WriteException(ex);
                        }
                    }
                    else
                    {
                        item.Enable = false;
                        item.SaveAsync();

                        _cache.Remove(key);
                    }
                }
            }
        }
Exemple #2
0
        private void DoAlarm(Object state)
        {
            while (_bag.TryTake(out var appId))
            {
                //Process(appId);
            }

            // 应用告警
            var list = AppTracer.FindAllWithCache();

            foreach (var item in list)
            {
                ProcessAppTracer(item);
            }

            // 节点告警
            var nodes = Node.FindAllWithCache();

            foreach (var item in nodes)
            {
                ProcessNode(item);
            }

            // Redis告警
            var rnodes = RedisNode.FindAllWithCache();

            foreach (var item in rnodes)
            {
                ProcessRedisNode(item);
            }

            if (Period > 0)
            {
                _timer.Period = Period * 1000;
            }
        }