public static AtomicInteger getOrCreateGauge(String name) {
    // We return a garbage value if metrics haven't been initialized so that callers don't have
    // to keep checking if the resulting value is null.
    if (self == null) return singletonAtomicInteger;
    AtomicInteger ai = self.gaugeAtomics.get(name);
    if (ai != null) return ai;
    synchronized (Metrics.class) {
      ai = self.gaugeAtomics.get(name);
      if (ai != null) return ai;
      ai = new AtomicInteger();
      final AtomicInteger forGauge = ai;
      self.gaugeAtomics.put(name, ai);
      self.registry.register(name, new Gauge<Integer>() {
        @Override
        public Integer getValue() {
          return forGauge.get();
        }
      });
      return ai;
    }
  }
Get the AtomicInteger behind an existing gauge, or create a new gauge if it does not already
exist.
@param name Name of gauge.  This should come from MetricConstants
@return AtomicInteger underlying this gauge.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/Metrics.java