diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobsWithProfiler.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobsWithProfiler.java index 9fa88287717..fa0c7d69764 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobsWithProfiler.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobsWithProfiler.java @@ -35,6 +35,7 @@ import org.apache.hadoop.mapreduce.*; import org.apache.hadoop.mapreduce.TaskAttemptID; import org.apache.hadoop.mapreduce.v2.api.records.JobId; +import org.apache.hadoop.util.Shell; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; @@ -43,6 +44,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.Assume.assumeFalse; + public class TestMRJobsWithProfiler { private static final Logger LOG = @@ -107,6 +110,8 @@ public static void tearDown() { @Test (timeout = 150000) public void testDefaultProfiler() throws Exception { + assumeFalse("The hprof agent has been removed since Java 9. Skipping.", + Shell.isJavaVersionAtLeast(9)); LOG.info("Starting testDefaultProfiler"); testProfilerInternal(true); } @@ -132,13 +137,21 @@ private void testProfilerInternal(boolean useDefault) throws Exception { sleepConf.setProfileTaskRange(false, String.valueOf(PROFILED_TASK_ID)); if (!useDefault) { - // use hprof for map to profile.out - sleepConf.set(MRJobConfig.TASK_MAP_PROFILE_PARAMS, - "-agentlib:hprof=cpu=samples,heap=sites,force=n,thread=y,verbose=n," - + "file=%s"); + if (Shell.isJavaVersionAtLeast(9)) { + // use JDK Flight Recorder + sleepConf.set(MRJobConfig.TASK_MAP_PROFILE_PARAMS, + "-XX:StartFlightRecording=dumponexit=true,filename=%s"); + sleepConf.set(MRJobConfig.TASK_REDUCE_PROFILE_PARAMS, + "-XX:StartFlightRecording=dumponexit=true,filename=%s"); + } else { + // use hprof for map to profile.out + sleepConf.set(MRJobConfig.TASK_MAP_PROFILE_PARAMS, + "-agentlib:hprof=cpu=samples,heap=sites,force=n,thread=y,verbose=n," + + "file=%s"); - // use Xprof for reduce to stdout - sleepConf.set(MRJobConfig.TASK_REDUCE_PROFILE_PARAMS, "-Xprof"); + // use Xprof for reduce to stdout + sleepConf.set(MRJobConfig.TASK_REDUCE_PROFILE_PARAMS, "-Xprof"); + } } sleepJob.setConf(sleepConf); @@ -211,6 +224,11 @@ private void testProfilerInternal(boolean useDefault) throws Exception { Assert.assertEquals(4, taLogDirs.size()); // all 4 attempts found + // Skip checking the contents because the JFR dumps binary files + if (Shell.isJavaVersionAtLeast(9)) { + return; + } + for (Map.Entry dirEntry : taLogDirs.entrySet()) { final TaskAttemptID tid = dirEntry.getKey(); final Path profilePath = new Path(dirEntry.getValue(),