Beispiel #1
0
  private void buildTransactionNameGraph(
      Model model, TransactionReport report, String type, String name, String ip) {
    TransactionType t = report.findOrCreateMachine(ip).findOrCreateType(type);
    TransactionName transactionName = t.findOrCreateName(name);
    transformTo60MinuteData(transactionName);

    if (transactionName != null) {
      String graph1 =
          m_builder.build(
              new DurationPayload(
                  "Duration Distribution", "Duration (ms)", "Count", transactionName));
      String graph2 =
          m_builder.build(new HitPayload("Hits Over Time", "Time (min)", "Count", transactionName));
      String graph3 =
          m_builder.build(
              new AverageTimePayload(
                  "Average Duration Over Time",
                  "Time (min)",
                  "Average Duration (ms)",
                  transactionName));
      String graph4 =
          m_builder.build(
              new FailurePayload("Failures Over Time", "Time (min)", "Count", transactionName));

      model.setGraph1(graph1);
      model.setGraph2(graph2);
      model.setGraph3(graph3);
      model.setGraph4(graph4);
    }
  }
  @Override
  public void visitType(TransactionType type) {
    if ("URL".equals(type.getId())) {
      Map<String, TransactionName> transactionNames = type.getNames();

      Set<String> names = transactionNames.keySet();
      Set<String> invalidates = new HashSet<String>();

      for (String temp : names) {
        int length = temp.length();

        for (int i = 0; i < length; i++) {
          // invalidate char
          if (temp.charAt(i) > 126 || temp.charAt(i) < 33) {
            invalidates.add(temp);
            continue;
          }
        }
      }

      for (String name : invalidates) {
        transactionNames.remove(name);
      }

      int size = transactionNames.size();

      if (size > m_maxItems) {
        List<TransactionName> all = new ArrayList<TransactionName>(transactionNames.values());

        Collections.sort(all, new TransactionNameCompator());
        type.getNames().clear();

        for (int i = 0; i < m_maxItems; i++) {
          type.addName(all.get(i));
        }

        TransactionName other = type.findOrCreateName("OTHERS");
        for (int i = m_maxItems; i < size; i++) {
          mergeName(other, all.get(i));
        }
      }

      List<String> toRemove = new ArrayList<String>();
      TransactionName other = type.findOrCreateName("OTHERS");

      transactionNames = type.getNames();
      names = transactionNames.keySet();
      for (String temp : names) {
        TransactionName tansactionName = transactionNames.get(temp);

        if (tansactionName.getTotalCount() == 1) {
          toRemove.add(temp);
          mergeName(other, tansactionName);
        }
      }

      for (String temp : toRemove) {
        transactionNames.remove(temp);
      }
    }
    super.visitType(type);
  }