Exemplo n.º 1
0
  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;
  }
Exemplo n.º 2
0
 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);
   }
 }