hadoop-ozone-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From avija...@apache.org
Subject [hadoop-ozone] branch master updated: HDDS-3035. Add ability to enable Ratis metrics in OzoneManager. (#570)
Date Sat, 22 Feb 2020 04:59:35 GMT
This is an automated email from the ASF dual-hosted git repository.

avijayan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 887cee2  HDDS-3035. Add ability to enable Ratis metrics in OzoneManager. (#570)
887cee2 is described below

commit 887cee24602e44c3cd25f1e155ef7c1aef9258a4
Author: Siddharth <swagle@apache.org>
AuthorDate: Fri Feb 21 20:59:29 2020 -0800

    HDDS-3035. Add ability to enable Ratis metrics in OzoneManager. (#570)
    
    * HDDS-3035. Add ability to enable Ratis metrics in OzoneManager.
    
    * HDDS-3035. Addressed review comments.
    
    * Checkstyle fix.
---
 .../apache/hadoop/ozone/om/TestOzoneManagerHA.java | 24 ++++++++++++++++++++--
 .../org/apache/hadoop/ozone/om/OzoneManager.java   | 21 ++++++++++++++++---
 2 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java
index a8066c6..9a30ed0 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java
@@ -17,6 +17,7 @@
 package org.apache.hadoop.ozone.om;
 
 import java.io.IOException;
+import java.lang.management.ManagementFactory;
 import java.net.ConnectException;
 import java.net.InetSocketAddress;
 import java.time.Instant;
@@ -34,6 +35,7 @@ import java.util.UUID;
 import org.apache.hadoop.ozone.OzoneAcl;
 import org.apache.hadoop.ozone.OzoneConfigKeys;
 import org.apache.hadoop.ozone.client.OzoneMultipartUploadPartListParts;
+import org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServer;
 import org.apache.hadoop.ozone.security.acl.OzoneObj;
 import org.apache.hadoop.ozone.security.acl.OzoneObjInfo;
 import org.apache.hadoop.security.UserGroupInformation;
@@ -96,8 +98,13 @@ import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.NOT_
 import static org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLIdentityType.USER;
 import static org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.READ;
 import static org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.WRITE;
+import static org.apache.ratis.server.metrics.RatisMetrics.RATIS_APPLICATION_NAME_METRICS;
 import static org.junit.Assert.fail;
 
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
 /**
  * Test Ozone Manager operation in distributed handler scenario.
  */
@@ -1083,8 +1090,6 @@ public class TestOzoneManagerHA {
     Assert.assertTrue(removeAcl);
   }
 
-
-
   @Test
   public void testOMRatisSnapshot() throws Exception {
     String userName = "user" + RandomStringUtils.randomNumeric(5);
@@ -1318,6 +1323,21 @@ public class TestOzoneManagerHA {
 
   }
 
+  @Test
+  public void testJMXMetrics() throws Exception {
+    // Verify any one ratis metric is exposed by JMX MBeanServer
+    OzoneManagerRatisServer ratisServer =
+        cluster.getOzoneManager(0).getOmRatisServer();
+    ObjectName oname = new ObjectName(RATIS_APPLICATION_NAME_METRICS, "name",
+        RATIS_APPLICATION_NAME_METRICS + ".log_worker." +
+            ratisServer.getRaftPeerId().toString() + ".flushCount");
+    MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
+    MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(oname);
+    Assert.assertNotNull(mBeanInfo);
+    Object flushCount = mBeanServer.getAttribute(oname, "Count");
+    Assert.assertTrue((long) flushCount >= 0);
+  }
+
   private void validateVolumesList(String userName,
       Set<String> expectedVolumes) throws Exception {
 
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
index 6d4cb75..57ef22f 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
@@ -57,6 +57,7 @@ import org.apache.hadoop.hdds.protocol.DatanodeDetails;
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
 import org.apache.hadoop.hdds.protocol.proto.SCMSecurityProtocolProtos.SCMGetCertResponseProto;
 import org.apache.hadoop.hdds.protocolPB.SCMSecurityProtocolClientSideTranslatorPB;
+import org.apache.hadoop.hdds.server.http.RatisDropwizardExports;
 import org.apache.hadoop.hdds.utils.HddsServerUtil;
 import org.apache.hadoop.hdds.scm.ScmInfo;
 import org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList;
@@ -208,6 +209,9 @@ import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.TOKE
 import static org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.S3_BUCKET_LOCK;
 import static org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.VOLUME_LOCK;
 import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneManagerService.newReflectiveBlockingService;
+
+import org.apache.ratis.metrics.MetricRegistries;
+import org.apache.ratis.metrics.MetricsReporting;
 import org.apache.ratis.proto.RaftProtos.RaftPeerRole;
 import org.apache.ratis.server.protocol.TermIndex;
 import org.apache.ratis.util.FileUtils;
@@ -216,6 +220,8 @@ import org.bouncycastle.pkcs.PKCS10CertificationRequest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import io.prometheus.client.CollectorRegistry;
+
 /**
  * Ozone Manager is the metadata manager of ozone.
  */
@@ -1068,14 +1074,23 @@ public final class OzoneManager extends ServiceRuntimeInfoImpl
    * Start service.
    */
   public void start() throws IOException {
-
     omClientProtocolMetrics.register();
+    HddsServerUtil.initializeMetrics(configuration, "OzoneManager");
+    if (configuration.getBoolean(
+        OMConfigKeys.OZONE_OM_RATIS_ENABLE_KEY, false)) {
+      // All the Ratis metrics (registered from now) will be published via JMX
+      // and via the prometheus exporter (used by the /prom servlet
+      MetricRegistries.global()
+          .addReporterRegistration(MetricsReporting.jmxReporter());
+      MetricRegistries.global().addReporterRegistration(
+          registry -> CollectorRegistry.defaultRegistry.register(
+              new RatisDropwizardExports(
+                  registry.getDropWizardMetricRegistry())));
+    }
 
     LOG.info(buildRpcServerStartMessage("OzoneManager RPC server",
         omRpcAddress));
 
-    HddsServerUtil.initializeMetrics(configuration, "OzoneManager");
-
     // Start Ratis services
     if (omRatisServer != null) {
       omRatisServer.start();


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


Mime
View raw message