Beispiel #1
0
        /// <summary>
        /// 自动mark down,怎么区分?
        /// </summary>
        /// <param name="allInOneKey"></param>
        public static void AutoMarkDownADatabase(String allInOneKey)
        {
            lock (lockObj)
            {
                markDownDatabases[allInOneKey] = markdownBean.EnableAutoMarkDown ? MarkDownEnums.AutoMarkDown : MarkDownEnums.FakeAutoMarkDown;

                var schedules = SplitUtil.SplitAsInt32(markdownBean.AutoMarkUpSchedule).ToArray();
                //排序
                Array.Sort <Int32>(schedules);
                markingUpDatabases[allInOneKey] = new MarkUpInfo()
                {
                    PreMarkUp             = false,
                    MarkDownTime          = DateTime.Now,
                    CurrentMarkUpIndex    = 0,
                    MarkUpSchedules       = schedules,
                    MarkUpSuccess         = new Int32[schedules.Length],
                    MarkUpFail            = new Int32[schedules.Length],
                    CurrentMarkUpSchedule = 0,
                    CurrentBatch          = 1,
                    MarkUpArray           = MarkUpInfo.InitMarkUpArray(schedules[0])
                };
            }
        }
Beispiel #2
0
        public static void AutoMarkUpMonitor(String allInOneKey, Boolean isAbnormalException)
        {
            if (markingUpDatabases.ContainsKey(allInOneKey) && markdownBean.AutoMarkUpBatches > 0)
            {
                lock (lockObj)
                {
                    if (markingUpDatabases.ContainsKey(allInOneKey) && markdownBean.AutoMarkUpBatches > 0)
                    {
                        if (isAbnormalException)
                        {
                            markingUpDatabases[allInOneKey].MarkUpFail[markingUpDatabases[allInOneKey].CurrentMarkUpSchedule]++;
                        }
                        else
                        {
                            markingUpDatabases[allInOneKey].MarkUpSuccess[markingUpDatabases[allInOneKey].CurrentMarkUpSchedule]++;
                        }

                        if (markingUpDatabases[allInOneKey].CurrentBatch > markdownBean.AutoMarkUpBatches)
                        {
                            markingUpDatabases[allInOneKey].CurrentBatch = 1;
                            //Pre Mark Up已经结束,如果监控到的状态良好,则取消Mark Down,否则回到上个阶段,并清空Pre Mark Up的记录
                            if (markingUpDatabases[allInOneKey].MarkUpFail[markingUpDatabases[allInOneKey].CurrentMarkUpSchedule] > 0)
                            {
                                markingUpDatabases[allInOneKey].PreMarkUp    = false;
                                markingUpDatabases[allInOneKey].MarkDownTime = DateTime.Now;
                                var markupMetrics = new MarkUpMetrics()
                                {
                                    AllInOneKey  = allInOneKey,
                                    Batches      = markdownBean.AutoMarkUpBatches,
                                    MarkUpDelay  = markdownBean.AutoMarkUpDelay,
                                    SuccessCount = markingUpDatabases[allInOneKey].MarkUpSuccess.Sum(),
                                    Success      = false
                                };

                                LogManager.Logger.MetricsMarkup(markupMetrics);
                                markingUpDatabases[allInOneKey].MarkUpSuccess[markingUpDatabases[allInOneKey].CurrentMarkUpSchedule] = 0;
                                markingUpDatabases[allInOneKey].MarkUpFail[markingUpDatabases[allInOneKey].CurrentMarkUpSchedule]    = 0;
                                if (markingUpDatabases[allInOneKey].CurrentMarkUpSchedule > 0)
                                {
                                    markingUpDatabases[allInOneKey].CurrentMarkUpSchedule--;
                                }
                            }
                            else
                            {
                                //如果部分完成,进入下一阶段
                                if (markingUpDatabases[allInOneKey].MarkUpSchedules.Length - 1 > markingUpDatabases[allInOneKey].CurrentMarkUpSchedule)
                                {
                                    markingUpDatabases[allInOneKey].CurrentMarkUpSchedule++;
                                    markingUpDatabases[allInOneKey].MarkUpArray        = MarkUpInfo.InitMarkUpArray(markingUpDatabases[allInOneKey].MarkUpSchedules[markingUpDatabases[allInOneKey].CurrentMarkUpSchedule]);
                                    markingUpDatabases[allInOneKey].CurrentMarkUpIndex = 0;
                                }
                                else
                                {
                                    var markupMetrics = new MarkUpMetrics()
                                    {
                                        AllInOneKey  = allInOneKey,
                                        Batches      = markdownBean.AutoMarkUpBatches,
                                        MarkUpDelay  = markdownBean.AutoMarkUpDelay,
                                        SuccessCount = markingUpDatabases[allInOneKey].MarkUpSuccess.Sum(),
                                        Success      = true
                                    };

                                    LogManager.Logger.MetricsMarkup(markupMetrics);
                                    //如果全部状态已完成,移除Mark Down数据库,情况Mark Up监控
                                    markDownDatabases.Remove(allInOneKey);
                                    markingUpDatabases.Remove(allInOneKey);
                                }
                            }
                        }
                    }
                }
            }
        }