HDDS-1710. Publish JVM metrics via Hadoop metrics

Signed-off-by: Anu Engineer <aengineer@apache.org>
This commit is contained in:
Márton Elek 2019-06-20 10:28:42 +02:00 committed by Anu Engineer
parent d59f2711e0
commit c533b79c32
5 changed files with 28 additions and 3 deletions

View File

@ -42,9 +42,13 @@ import org.apache.hadoop.hdds.scm.ScmConfigKeys;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.protocol.SCMSecurityProtocol;
import org.apache.hadoop.hdds.scm.protocolPB.ScmBlockLocationProtocolPB;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.ipc.Client;
import org.apache.hadoop.ipc.ProtobufRpcEngine;
import org.apache.hadoop.ipc.RPC;
import org.apache.hadoop.metrics2.MetricsSystem;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.source.JvmMetrics;
import org.apache.hadoop.metrics2.util.MBeans;
import org.apache.hadoop.net.DNS;
import org.apache.hadoop.net.NetUtils;
@ -475,4 +479,18 @@ public final class HddsUtils {
.orElse(ScmConfigKeys.OZONE_SCM_SECURITY_SERVICE_PORT_DEFAULT));
}
/**
* Initialize hadoop metrics systen for Ozone servers.
* @param configuration OzoneConfiguration to use.
* @param serverName The logical name of the server components. (eg.
* @return
*/
public static MetricsSystem initializeMetrics(OzoneConfiguration configuration,
String serverName) {
MetricsSystem metricsSystem = DefaultMetricsSystem.initialize(serverName);
JvmMetrics.create(serverName,
configuration.get(DFSConfigKeys.DFS_METRICS_SESSION_ID_KEY),
DefaultMetricsSystem.instance());
return metricsSystem;
}
}

View File

@ -170,8 +170,8 @@ public class HddsDatanodeService extends GenericCli implements ServicePlugin {
}
public void start() {
DefaultMetricsSystem.initialize("HddsDatanode");
OzoneConfiguration.activate();
HddsUtils.initializeMetrics(conf, "HddsDatanode");
if (HddsUtils.isHddsEnabled(conf)) {
try {
String hostname = HddsUtils.getHostName(conf);

View File

@ -81,11 +81,13 @@ import org.apache.hadoop.hdds.security.x509.certificate.authority.DefaultCAServe
import org.apache.hadoop.hdds.server.ServiceRuntimeInfoImpl;
import org.apache.hadoop.hdds.server.events.EventPublisher;
import org.apache.hadoop.hdds.server.events.EventQueue;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.DFSUtil;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.ipc.RPC;
import org.apache.hadoop.metrics2.MetricsSystem;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.source.JvmMetrics;
import org.apache.hadoop.metrics2.util.MBeans;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneSecurityUtil;
@ -760,7 +762,8 @@ public final class StorageContainerManager extends ServiceRuntimeInfoImpl
buildRpcServerStartMessage(
"StorageContainerLocationProtocol RPC server",
getClientRpcAddress()));
ms = DefaultMetricsSystem.initialize("StorageContainerManager");
ms = HddsUtils.initializeMetrics(configuration, "StorageContainerManager");
commandWatcherLeaseManager.start();
getClientProtocolServer().start();

View File

@ -65,6 +65,7 @@ import org.apache.hadoop.hdds.security.x509.certificate.utils.CertificateCodec;
import org.apache.hadoop.hdds.security.x509.certificates.utils.CertificateSignRequest;
import org.apache.hadoop.hdds.server.ServiceRuntimeInfoImpl;
import org.apache.hadoop.hdds.tracing.TracingUtil;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.DFSUtil;
import org.apache.hadoop.hdfs.util.PersistentLongFile;
import org.apache.hadoop.io.Text;
@ -73,6 +74,7 @@ import org.apache.hadoop.ipc.Client;
import org.apache.hadoop.ipc.ProtobufRpcEngine;
import org.apache.hadoop.ipc.RPC;
import org.apache.hadoop.ipc.Server;
import org.apache.hadoop.metrics2.source.JvmMetrics;
import org.apache.hadoop.ozone.OzoneAcl;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneIllegalArgumentException;
@ -1307,7 +1309,7 @@ public final class OzoneManager extends ServiceRuntimeInfoImpl
LOG.info(buildRpcServerStartMessage("OzoneManager RPC server",
omRpcAddress));
DefaultMetricsSystem.initialize("OzoneManager");
HddsUtils.initializeMetrics(configuration, "OzoneManager");
metadataManager.start(configuration);
startSecretManagerIfNecessary();

View File

@ -18,6 +18,7 @@ package org.apache.hadoop.ozone.freon;
import java.io.IOException;
import org.apache.hadoop.hdds.HddsUtils;
import org.apache.hadoop.hdds.cli.GenericCli;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.tracing.TracingUtil;
@ -49,6 +50,7 @@ public class Freon extends GenericCli {
@Override
public void execute(String[] argv) {
HddsUtils.initializeMetrics(createOzoneConfiguration(), "ozone-freon");
TracingUtil.initTracing("freon");
super.execute(argv);
}