Skip to content

Commit

Permalink
HBASE-29045 Script not found when enable profiler servlet
Browse files Browse the repository at this point in the history
  • Loading branch information
chaijunjie0101 committed Jan 19, 2025
1 parent 6f8db78 commit 7a985b7
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -67,7 +70,8 @@ public class ProfileServlet extends HttpServlet {
private static final String CONTENT_TYPE_TEXT = "text/plain; charset=utf-8";
private static final String ASYNC_PROFILER_HOME_ENV = "ASYNC_PROFILER_HOME";
private static final String ASYNC_PROFILER_HOME_SYSTEM_PROPERTY = "async.profiler.home";
private static final String PROFILER_SCRIPT = "/profiler.sh";
private static final String OLD_PROFILER_SCRIPT = "profiler.sh";
private static final String PROFILER_SCRIPT = "asprof";
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-hbase";
Expand Down Expand Up @@ -195,7 +199,13 @@ protected void doGet(final HttpServletRequest req, final HttpServletResponse res
new File(OUTPUT_DIR, "async-prof-pid-" + pid + "-" + event.name().toLowerCase() + "-"
+ ID_GEN.incrementAndGet() + "." + output.name().toLowerCase());
List<String> cmd = new ArrayList<>();
cmd.add(asyncProfilerHome + PROFILER_SCRIPT);
Path profilerScriptPath = Paths.get(asyncProfilerHome, "bin", PROFILER_SCRIPT);
if (!Files.exists(profilerScriptPath)) {
LOG.info("{} not exist, will use old async-profiler script path (version <= 2.9).",
profilerScriptPath);
profilerScriptPath = Paths.get(asyncProfilerHome, OLD_PROFILER_SCRIPT);
}
cmd.add(profilerScriptPath.toString());
cmd.add("-e");
cmd.add(event.getInternalName());
cmd.add("-d");
Expand Down

0 comments on commit 7a985b7

Please sign in to comment.