Skip to content

Commit

Permalink
addressing review
Browse files Browse the repository at this point in the history
  • Loading branch information
virajjasani committed Jan 4, 2022
1 parent 8501c77 commit 49bff7c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
Expand Up @@ -783,10 +783,10 @@ private void addAsyncProfilerServlet(ContextHandlerCollection contexts) throws I
if (Files.notExists(tmpDir)) {
Files.createDirectories(tmpDir);
}
ServletContextHandler genCtx = new ServletContextHandler(contexts, "/prof-output");
ServletContextHandler genCtx = new ServletContextHandler(contexts, "/prof-output-hadoop");
genCtx.addServlet(ProfileOutputServlet.class, "/*");
genCtx.setResourceBase(tmpDir.toAbsolutePath().toString());
genCtx.setDisplayName("prof-output");
genCtx.setDisplayName("prof-output-hadoop");
} else {
addServlet("prof", "/prof", ProfilerDisabledServlet.class);
LOG.info("ASYNC_PROFILER_HOME environment variable and async.profiler.home system property "
Expand Down
Expand Up @@ -110,7 +110,7 @@ public class ProfileServlet extends HttpServlet {
private static final int DEFAULT_DURATION_SECONDS = 10;
private static final AtomicInteger ID_GEN = new AtomicInteger(0);

static final String OUTPUT_DIR = System.getProperty("java.io.tmpdir") + "/prof-output";
static final String OUTPUT_DIR = System.getProperty("java.io.tmpdir") + "/prof-output-hadoop";

private enum Event {

Expand Down Expand Up @@ -279,7 +279,7 @@ protected void doGet(final HttpServletRequest req, final HttpServletResponse res
// set response and set refresh header to output location
setResponseHeader(resp);
resp.setStatus(HttpServletResponse.SC_ACCEPTED);
String relativeUrl = "/prof-output/" + outputFile.getName();
String relativeUrl = "/prof-output-hadoop/" + outputFile.getName();
resp.getWriter().write("Started [" + event.getInternalName()
+ "] profiling. This page will automatically redirect to " + relativeUrl + " after "
+ duration + " seconds. "
Expand Down
Expand Up @@ -28,6 +28,9 @@ HotSpot-specific APIs to collect stack traces and to track memory
allocations. The profiler works with OpenJDK, Oracle JDK and other
Java runtimes based on the HotSpot JVM.

Hadoop profiler servlet supports Async Profiler major versions
1.x and 2.x.

Prerequisites
-------------

Expand Down
Expand Up @@ -62,18 +62,27 @@ public void testQuery() throws Exception {
(HttpURLConnection) new URL(baseUrl, "/prof").openConnection();
assertEquals("GET", conn.getHeaderField(ProfileServlet.ACCESS_CONTROL_ALLOW_METHODS));
assertNotNull(conn.getHeaderField(ProfileServlet.ACCESS_CONTROL_ALLOW_ORIGIN));
conn.disconnect();
}

@Test
public void testRequestMethods() throws IOException {
HttpURLConnection connection = getConnection("PUT");
assertEquals("Unexpected response code", HttpServletResponse.SC_METHOD_NOT_ALLOWED,
getConnection("PUT").getResponseCode());
connection.getResponseCode());
connection.disconnect();
connection = getConnection("POST");
assertEquals("Unexpected response code", HttpServletResponse.SC_METHOD_NOT_ALLOWED,
getConnection("POST").getResponseCode());
connection.getResponseCode());
connection.disconnect();
connection = getConnection("DELETE");
assertEquals("Unexpected response code", HttpServletResponse.SC_METHOD_NOT_ALLOWED,
getConnection("DELETE").getResponseCode());
connection.getResponseCode());
connection.disconnect();
connection = getConnection("GET");
assertEquals("Unexpected response code", HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
getConnection("GET").getResponseCode());
connection.getResponseCode());
connection.disconnect();
}

private HttpURLConnection getConnection(final String method) throws IOException {
Expand Down

0 comments on commit 49bff7c

Please sign in to comment.