Exemplo n.º 1
0
        protected override void SendBuffer(LoggingEvent[] events)
        {
            try
            {
                if (!ValidateHelper.IsPlumpList(events))
                {
                    return;
                }

                //缓冲设置的越小,阻塞的几率越大==========暂时不开启
                if (this.BufferSize < this.ThreadHold && false)
                {
                    //等待的概率
                    var AskProbability = 1 - ((double)this.BufferSize) / this.ThreadHold;

                    var r = ran.RealNext(this.ThreadHold);
                    if (r < AskProbability * this.ThreadHold)
                    {
                        //等待结束
                        var task = this.WriterActor.Ask <bool>(events);
                        AsyncHelper_.RunSync(() => task);
                        return;
                    }
                }
                //不等待结束
                this.WriterActor.Tell(events);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.GetInnerExceptionAsJson());
            }
        }
Exemplo n.º 2
0
        public override void Dispose()
        {
            if (ValidateHelper.IsPlumpString(this._no))
            {
                AsyncHelper_.RunSync(() => this.ReleaseLock());
            }

            base.Dispose();
        }
Exemplo n.º 3
0
 /// <summary>
 /// 初始化
 /// </summary>
 private void Init()
 {
     try
     {
         //清理无用节点
         AsyncHelper_.RunSync(() => this.ClearDeadNodes());
         //读取节点并添加监视
         AsyncHelper_.RunSync(() => this.NodeChildrenChanged(this._base_path));
     }
     catch (Exception e)
     {
         throw new Exception("订阅服务节点失败", e);
     }
 }
Exemplo n.º 4
0
 private void StartWatch()
 {
     try
     {
         this.Retry().Execute(() =>
         {
             AsyncHelper_.RunSync(() => this.NodeChildrenChanged(this._base_path));
         });
     }
     catch (Exception e)
     {
         throw new Exception("订阅服务节点失败", e);
     }
 }
Exemplo n.º 5
0
        public void Dispose()
        {
            try
            {
                AsyncHelper_.RunSync(() => this.ReleaseLock());
            }
            catch (Exception e)
            {
                logger.AddWarningLog(e: e, msg: e.Message);
            }

            try
            {
                this._reset.Dispose();
            }
            catch (Exception e)
            {
                logger.AddWarningLog(e: e, msg: e.Message);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 不会卡死
        /// </summary>
        /// <returns></returns>
        public ActionResult mimimi1()
        {
            var data = AsyncHelper_.RunSync(() => this._clientRepo.GetListAsync(null));

            return(GetJson(data));
        }
Exemplo n.º 7
0
 public void Reg() => AsyncHelper_.RunSync(() => this.RegisterService());