klcopp commented on a change in pull request #3032:
URL: https://github.com/apache/hive/pull/3032#discussion_r808886769



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/Metrics.java
##########
@@ -160,6 +159,47 @@ public Integer getValue() {
     }
   }
 
+  /**
+   * Get a Map that represents a multi-field metric,
+   * or create a new one if it does not already exist.
+   * @param name Name of map metric.  This should come from MetricConstants
+   * @return MapMetric .
+   */
+  public static MapMetrics getOrCreateMapMetrics(String name) {
+    if (self == null) {
+      return dummyMapMetrics;
+    }
+
+    Map<String, Metric> metrics = self.registry.getMetrics();
+    Metric map = metrics.get(name);
+    if (map instanceof MapMetrics) {

Review comment:
       Might need a null check here as well

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/Metrics.java
##########
@@ -160,6 +159,47 @@ public Integer getValue() {
     }
   }
 
+  /**
+   * Get a Map that represents a multi-field metric,
+   * or create a new one if it does not already exist.
+   * @param name Name of map metric.  This should come from MetricConstants
+   * @return MapMetric .
+   */
+  public static MapMetrics getOrCreateMapMetrics(String name) {
+    if (self == null) {
+      return dummyMapMetrics;
+    }
+
+    Map<String, Metric> metrics = self.registry.getMetrics();
+    Metric map = metrics.get(name);
+    if (map instanceof MapMetrics) {
+      return (MapMetrics) map;
+    }
+
+    // Looks like it doesn't exist.  Lock so that two threads don't create it 
at once.
+    synchronized (Metrics.class) {
+      // Recheck to make sure someone didn't create it while we waited.

Review comment:
       The recheck is missing. To follow the pattern of the other metrics, this 
block should look like:
   
   ```
   metrics = self.registry.getMetrics();
         map = metrics.get(name);
         if (map != null && map instanceof MapMetrics) {
           return (MapMetrics) map;
         }
   // then register the metric and return it
   ```

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/AcidMetricService.java
##########
@@ -93,12 +93,9 @@
 public class AcidMetricService implements MetastoreTaskThread {
 
   private static final Logger LOG = 
LoggerFactory.getLogger(AcidMetricService.class);
-  public static final String OBJECT_NAME_PREFIX = 
"metrics:type=compaction,name=";

Review comment:
       Is this prefix omitted completely? If left out, it might introduce some 
backwards incompatibility

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/JsonReporter.java
##########
@@ -160,7 +158,7 @@ public void report(SortedMap<String, Gauge> sortedMap, 
SortedMap<String, Counter
       try (BufferedWriter bw = Files.newBufferedWriter(tmpFile, 
StandardCharsets.UTF_8)) {
         bw.write(json);
       } catch (IOException e) {
-        LOG.error("Unable to write to temp file {}" + tmpFile, e);
+        LOG.error("Unable to write to temp file {}", tmpFile, e);

Review comment:
       Nit: if you want to do a good deed:  `e` needs its own `{}`




-- 
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.

To unsubscribe, e-mail: [email protected]

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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to