From e5ef06bc2db3361133c2ed08727b3302462e14cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Elek?= Date: Tue, 19 Feb 2019 15:23:37 +0100 Subject: [PATCH 1/6] HDDS-919. Enable prometheus endpoints for Ozone datanodes. Contributed by Elek, Marton. --- .../apache/hadoop/hdds/HddsConfigKeys.java | 20 ++++ .../src/main/resources/ozone-default.xml | 104 ++++++++++++++++++ hadoop-hdds/container-service/pom.xml | 4 + .../apache/hadoop/HddsDatanodeHttpServer.java | 86 +++++++++++++++ .../hadoop/ozone/HddsDatanodeService.java | 17 +++ .../main/compose/ozone/docker-compose.yaml | 1 + 6 files changed, 232 insertions(+) create mode 100644 hadoop-hdds/container-service/src/main/java/org/apache/hadoop/HddsDatanodeHttpServer.java diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java index c2657718058d6..184e3d880cd1b 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java @@ -227,4 +227,24 @@ private HddsConfigKeys() { public static final String HDDS_SECURITY_CLIENT_SCM_CERTIFICATE_PROTOCOL_ACL = "hdds.security.client.scm.certificate.protocol.acl"; + public static final String HDDS_DATANODE_HTTP_ENABLED_KEY = + "hdds.datanode.http.enabled"; + public static final String HDDS_DATANODE_HTTP_BIND_HOST_KEY = + "hdds.datanode.http-bind-host"; + public static final String HDDS_DATANODE_HTTPS_BIND_HOST_KEY = + "hdds.datanode.https-bind-host"; + public static final String HDDS_DATANODE_HTTP_ADDRESS_KEY = + "hdds.datanode.http-address"; + public static final String HDDS_DATANODE_HTTPS_ADDRESS_KEY = + "hdds.datanode.https-address"; + + public static final String HDDS_DATANODE_HTTP_BIND_HOST_DEFAULT = "0.0.0.0"; + public static final int HDDS_DATANODE_HTTP_BIND_PORT_DEFAULT = 9882; + public static final int HDDS_DATANODE_HTTPS_BIND_PORT_DEFAULT = 9883; + public static final String + HDDS_DATANODE_HTTP_KERBEROS_PRINCIPAL_KEY = + "hdds.datanode.http.kerberos.principal"; + public static final String + HDDS_DATANODE_HTTP_KERBEROS_KEYTAB_FILE_KEY = + "hdds.datanode.http.kerberos.keytab"; } \ No newline at end of file diff --git a/hadoop-hdds/common/src/main/resources/ozone-default.xml b/hadoop-hdds/common/src/main/resources/ozone-default.xml index 8469fdce20b3c..373bb7e0be476 100644 --- a/hadoop-hdds/common/src/main/resources/ozone-default.xml +++ b/hadoop-hdds/common/src/main/resources/ozone-default.xml @@ -2028,5 +2028,109 @@ client ozone manager protocol. + + hdds.datanode.http.kerberos.principal + HTTP/_HOST@EXAMPLE.COM + HDDS, SECURITY, MANAGEMENT + + The kerberos principal for the datanode http server. + + + + hdds.datanode.http.kerberos.keytab + /etc/security/keytabs/HTTP.keytab + HDDS, SECURITY, MANAGEMENT + + The kerberos keytab file for datanode http server + + + + hdds.datanode.http-address + 0.0.0.0:9882 + HDDS, MANAGEMENT + + The address and the base port where the Datanode web ui will listen on. + If the port is 0 then the server will start on a free port. + + + + hdds.datanode.http-bind-host + 0.0.0.0 + HDDS, MANAGEMENT + + The actual address the Datanode web server will bind to. If this + optional address is set, it overrides only the hostname portion of + hdds.datanode.http-address. + + + + hdds.datanode.http.enabled + true + HDDS, MANAGEMENT + + Property to enable or disable Datanode web ui. + + + + hdds.datanode.https-address + 0.0.0.0:9883 + HDDS, MANAGEMENT, SECURITY + + The address and the base port where the Datanode web UI will listen + on using HTTPS. + If the port is 0 then the server will start on a free port. + + + + hdds.datanode.https-bind-host + 0.0.0.0 + HDDS, MANAGEMENT, SECURITY + + The actual address the Datanode web server will bind to using HTTPS. + If this optional address is set, it overrides only the hostname portion of + hdds.datanode.http-address. + + + + ozone.client.retry.max.attempts + 10 + + Max retry attempts for Ozone RpcClient talking to OzoneManagers. + + + + ozone.client.failover.max.attempts + 15 + + Expert only. The number of client failover attempts that should be + made before the failover is considered failed. + + + + ozone.client.failover.sleep.base.millis + 500 + + Expert only. The time to wait, in milliseconds, between failover + attempts increases exponentially as a function of the number of + attempts made so far, with a random factor of +/- 50%. This option + specifies the base value used in the failover calculation. The + first failover will retry immediately. The 2nd failover attempt + will delay at least ozone.client.failover.sleep.base.millis + milliseconds. And so on. + + + + ozone.client.failover.sleep.max.millis + 15000 + + Expert only. The time to wait, in milliseconds, between failover + attempts increases exponentially as a function of the number of + attempts made so far, with a random factor of +/- 50%. This option + specifies the maximum value to wait between failovers. + Specifically, the time between two failover attempts will not + exceed +/- 50% of ozone.client.failover.sleep.max.millis + milliseconds. + + diff --git a/hadoop-hdds/container-service/pom.xml b/hadoop-hdds/container-service/pom.xml index cbb3b89501219..c12929f774ca6 100644 --- a/hadoop-hdds/container-service/pom.xml +++ b/hadoop-hdds/container-service/pom.xml @@ -37,6 +37,10 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> org.apache.hadoop hadoop-hdds-server-framework + + org.apache.hadoop + hadoop-hdds-server-framework + org.mockito diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/HddsDatanodeHttpServer.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/HddsDatanodeHttpServer.java new file mode 100644 index 0000000000000..f00a5e9d19833 --- /dev/null +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/HddsDatanodeHttpServer.java @@ -0,0 +1,86 @@ +/** + * 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; + +import java.io.IOException; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hdds.HddsConfigKeys; +import org.apache.hadoop.hdds.server.BaseHttpServer; + +/** + * Simple http server to provide basic monitoring for hdds datanode. + *

+ * This server is used to access default /conf /prom /prof endpoints. + */ +public class HddsDatanodeHttpServer extends BaseHttpServer { + + public HddsDatanodeHttpServer(Configuration conf) throws IOException { + super(conf, "hddsDatanode"); + } + + @Override + protected String getHttpAddressKey() { + return HddsConfigKeys.HDDS_DATANODE_HTTP_ADDRESS_KEY; + } + + @Override + protected String getHttpBindHostKey() { + return HddsConfigKeys.HDDS_DATANODE_HTTP_BIND_HOST_KEY; + } + + @Override + protected String getHttpsAddressKey() { + return HddsConfigKeys.HDDS_DATANODE_HTTPS_ADDRESS_KEY; + } + + @Override + protected String getHttpsBindHostKey() { + return HddsConfigKeys.HDDS_DATANODE_HTTPS_BIND_HOST_KEY; + } + + @Override + protected String getBindHostDefault() { + return HddsConfigKeys.HDDS_DATANODE_HTTP_BIND_HOST_DEFAULT; + } + + @Override + protected int getHttpBindPortDefault() { + return HddsConfigKeys.HDDS_DATANODE_HTTP_BIND_PORT_DEFAULT; + } + + @Override + protected int getHttpsBindPortDefault() { + return HddsConfigKeys.HDDS_DATANODE_HTTPS_BIND_PORT_DEFAULT; + } + + @Override + protected String getKeytabFile() { + return HddsConfigKeys.HDDS_DATANODE_HTTP_KERBEROS_KEYTAB_FILE_KEY; + } + + @Override + protected String getSpnegoPrincipal() { + return HddsConfigKeys.HDDS_DATANODE_HTTP_KERBEROS_PRINCIPAL_KEY; + } + + @Override + protected String getEnabledKey() { + return HddsConfigKeys.HDDS_DATANODE_HTTP_ENABLED_KEY; + } +} 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 3a92a4adf1db9..3ca6263961b93 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 @@ -19,6 +19,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; + +import org.apache.hadoop.HddsDatanodeHttpServer; import org.apache.hadoop.conf.Configurable; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hdds.HddsUtils; @@ -67,6 +69,7 @@ public class HddsDatanodeService extends GenericCli implements ServicePlugin { private DatanodeDetails datanodeDetails; private DatanodeStateMachine datanodeStateMachine; private List plugins; + private HddsDatanodeHttpServer httpServer; /** * Default constructor. @@ -180,6 +183,12 @@ public void start(Object service) { LOG.info("Hdds Datanode login successful."); } datanodeStateMachine = new DatanodeStateMachine(datanodeDetails, conf); + try { + httpServer = new HddsDatanodeHttpServer(conf); + httpServer.start(); + } catch (Exception ex) { + LOG.error("HttpServer failed to start.", ex); + } startPlugins(); // Starting HDDS Daemons datanodeStateMachine.startDaemon(); @@ -294,6 +303,14 @@ public void stop() { if (datanodeStateMachine != null) { datanodeStateMachine.stopDaemon(); } + if (httpServer != null) { + try { + httpServer.stop(); + } catch (Exception e) { + LOG.error("Stopping HttpServer is failed.", e); + } + } + } @Override diff --git a/hadoop-ozone/dist/src/main/compose/ozone/docker-compose.yaml b/hadoop-ozone/dist/src/main/compose/ozone/docker-compose.yaml index 487c4eb29b153..91105923dd711 100644 --- a/hadoop-ozone/dist/src/main/compose/ozone/docker-compose.yaml +++ b/hadoop-ozone/dist/src/main/compose/ozone/docker-compose.yaml @@ -23,6 +23,7 @@ services: - ../..:/opt/hadoop ports: - 9864 + - 9882 command: ["/opt/hadoop/bin/ozone","datanode"] env_file: - ./docker-config From 9834a285ae7a95b5b5ca149d036982814d3e396f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Elek?= Date: Tue, 26 Feb 2019 11:57:04 +0100 Subject: [PATCH 2/6] fix configuration tags --- hadoop-hdds/common/src/main/resources/ozone-default.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/hadoop-hdds/common/src/main/resources/ozone-default.xml b/hadoop-hdds/common/src/main/resources/ozone-default.xml index 373bb7e0be476..a4f49e762b31a 100644 --- a/hadoop-hdds/common/src/main/resources/ozone-default.xml +++ b/hadoop-hdds/common/src/main/resources/ozone-default.xml @@ -2028,6 +2028,7 @@ client ozone manager protocol. + hdds.datanode.http.kerberos.principal HTTP/_HOST@EXAMPLE.COM From 699d181e05b35ba548bd6605addfab5cdd6c199c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Elek?= Date: Tue, 26 Feb 2019 12:30:14 +0100 Subject: [PATCH 3/6] move the new http server to the existing package --- .../org/apache/hadoop/{ => ozone}/HddsDatanodeHttpServer.java | 2 +- .../main/java/org/apache/hadoop/ozone/HddsDatanodeService.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) rename hadoop-hdds/container-service/src/main/java/org/apache/hadoop/{ => ozone}/HddsDatanodeHttpServer.java (98%) diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/HddsDatanodeHttpServer.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeHttpServer.java similarity index 98% rename from hadoop-hdds/container-service/src/main/java/org/apache/hadoop/HddsDatanodeHttpServer.java rename to hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeHttpServer.java index f00a5e9d19833..3dcfcfe547c76 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/HddsDatanodeHttpServer.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeHttpServer.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop; +package org.apache.hadoop.ozone; import java.io.IOException; 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 3ca6263961b93..3c205e6540474 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 @@ -20,7 +20,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; -import org.apache.hadoop.HddsDatanodeHttpServer; import org.apache.hadoop.conf.Configurable; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hdds.HddsUtils; From 0944c3c4239e39af87b6826a10ef248aebaa9bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Elek?= Date: Thu, 28 Feb 2019 19:04:15 +0100 Subject: [PATCH 4/6] remove redundant dependency --- hadoop-hdds/container-service/pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hadoop-hdds/container-service/pom.xml b/hadoop-hdds/container-service/pom.xml index c12929f774ca6..cbb3b89501219 100644 --- a/hadoop-hdds/container-service/pom.xml +++ b/hadoop-hdds/container-service/pom.xml @@ -37,10 +37,6 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> org.apache.hadoop hadoop-hdds-server-framework - - org.apache.hadoop - hadoop-hdds-server-framework - org.mockito From 130aa624fbcb2f57062e7a1cfc5528b2a8c4ac89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Elek?= Date: Fri, 1 Mar 2019 17:22:25 +0100 Subject: [PATCH 5/6] Use randomized port for HDDS datanode web server --- .../test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java index 0ed8e8b4d5519..dbeb0b56e2e9c 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java @@ -577,6 +577,7 @@ private void configureOM() { private void configureHddsDatanodes() { conf.set(ScmConfigKeys.HDDS_REST_HTTP_ADDRESS_KEY, "0.0.0.0:0"); + conf.set(HddsConfigKeys.HDDS_DATANODE_HTTP_ADDRESS_KEY, "0.0.0.0:0"); conf.set(HDDS_DATANODE_PLUGINS_KEY, "org.apache.hadoop.ozone.web.OzoneHddsDatanodeService"); conf.setBoolean(OzoneConfigKeys.DFS_CONTAINER_IPC_RANDOM_PORT, From 8ae7bb747ff171a6df3a7f34a3f9c51dab528994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Elek?= Date: Fri, 1 Mar 2019 17:27:18 +0100 Subject: [PATCH 6/6] add missing gitkeep file --- .../resources/webapps/hddsDatanode/.gitkeep | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/.gitkeep diff --git a/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/.gitkeep b/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/.gitkeep new file mode 100644 index 0000000000000..ff1232e5fcaa0 --- /dev/null +++ b/hadoop-hdds/container-service/src/main/resources/webapps/hddsDatanode/.gitkeep @@ -0,0 +1,17 @@ +/** + * 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. + */ \ No newline at end of file