HBASE-22225 Profiler tab on Master/RS UI not working w/o comprehensive message

This commit is contained in:
Andrew Purtell 2019-04-26 16:41:31 -07:00
parent e0cc651098
commit 6b6afc4830
No known key found for this signature in database
GPG Key ID: 8597754DD5365CCD
2 changed files with 26 additions and 2 deletions

View File

@ -698,6 +698,7 @@ public class HttpServer implements FilterContainer {
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.");
}

View File

@ -83,6 +83,7 @@ import org.slf4j.LoggerFactory;
*/
@InterfaceAudience.Private
public class ProfileServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(ProfileServlet.class);
@ -174,7 +175,10 @@ public class ProfileServlet extends HttpServlet {
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;
}
@ -355,7 +359,7 @@ public class ProfileServlet extends HttpServlet {
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);
@ -370,4 +374,23 @@ public class ProfileServlet extends HttpServlet {
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;
}
}
}