diff --git a/hbase-http/src/main/java/org/apache/hadoop/hbase/http/log/LogLevel.java b/hbase-http/src/main/java/org/apache/hadoop/hbase/http/log/LogLevel.java index 91b2615b81b9..e09d3576c510 100644 --- a/hbase-http/src/main/java/org/apache/hadoop/hbase/http/log/LogLevel.java +++ b/hbase-http/src/main/java/org/apache/hadoop/hbase/http/log/LogLevel.java @@ -336,6 +336,8 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) String logName = ServletUtil.getParameter(request, "log"); String level = ServletUtil.getParameter(request, "level"); + String[] readOnlyLogLevels = conf.getStrings("hbase.ui.readonly.logLevels"); + if (logName != null) { out.println("

Results:

"); out.println(MARKER @@ -345,6 +347,12 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) out.println(MARKER + "Log Class: " + log.getClass().getName() +"
"); if (level != null) { + if (!isLogLevelChangeAllowed(logName, readOnlyLogLevels)) { + response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED, + "Modification of logger " + logName + " not allowed."); + return; + } + out.println(MARKER + "Submitted Level: " + level + "
"); } process(log, level, out); @@ -360,6 +368,18 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) out.close(); } + private boolean isLogLevelChangeAllowed(String logger, String[] readOnlyLogLevels) { + if (readOnlyLogLevels == null) { + return true; + } + for (String readOnlyLogLevel : readOnlyLogLevels) { + if (readOnlyLogLevel.equals(logger)) { + return false; + } + } + return true; + } + static final String FORMS = "
\n" + "
\n" + "\n" + "
\n" + "Actions:" + "

"