Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-29045 Support new async-profiler > 2.9 version #6614

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,14 @@ 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(
"async-profiler script {} does not exist, fallback to use old script {}(version <= 2.9).",
PROFILER_SCRIPT, OLD_PROFILER_SCRIPT);
profilerScriptPath = Paths.get(asyncProfilerHome, OLD_PROFILER_SCRIPT);
}
cmd.add(profilerScriptPath.toString());
cmd.add("-e");
cmd.add(event.getInternalName());
cmd.add("-d");
Expand Down