You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bb...@apache.org on 2024/01/25 14:47:17 UTC
(hbase) branch branch-2.6 updated: HBASE-28315 Remove noisy WARN from trying to construct MetricsServlet (#5651)
This is an automated email from the ASF dual-hosted git repository.
bbeaudreault pushed a commit to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.6 by this push:
new 6f6f877a419 HBASE-28315 Remove noisy WARN from trying to construct MetricsServlet (#5651)
6f6f877a419 is described below
commit 6f6f877a419c5ab56cfccb79b8ed5679f2a0fd6b
Author: Bryan Beaudreault <bb...@apache.org>
AuthorDate: Thu Jan 25 09:30:47 2024 -0500
HBASE-28315 Remove noisy WARN from trying to construct MetricsServlet (#5651)
Signed-off-by: Duo Zhang <zh...@apache.org>
---
.../java/org/apache/hadoop/hbase/http/HttpServer.java | 19 ++++++++++++-------
.../org/apache/hadoop/hbase/http/ServletConfig.java | 16 +++++++++++++---
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/hbase-http/src/main/java/org/apache/hadoop/hbase/http/HttpServer.java b/hbase-http/src/main/java/org/apache/hadoop/hbase/http/HttpServer.java
index f6f41314639..0050cec0615 100644
--- a/hbase-http/src/main/java/org/apache/hadoop/hbase/http/HttpServer.java
+++ b/hbase-http/src/main/java/org/apache/hadoop/hbase/http/HttpServer.java
@@ -169,7 +169,9 @@ public class HttpServer implements FilterContainer {
.put("jmx",
new ServletConfig("jmx", "/jmx", "org.apache.hadoop.hbase.http.jmx.JMXJsonServlet"))
.put("metrics",
- new ServletConfig("metrics", "/metrics", "org.apache.hadoop.metrics.MetricsServlet"))
+ // MetricsServlet is deprecated in hadoop 2.8 and removed in 3.0. We shouldn't expect it,
+ // so pass false so that we don't create a noisy warn during instantiation.
+ new ServletConfig("metrics", "/metrics", "org.apache.hadoop.metrics.MetricsServlet", false))
.put("prometheus", new ServletConfig("prometheus", "/prometheus",
"org.apache.hadoop.hbase.http.prometheus.PrometheusHadoopServlet"))
.build();
@@ -836,16 +838,19 @@ public class HttpServer implements FilterContainer {
/* register metrics servlets */
String[] enabledServlets = conf.getStrings(METRIC_SERVLETS_CONF_KEY, METRICS_SERVLETS_DEFAULT);
for (String enabledServlet : enabledServlets) {
- try {
- ServletConfig servletConfig = METRIC_SERVLETS.get(enabledServlet);
- if (servletConfig != null) {
+ ServletConfig servletConfig = METRIC_SERVLETS.get(enabledServlet);
+ if (servletConfig != null) {
+ try {
Class<?> clz = Class.forName(servletConfig.getClazz());
addPrivilegedServlet(servletConfig.getName(), servletConfig.getPathSpec(),
clz.asSubclass(HttpServlet.class));
+ } catch (Exception e) {
+ if (servletConfig.isExpected()) {
+ // metrics are not critical to read/write, so an exception here shouldn't be fatal
+ // if the class was expected we should warn though
+ LOG.warn("Couldn't register the servlet " + enabledServlet, e);
+ }
}
- } catch (Exception e) {
- /* shouldn't be fatal, so warn the user about it */
- LOG.warn("Couldn't register the servlet " + enabledServlet, e);
}
}
}
diff --git a/hbase-http/src/main/java/org/apache/hadoop/hbase/http/ServletConfig.java b/hbase-http/src/main/java/org/apache/hadoop/hbase/http/ServletConfig.java
index befe6095760..366dbfd9f22 100644
--- a/hbase-http/src/main/java/org/apache/hadoop/hbase/http/ServletConfig.java
+++ b/hbase-http/src/main/java/org/apache/hadoop/hbase/http/ServletConfig.java
@@ -23,14 +23,20 @@ import org.apache.yetus.audience.InterfaceAudience;
@InterfaceAudience.Private
class ServletConfig {
- private String name;
- private String pathSpec;
- private String clazz;
+ private final String name;
+ private final String pathSpec;
+ private final String clazz;
+ private final boolean expected;
public ServletConfig(String name, String pathSpec, String clazz) {
+ this(name, pathSpec, clazz, true);
+ }
+
+ public ServletConfig(String name, String pathSpec, String clazz, boolean expected) {
this.name = name;
this.pathSpec = pathSpec;
this.clazz = clazz;
+ this.expected = expected;
}
public String getName() {
@@ -44,4 +50,8 @@ class ServletConfig {
public String getClazz() {
return clazz;
}
+
+ public boolean isExpected() {
+ return expected;
+ }
}