예제 #1
0
        public void add_info(RECORD_INFO p)
        {
            lock (_map_stat_info)
            {
                STAT_INFO info;
                if (_map_stat_info.TryGetValue(p.op, out info))
                {
                    add_stat_2_info(p, ref info);
                }
                else
                {
                    info = new STAT_INFO();
                    add_stat_2_info(p, ref info);
                    _map_stat_info.Add(p.op, info);
                }
            }

            /* has problem
             * if(p.errcode != -30000)   //业务不存在的错误码,如果业务不存在,不添加业务统计和创建相关的文件
             * {
             *  Dictionary<string, STAT_INFO> busi_stat;
             *  if (_map_biz_stat.TryGetValue(p.biz_name, out busi_stat))
             *  { }
             *  else
             *  {
             *      busi_stat = new Dictionary<string, STAT_INFO>();
             *      _map_biz_stat.Add(p.biz_name, busi_stat);
             *  }
             *
             *
             *  STAT_INFO busi_stat_info;
             *  if (busi_stat.TryGetValue(p.op, out busi_stat_info))
             *  {
             *      add_stat_2_info(p, ref busi_stat_info);
             *  }
             *  else
             *  {
             *      busi_stat_info = new STAT_INFO();
             *      add_stat_2_info(p, ref busi_stat_info);
             *      busi_stat.Add(p.op, info);
             *  }
             * }*/
            return;
        }
예제 #2
0
        public int add_stat_2_info(RECORD_INFO p, ref STAT_INFO info)
        {
            //STAT_INFO &info = _map_stat_info[p->op];

            info.all_total_t += p.cost_t;

            for (int i = _vec_cost_time.Count - 1; i >= 0; i--)
            {
                if (p.cost_t > _vec_cost_time[i])
                {
                    int num;
                    if (info.map_time.TryGetValue(_vec_cost_time[i], out num))
                    {
                        info.map_time[_vec_cost_time[i]]++;
                    }
                    else
                    {
                        info.map_time.Add(_vec_cost_time[i], 1);
                    }
                    break;
                }
            }

            if (p.errcode == 1)
            {
                info.succ_num++;
                info.suc_total_t += p.cost_t;
                info.size        += p.size;
            }
            else
            {
                int count = 0;
                if (info.map_ip.TryGetValue(p.ip, out count))
                {
                    info.map_ip[p.ip]++;
                }
                else
                {
                    info.map_ip.Add(p.ip, 1);
                }

                if (info.map_uin.TryGetValue(p.uin, out count))
                {
                    info.map_uin[p.uin]++;
                }
                else
                {
                    info.map_uin.Add(p.uin, 1);
                }
                info.err_total_t += p.cost_t;

                if (info.map_err.TryGetValue(p.errcode, out count))
                {
                    info.map_err[p.errcode]++;
                }
                else
                {
                    info.map_err.Add(p.errcode, 1);
                }

                info.err_num++;
                if (_map_normal_err.ContainsKey(p.errcode))
                {
                    info.err_normal++;
                }
                else
                {
                    info.err_fail++;
                }
            }
            return(0);
        }