@Override @OutboundActionMeta(name = "batch") public void handleOutbound(Context ctx) throws ServletException, IOException { Payload payload = ctx.getPayload(); HttpServletRequest request = ctx.getHttpServletRequest(); HttpServletResponse response = ctx.getHttpServletResponse(); String userIp = m_util.getRemoteIp(request); String version = payload.getVersion(); boolean success = true; if (userIp != null) { if ("1".equals(version)) { processVersion1(payload, request, userIp); } else if ("2".equals(version)) { processVersion2(payload, request, userIp); } else { success = false; Cat.logEvent("InvalidVersion", version, Event.SUCCESS, version); } } else { success = false; Cat.logEvent("unknownIp", "batch", Event.SUCCESS, null); m_logger.info( "unknown http request, x-forwarded-for:" + request.getHeader("x-forwarded-for")); } if (success) { response.getWriter().write("OK"); } else { response.getWriter().write("validate request!"); } }
@Override @OutboundActionMeta(name = "t") public void handleOutbound(Context ctx) throws ServletException, IOException { Model model = new Model(ctx); Payload payload = ctx.getPayload(); normalize(model, payload); String type = payload.getType(); switch (payload.getAction()) { case HOURLY_REPORT: showHourlyReport(model, payload); DisplayNames displayNameReport = model.getDisplayNameReport(); if ((!StringUtils.isEmpty(type)) && displayNameReport != null) { buildTransactionNameGraph(displayNameReport.getResults(), model); } break; case HISTORY_REPORT: showSummarizeReport(model, payload); displayNameReport = model.getDisplayNameReport(); if ((!StringUtils.isEmpty(type)) && displayNameReport != null) { buildTransactionNameGraph(displayNameReport.getResults(), model); } break; case HISTORY_GRAPH: m_historyGraph.buildTrendGraph(model, payload); break; case GRAPHS: showHourlyGraphs(model, payload); break; case MOBILE: showHourlyReport(model, payload); if (!StringUtils.isEmpty(payload.getType())) { DisplayNames report = model.getDisplayNameReport(); String json = m_gson.toJson(report); model.setMobileResponse(json); } else { DisplayTypes report = model.getDisplayTypeReport(); String json = m_gson.toJson(report); model.setMobileResponse(json); } break; case MOBILE_GRAPHS: MobileGraphs graphs = showMobileGraphs(model, payload); if (graphs != null) { model.setMobileResponse(m_gson.toJson(graphs)); } break; } if (payload.isXml()) { m_xmlViewer.view(ctx, model); } else { m_jspViewer.view(ctx, model); } }
@Override @OutboundActionMeta(name = "alarm") public void handleOutbound(Context ctx) throws ServletException, IOException { Model model = new Model(ctx); Payload payload = ctx.getPayload(); Action action = payload.getAction(); int userId = getLoginUserId(ctx); boolean result = false; switch (action) { case ALARM_RECORD_LIST: m_recordManager.queryUserAlarmRecords(model, userId); break; case ALARM_RULE_ADD: m_ruleManager.ruleAdd(payload, model); break; case ALARM_RULE_ADD_SUBMIT: m_ruleManager.ruleAddSubmit(payload, model); break; case ALARM_RULE_UPDATE: m_ruleManager.ruleUpdate(payload, model); break; case ALARM_RULE_UPDATE_SUBMIT: m_ruleManager.ruleUpdateSubmit(payload, model); break; case EXCEPTION_ALARM_RULE_DELETE: m_ruleManager.ruleDelete(payload); m_ruleManager.queryExceptionRuleList(model, userId); break; case EXCEPTION_ALARM_RULE_SUB: result = m_ruleManager.ruleSub(payload, userId); if (result) { model.setOpState(SUCCESS); } else { model.setOpState(FAIL); } break; case EXCEPTION_ALARM_RULE_LIST: m_ruleManager.queryExceptionRuleList(model, userId); break; case ALARM_TEMPLATE_LIST: m_templateManager.queryTemplateByName(payload, model); break; case ALARM_TEMPLATE_ADD: break; case ALARM_TEMPLATE_ADD_SUBMIT: m_templateManager.templateAddSubmit(payload, model); break; case ALARM_TEMPLATE_DELETE: break; case ALARM_TEMPLATE_UPDATE: m_templateManager.templateUpdate(payload, model); break; case ALARM_TEMPLATE_UPDATE_SUBMIT: m_templateManager.templateUpdateSubmit(payload, model); break; case SERVICE_ALARM_RULE_DELETE: m_ruleManager.ruleDelete(payload); m_ruleManager.queryServiceRuleList(model, userId); break; case SERVICE_ALARM_RULE_LIST: m_ruleManager.queryServiceRuleList(model, userId); break; case SERVICE_ALARM_RULE_SUB: result = m_ruleManager.ruleSub(payload, userId); if (result) { model.setOpState(SUCCESS); } else { model.setOpState(FAIL); } break; case ALARM_RECORD_DETAIL: m_recordManager.queryAlarmRecordDetail(payload, model); break; case SCHEDULED_REPORT_ADD: m_scheduledManager.scheduledReportAdd(payload, model); break; case SCHEDULED_REPORT_ADD_SUBMIT: m_scheduledManager.scheduledReportAddSubmit(payload, model); break; case SCHEDULED_REPORT_DELETE: m_scheduledManager.scheduledReportDelete(payload); m_scheduledManager.queryScheduledReports(model, userId); break; case SCHEDULED_REPORT_LIST: m_scheduledManager.queryScheduledReports(model, userId); break; case SCHEDULED_REPORT_UPDATE: m_scheduledManager.scheduledReportUpdate(payload, model); break; case SCHEDULED_REPORT_UPDATE_SUBMIT: m_scheduledManager.scheduledReportUpdateSubmit(payload, model); break; case SCHEDULED_REPORT_SUB: result = m_scheduledManager.scheduledReportSub(payload, userId); if (result) { model.setOpState(SUCCESS); } else { model.setOpState(FAIL); } break; case REPORT_RECORD_LIST: m_recordManager.queryUserReportRecords(model, userId); break; } model.setAction(payload.getAction()); model.setPage(SystemPage.ALARM); m_jspViewer.view(ctx, model); }
@Override @PreInboundActionMeta("login") @OutboundActionMeta(name = "config") public void handleOutbound(Context ctx) throws ServletException, IOException { Model model = new Model(ctx); Payload payload = ctx.getPayload(); model.setPage(SystemPage.CONFIG); Action action = payload.getAction(); storeModifyInfo(ctx, payload); model.setAction(action); switch (action) { case PROJECT_ALL: case PROJECT_UPDATE_SUBMIT: case PROJECT_DELETE: case DOMAIN_GROUP_CONFIGS: case DOMAIN_GROUP_CONFIG_UPDATE: case DOMAIN_GROUP_CONFIG_DELETE: case DOMAIN_GROUP_CONFIG_SUBMIT: case BUG_CONFIG_UPDATE: case ROUTER_CONFIG_UPDATE: case ALERT_SENDER_CONFIG_UPDATE: case BLACK_CONFIG_UPDATE: case STORAGE_GROUP_CONFIG_UPDATE: case SERVER_FILTER_CONFIG_UPDATE: case ALL_REPORT_CONFIG: m_globalConfigProcessor.process(action, payload, model); break; case THIRD_PARTY_RULE_CONFIGS: case THIRD_PARTY_RULE_UPDATE: case THIRD_PARTY_RULE_SUBMIT: case THIRD_PARTY_RULE_DELETE: m_thirdPartyConfigProcessor.process(action, payload, model); break; case AGGREGATION_ALL: case AGGREGATION_UPDATE: case AGGREGATION_UPDATE_SUBMIT: case AGGREGATION_DELETE: case URL_PATTERN_CONFIG_UPDATE: case URL_PATTERN_ALL: case URL_PATTERN_UPDATE: case URL_PATTERN_UPDATE_SUBMIT: case URL_PATTERN_DELETE: case WEB_RULE: case WEB_RULE_ADD_OR_UPDATE: case WEB_RULE_ADD_OR_UPDATE_SUBMIT: case WEB_RULE_DELETE: m_patternConfigProcessor.processPatternConfig(action, payload, model); break; case TOPOLOGY_GRAPH_NODE_CONFIG_LIST: case TOPOLOGY_GRAPH_NODE_CONFIG_ADD_OR_UPDATE: case TOPOLOGY_GRAPH_NODE_CONFIG_ADD_OR_UPDATE_SUBMIT: case TOPOLOGY_GRAPH_NODE_CONFIG_DELETE: case TOPOLOGY_GRAPH_EDGE_CONFIG_LIST: case TOPOLOGY_GRAPH_EDGE_CONFIG_ADD_OR_UPDATE: case TOPOLOGY_GRAPH_EDGE_CONFIG_ADD_OR_UPDATE_SUBMIT: case TOPOLOGY_GRAPH_EDGE_CONFIG_DELETE: case TOPOLOGY_GRAPH_PRODUCT_LINE: case TOPOLOGY_GRAPH_PRODUCT_LINE_ADD_OR_UPDATE: case TOPOLOGY_GRAPH_PRODUCT_LINE_DELETE: case TOPOLOGY_GRAPH_PRODUCT_LINE_ADD_OR_UPDATE_SUBMIT: case TOPO_GRAPH_FORMAT_CONFIG_UPDATE: m_topologyConfigProcessor.process(action, payload, model); break; case METRIC_CONFIG_ADD_OR_UPDATE: case METRIC_CONFIG_ADD_OR_UPDATE_SUBMIT: case METRIC_RULE_ADD_OR_UPDATE: case METRIC_RULE_ADD_OR_UPDATE_SUBMIT: case METRIC_CONFIG_LIST: case METRIC_CONFIG_DELETE: case METRIC_CONFIG_BATCH_DELETE: case METRIC_RULE_CONFIG_UPDATE: m_metricConfigProcessor.process(action, payload, model); break; case EXCEPTION: case EXCEPTION_THRESHOLD_DELETE: case EXCEPTION_THRESHOLD_UPDATE: case EXCEPTION_THRESHOLD_ADD: case EXCEPTION_THRESHOLD_UPDATE_SUBMIT: case EXCEPTION_EXCLUDE_DELETE: case EXCEPTION_EXCLUDE_ADD: case EXCEPTION_EXCLUDE_UPDATE_SUBMIT: m_exceptionConfigProcessor.process(action, payload, model); break; case NETWORK_RULE_CONFIG_LIST: case NETWORK_RULE_ADD_OR_UPDATE: case NETWORK_RULE_ADD_OR_UPDATE_SUBMIT: case NETWORK_RULE_DELETE: case NET_GRAPH_CONFIG_UPDATE: m_networkConfigProcessor.process(action, payload, model); break; case DATABASE_RULE_CONFIG_LIST: case DATABASE_RULE_ADD_OR_UPDATE: case DATABASE_RULE_ADD_OR_UPDATE_SUBMIT: case DATABASE_RULE_DELETE: m_databaseConfigProcessor.process(action, payload, model); break; case SYSTEM_RULE_CONFIG_LIST: case SYSTEM_RULE_ADD_OR_UPDATE: case SYSTEM_RULE_ADD_OR_UPDATE_SUBMIT: case SYSTEM_RULE_DELETE: m_systemConfigProcessor.process(action, payload, model); break; case HEARTBEAT_RULE_CONFIG_LIST: case HEARTBEAT_RULE_ADD_OR_UPDATE: case HEARTBEAT_RULE_ADD_OR_UPDATE_SUBMIT: case HEARTBEAT_RULE_DELETE: m_heartbeatConfigProcessor.process(action, payload, model); break; case STORAGE_RULE: case STORAGE_RULE_ADD_OR_UPDATE: case STORAGE_RULE_ADD_OR_UPDATE_SUBMIT: case STORAGE_RULE_DELETE: m_storageConfigProcessor.process(action, payload, model); break; case APP_NAME_CHECK: case APP_LIST: case APP_COMMMAND_UPDATE: case APP_COMMAND_SUBMIT: case APP_COMMAND_DELETE: case APP_CODE_UPDATE: case APP_CODE_SUBMIT: case APP_CODE_ADD: case APP_CODE_DELETE: case APP_SPEED_UPDATE: case APP_SPEED_ADD: case APP_SPEED_DELETE: case APP_SPEED_SUBMIT: case APP_CONFIG_UPDATE: case APP_RULE: case APP_RULE_ADD_OR_UPDATE: case APP_RULE_ADD_OR_UPDATE_SUBMIT: case APP_RULE_DELETE: case APP_COMPARISON_CONFIG_UPDATE: case APP_RULE_BATCH_UPDATE: case APP_CONSTANT_ADD: case APP_CONSTANT_UPDATE: case APP_CONSTATN_DELETE: case APP_CONSTATN_SUBMIT: case APP_COMMAND_FORMAT_CONFIG: m_appConfigProcessor.process(action, payload, model); break; case TRANSACTION_RULE: case TRANSACTION_RULE_ADD_OR_UPDATE: case TRANSACTION_RULE_ADD_OR_UPDATE_SUBMIT: case TRANSACTION_RULE_DELETE: m_transactionConfigProcessor.process(action, payload, model); break; case EVENT_RULE: case EVENT_RULE_ADD_OR_UPDATE: case EVENT_RULE_ADD_OR_UPDATE_SUBMIT: case EVENT_RULE_DELETE: m_eventConfigProcessor.process(action, payload, model); break; case ALERT_DEFAULT_RECEIVERS: case ALERT_POLICY: m_alertConfigProcessor.process(action, payload, model); break; case DISPLAY_POLICY: case ACTIVITY_CONFIG_UPDATE: m_displayConfigProfessor.process(action, payload, model); break; } m_jspViewer.view(ctx, model); }
@Override @OutboundActionMeta(name = "t") public void handleOutbound(Context ctx) throws ServletException, IOException { Model model = new Model(ctx); Payload payload = ctx.getPayload(); normalize(model, payload); String domain = payload.getDomain(); Action action = payload.getAction(); String ipAddress = payload.getIpAddress(); String group = payload.getGroup(); String type = payload.getType(); String name = payload.getName(); String ip = payload.getIpAddress(); if (StringUtils.isEmpty(group)) { group = m_configManager.queryDefaultGroup(domain); payload.setGroup(group); } model.setGroupIps(m_configManager.queryIpByDomainAndGroup(domain, group)); model.setGroups(m_configManager.queryDomainGroup(payload.getDomain())); switch (action) { case HOURLY_REPORT: TransactionReport report = getHourlyReport(payload); report = m_mergeManager.mergerAllIp(report, ipAddress); calculateTps(payload, report); if (report != null) { model.setReport(report); buildTransactionMetaInfo(model, payload, report); } break; case HISTORY_REPORT: report = m_reportService.queryTransactionReport( domain, payload.getHistoryStartDate(), payload.getHistoryEndDate()); calculateTps(payload, report); if (report != null) { model.setReport(report); buildTransactionMetaInfo(model, payload, report); } break; case HISTORY_GRAPH: m_historyGraph.buildTrendGraph(model, payload); break; case GRAPHS: report = getTransactionGraphReport(model, payload); if (name == null || name.length() == 0) { name = Constants.ALL; } report = m_mergeManager.mergerAllName(report, ip, name); model.setReport(report); buildTransactionNameGraph(model, report, type, name, ip); break; case HOURLY_GROUP_REPORT: report = getHourlyReport(payload); report = filterReportByGroup(report, domain, group); report = m_mergeManager.mergerAllIp(report, ipAddress); calculateTps(payload, report); if (report != null) { model.setReport(report); buildTransactionMetaInfo(model, payload, report); } break; case HISTORY_GROUP_REPORT: report = m_reportService.queryTransactionReport( domain, payload.getHistoryStartDate(), payload.getHistoryEndDate()); calculateTps(payload, report); report = filterReportByGroup(report, domain, group); report = m_mergeManager.mergerAllIp(report, ipAddress); if (report != null) { model.setReport(report); buildTransactionMetaInfo(model, payload, report); } break; case GROUP_GRAPHS: report = getTransactionGraphReport(model, payload); report = filterReportByGroup(report, domain, group); if (name == null || name.length() == 0) { name = Constants.ALL; } report = m_mergeManager.mergerAllName(report, ip, name); model.setReport(report); buildTransactionNameGraph(model, report, type, name, ip); break; case HISTORY_GROUP_GRAPH: List<String> ips = m_configManager.queryIpByDomainAndGroup(domain, group); m_historyGraph.buildGroupTrendGraph(model, payload, ips); break; } if (payload.isXml()) { m_xmlViewer.view(ctx, model); } else { m_jspViewer.view(ctx, model); } }