Exemple #1
0
        /// <summary>
        /// 取得已消费的数量
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="lastMqId"></param>
        /// <returns></returns>
        public long GetMsgCount(DbConn conn, long lastMqId)
        {
            return(SqlHelper.Visit((ps) =>
            {
                MQIDInfo info = PartitionRuleHelper.GetMQIDInfo(lastMqId);
                string sql = "SELECT SUM(mqcount) FROM [tb_partition_messagequeue_report] WITH(NOLOCK) WHERE [day]<@day AND partitionid=@partitionid";
                ps.Add("@day", info.Day);
                ps.Add("@partitionid", PartitionRuleHelper.GetPartitionID(new PartitionIDInfo()
                {
                    DataNodePartition = info.DataNodePartition, TablePartition = info.TablePartition
                }));
                string tableName = PartitionRuleHelper.GetTableName(info.TablePartition, info.Day);
                object obj = conn.ExecuteScalar(sql, ps.ToParameters());
                long msgCount = 0;
                if (obj != DBNull.Value && obj != null)
                {
                    msgCount = LibConvert.ObjToInt64(obj);
                }

                long lastCount = 0;
                using (DbConn nodeConn = DbConfig.CreateConn(DataConfig.DataNodeParConn(PartitionRuleHelper.PartitionNameRule(info.DataNodePartition))))
                {
                    nodeConn.Open();
                    var dal = new tb_messagequeue_dal(); dal.TableName = tableName;
                    lastCount = dal.GetLastDayMsgCount(nodeConn, lastMqId);
                }

                return msgCount + lastCount;
            }));
        }
