diff --git a/hadoop-hdds/container-service/pom.xml b/hadoop-hdds/container-service/pom.xml index d10d2a358ce1..392cc44c72a1 100644 --- a/hadoop-hdds/container-service/pom.xml +++ b/hadoop-hdds/container-service/pom.xml @@ -107,6 +107,37 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd"> ${basedir}/dev-support/findbugsExcludeFile.xml + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-common-html + prepare-package + + unpack + + + + + org.apache.hadoop + hadoop-hdds-server-framework + ${project.build.outputDirectory} + + webapps/static/**/*.* + + + org.apache.hadoop + hadoop-hdds-docs + ${project.build.outputDirectory}/webapps/hddsDatanode + docs/**/*.* + + + true + + + + diff --git a/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/.gitkeep b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/DNMXBean.java similarity index 72% rename from hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/.gitkeep rename to hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/DNMXBean.java index ff1232e5fcaa..d36fcdb6fc70 100644 --- a/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/.gitkeep +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/DNMXBean.java @@ -14,4 +14,16 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ \ No newline at end of file + */ + +package org.apache.hadoop.ozone; + +import org.apache.hadoop.hdds.annotation.InterfaceAudience; +import org.apache.hadoop.hdds.server.ServiceRuntimeInfo; + +/** + * This is the JMX management interface for DN information. + */ +@InterfaceAudience.Private +public interface DNMXBean extends ServiceRuntimeInfo { +} diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/DNMXBeanImpl.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/DNMXBeanImpl.java new file mode 100644 index 000000000000..18ad66ce5a69 --- /dev/null +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/DNMXBeanImpl.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.ozone; + +import org.apache.hadoop.hdds.server.ServiceRuntimeInfoImpl; +import org.apache.hadoop.hdds.utils.VersionInfo; + +/** + * This is the JMX management class for DN information. + */ +public class DNMXBeanImpl extends ServiceRuntimeInfoImpl implements DNMXBean { + public DNMXBeanImpl( + VersionInfo versionInfo) { + super(versionInfo); + } +} \ No newline at end of file diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java index 7e896e715598..0b06668ab4c6 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java @@ -23,12 +23,14 @@ import java.security.KeyPair; import java.security.cert.CertificateException; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.ConcurrentHashMap; +import com.sun.jmx.mbeanserver.Introspector; import org.apache.hadoop.conf.Configurable; import org.apache.hadoop.hdds.DFSConfigKeysLegacy; import org.apache.hadoop.hdds.HddsUtils; @@ -49,6 +51,7 @@ import org.apache.hadoop.hdds.server.http.RatisDropwizardExports; import org.apache.hadoop.hdds.tracing.TracingUtil; import org.apache.hadoop.hdds.utils.HddsVersionInfo; +import org.apache.hadoop.metrics2.util.MBeans; import org.apache.hadoop.ozone.container.common.helpers.ContainerUtils; import org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine; import org.apache.hadoop.ozone.container.common.utils.HddsVolumeUtil; @@ -70,6 +73,8 @@ import org.slf4j.LoggerFactory; import picocli.CommandLine.Command; +import javax.management.ObjectName; + /** * Datanode service plugin to start the HDDS container services. */ @@ -95,6 +100,10 @@ public class HddsDatanodeService extends GenericCli implements ServicePlugin { private volatile AtomicBoolean isStopped = new AtomicBoolean(false); private final Map ratisMetricsMap = new ConcurrentHashMap<>(); + private DNMXBeanImpl serviceRuntimeInfo = + new DNMXBeanImpl(HddsVersionInfo.HDDS_VERSION_INFO) {}; + private ObjectName dnInfoBeanName; + //Constructor for DataNode PluginService public HddsDatanodeService(){} @@ -132,6 +141,7 @@ private static HddsDatanodeService createHddsDatanodeService( public static void main(String[] args) { try { + Introspector.checkCompliance(DNMXBeanImpl.class); HddsDatanodeService hddsDatanodeService = createHddsDatanodeService(args, true); hddsDatanodeService.run(args); @@ -180,6 +190,8 @@ public void start(OzoneConfiguration configuration) { } public void start() { + serviceRuntimeInfo.setStartTime(); + RatisDropwizardExports. registerRatisMetricReporters(ratisMetricsMap); @@ -245,7 +257,7 @@ public void start() { .equalsIgnoreCase(System.getenv("OZONE_DATANODE_STANDALONE_TEST"))) { startRatisForTest(); } - + registerMXBean(); } catch (IOException e) { throw new RuntimeException("Can't start the HDDS datanode plugin", e); } catch (AuthenticationException ex) { @@ -345,6 +357,21 @@ private void getSCMSignedCert(OzoneConfiguration config) { } } + private void registerMXBean() { + Map jmxProperties = new HashMap<>(); + jmxProperties.put("component", "ServerRuntime"); + this.dnInfoBeanName = HddsUtils.registerWithJmxProperties( + "HddsDatanodeService", + "HddsDatanodeServiceInfo", jmxProperties, this.serviceRuntimeInfo); + } + + private void unregisterMXBean() { + if (this.dnInfoBeanName != null) { + MBeans.unregister(this.dnInfoBeanName); + this.dnInfoBeanName = null; + } + } + /** * Creates CSR for DN. * @param config @@ -512,6 +539,7 @@ public void stop() { LOG.error("Stopping HttpServer is failed.", e); } } + unregisterMXBean(); } } diff --git a/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/dn-overview.html b/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/dn-overview.html new file mode 100644 index 000000000000..d4f7a17c0b76 --- /dev/null +++ b/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/dn-overview.html @@ -0,0 +1,21 @@ + + + + + +
diff --git a/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/dn.js b/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/dn.js new file mode 100644 index 000000000000..c43eb42bdc25 --- /dev/null +++ b/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/dn.js @@ -0,0 +1,35 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +(function () { + "use strict"; + angular.module('dn', ['ozone', 'nvd3']); + + angular.module('dn').component('dnOverview', { + templateUrl: 'dn-overview.html', + require: { + overview: "^overview" + }, + controller: function ($http) { + var ctrl = this; + $http.get("jmx?qry=Hadoop:service=HddsDatanode,name=StorageContainerMetrics") + .then(function (result) { + ctrl.dnmetrics = result.data.beans[0]; + }); + } + }); +})(); diff --git a/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/index.html b/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/index.html new file mode 100644 index 000000000000..b1f703c0d659 --- /dev/null +++ b/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/index.html @@ -0,0 +1,76 @@ + + + + + + + + + + + HDDS Datanode Service + + + + + + + + + + + +

+ +
+ + + +
+ + + + + + + + + + + + diff --git a/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/main.html b/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/main.html new file mode 100644 index 000000000000..c639b0bb2b50 --- /dev/null +++ b/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/main.html @@ -0,0 +1,20 @@ + + + + +