/** * 这是提供给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"; }
/** * @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"; }
public Map<String, KeyValuePo> findMonitorCountKeyMapByDate(int appId, String date) { try { return dao.findMonitorCountKeyMapByDate(appId, date); } catch (Exception e) { logger.error("", e); } return null; }
/** * @param date yyyy-MM-dd * @return * @throws Exception */ public Map<Integer, MonitorVo> findMonitorCountMapByDate(String date) throws Exception { if (dao != null) { Map<Integer, MonitorVo> result = dao.findMonitorCountMapByDate(date); return result; } else { return null; } }
/** * add by zhongting.zy * * @param date yyyy-MM-dd * @return * @throws Exception */ public Map<Integer, MonitorVo> findMonitorCountMapByDate(AppInfoPo appInfo, String date) throws Exception { if (dao != null && appInfo != null) { Map<Integer, MonitorVo> result = dao.findMonitorCountMapByDate(appInfo.getAppId(), appInfo.getOpsName(), date); return result; } else { return null; } }
/** * 查询某个key 一天内的走势 * * @param appId * @param keyId * @param startCollectDate yyyy-MM-dd * @param endCollectDate yyyy-MM-dd * @return */ public List<KeyValuePo> findMonitorDataListByDate( Integer appId, Integer keyId, String startCollectDate, String endCollectDate) { try { return dao.findKeyDetailByDate(appId, keyId, startCollectDate, endCollectDate); } catch (Exception e) { logger.error("查询某个key 一天内的走势 出错", e); } return null; }
/** * @param date yyyy-MM-dd * @return * @throws Exception */ public Map<Integer, MonitorVo> findMonitorCountMapByDate(Integer appid, String date) throws Exception { if (dao != null) { AppInfoPo appInfo = AppInfoAo.get().findAppInfoById(appid); Map<Integer, MonitorVo> result = dao.findMonitorCountMapByDate(appid, appInfo.getOpsName(), date); return result; } else { return null; } }
/** * 查询某个key 一天内的走势 * * @param appId * @param keyId * @param collectDate yyyy-MM-dd * @return */ public List<KeyValuePo> findMonitorDataListByTime( Integer appId, Integer keyId, String collectTime) { if (collectTime == null) return null; try { return dao.findKeyDetailByTime(appId, keyId, collectTime); } catch (Exception e) { logger.error("查询某个key 一天内的走势 出错", e); } return new ArrayList<KeyValuePo>(); }
public Map<Long, String> findMonitorCountStrMapAsValueByDate( long appId, String date, long[] keyId) throws Exception { if (dao != null) { try { Map<Long, String> result = dao.findMonitorCountStrMapAsValueByDate(appId, date, keyId); return result; } catch (Exception e) { logger.error("查询出错", e); } } return null; }
public Map<Date, Integer> findAppHostCount(int appId, Integer[] keyIds, Date start, Date end) { Map<Date, Integer> map = new HashMap<Date, Integer>(); for (Integer keyId : keyIds) { List<KeyValuePo> list = dao.findMonitorCountByDate(appId, keyId, start, end); for (KeyValuePo po : list) { Integer n = map.get(po.getCollectTime()); if (n == null) { map.put(po.getCollectTime(), Integer.parseInt(po.getValueStr())); } else { map.put(po.getCollectTime(), n + Integer.parseInt(po.getValueStr())); } } } return map; }
/** * 查询统计表中时间段内的数据 * * @param appId * @param keyId * @param startDate * @param endDate * @return */ public List<KeyValuePo> findMonitorCountByDate( int appId, int keyId, Date startDate, Date endDate) { return dao.findMonitorCountByDate(appId, keyId, startDate, endDate); }
/** * * * 这是查询C应用在在某一天的所有关联key的列表,这个key列表给统计rt的时候用,这里查出c应用所有关联的key为匹配IN_HSF-ProviderDetail\\_%\\_COUNTTIMES的值 * * @param appId * @param keyId * @param date * @return * @throws Exception */ public List<KeyValuePo> findCappRtDetailByTime(Integer appId, String date) throws Exception { return dao.findCappRtDetailByTime(appId, date); }
/** * 获取应用在一天内产生的记录数量 * * @param appId * @param date * @return */ public int getDataById(int appId, String collectTime) { return dao.getDataById(appId, collectTime); }
/** * 返回keyId和keyValue的map * * @return */ public Map<Integer, String> getKeyMap() { return dao.getKeyMap(); }
public void addDayMonitorCount(int appId, int keyId, String m_data, String collectTime) { dao.addDayMonitorCount(appId, keyId, m_data, collectTime); }
public List<Integer> getAppIds(String collectTime) { return dao.getAppIds(collectTime); }
/** * @param appid * @param date * @return */ public Map<Integer, Map<Integer, KeyValueBaseLinePo>> findMonitorBaseLine( Integer appid, String date) { return dao.findMonitorBaseLine(appid, date); }
/** * 获取全部app * * @return */ public List<AppInfoPo> findAllApp() { return dao.findAllApp(); }
public KeyValuePo findKeyValueFromCountByDate(int keyId, int appid, String date) { return dao.findKeyValueFromCountByDate(keyId, appid, date); }
/** * 取得最大的一次 * * @param keyId * @param appid * @return */ public KeyValuePo findKeyValueFromCountMax(int keyId, int appid) { return dao.findKeyValueFromCountMax(keyId, appid); }
/** * 这是C应用的pv累加m_data的总值,应用包含所有key为IN_HSF-ProviderDetail开头且结尾是COUNTTIMES的 * * @param appId * @param date * @return */ public long findCappPvCountByDate(int appId, String date) { return dao.findCappPvCountByDate(appId, date); }