From 16c0f3224b1365c808838e09b8e07ac70b05b9b2 Mon Sep 17 00:00:00 2001 From: Balazs Meszaros Date: Mon, 16 Apr 2018 16:33:48 +0200 Subject: [PATCH] HBASE-20427 thrift.jsp displays "Framed transport" incorrectly --- .../hbase/thrift/ThriftServerRunner.java | 24 +++++++++++++------ .../resources/hbase-webapps/thrift/thrift.jsp | 11 +++++---- 2 files changed, 23 insertions(+), 12 deletions(-) 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..eaf880ee94 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 @@ -138,6 +138,7 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.hbase.thirdparty.com.google.common.base.Joiner; +import org.apache.hbase.thirdparty.com.google.common.base.Splitter; import org.apache.hbase.thirdparty.com.google.common.base.Throwables; import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder; import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine; @@ -223,7 +224,7 @@ public class ThriftServerRunner implements Runnable { private final JvmPauseMonitor pauseMonitor; /** An enum of server implementation selections */ - enum ImplType { + public enum ImplType { HS_HA("hsha", true, THsHaServer.class, true), NONBLOCKING("nonblocking", true, TNonblockingServer.class, true), THREAD_POOL("threadpool", false, TBoundedThreadPoolServer.class, true), @@ -237,7 +238,7 @@ public class ThriftServerRunner implements Runnable { final Class serverClass; final boolean canSpecifyBindIP; - ImplType(String option, boolean isAlwaysFramed, + private ImplType(String option, boolean isAlwaysFramed, Class serverClass, boolean canSpecifyBindIP) { this.option = option; this.isAlwaysFramed = isAlwaysFramed; @@ -254,7 +255,15 @@ public class ThriftServerRunner implements Runnable { return "-" + option; } - String getDescription() { + public String getOption() { + return option; + } + + public boolean isAlwaysFramed() { + return isAlwaysFramed; + } + + public String getDescription() { StringBuilder sb = new StringBuilder("Use the " + serverClass.getSimpleName()); if (isAlwaysFramed) { @@ -274,7 +283,7 @@ public class ThriftServerRunner implements Runnable { return group; } - static ImplType getServerImpl(Configuration conf) { + public static ImplType getServerImpl(Configuration conf) { String confType = conf.get(SERVER_TYPE_CONF_KEY, THREAD_POOL.option); for (ImplType t : values()) { if (confType.equals(t.option)) { @@ -1977,13 +1986,14 @@ public class ThriftServerRunner implements Runnable { public static void registerFilters(Configuration conf) { String[] filters = conf.getStrings("hbase.thrift.filters"); + Splitter splitter = Splitter.on(':'); if(filters != null) { for(String filterClass: filters) { - String[] filterPart = filterClass.split(":"); - if(filterPart.length != 2) { + List filterPart = splitter.splitToList(":"); + if(filterPart.size() != 2) { LOG.warn("Invalid filter specification " + filterClass + " - skipping"); } else { - ParseFilter.registerFilter(filterPart[0], filterPart[1]); + ParseFilter.registerFilter(filterPart.get(0), filterPart.get(1)); } } } 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..eb329fecb1 100644 --- a/hbase-thrift/src/main/resources/hbase-webapps/thrift/thrift.jsp +++ b/hbase-thrift/src/main/resources/hbase-webapps/thrift/thrift.jsp @@ -20,6 +20,7 @@ <%@ page contentType="text/html;charset=UTF-8" import="org.apache.hadoop.conf.Configuration" import="org.apache.hadoop.hbase.HBaseConfiguration" + import="org.apache.hadoop.hbase.thrift.ThriftServerRunner.ImplType" import="org.apache.hadoop.hbase.util.VersionInfo" import="java.util.Date" %> @@ -29,9 +30,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"); +ImplType implType = ImplType.getServerImpl(conf); +String framed = implType.isAlwaysFramed() + ? "true" : conf.get("hbase.regionserver.thrift.framed", "false"); String compact = conf.get("hbase.regionserver.thrift.compact", "false"); -String framed = conf.get("hbase.regionserver.thrift.framed", "false"); %> @@ -69,9 +71,8 @@ String framed = conf.get("hbase.regionserver.thrift.framed", "false"); <% } %> - - +
@@ -106,7 +107,7 @@ String framed = conf.get("hbase.regionserver.thrift.framed", "false"); Thrift Impl Type - <%= implType %> + <%= implType.getOption() %> Thrift RPC engine implementation type chosen by this Thrift server -- 2.17.0