From 96ea12cd5be68d7bba668cb3fa922e33c8aa1ae6 Mon Sep 17 00:00:00 2001 From: Guangxu Cheng Date: Thu, 12 Apr 2018 17:48:17 +0800 Subject: [PATCH] Show Thrift server type on Thrift WebUI --- .../java/org/apache/hadoop/hbase/thrift/ThriftServer.java | 1 + .../org/apache/hadoop/hbase/thrift/ThriftServerRunner.java | 12 ++++++------ .../java/org/apache/hadoop/hbase/thrift2/ThriftServer.java | 4 +++- .../src/main/resources/hbase-webapps/thrift/thrift.jsp | 8 +++++++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java index d8b814e5a7..bfb25fa91e 100644 --- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java +++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java @@ -91,6 +91,7 @@ public class ThriftServer { processOptions(args); serverRunner = new ThriftServerRunner(conf); + conf.set("hbase.regionserver.thrift.server.type", ThriftMetrics.ThriftServerType.ONE.name()); // Put up info server. int port = conf.getInt("hbase.thrift.info.port", 9095); diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java index 39ea259426..9eeb62aa19 100644 --- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java +++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java @@ -155,8 +155,8 @@ public class ThriftServerRunner implements Runnable { private static final int DEFAULT_HTTP_MAX_HEADER_SIZE = 64 * 1024; // 64k - static final String SERVER_TYPE_CONF_KEY = - "hbase.regionserver.thrift.server.type"; + static final String THRIFT_IMPL_TYPE_CONF_KEY = + "hbase.regionserver.thrift.impl.type"; static final String BIND_CONF_KEY = "hbase.regionserver.thrift.ipaddress"; static final String COMPACT_CONF_KEY = "hbase.regionserver.thrift.compact"; @@ -275,7 +275,7 @@ public class ThriftServerRunner implements Runnable { } static ImplType getServerImpl(Configuration conf) { - String confType = conf.get(SERVER_TYPE_CONF_KEY, THREAD_POOL.option); + String confType = conf.get(THRIFT_IMPL_TYPE_CONF_KEY, THREAD_POOL.option); for (ImplType t : values()) { if (confType.equals(t.option)) { return t; @@ -294,14 +294,14 @@ public class ThriftServerRunner implements Runnable { } } if (numChosen < 1) { - LOG.info("Using default thrift server type"); + LOG.info("Using default thrift implementation type"); chosenType = DEFAULT; } else if (numChosen > 1) { throw new AssertionError("Exactly one option out of " + Arrays.toString(values()) + " has to be specified"); } - LOG.info("Using thrift server type " + chosenType.option); - conf.set(SERVER_TYPE_CONF_KEY, chosenType.option); + LOG.info("Using thrift implementation type " + chosenType.option); + conf.set(THRIFT_IMPL_TYPE_CONF_KEY, chosenType.option); } public String simpleClassName() { diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java index 5681569cc5..2df76f4e61 100644 --- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java +++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java @@ -447,7 +447,7 @@ public class ThriftServer extends Configured implements Tool { String implType = getImplType(nonblocking, hsha, selector); - conf.set("hbase.regionserver.thrift.server.type", implType); + conf.set("hbase.regionserver.thrift.impl.type", implType); conf.setInt("hbase.regionserver.thrift.port", listenPort); registerFilters(conf); @@ -508,6 +508,8 @@ public class ThriftServer extends Configured implements Tool { System.exit(1); } + // set the thrift server type + conf.set("hbase.regionserver.thrift.server.type", ThriftMetrics.ThriftServerType.TWO.name()); // Put up info server. startInfoServer(conf); diff --git a/hbase-thrift/src/main/resources/hbase-webapps/thrift/thrift.jsp b/hbase-thrift/src/main/resources/hbase-webapps/thrift/thrift.jsp index 579d0f7d38..e28b04abc2 100644 --- a/hbase-thrift/src/main/resources/hbase-webapps/thrift/thrift.jsp +++ b/hbase-thrift/src/main/resources/hbase-webapps/thrift/thrift.jsp @@ -29,9 +29,10 @@ Configuration conf = (Configuration)getServletContext().getAttribute("hbase.conf long startcode = conf.getLong("startcode", System.currentTimeMillis()); String listenPort = conf.get("hbase.regionserver.thrift.port", "9090"); String serverInfo = listenPort + "," + String.valueOf(startcode); -String implType = conf.get("hbase.regionserver.thrift.server.type", "threadpool"); +String implType = conf.get("hbase.regionserver.thrift.impl.type", "threadpool"); String compact = conf.get("hbase.regionserver.thrift.compact", "false"); String framed = conf.get("hbase.regionserver.thrift.framed", "false"); +String serverType = conf.get("hbase.regionserver.thrift.server.type", "unknown"); %> @@ -119,6 +120,11 @@ String framed = conf.get("hbase.regionserver.thrift.framed", "false"); <%= framed %> Thrift RPC engine uses framed transport + + Thrift Server Type + <%= serverType %> + The type of this Thrift server + -- 2.13.0