コード例 #1
0
ファイル: DisplayNames.java プロジェクト: haiyang/cat
  public DisplayNames display(
      String sorted, String type, String ip, TransactionReport report, String queryName) {
    Map<String, TransactionType> types = report.getMachines().get(ip).getTypes();
    TransactionName all = new TransactionName("TOTAL");
    all.setTotalPercent(1);
    if (types != null) {
      TransactionType names = types.get(type);

      if (names != null) {
        for (Entry<String, TransactionName> entry : names.getNames().entrySet()) {
          String transTypeName = entry.getValue().getId();
          boolean isAdd =
              (queryName == null || queryName.length() == 0 || isFit(queryName, transTypeName));
          if (isAdd) {
            m_results.add(new TransactionNameModel(entry.getKey(), entry.getValue()));
            mergeName(all, entry.getValue());
          }
        }
      }
    }
    if (sorted == null) {
      sorted = "avg";
    }
    Collections.sort(m_results, new TransactionNameComparator(sorted));

    long total = all.getTotalCount();
    for (TransactionNameModel nameModel : m_results) {
      TransactionName transactionName = nameModel.getDetail();
      transactionName.setTotalPercent(transactionName.getTotalCount() / (double) total);
    }
    m_results.add(0, new TransactionNameModel("TOTAL", all));
    return this;
  }
コード例 #2
0
ファイル: Handler.java プロジェクト: ray-dong/cat
  private TransactionName getTransactionName(Payload payload) {
    String domain = payload.getDomain();
    String type = payload.getType();
    String name = payload.getName();
    String ip = payload.getIpAddress();
    String ipAddress = payload.getIpAddress();
    String date = String.valueOf(payload.getDate());
    ModelRequest request =
        new ModelRequest(domain, payload.getPeriod()) //
            .setProperty("date", date) //
            .setProperty("type", payload.getType()) //
            .setProperty("name", payload.getName()) //
            .setProperty("ip", ipAddress);
    if (name == null || name.length() == 0) {
      request.setProperty("name", "*");
      request.setProperty("all", "true");
      name = CatString.ALL;
    }
    ModelResponse<TransactionReport> response = m_service.invoke(request);
    TransactionReport report = response.getModel();

    report = m_mergeManager.mergerAll(report, ipAddress, name);
    TransactionType t = report.getMachines().get(ip).findType(type);
    if (t != null) {
      TransactionName n = t.findName(name);
      if (n != null) {
        n.accept(m_computer);
      }
      return n;
    } else {
      return null;
    }
  }
コード例 #3
0
ファイル: Handler.java プロジェクト: LyneLiu/cat
  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);
    }
  }
コード例 #4
0
ファイル: Handler.java プロジェクト: ray-dong/cat
 private void calculateTps(Payload payload, TransactionReport report) {
   try {
     if (payload != null && report != null) {
       boolean isCurrent = payload.getPeriod().isCurrent();
       String ip = payload.getIpAddress();
       Machine machine = report.getMachines().get(ip);
       if (machine == null) {
         return;
       }
       for (TransactionType transType : machine.getTypes().values()) {
         long totalCount = transType.getTotalCount();
         double tps = 0;
         if (isCurrent) {
           double seconds =
               (System.currentTimeMillis() - payload.getCurrentDate()) / (double) 1000;
           tps = totalCount / seconds;
         } else {
           double time =
               (report.getEndTime().getTime() - report.getStartTime().getTime()) / (double) 1000;
           tps = totalCount / (double) time;
         }
         transType.setTps(tps);
         for (TransactionName transName : transType.getNames().values()) {
           long totalNameCount = transName.getTotalCount();
           double nameTps = 0;
           if (isCurrent) {
             double seconds =
                 (System.currentTimeMillis() - payload.getCurrentDate()) / (double) 1000;
             nameTps = totalNameCount / seconds;
           } else {
             double time =
                 (report.getEndTime().getTime() - report.getStartTime().getTime()) / (double) 1000;
             nameTps = totalNameCount / (double) time;
           }
           transName.setTps(nameTps);
           transName.setTotalPercent((double) totalNameCount / totalCount);
         }
       }
     }
   } catch (Exception e) {
     Cat.logError(e);
   }
 }
コード例 #5
0
ファイル: UrlTransactionBugTest.java プロジェクト: Shacho/cat
 @Override
 public void visitType(TransactionType type) {
   if ("URL".equals(type.getId())) {
     super.visitType(type);
   }
 }
コード例 #6
0
  @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);
  }