HADOOP-18077. ProfileOutputServlet unable to proceed due to NPE (#3875)

This commit is contained in:
Viraj Jasani 2022-01-12 13:50:34 +05:30 committed by GitHub
parent e2d620192a
commit 93294f0329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -772,10 +772,11 @@ private void initializeWebServer(String name, String hostName,
addDefaultServlets();
addPrometheusServlet(conf);
addAsyncProfilerServlet(contexts);
addAsyncProfilerServlet(contexts, conf);
}
private void addAsyncProfilerServlet(ContextHandlerCollection contexts) throws IOException {
private void addAsyncProfilerServlet(ContextHandlerCollection contexts, Configuration conf)
throws IOException {
final String asyncProfilerHome = ProfileServlet.getAsyncProfilerHome();
if (asyncProfilerHome != null && !asyncProfilerHome.trim().isEmpty()) {
addServlet("prof", "/prof", ProfileServlet.class);
@ -787,6 +788,7 @@ private void addAsyncProfilerServlet(ContextHandlerCollection contexts) throws I
genCtx.addServlet(ProfileOutputServlet.class, "/*");
genCtx.setResourceBase(tmpDir.toAbsolutePath().toString());
genCtx.setDisplayName("prof-output-hadoop");
setContextAttributes(genCtx, conf);
} else {
addServlet("prof", "/prof", ProfilerDisabledServlet.class);
LOG.info("ASYNC_PROFILER_HOME environment variable and async.profiler.home system property "

View File

@ -36,9 +36,15 @@ protected void doGet(final HttpServletRequest req, final HttpServletResponse res
throws IOException {
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
ProfileServlet.setResponseHeader(resp);
// TODO : Replace github.com link with
// https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/
// AsyncProfilerServlet.html once Async profiler changes are released
// in 3.x (3.4.0 as of today).
resp.getWriter().write("The profiler servlet was disabled at startup.\n\n"
+ "Please ensure the prerequisites for the Profiler Servlet have been installed and the\n"
+ "environment is properly configured.");
+ "environment is properly configured. \n\n"
+ "For more details, please refer to: https://github.com/apache/hadoop/blob/trunk/"
+ "hadoop-common-project/hadoop-common/src/site/markdown/AsyncProfilerServlet.md");
}
}