private void processVersion2(Payload payload, HttpServletRequest request, String userIp) { String content = payload.getContent(); String records[] = content.split("\n"); IpInfo ipInfo = m_ipService.findIpInfoByString(userIp); if (ipInfo != null) { String province = ipInfo.getProvince(); String operatorStr = ipInfo.getChannel(); Integer cityId = m_appConfigManager.getCities().get(province); Integer operatorId = m_appConfigManager.getOperators().get(operatorStr); if (cityId != null && operatorId != null) { for (String record : records) { try { if (!StringUtils.isEmpty(record)) { processOneRecord(cityId, operatorId, record); } } catch (Exception e) { Cat.logError(e); } } } else { Cat.logEvent("Unknown", province + ":" + operatorStr, Event.SUCCESS, null); } } }
private void processVersion1(Payload payload, HttpServletRequest request, String userIp) { try { String content = payload.getContent(); String[] lines = content.split("\n"); long time = System.currentTimeMillis(); for (String line : lines) { String[] tabs = line.split("\t"); // timstampTABtargetUrlTABdurationTABhttpCodeTABerrorCodeENTER if (tabs.length == 5 && validate(tabs[3], tabs[4])) { MonitorEntity entity = new MonitorEntity(); String httpStatus = tabs[3]; String errorCode = tabs[4]; if (StringUtils.isEmpty(errorCode)) { errorCode = Constrants.NOT_SET; } if (StringUtils.isEmpty(httpStatus)) { httpStatus = Constrants.NOT_SET; } // entity.setTimestamp(Long.parseLong(tabs[0])); entity.setTimestamp(time); entity.setTargetUrl(tabs[1]); entity.setDuration(Double.parseDouble(tabs[2])); entity.setHttpStatus(httpStatus); entity.setErrorCode(errorCode); entity.setIp(userIp); if ("200".equals(httpStatus)) { entity.setCount(10); } else { entity.setCount(1); } m_manager.offer(entity); } } } catch (Exception e) { m_logger.error(e.getMessage(), e); } }