@Override
    public String toString() {
      long avgRead     = 0L;
      long avgWrite    = 0L;
      long totalMillis = 0L;

      if (0 < readLockCounts.value()) {
        avgRead = readLockWaitTimeTotal.value() / readLockCounts.value();
      }

      if (0 < writeLockCounts.value()) {
        avgWrite = writeLockWaitTimeTotal.value() / writeLockCounts.value();
      }

      totalMillis = (readLockWaitTimeTotal.value() / 1000000L)
                    + (writeLockWaitTimeTotal.value() / 1000000L);

      StringBuffer sb = new StringBuffer();
      sb.append("{ \"type\" : \"R/W Lock Stats\", \"label\" : \"");
      sb.append(lockLabel);
      sb.append("\", \"totalLockWaitTimeMillis\" : ");
      sb.append(totalMillis);
      sb.append(", \"readLock\" : { \"count\" : ");
      sb.append(readLockCounts.value());
      sb.append(", \"avgWaitTimeNanos\" : ");
      sb.append(avgRead);
      sb.append(", \"maxWaitTimeNanos\" : ");
      sb.append(readLockWaitTimeMax.value());
      sb.append(" }, \"writeLock\" : { \"count\" : ");
      sb.append(writeLockCounts.value());
      sb.append(", \"avgWaitTimeNanos\" : ");
      sb.append(avgWrite);
      sb.append(", \"maxWaitTimeNanos\" : ");
      sb.append(writeLockWaitTimeMax.value());
      sb.append(" } }");

      return sb.toString();
    }
Creates a new metrics collection instance.
Several locks can share a single <code>MetricsSource</code> instances
where all of them  increment the metrics counts together. This can be
interesting to have a single instance for a group of related locks. The
group should then be identified by the label.

@param label The identifier of the metrics collection
llap-common/src/java/org/apache/hadoop/hive/llap/metrics/ReadWriteLockMetrics.java