Exemple #2
0
 public ActionResult Add(tb_messagequeue_model model, string node, string tablepartition,string daypartition)
 {
     DateTime serverdate = DateTime.Now;
     using (DbConn conn = DbConfig.CreateConn(DataConfig.MqManage))
     {
         conn.Open();
         serverdate = conn.GetServerDate();
     }
     using (DbConn conn = DbConfig.CreateConn(DataConfig.DataNodeParConn(node)))
     {
         conn.Open();
         model.sqlcreatetime = serverdate;
         model.mqcreatetime = DateTime.Now;
         string tablename = PartitionRuleHelper.GetTableName(Convert.ToInt32(tablepartition), DateTime.ParseExact(daypartition, "yyMMdd", CultureInfo.InvariantCulture));
         var dal =  new tb_messagequeue_dal();dal.TableName=tablename;
         if (dal.Add(conn, tablename, model))
         {
             return RedirectToAction("index");
         }
         else
         {
             ModelState.AddModelError("Error", "更新错误");
             return View(model);
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// 任务调度平台根据发布的任务时间配置,定时回调运行方法
        /// 开发人员的任务插件必须要重载并该方法
        /// </summary>
        public override void Run()
        {
            ConfigHelper.LoadConfig(this.AppConfig["BusinessMQManageConnectString"]);
            List<tb_partition_model> userdpartitions = new List<tb_partition_model>();
            Dictionary<int, tb_datanode_model> datanodemodels = new Dictionary<int, tb_datanode_model>();
            DateTime servertime = DateTime.Now;
            SqlHelper.ExcuteSql(this.AppConfig["BusinessMQManageConnectString"], (c) =>
            {
                tb_partition_dal partitiondal = new tb_partition_dal();
                userdpartitions = partitiondal.List(c, true);
                tb_datanode_dal datanodedal = new tb_datanode_dal();
                var ms = datanodedal.List(c);
                foreach (var m in ms)
                {
                    datanodemodels.Add(m.datanodepartition, m);
                }
                servertime = c.GetServerDate();
            });

            List<Exception> exps = new List<Exception>();
            foreach (var p in userdpartitions)
            {
                var partitioninfo = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetPartitionIDInfo(p.partitionid);
                List<DateTime> days = new List<DateTime>() { servertime.Date, servertime.Date.AddDays(1), servertime.Date.AddDays(2) };
                //检查三天表创建情况
                foreach (var day in days)
                {
                    var tablename = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetTableName(partitioninfo.TablePartition, day);//
                    SqlHelper.ExcuteSql(this.GetDataNodeConnectString(datanodemodels[partitioninfo.DataNodePartition]), (c) =>
                    {
                        bool exsit = c.TableIsExist(tablename);
                        if (exsit != true)
                        {
                            exps.Add(new Exception(string.Format("分区{0}表{1}不存在", p.partitionid, tablename)));
                        }
                    });
                }

                //检测当天的数据量是否过大
                var todaytablename = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetTableName(partitioninfo.TablePartition, servertime.Date);//
                SqlHelper.ExcuteSql(this.GetDataNodeConnectString(datanodemodels[partitioninfo.DataNodePartition]), (c) =>
                {
                    tb_messagequeue_dal dal = new tb_messagequeue_dal(); dal.TableName = todaytablename;
                    var maxid = dal.GetMaxID(c);
                    if (maxid % 100000000 >= 70000000)
                    {
                        exps.Add(new Exception(string.Format("数据量超过70000000,当前最大mqid:{0}", maxid)));
                    }
                });
            }
            Error(this.AppConfig["BusinessMQManageConnectString"], "数据异常任务之表创建检查", exps);
        }
Exemple #4
0
 public ActionResult Delete(long id, string node)
 {
     using (DbConn conn = DbConfig.CreateConn(DataConfig.DataNodeParConn(node)))
     {
         conn.Open();
         var mqidinfo = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetMQIDInfo(Convert.ToInt64(id));
         string tablename = PartitionRuleHelper.GetTableName(mqidinfo.TablePartition, mqidinfo.Day);
         var dal = new tb_messagequeue_dal(); dal.TableName = tablename;
         if (dal.SetState(conn,id,(byte)XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.EnumMessageState.Deleted))
         {
             return Json(new { code = 1, msg = "删除成功" });
         }
         return Json(new { code = -1, msg = "删除失败" });
     }
 }
Exemple #5
0
        /// <summary>
        /// 取得未消费的数量
        /// </summary>
        /// <param name="lastMqId"></param>
        /// <returns></returns>
        public long GetNonMsgCount(DbConn conn, long lastMqId)
        {
            return(SqlHelper.Visit((ps) =>
            {
                MQIDInfo info = PartitionRuleHelper.GetMQIDInfo(lastMqId);
                var currentday = conn.GetServerDate().Date;

                string sql = "SELECT SUM(mqcount) FROM [tb_partition_messagequeue_report] WITH(NOLOCK) WHERE [day]>@day AND partitionid=@partitionid AND [day]<>@currentday";
                ps.Add("@day", info.Day); ps.Add("@currentday", currentday);
                ps.Add("@partitionid", PartitionRuleHelper.GetPartitionID(new PartitionIDInfo()
                {
                    DataNodePartition = info.DataNodePartition, TablePartition = info.TablePartition
                }));

                object obj = conn.ExecuteScalar(sql, ps.ToParameters());
                long msgCount = 0;
                if (obj != DBNull.Value && obj != null)
                {
                    msgCount = LibConvert.ObjToInt64(obj);
                }

                long firstCount = 0; long lastCount = 0;
                using (DbConn nodeConn = DbConfig.CreateConn(DataConfig.DataNodeParConn(PartitionRuleHelper.PartitionNameRule(info.DataNodePartition))))
                {
                    nodeConn.Open();
                    string firsttableName = PartitionRuleHelper.GetTableName(info.TablePartition, info.Day);
                    var msgDal = new tb_messagequeue_dal(); msgDal.TableName = firsttableName;
                    firstCount = msgDal.GetLastDayNonMsgCount(nodeConn, lastMqId);
                    if (info.Day != currentday)//不是今天
                    {
                        string lasttableName = PartitionRuleHelper.GetTableName(info.TablePartition, currentday);
                        var dal = new tb_messagequeue_dal(); dal.TableName = lasttableName;
                        long maxmqid = dal.GetMaxID(nodeConn);
                        if (lastMqId == 0)
                        {
                            lastCount = 0;
                        }
                        else
                        {
                            lastCount = dal.GetLastDayMsgCount(nodeConn, maxmqid);
                        }
                    }
                }
                //最后一天剩余
                return msgCount + firstCount + lastCount;
            }));
        }
Exemple #6
0
 private void MoveDataToToday(DateTime fromdate, DateTime serverdate, tb_partition_model p, Dictionary<int, tb_datanode_model> datanodemodels)
 {
     var partitioninfo = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetPartitionIDInfo(p.partitionid);
     var fromtablename = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetTableName(partitioninfo.TablePartition, fromdate);
     var currenttablename = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetTableName(partitioninfo.TablePartition, serverdate);
     //二分法查找起始点
     long startmovemqid = StartMoveMQID(fromtablename, partitioninfo, datanodemodels, p, fromdate);
     if (startmovemqid <= -1)
         return;
     //为了解决可能出现的并发插入,网络极度延迟可能导致的数据顺序乱掉,起始点再往前追溯1000条
     startmovemqid = startmovemqid - 1000;
     if (startmovemqid <= 0)
         startmovemqid = 1;
     //从起始点开始批量扫描
     tb_messagequeue_dal dal = new tb_messagequeue_dal(); dal.TableName = fromtablename; var moveMessages = new List<tb_messagequeue_model>();
     do
     {
         SqlHelper.ExcuteSql(this.GetDataNodeConnectString(datanodemodels[partitioninfo.DataNodePartition]), (c) =>
         {
            moveMessages = dal.GetListMoreThanID(c,1000,startmovemqid);
         });
         //对每条数据进行逐条迁移
          foreach (var message in moveMessages)
         {
             startmovemqid = Math.Max(startmovemqid, message.id);//起始id自增
             if (message.sqlcreatetime.Date > fromdate.Date && message.state == (byte)XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.EnumMessageState.CanRead)
             {
                 SqlHelper.ExcuteSql(this.GetDataNodeConnectString(datanodemodels[partitioninfo.DataNodePartition]), (c) =>
               {
                   tb_messagequeue_dal fromdal = new tb_messagequeue_dal(); fromdal.TableName = fromtablename;
                   tb_messagequeue_dal todal = new tb_messagequeue_dal(); todal.TableName = currenttablename;
                   todal.AddMove(c,new tb_messagequeue_model()
                   {
                       message = message.message,
                       state = (byte)XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.EnumMessageState.CanRead,
                    mqcreatetime=message.mqcreatetime, source=(byte)XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.EnumMessageSource.Moved });//迁移到最新使用表
                    fromdal.SetState(c, message.id, (byte)XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.EnumMessageState.Moved);//原消息设置为已迁移
               });
             }
         }
     } while (moveMessages.Count>0);
 }
Exemple #7
0
 private long StartMoveMQID(string fromtablename, PartitionIDInfo info, Dictionary<int, tb_datanode_model> datanodemodels, tb_partition_model p, DateTime tabletime)
 {
     long r = -1;
     SqlHelper.ExcuteSql(this.GetDataNodeConnectString(datanodemodels[info.DataNodePartition]), (c) =>
     {
         bool exsit = c.TableIsExist(fromtablename);
         if (exsit == true)
         {
             tb_messagequeue_dal dal = new tb_messagequeue_dal(); dal.TableName = fromtablename;
             long maxid = dal.GetMaxID(c); long minid = dal.GetMinID(c);
             int findcount = 0;
             while (findcount<=30)//二分查找算法,超过30次意味着算法若对,查询过一亿的数据,说明算法有问题
             {
                 findcount++;
                 KeyValuePair<long, DateTime> mininfo = dal.GetIDCreateTime(c, minid); KeyValuePair<long, DateTime> maxinfo = dal.GetIDCreateTime(c, maxid);
                 if (mininfo.Value.Date <= tabletime.Date && maxinfo.Value.Date > tabletime.Date)//最小id小于等于当天,最大id>当天,说明中间有数据要迁移
                 {
                     var midid = (long)((maxinfo.Key + mininfo.Key) / 2); KeyValuePair<long, DateTime> midinfo = dal.GetIDCreateTime(c, midid);
                     if (midinfo.Value.Date <= tabletime.Date)//往大的查找
                     {
                         minid = midid;
                     }
                     else//往小的查找
                     {
                         maxid = minid;
                     }
                     System.Threading.Thread.Sleep(50);//避免给数据库大的压力
                 }
                 else if (mininfo.Value.Date > tabletime.Date)//最小id的时间超过表当天
                 {
                     r = mininfo.Key; return;
                 }
                 else if (maxinfo.Value.Date <= tabletime.Date)//最大id的时间小于或等同当天
                 {
                     r = maxinfo.Key; return;
                 }
             }
             if (findcount >= 30)
                 throw new Exception("二分查找算法错误,查找次数超过30次");
         }
     });
     return r;
 }
        /// <summary>
        /// 取得已消费的数量
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="lastMqId"></param>
        /// <returns></returns>
        public long GetMsgCount(DbConn conn, long lastMqId)
        {
            return SqlHelper.Visit((ps) =>
            {
                MQIDInfo info = PartitionRuleHelper.GetMQIDInfo(lastMqId);
                string sql = "SELECT SUM(mqcount) FROM [tb_partition_messagequeue_report] WITH(NOLOCK) WHERE [day]<@day AND partitionid=@partitionid";
                ps.Add("@day", info.Day);
                ps.Add("@partitionid", PartitionRuleHelper.GetPartitionID(new PartitionIDInfo() { DataNodePartition = info.DataNodePartition, TablePartition = info.TablePartition }));
                string tableName = PartitionRuleHelper.GetTableName(info.TablePartition, info.Day);
                object obj = conn.ExecuteScalar(sql, ps.ToParameters());
                long msgCount = 0;
                if (obj != DBNull.Value && obj != null)
                {
                    msgCount = LibConvert.ObjToInt64(obj);
                }

                long lastCount = 0;
                using (DbConn nodeConn = DbConfig.CreateConn(DataConfig.DataNodeParConn(PartitionRuleHelper.PartitionNameRule(info.DataNodePartition))))
                {
                    nodeConn.Open();
                    var dal = new tb_messagequeue_dal(); dal.TableName = tableName;
                    lastCount = dal.GetLastDayMsgCount(nodeConn, lastMqId);
                }

                return msgCount + lastCount;
            });
        }
        /// <summary>
        /// 取得未消费的数量
        /// </summary>
        /// <param name="lastMqId"></param>
        /// <returns></returns>
        public long GetNonMsgCount(DbConn conn, long lastMqId)
        {
            return SqlHelper.Visit((ps) =>
              {
              MQIDInfo info = PartitionRuleHelper.GetMQIDInfo(lastMqId);
              var currentday = conn.GetServerDate().Date;

              string sql = "SELECT SUM(mqcount) FROM [tb_partition_messagequeue_report] WITH(NOLOCK) WHERE [day]>@day AND partitionid=@partitionid AND [day]<>@currentday";
              ps.Add("@day", info.Day); ps.Add("@currentday", currentday);
              ps.Add("@partitionid", PartitionRuleHelper.GetPartitionID(new PartitionIDInfo() { DataNodePartition = info.DataNodePartition, TablePartition = info.TablePartition }));

              object obj = conn.ExecuteScalar(sql, ps.ToParameters());
              long msgCount = 0;
              if (obj != DBNull.Value && obj != null)
              {
                  msgCount = LibConvert.ObjToInt64(obj);
              }

              long firstCount = 0; long lastCount = 0;
              using (DbConn nodeConn = DbConfig.CreateConn(DataConfig.DataNodeParConn(PartitionRuleHelper.PartitionNameRule(info.DataNodePartition))))
              {
                  nodeConn.Open();
                  string firsttableName = PartitionRuleHelper.GetTableName(info.TablePartition, info.Day);
                  var msgDal = new tb_messagequeue_dal(); msgDal.TableName = firsttableName;
                  firstCount = msgDal.GetLastDayNonMsgCount(nodeConn, lastMqId);
                  if (info.Day != currentday)//不是今天
                  {
                      string lasttableName = PartitionRuleHelper.GetTableName(info.TablePartition, currentday);
                      var dal = new tb_messagequeue_dal(); dal.TableName = lasttableName;
                      long maxmqid = dal.GetMaxID(nodeConn);
                      if (lastMqId == 0)
                          lastCount = 0;
                      else
                          lastCount = dal.GetLastDayMsgCount(nodeConn, maxmqid);
                  }
              }
              //最后一天剩余
              return msgCount + firstCount + lastCount;
              });
        }
        public override void Run()
        {
            ConfigHelper.LoadConfig(this.AppConfig["BusinessMQManageConnectString"]);

            List<tb_datanode_model> nodeList = new List<tb_datanode_model>();

            using (DbConn conn = DbConfig.CreateConn(this.AppConfig["BusinessMQManageConnectString"]))
            {
                conn.Open();
                List<tb_partition_model> createTimeList = new tb_consumer_dal().GetClientCreateTime(conn);
                var serverdate = conn.GetServerDate().Date; var timenow = conn.GetServerDate();
                nodeList = new tb_datanode_dal().List(conn);
                List<Exception> exps = new List<Exception>();
                foreach (var item in nodeList)
                {
                    try
                    {
                        string dataNode = PartitionRuleHelper.GetDataNodeName(item.datanodepartition);
                        string nodeConn = string.Format("server={0};Initial Catalog={1};User ID={2};Password={3};", item.serverip, dataNode, item.username, item.password);
                        string partitionId = PartitionRuleHelper.PartitionNameRule(item.datanodepartition);
                        string t = PartitionRuleHelper.GetDataNodeName(item.datanodepartition);

                        using (DbConn dataNodeConn = DbConfig.CreateConn(nodeConn))
                        {
                            dataNodeConn.Open();
                            var tablesinfo = new tb_messagequeue_dal().GetDataNodeTable(dataNodeConn, serverdate.AddDays(-30));
                            foreach (var table in tablesinfo)
                            {
                                string tablename = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetTableName(table.TablePartition, table.Day);

                                TableInfo info = PartitionRuleHelper.GetTableInfo(tablename);
                                var beginId = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetMQID(new MQIDInfo() { AutoID = 0, DataNodePartition = item.datanodepartition, Day = table.Day, TablePartition = table.TablePartition });

                                int mqPartitionId = PartitionRuleHelper.GetPartitionID(new PartitionIDInfo() { DataNodePartition = item.datanodepartition, TablePartition = table.TablePartition });
                                tb_partition_model timeModel = createTimeList.Where(q => q.partitionid == mqPartitionId).FirstOrDefault();
                                DateTime time = DateTime.Parse("2015-01-01");
                                if (timeModel != null)
                                {
                                    time = timeModel.createtime;
                                }
                                var dal = new tb_messagequeue_dal(); dal.TableName = tablename;

                                int count = dal.GetCount(dataNodeConn, time);
                                long maxId = dal.GetMaxID(dataNodeConn, time); maxId = (maxId == 0 ? beginId : maxId);
                                long minId = dal.GetMinID(dataNodeConn, time); minId = (minId == 0 ? beginId : minId);
                                tb_partition_messagequeue_report_model model = new tb_partition_messagequeue_report_model();
                                model.partitionid = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetPartitionID(new PartitionIDInfo() { DataNodePartition = item.datanodepartition, TablePartition = table.TablePartition });

                                MQIDInfo mqInfo = PartitionRuleHelper.GetMQIDInfo(maxId);
                                model.day = mqInfo.Day;
                                model.lastupdatetime = timenow;
                                model.createtime = timenow;
                                model.mqmaxid = maxId;
                                model.mqminid = minId;
                                model.mqcount = count;
                                new tb_partition_messagequeue_report_dal().AddReport(conn, model);
                            }

                        }
                    }
                    catch (Exception exp)
                    {
                        exps.Add(exp);
                    }

                }
                Error(this.AppConfig["BusinessMQManageConnectString"], "消息统计出错", exps);
            }
        }
Exemple #11
0
        /// <summary>
        /// 任务调度平台根据发布的任务时间配置,定时回调运行方法
        /// 开发人员的任务插件必须要重载并该方法
        /// </summary>
        public override void Run()
        {
            runcount++;

            ConfigHelper.LoadConfig(this.AppConfig["BusinessMQManageConnectString"]);

            List<tb_partition_model> userdpartitions = new List<tb_partition_model>();
            Dictionary<int, tb_datanode_model> datanodemodels = new Dictionary<int, tb_datanode_model>();
            List<RegisterdConsumersModel> registeredconsumermodels = new List<RegisterdConsumersModel>();
            List<tb_consumer_model> consumers = new List<tb_consumer_model>();
            DateTime servertime = DateTime.Now;
            SqlHelper.ExcuteSql(this.AppConfig["BusinessMQManageConnectString"], (c) =>
            {
                tb_partition_dal partitiondal = new tb_partition_dal();
                userdpartitions = partitiondal.List(c, true);
                tb_datanode_dal datanodedal = new tb_datanode_dal();
                var ms = datanodedal.List(c);
                foreach (var m in ms)
                {
                    datanodemodels.Add(m.datanodepartition, m);
                }
                servertime = c.GetServerDate();

                //获取当前注册的消费者
                tb_consumer_dal consumerdal = new tb_consumer_dal();
                registeredconsumermodels = consumerdal.GetRegisterdConsumers(c);
                consumers = consumerdal.GetAllList(c);
            });
            //消费者端心跳停止,异常退出检测(超过1分钟)
            List<Exception> exps = new List<Exception>();
            foreach (var c in consumers)
            {
                if ((servertime - c.lastheartbeat) > TimeSpan.FromMinutes(1))
                {
                    exps.Add(new Exception(string.Format("当前消费者tempid:{0},consumerclientid:{1}", c.tempid, c.consumerclientid)));
                }
            }
            Error(this.AppConfig["BusinessMQManageConnectString"], "消费者端心跳停止,异常退出检测(超过1分钟),若是异常停止,请手工清除消费者中断", exps);
            //消费者端长时间无消费,但是还有多余消息(超过10分钟未消费,但还有多余消息未消费)
            exps.Clear();
            foreach (var c in registeredconsumermodels)
            {
                if ((servertime - c.consumerpartitionmodel.lastupdatetime) > TimeSpan.FromMinutes(10))
                {
                    var partitionidinfo = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetPartitionIDInfo(c.consumerpartitionmodel.partitionid);
                    var tablename = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetTableName(partitionidinfo.TablePartition, servertime.Date);
                    SqlHelper.ExcuteSql(this.GetDataNodeConnectString(datanodemodels[partitionidinfo.DataNodePartition]), (conn) =>
                    {
                        tb_messagequeue_dal messagedal = new tb_messagequeue_dal(); messagedal.TableName = tablename;
                        long maxmqid = messagedal.GetMaxID(conn);
                        if (maxmqid > c.consumerpartitionmodel.lastmqid && (servertime - messagedal.GetIDCreateTime(conn, maxmqid).Value > TimeSpan.FromMinutes(10)))//还有消息未消费,且该消息的创建时间是10分钟前
                        {
                            exps.Add(new Exception(string.Format("当前消费者tempid:{0},consumerclientid:{1},client:{2},clientname:{3}", c.consumermodel.tempid,
                                                   c.consumermodel.consumerclientid, c.consumerclientmodel.client, c.consumermodel.clientname)));
                        }
                    });
                }
            }
            Error(this.AppConfig["BusinessMQManageConnectString"], "消费者端长时间无消费,但是还有多余消息(超过已创建超过10分钟的消息未消费),可能是消费者处理逻辑异常", exps);
            //某个分区没有指定消费者(分区没有消费信息,或者分区消费最后消费时间超过1个小时无消费)
            exps.Clear();
            if (runcount % (12*6) == 0)
            {
                foreach (var u in userdpartitions)
                {
                    bool isfind = false;
                    foreach (var c in registeredconsumermodels)
                    {
                        if (c.consumerpartitionmodel.partitionid == u.partitionid)
                        {
                            isfind = true; break;
                        }
                    }
                    if (isfind == false)
                    {
                        SqlHelper.ExcuteSql(this.AppConfig["BusinessMQManageConnectString"], (c) =>
                        {
                            tb_consumer_partition_dal dal = new tb_consumer_partition_dal();
                            var model = dal.GetByPartitionId(c, u.partitionid);
                            if (model == null)
                                exps.Add(new Exception(string.Format("分区{0}未指定消费者", u.partitionid)));
                            //else if((servertime - model.lastupdatetime) > TimeSpan.FromHours(24))
                            //     exps.Add(new Exception(string.Format("分区{0}消费者已注销,且有1天未消费", u.partitionid)));

                        });

                    }
                }
                Error(this.AppConfig["BusinessMQManageConnectString"], "某个分区没有指定消费者(分区没有消费信息)", exps);
            }
        }
Exemple #12
0
 public JsonResult GetDayList(string node, string tablepartition)
 {
     try
     {
         string mqpath = "";
         using (DbConn conn = DbConfig.CreateConn(DataConfig.MqManage))
         {
             conn.Open();
             tb_mqpath_dal mqpathdal = new tb_mqpath_dal();
             var model = mqpathdal.GetByPartitionID(conn, PartitionRuleHelper.GetPartitionID(new PartitionIDInfo() { DataNodePartition = Convert.ToInt32(node), TablePartition = Convert.ToInt32(tablepartition) }));
             if(model!=null)
                 mqpath = model.mqpath;
         }
         using (DbConn conn = DbConfig.CreateConn(DataConfig.DataNodeParConn(node)))
         {
             conn.Open();
             var array = new tb_messagequeue_dal().GetDayPartitions(conn, Convert.ToInt32(tablepartition)).Select(c => c.ToString("yyMMdd")).ToList();
             if (array != null && array.Count > 0)
             {
                 return Json(new { array, mqpath }, JsonRequestBehavior.AllowGet);
             }
             return Json("", JsonRequestBehavior.AllowGet);
         }
     }
     catch (Exception ex)
     {
         return Json("", JsonRequestBehavior.AllowGet);
     }
 }
Exemple #13
0
 public ActionResult Update(tb_messagequeue_model model, string node, long id)
 {
     ViewBag.node = node;
     var mqidinfo = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetMQIDInfo(Convert.ToInt64(id));
     ViewBag.tablepartition = mqidinfo.TablePartition; ViewBag.daypartition = mqidinfo.Day.ToString("yyMMdd");
     string tablename = PartitionRuleHelper.GetTableName(mqidinfo.TablePartition, mqidinfo.Day);
     var dal = new tb_messagequeue_dal(); dal.TableName = tablename;
     using (DbConn conn = DbConfig.CreateConn(DataConfig.DataNodeParConn(node)))
     {
         conn.Open();
         tb_messagequeue_model result = dal.GetModel(conn, id, tablename);
         if (result != null)
         {
             result.message = model.message;
             result.state = model.state;
             result.source = model.source;
             if (dal.Update(conn, result, tablename))
             {
                 return RedirectToAction("Index", new { node =node, tablepartition = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.PartitionNameRule( mqidinfo.TablePartition), daypartition = mqidinfo.Day.ToString("yyMMdd"), mqid = id });
             }
         }
         ModelState.AddModelError("Error", "更新错误");
         return View(result);
     }
 }
Exemple #14
0
 public ActionResult Update(long id, string node)
 {
     using (DbConn conn = DbConfig.CreateConn(DataConfig.DataNodeParConn(node)))
     {
         conn.Open();
         ViewBag.node = node;
         var mqidinfo = XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.GetMQIDInfo(Convert.ToInt64(id));
         ViewBag.tablepartition = mqidinfo.TablePartition; ViewBag.daypartition = mqidinfo.Day.ToString("yyMMdd");
         string tablename = PartitionRuleHelper.GetTableName(mqidinfo.TablePartition, mqidinfo.Day);
         var dal = new tb_messagequeue_dal(); dal.TableName = tablename;
         tb_messagequeue_model model = dal.GetModel(conn, id, tablename);
         return View(model);
     }
 }
Exemple #15
0
        public ActionResult Index(string node = "", string tablepartition = "", string daypartition = "", string mqid= "",bool isclick=false, int pageIndex = 1, int pageSize = 30)
        {
            ViewBag.mqid = mqid;
            ViewBag.node = node;
            ViewBag.tablepartition = tablepartition; ViewBag.daypartition = daypartition; ViewBag.isclick = isclick;
            int count = 0;
            IList<tb_messagequeue_model> list = new List<tb_messagequeue_model>();
            PagedList<tb_messagequeue_model> pageList = new PagedList<tb_messagequeue_model>(list, pageIndex, pageSize, count);
            if (!string.IsNullOrWhiteSpace(node))
            {

                using (DbConn conn = DbConfig.CreateConn(DataConfig.DataNodeParConn(node)))
                {
                    conn.Open();
                    string tablename = PartitionRuleHelper.GetTableName(Convert.ToInt32(tablepartition), DateTime.ParseExact(daypartition, "yyMMdd", CultureInfo.InvariantCulture));
                    tb_messagequeue_dal dal = new tb_messagequeue_dal(); dal.TableName = tablename;
                    list = dal.GetPageList(conn, pageIndex, pageSize, mqid, ref count);
                    pageList = new PagedList<tb_messagequeue_model>(list, pageIndex, pageSize, count);
                }
            }
            if (Request.IsAjaxRequest())
            {
                return PartialView("List", pageList);
            }
            return View(pageList);
        }
Exemple #16
0
        public JsonResult GetPartitionList(string node)
        {
            try
            {

                using (DbConn conn = DbConfig.CreateConn(DataConfig.DataNodeParConn(node)))
                {
                    conn.Open();
                    var array = new tb_messagequeue_dal().GetTablePartitions(conn).Select(c => XXF.BaseService.MessageQuque.BusinessMQ.SystemRuntime.PartitionRuleHelper.PartitionNameRule(c)).ToList();
                    if (array != null && array.Count > 0)
                    {
                        return Json(array, JsonRequestBehavior.AllowGet);
                    }
                    return Json("", JsonRequestBehavior.AllowGet);
                }

            }
            catch (Exception ex)
            {
                return Json("", JsonRequestBehavior.AllowGet);
            }
        }