예제 #1
0
파일: MonitorDayAo.java 프로젝트: kevx/csp
  /**
   * @param appId
   * @param date
   * @return
   */
  public String findCappRtCountByDate(int appId, String date) throws Exception {

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date c = sdf.parse(date);
    Calendar cal = Calendar.getInstance();
    cal.setTime(c);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    Date colectDate = cal.getTime();

    List<KeyValuePo> listPo =
        dao.findCappRtCountByTime(appId, colectDate); // 返回的是20:30~22:30每个key的平均值和key的列表
    // 下面是对返回的20:30~22:30的记录进行平均,
    Double aveValue = 0d;
    int size = 0;
    for (KeyValuePo po : listPo) {
      Double value = Double.parseDouble(po.getValueStr());
      if (value < 1000) { // 大于100的剔除掉
        aveValue = Arith.add(aveValue, value);
        size++;
      }
    }

    if (size > 0) {
      aveValue = Arith.div(aveValue, size, 2); // 总调用量/接口数	
      return aveValue.toString();
    }
    return "0";
  }
예제 #2
0
파일: MonitorDayAo.java 프로젝트: kevx/csp
  /**
   * 这是提供给C应用查询qps的,返回C应用所有相关key的mData的一个平均值
   *
   * @param appId
   * @param collectTime //yyyy-MM-dd
   * @return
   * @throws Exception
   */
  public String findCappQpsCountByDate(Integer appId, String collectTime) throws Exception {

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date c = sdf.parse(collectTime);
    Calendar cal = Calendar.getInstance();
    cal.setTime(c);
    cal.set(Calendar.HOUR_OF_DAY, 20);
    cal.set(Calendar.MINUTE, 30);
    cal.set(Calendar.SECOND, 0);
    Date startDate = cal.getTime();
    cal.set(Calendar.HOUR_OF_DAY, 22);
    cal.set(Calendar.MINUTE, 30);
    cal.set(Calendar.SECOND, 0);
    Date endDate = cal.getTime();

    List<KeyValuePo> listPo =
        dao.findCappQpsCountByTime(appId, startDate, endDate); // 返回的是20:30~22:30每一分钟的记录
    // 下面是对返回的20:30~22:30的记录进行平均,
    Double aveValue = 0d;
    int size = 0;
    for (KeyValuePo po : listPo) {
      Double value = Double.parseDouble(po.getValueStr());
      aveValue = Arith.add(aveValue, value);
      size++;
    }

    if (size > 0) {
      aveValue = Arith.div(aveValue, size, 2);
      return aveValue.toString();
    }
    return "0";
  }
예제 #3
0
파일: MonitorDayAo.java 프로젝트: kevx/csp
 public String parseCenterAppQps(Integer appId, Integer keyId, String collectTime) {
   SimpleDateFormat sdf1 = new SimpleDateFormat("HHmm");
   List<KeyValuePo> listPo = findMonitorDataListByTime(appId, keyId, collectTime);
   Double aveValue = 0d;
   int size = 0;
   for (KeyValuePo po : listPo) {
     Date date = po.getCollectTime();
     Double value = Double.parseDouble(po.getValueStr());
     int time = Integer.parseInt(sdf1.format(date));
     if (time >= 2030 && time <= 2230) {
       aveValue = Arith.add(aveValue, value);
       size++;
     }
   }
   if (size > 0) {
     aveValue = Arith.div(aveValue, size, 2);
     return aveValue.toString();
   }
   return "0";
 }
예제 #4
0
  private String createMessage(KeyJudgeEnum e, RangeDefine d, int keyId) {

    if (e == KeyJudgeEnum.greaterTo) {
      double l = d.getLessthan();
      if (keyId == 176) {
        l = Arith.div(l, 1000, 2);
      }

      return "超过阀值" + l;

    } else if (e == KeyJudgeEnum.lessTo) {
      double l = d.getGreaterthan();
      if (keyId == 176) {
        l = Arith.div(l, 1000, 2);
      }

      return "小于阀值" + l;
    } else if (e == KeyJudgeEnum.equalTo) {

      return null;
    }
    return null;
  }