Skip to content

Commit 5b66a53

Browse files
HBASE-29045 Support new async-profiler > 2.9 version (#6614)
Signed-off-by: Nihal Jain <[email protected]> Signed-off-by: Pankaj Kumar<[email protected]> Reviewed-by: Aman Poonia <[email protected]>
1 parent cde8be1 commit 5b66a53

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

hbase-http/src/main/java/org/apache/hadoop/hbase/http/ProfileServlet.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
import java.io.File;
2121
import java.io.IOException;
22+
import java.nio.file.Files;
23+
import java.nio.file.Path;
24+
import java.nio.file.Paths;
2225
import java.util.ArrayList;
2326
import java.util.List;
2427
import java.util.concurrent.TimeUnit;
@@ -67,7 +70,8 @@ public class ProfileServlet extends HttpServlet {
6770
private static final String CONTENT_TYPE_TEXT = "text/plain; charset=utf-8";
6871
private static final String ASYNC_PROFILER_HOME_ENV = "ASYNC_PROFILER_HOME";
6972
private static final String ASYNC_PROFILER_HOME_SYSTEM_PROPERTY = "async.profiler.home";
70-
private static final String PROFILER_SCRIPT = "/profiler.sh";
73+
private static final String OLD_PROFILER_SCRIPT = "profiler.sh";
74+
private static final String PROFILER_SCRIPT = "asprof";
7175
private static final int DEFAULT_DURATION_SECONDS = 10;
7276
private static final AtomicInteger ID_GEN = new AtomicInteger(0);
7377
static final String OUTPUT_DIR = System.getProperty("java.io.tmpdir") + "/prof-output-hbase";
@@ -195,7 +199,14 @@ protected void doGet(final HttpServletRequest req, final HttpServletResponse res
195199
new File(OUTPUT_DIR, "async-prof-pid-" + pid + "-" + event.name().toLowerCase() + "-"
196200
+ ID_GEN.incrementAndGet() + "." + output.name().toLowerCase());
197201
List<String> cmd = new ArrayList<>();
198-
cmd.add(asyncProfilerHome + PROFILER_SCRIPT);
202+
Path profilerScriptPath = Paths.get(asyncProfilerHome, "bin", PROFILER_SCRIPT);
203+
if (!Files.exists(profilerScriptPath)) {
204+
LOG.info(
205+
"async-profiler script {} does not exist, fallback to use old script {}(version <= 2.9).",
206+
PROFILER_SCRIPT, OLD_PROFILER_SCRIPT);
207+
profilerScriptPath = Paths.get(asyncProfilerHome, OLD_PROFILER_SCRIPT);
208+
}
209+
cmd.add(profilerScriptPath.toString());
199210
cmd.add("-e");
200211
cmd.add(event.getInternalName());
201212
cmd.add("-d");

0 commit comments

Comments
 (0)