bharathv commented on a change in pull request #3018:
URL: https://github.com/apache/hbase/pull/3018#discussion_r594503325



##########
File path: 
hbase-hadoop-compat/src/main/java/org/apache/hadoop/metrics2/lib/DynamicMetricsRegistry.java
##########
@@ -452,6 +450,41 @@ public MutableGaugeLong getGauge(String gaugeName, long 
potentialStartingValue)
     return (MutableGaugeLong) metric;
   }
 
+  /**
+   * Get a MetricMutableGaugeInt from the storage.  If it is not there 
atomically put it.
+   *
+   * @param gaugeName              name of the gauge to create or get.
+   * @param potentialStartingValue value of the new gauge if we have to create 
it.
+   */
+  public MutableGaugeInt getGaugeInt(String gaugeName, int 
potentialStartingValue) {
+    //Try and get the guage.
+    MutableMetric metric = metricsMap.get(gaugeName);
+
+    //If it's not there then try and put a new one in the storage.
+    if (metric == null) {
+
+      //Create the potential new gauge.
+      MutableGaugeInt newGauge = new MutableGaugeInt(new 
MetricsInfoImpl(gaugeName, ""),
+        potentialStartingValue);
+
+      // Try and put the gauge in.  This is atomic.
+      metric = metricsMap.putIfAbsent(gaugeName, newGauge);
+
+      //If the value we get back is null then the put was successful and we 
will return that.
+      //otherwise gaugeLong should contain the thing that was in before the 
put could be completed.

Review comment:
       s/gaugeLong/gaugeInt -> copy-paste error.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to