public void handleOutbound(Context ctx) throws ServletException, IOException {
Model model = new Model(ctx);
Payload payload = ctx.getPayload();
normalize(model, payload);
ProblemReport report = null;
ProblemStatistics problemStatistics = new ProblemStatistics();
String ip = model.getIpAddress();
LongConfig longConfig = new LongConfig();
Action action = payload.getAction();
String domain = payload.getDomain();
String group = payload.getGroup();
longConfig.setSqlThreshold(payload.getSqlThreshold()).setUrlThreshold(payload.getUrlThreshold())
.setServiceThreshold(payload.getServiceThreshold());
longConfig.setCacheThreshold(payload.getCacheThreshold()).setCallThreshold(payload.getCallThreshold());
problemStatistics.setLongConfig(longConfig);
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 HOULY_REPORT:
report = getHourlyReport(payload, VIEW);
model.setReport(report);
if (ip.equals(Constants.ALL)) {
problemStatistics.setAllIp(true);
} else {
problemStatistics.setIp(ip);
}
problemStatistics.visitProblemReport(report);
model.setAllStatistics(problemStatistics);
break;
case HISTORY_REPORT:
report = showSummarizeReport(model, payload);
if (ip.equals(Constants.ALL)) {
problemStatistics.setAllIp(true);
problemStatistics.visitProblemReport(report);
} else {
problemStatistics.setIp(ip);
problemStatistics.visitProblemReport(report);
}
model.setReport(report);
model.setAllStatistics(problemStatistics);
break;
case HISTORY_GRAPH:
m_historyGraphs.buildTrendGraph(model, payload);
report = showSummarizeReport(model, payload);
buildDistributionChart(model, payload, report);
break;
case GROUP:
report = showHourlyReport(model, payload);
if (report != null) {
model.setGroupLevelInfo(new GroupLevelInfo(model).display(report));
}
break;
case HOUR_GRAPH:
report = getHourlyReport(payload, DETAIL);
String type = payload.getType();
String state = payload.getStatus();
Date start = report.getStartTime();
HourlyLineChartVisitor vistor = new HourlyLineChartVisitor(ip, type, state, start);
vistor.visitProblemReport(report);
model.setErrorsTrend(m_jsonBuilder.toJson(vistor.getGraphItem()));
buildDistributionChart(model, payload, report);
break;
case HOURLY_GROUP_REPORT:
report = getHourlyReport(payload, VIEW);
report = filterReportByGroup(report, domain, group);
model.setReport(report);
if (ip.equals(Constants.ALL)) {
problemStatistics.setAllIp(true);
} else {
problemStatistics.setIp(ip);
}
problemStatistics.visitProblemReport(report);
model.setAllStatistics(problemStatistics);
break;
case GROUP_GRAPHS:
report = getHourlyReport(payload, DETAIL);
report = filterReportByGroup(report, domain, group);
type = payload.getType();
state = payload.getStatus();
start = report.getStartTime();
vistor = new HourlyLineChartVisitor("", type, state, start);
vistor.visitProblemReport(report);
model.setErrorsTrend(m_jsonBuilder.toJson(vistor.getGraphItem()));
buildDistributionChart(model, payload, report);
break;