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 2020/10/20 18:29:32 UTC

[GitHub] [hadoop-ozone] smengcl commented on a change in pull request #1506: HDDS-4359. Expose VolumeIOStats in DN JMX

smengcl commented on a change in pull request #1506:
URL: https://github.com/apache/hadoop-ozone/pull/1506#discussion_r508747977



##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeIOStats.java
##########
@@ -18,121 +18,135 @@
 
 package org.apache.hadoop.ozone.container.common.volume;
 
-import java.util.concurrent.atomic.AtomicLong;
+import org.apache.hadoop.metrics2.MetricsSystem;
+import org.apache.hadoop.metrics2.annotation.Metric;
+import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
+import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+import org.apache.hadoop.metrics2.lib.MutableCounterLong;
 
 /**
  * This class is used to track Volume IO stats for each HDDS Volume.
  */
 public class VolumeIOStats {
+  private String name = VolumeIOStats.class.getSimpleName();
 
-  private final AtomicLong readBytes;
-  private final AtomicLong readOpCount;
-  private final AtomicLong writeBytes;
-  private final AtomicLong writeOpCount;
-  private final AtomicLong readTime;
-  private final AtomicLong writeTime;
+  private @Metric MutableCounterLong readBytes;
+  private @Metric MutableCounterLong readOpCount;
+  private @Metric MutableCounterLong writeBytes;
+  private @Metric MutableCounterLong writeOpCount;
+  private @Metric MutableCounterLong readTime;
+  private @Metric MutableCounterLong writeTime;
+  private MetricsRegistry registry;
 
   public VolumeIOStats() {
-    readBytes = new AtomicLong(0);
-    readOpCount = new AtomicLong(0);
-    writeBytes = new AtomicLong(0);
-    writeOpCount = new AtomicLong(0);
-    readTime = new AtomicLong(0);
-    writeTime = new AtomicLong(0);
+    init();
+  }
+
+  public VolumeIOStats(String identifier) {
+    this.name += '-' + identifier;
+    init();
+  }
+
+  public void init() {
+    DefaultMetricsSystem.initialize(name);
+    MetricsSystem ms = DefaultMetricsSystem.instance();
+    ms.register(name, "Volume I/O Statistics", this);

Review comment:
       oops. thanks for the reminder!




----------------------------------------------------------------
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:
users@infra.apache.org



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