示例#1
0
  private double[] getDataFromHourlyDetail(
      StateReport report, long start, int size, String key, String ip) {
    double[] result = new double[size];
    StateShow show = new StateShow(ip);
    show.visitStateReport(report);

    Map<Long, Message> messages = show.getMessagesMap();
    for (int i = 0; i < size; i++) {
      Message message = messages.get(i * 60 * 1000 + start);

      if (message != null) {
        if (key.equalsIgnoreCase("total")) {
          result[i] = message.getTotal();
        } else if (key.equalsIgnoreCase("totalLoss")) {
          result[i] = message.getTotalLoss();
        } else if (key.equalsIgnoreCase("avgTps")) {
          result[i] = message.getTotal();
        } else if (key.equalsIgnoreCase("maxTps")) {
          result[i] = message.getTotal();
        } else if (key.equalsIgnoreCase("dump")) {
          result[i] = message.getDump();
        } else if (key.equalsIgnoreCase("dumpLoss")) {
          result[i] = message.getDumpLoss();
        } else if (key.equalsIgnoreCase("pigeonTimeError")) {
          result[i] = message.getPigeonTimeError();
        } else if (key.equalsIgnoreCase("networkTimeError")) {
          result[i] = message.getNetworkTimeError();
        } else if (key.equalsIgnoreCase("blockTotal")) {
          result[i] = message.getBlockTotal();
        } else if (key.equalsIgnoreCase("blockLoss")) {
          result[i] = message.getBlockLoss();
        } else if (key.equalsIgnoreCase("blockTime")) {
          result[i] = message.getBlockTime() * 1.0 / 60 / 1000;
        } else if (key.equalsIgnoreCase("size")) {
          result[i] = message.getSize() / 1024 / 1024;
        } else if (key.equalsIgnoreCase("delayAvg")) {
          if (message.getDelayCount() > 0) {
            result[i] = message.getDelaySum() / message.getDelayCount();
          }
        }
      }
    }
    return result;
  }
示例#2
0
  private Machine buildStateInfo(Machine machine) {
    long minute = 1000 * 60;
    long start = m_startTime;
    long end = m_startTime + minute * 60;
    double maxTps = 0;
    long current = System.currentTimeMillis();
    int size = 0;

    if (end > current) {
      end = current;
    }
    for (; start < end; start += minute) {
      Statistic state = m_serverStateManager.findOrCreateState(start);
      Message temp = machine.findOrCreateMessage(start);
      Map<String, AtomicLong> totals = state.getMessageTotals();
      Map<String, AtomicLong> totalLosses = state.getMessageTotalLosses();
      Map<String, AtomicLong> sizes = state.getMessageSizes();

      for (Entry<String, AtomicLong> entry : totals.entrySet()) {
        String domain = entry.getKey();
        long value = entry.getValue().get();
        ProcessDomain processDomain = machine.findOrCreateProcessDomain(domain);
        Detail detail = processDomain.findOrCreateDetail(start);

        processDomain.setTotal(value + processDomain.getTotal());
        detail.setTotal(value + detail.getTotal());
      }
      for (Entry<String, AtomicLong> entry : totalLosses.entrySet()) {
        String domain = entry.getKey();
        long value = entry.getValue().get();
        ProcessDomain processDomain = machine.findOrCreateProcessDomain(domain);
        Detail detail = processDomain.findOrCreateDetail(start);

        processDomain.setTotalLoss(value + processDomain.getTotalLoss());
        detail.setTotalLoss(value + detail.getTotalLoss());
      }
      for (Entry<String, AtomicLong> entry : sizes.entrySet()) {
        String domain = entry.getKey();
        long value = entry.getValue().get();
        ProcessDomain processDomain = machine.findOrCreateProcessDomain(domain);
        Detail detail = processDomain.findOrCreateDetail(start);

        processDomain.setSize(value + processDomain.getSize());
        detail.setSize(value + detail.getSize());
      }

      long messageTotal = state.getMessageTotal();
      long messageTotalLoss = state.getMessageTotalLoss();
      long messageSize = state.getMessageSize();
      long blockTotal = state.getBlockTotal();
      long blockLoss = state.getBlockLoss();
      long blockTime = state.getBlockTime();
      long pigeonTimeError = state.getPigeonTimeError();
      long networkTimeError = state.getNetworkTimeError();
      long messageDump = state.getMessageDump();
      long messageDumpLoss = state.getMessageDumpLoss();
      int processDelayCount = state.getProcessDelayCount();
      double processDelaySum = state.getProcessDelaySum();

      temp.setTotal(messageTotal).setTotalLoss(messageTotalLoss).setSize(messageSize);
      temp.setBlockTotal(blockTotal).setBlockLoss(blockLoss).setBlockTime(blockTime);
      temp.setPigeonTimeError(pigeonTimeError)
          .setNetworkTimeError(networkTimeError)
          .setDump(messageDump);
      temp.setDumpLoss(messageDumpLoss)
          .setDelayCount(processDelayCount)
          .setDelaySum(processDelaySum);

      machine
          .setTotal(messageTotal + machine.getTotal())
          .setTotalLoss(messageTotalLoss + machine.getTotalLoss())
          .setSize(messageSize + machine.getSize());
      machine
          .setBlockTotal(machine.getBlockTotal() + blockTotal)
          .setBlockLoss(machine.getBlockLoss() + blockLoss)
          .setBlockTime(machine.getBlockTime() + blockTime);
      machine
          .setPigeonTimeError(machine.getPigeonTimeError() + pigeonTimeError)
          .setNetworkTimeError(machine.getNetworkTimeError() + networkTimeError)
          .setDump(machine.getDump() + messageDump);
      machine
          .setDumpLoss(machine.getDumpLoss() + messageDumpLoss)
          .setDelayCount(machine.getDelayCount() + processDelayCount)
          .setDelaySum(machine.getDelaySum() + processDelaySum);

      double avg = 0;
      long count = machine.getDelayCount();

      if (count > 0) {
        avg = machine.getDelaySum() / count;
        machine.setDelayAvg(avg);
      }
      if (messageTotal > maxTps) {
        maxTps = messageTotal;
      }
      temp.setTime(new Date(start));
      size++;
    }

    double avgTps = 0;
    if (size > 0) {
      avgTps = machine.getTotal() / (double) size;
    }
    machine.setAvgTps(avgTps);
    machine.setMaxTps(maxTps);
    return machine;
  }