@SuppressWarnings("unchecked")
  private <T> T returnExistingWithCast(MutableMetric metric, Class<T> metricClass, String name) {
    if (!metricClass.isAssignableFrom(metric.getClass())) {
      throw new MetricsException("Metric already exists in registry for metric name: " + name
        + " and not of type " + metricClass + " but instead of type " + metric.getClass());
    }

    return (T) metric;
  }
Get a MetricMutableCounterLong from the storage. If it is not there atomically put it.
@param counterName            Name of the counter to get
@param potentialStartingValue starting value if we have to create a new counter
hbase-hadoop-compat/src/main/java/org/apache/hadoop/metrics2/lib/DynamicMetricsRegistry.java