예제 #1
0
  /**
   * Add <code>valueToAdd</code> metrics to the <code>avg</code> metrics object for the metric
   * <code>metric</code>
   *
   * @param metric the metric type being added
   * @param avg the average metric object that is being added to
   * @param valueToAdd the values being added to <code>avg</code> object
   */
  private void addToAvg(String metric, AvgMetric avg, HCPerfElement valueToAdd) {
    if (valueToAdd == null) return;

    BigInteger execTime = valueToAdd.getExecTime();
    BigInteger ops = valueToAdd.getOps();
    String opsPerSec = valueToAdd.getOpSec();
    if (execTime == null || ops == null || opsPerSec == null) {
      // These should never be null
      Logger.getLogger(CommandPerfStats.class.getName())
          .log(
              Level.WARNING,
              "CLI Internal Error: "
                  + metric
                  + " got unexpected null value, execTime="
                  + execTime
                  + " ops="
                  + ops);
      return;
    }

    // The underlying code on the server always does it calculations
    // using the time interval we specified.  We need the actual time
    // interval to get really accurate calculations here.  However,
    // since the design of performance needs to change (in where
    // the client should do the calculations) for now keep it simple and
    // just use the time interval we set since we know this is what
    // the master is doing for us.  This won't be accurate if 2+ users
    // are doing performance monitoring.
    String kbPerSec = valueToAdd.getKbSec();
    if (kbPerSec == null) avg.add(ops.longValue(), pollingInterval, execTime.longValue());
    else avg.add(ops.longValue(), pollingInterval, execTime.longValue(), Double.valueOf(kbPerSec));
  }