|
19 | 19 |
|
20 | 20 | import java.io.File;
|
21 | 21 | import java.io.IOException;
|
| 22 | +import java.nio.file.Files; |
| 23 | +import java.nio.file.Path; |
| 24 | +import java.nio.file.Paths; |
22 | 25 | import java.util.ArrayList;
|
23 | 26 | import java.util.List;
|
24 | 27 | import java.util.concurrent.TimeUnit;
|
@@ -67,7 +70,8 @@ public class ProfileServlet extends HttpServlet {
|
67 | 70 | private static final String CONTENT_TYPE_TEXT = "text/plain; charset=utf-8";
|
68 | 71 | private static final String ASYNC_PROFILER_HOME_ENV = "ASYNC_PROFILER_HOME";
|
69 | 72 | 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"; |
71 | 75 | private static final int DEFAULT_DURATION_SECONDS = 10;
|
72 | 76 | private static final AtomicInteger ID_GEN = new AtomicInteger(0);
|
73 | 77 | 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
|
195 | 199 | new File(OUTPUT_DIR, "async-prof-pid-" + pid + "-" + event.name().toLowerCase() + "-"
|
196 | 200 | + ID_GEN.incrementAndGet() + "." + output.name().toLowerCase());
|
197 | 201 | 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()); |
199 | 210 | cmd.add("-e");
|
200 | 211 | cmd.add(event.getInternalName());
|
201 | 212 | cmd.add("-d");
|
|
0 commit comments