stoty commented on code in PR #1431:
URL: https://github.com/apache/phoenix/pull/1431#discussion_r861979379


##########
phoenix-core/src/main/java/org/apache/phoenix/monitoring/MetricUtil.java:
##########
@@ -38,4 +46,22 @@ public static MetricsStopWatch getMetricsStopWatch(boolean 
isRequestMetricsEnabl
         return new MetricsStopWatch(true);
     }
 
+    // We need to cover the case when JmxCacheBuster has just stopped the 
HBase metrics
+    // system, and not accidentally overwrite the DefaultMetricsSystem 
singleton.
+    // See PHOENIX-6699
+    public static boolean isDefaultMetricsInitialized() {
+        try {
+            MetricsSystemImpl metrics = (MetricsSystemImpl) 
DefaultMetricsSystem.instance();
+            Field prefixField = 
MetricsSystemImpl.class.getDeclaredField("prefix");

Review Comment:
   _MetricsSystemImpl.monitoring_ is not useful for this purpose, as it is set 
to false when the metrics system is stopped.
   This is why we can overwrite the stopped Default Metrics System:
   
https://github.com/apache/hadoop/blob/7bd7725532fd139d2e0e1662df7700f7ab95067a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java#L156
   
   _MetricsSystemImpl.prefix_ is only written by the init() method, it is not 
touched otherwise, so it can be used to check for the codition when the 
MetricsSystemImpl is initialized, but in a stopped state:
   
https://github.com/apache/hadoop/blob/7bd7725532fd139d2e0e1662df7700f7ab95067a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java#L154
   
   I don't think we have to worry about a race around prefix, AFAICT by the 
time the Phoenix classes are loaded, HBase has long initialized DefaultMetrics, 
and prefix has been set.
   



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

Reply via email to