Exemplo n.º 1
0
  private TransactionReport filterReportByGroup(
      TransactionReport report, String domain, String group) {
    List<String> ips = m_configManager.queryIpByDomainAndGroup(domain, group);
    List<String> removes = new ArrayList<String>();

    for (Machine machine : report.getMachines().values()) {
      String ip = machine.getIp();

      if (!ips.contains(ip)) {
        removes.add(ip);
      }
    }
    for (String ip : removes) {
      report.getMachines().remove(ip);
    }
    return report;
  }
Exemplo n.º 2
0
  @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);
    }
  }