You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/10/21 09:22:19 UTC

[GitHub] [ozone] szetszwo commented on a diff in pull request #3858: HDDS-7349. Flaky integration test have memory leak for RatisDropwizardExports

szetszwo commented on code in PR #3858:
URL: https://github.com/apache/ozone/pull/3858#discussion_r1001565783


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/RatisDropwizardExports.java:
##########
@@ -43,14 +44,15 @@ public RatisDropwizardExports(MetricRegistry registry) {
   }
 
   public static void registerRatisMetricReporters(
-      Map<String, RatisDropwizardExports> ratisMetricsMap) {
+      Map<String, RatisDropwizardExports> ratisMetricsMap,
+      AtomicBoolean isStopped) {

Review Comment:
   Use `BooleanSupplier`.



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/RatisDropwizardExports.java:
##########
@@ -69,12 +71,19 @@ public static void clear(Map<String, RatisDropwizardExports>
   }
 
   private static void registerDropwizard(RatisMetricRegistry registry,
-      Map<String, RatisDropwizardExports> ratisMetricsMap) {
+      Map<String, RatisDropwizardExports> ratisMetricsMap,
+      AtomicBoolean isStopped) {
+    if (isStopped.get()) {
+      return;
+    }
+    
+    String name = registry.getMetricRegistryInfo().getName();
     RatisDropwizardExports rde = new RatisDropwizardExports(
         registry.getDropWizardMetricRegistry());
-    CollectorRegistry.defaultRegistry.register(rde);
-    String name = registry.getMetricRegistryInfo().getName();

Review Comment:
   Keep `name` declared after `rde`, i.e.
   ```java
        RatisDropwizardExports rde = new RatisDropwizardExports(
            registry.getDropWizardMetricRegistry());
        String name = registry.getMetricRegistryInfo().getName();
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -438,6 +439,7 @@ private enum State {
   private static final int MSECS_PER_MINUTE = 60 * 1000;
 
   private final boolean isSecurityEnabled;
+  private final AtomicBoolean isStopped = new AtomicBoolean(false);

Review Comment:
   Use `omState` and do not add `isStopped`.



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/RatisDropwizardExports.java:
##########
@@ -69,12 +71,19 @@ public static void clear(Map<String, RatisDropwizardExports>
   }
 
   private static void registerDropwizard(RatisMetricRegistry registry,
-      Map<String, RatisDropwizardExports> ratisMetricsMap) {
+      Map<String, RatisDropwizardExports> ratisMetricsMap,
+      AtomicBoolean isStopped) {

Review Comment:
   Use `BooleanSupplier`.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -1967,7 +1969,7 @@ private void initializeRatisServer(boolean shouldBootstrap)
       if (omRatisServer == null) {
         // This needs to be done before initializing Ratis.
         RatisDropwizardExports.
-            registerRatisMetricReporters(ratisMetricsMap);
+            registerRatisMetricReporters(ratisMetricsMap, isStopped);

Review Comment:
   Use `() -> omState == State.STOPPED`.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org