Example #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;
  }
Example #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);
   }
 }