use of com.sohu.tv.jedis.stat.model.ClientReportBean in project cachecloud by sohutv.
the class ClientDataCollectReportExecutor method collectReportAllData.
/**
* 收集上报数据
* @param currentMinuteStamp
*/
private void collectReportAllData(String currentMinuteStamp) {
//1. 获取上一分钟的所有数据
String lastMinute = getLastMinute(currentMinuteStamp);
if (lastMinute == null || "".equals(lastMinute.trim())) {
return;
}
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
list.addAll(collectReportCostTimeData(lastMinute));
list.addAll(collectReportValueDistriData(lastMinute));
list.addAll(collectReportExceptionData(lastMinute));
//上报统计数据,观察是否存在内存泄露的情况
Map<String, Object> otherInfo = new HashMap<String, Object>(4, 1);
otherInfo.put(ClientReportConstant.COST_MAP_SIZE, UsefulDataCollector.getDataCostTimeMapAll().size());
otherInfo.put(ClientReportConstant.VALUE_MAP_SIZE, UsefulDataCollector.getDataValueLengthDistributeMapAll().size());
otherInfo.put(ClientReportConstant.EXCEPTION_MAP_SIZE, UsefulDataCollector.getDataExceptionMapAll().size());
otherInfo.put(ClientReportConstant.COLLECTION_MAP_SIZE, UsefulDataCollector.getCollectionCostTimeMapAll().size());
//2. 上报数据
if (!list.isEmpty()) {
ClientReportBean ccReportBean = new ClientReportBean(clientIp, NumberUtil.toLong(lastMinute), System.currentTimeMillis(), list, otherInfo);
ClientReportDataCenter.reportData(ccReportBean);
}
}
use of com.sohu.tv.jedis.stat.model.ClientReportBean in project cachecloud by sohutv.
the class RedisClientReportDataController method reportData.
/**
* 上报客户端上传数据
*
* @param appId
* @param model
*/
@RequestMapping(value = "/reportData.json", method = RequestMethod.POST)
public void reportData(HttpServletRequest request, HttpServletResponse response, Model model) {
// 1. 验证版本的正确性
String clientVersion = request.getParameter(ClientReportConstant.CLIENT_VERSION);
if (!checkClientVersion(clientVersion)) {
return;
}
// 2. 验证json的正确性
String json = request.getParameter(ClientReportConstant.JSON_PARAM);
ClientReportBean clientReportBean = checkReportJson(json);
if (clientReportBean == null) {
logger.error("reportWrong json: {}", json);
return;
}
// 3.使用访问web的ip作为客户端最终的ip
String clientIp = IpUtil.getIpAddr(request);
if (StringUtils.isNotBlank(clientIp)) {
clientReportBean.setClientIp(clientIp);
}
// 4. 根据类型处理数据
boolean result = clientReportDataService.deal(clientReportBean);
if (!result) {
logger.error("ClientReportDataService deal fail, clientReportBean is {}", clientReportBean);
}
}
Aggregations