/// <summary> /// 添加历史 /// </summary> /// <param name="arn"></param> public RetryNode AddHistory(RetryNode arn) { RetryNode node = null; this.historyLock.EnterUpgradeableReadLock(); try { if (this.history.ContainsKey(arn.Name)) { node = this.history[arn.Name]; if (node.IsValid()) { AqiManage.Remind.Log_Debug("上次时区数据已经丢失,此时区又出现错误", new string[] { this.name, arn.RunnerName }); node.Concat(arn); } else { this.historyLock.EnterWriteLock(); try { this.history[arn.Name] = arn; } finally { this.historyLock.ExitWriteLock(); } } } else { this.historyLock.EnterWriteLock(); try { this.history.Add(arn.Name, arn); } finally { this.historyLock.ExitWriteLock(); } } node = this.history[arn.Name]; } finally { this.historyLock.ExitUpgradeableReadLock(); } return(node); }
/// <summary> /// 再次入重试队列 /// 循环线程 /// </summary> /// <param name="arn"></param> /// <param name="ex"></param> public void PutAgain(RetryNode arn, Exception ex) { //更新计数 arn.Update(ex); //检查有效性 if (!arn.IsValid()) { //读取配置 if (AqiManage.Setting.Get <bool>("AqiRetryer.AlwayRetry")) { //继续重试 AqiManage.Remind.Log_Debug("重试已经无效,仍然尝试重试", new string[] { this.name, arn.RunnerName }); } else { //停止重试 AqiManage.Remind.Log_Error("重试已经无效,暂停", new string[] { this.name, arn.RunnerName }); return; } } //入队列:继续重试 this.Push(arn.Name); AqiManage.Remind.Log_Info("已添加到重试队列", new string[] { this.name, arn.RunnerName, arn.Name }); }