Skip to content

Commit

Permalink
HBASE-22225 Profiler tab on Master/RS UI not working w/o comprehensiv…
Browse files Browse the repository at this point in the history
…e message
  • Loading branch information
apurtell committed Apr 29, 2019
1 parent 729072e commit 4b84ab3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ protected void addDefaultServlets(ContextHandlerCollection contexts) throws IOEx
genCtx.setResourceBase(tmpDir.toAbsolutePath().toString());
genCtx.setDisplayName("prof-output");
} else {
addServlet("prof", "/prof", ProfileServlet.DisabledServlet.class);
LOG.info("ASYNC_PROFILER_HOME environment variable and async.profiler.home system property " +
"not specified. Disabling /prof endpoint.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
*/
@InterfaceAudience.Private
public class ProfileServlet extends HttpServlet {

private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(ProfileServlet.class);

Expand Down Expand Up @@ -176,7 +177,10 @@ protected void doGet(final HttpServletRequest req, final HttpServletResponse res
if (asyncProfilerHome == null || asyncProfilerHome.trim().isEmpty()) {
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
setResponseHeader(resp);
resp.getWriter().write("ASYNC_PROFILER_HOME env is not set.");
resp.getWriter().write("ASYNC_PROFILER_HOME env is not set.\n\n" +
"Please ensure the prerequsites for the Profiler Servlet have been installed and the\n" +
"environment is properly configured. For more information please see\n" +
"http://hbase.apache.org/book.html#profiler\n");
return;
}

Expand Down Expand Up @@ -357,7 +361,7 @@ private Output getOutput(final HttpServletRequest req) {
return Output.SVG;
}

private void setResponseHeader(final HttpServletResponse response) {
private static void setResponseHeader(final HttpServletResponse response) {
response.setHeader(ACCESS_CONTROL_ALLOW_METHODS, ALLOWED_METHODS);
response.setHeader(ACCESS_CONTROL_ALLOW_ORIGIN, "*");
response.setContentType(CONTENT_TYPE_TEXT);
Expand All @@ -372,4 +376,23 @@ static String getAsyncProfilerHome() {

return asyncProfilerHome;
}

public static class DisabledServlet extends HttpServlet {

private static final long serialVersionUID = 1L;

@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
throws IOException {
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
setResponseHeader(resp);
resp.getWriter().write("The profiler servlet was disabled at startup.\n\n" +
"Please ensure the prerequsites for the Profiler Servlet have been installed and the\n" +
"environment is properly configured. For more information please see\n" +
"http://hbase.apache.org/book.html#profiler\n");
return;
}

}

}

0 comments on commit 4b84ab3

Please sign in to comment.