Skip to content

Commit 2045a9d

Browse files
authored
MAPREDUCE-7305. [JDK 11] TestMRJobsWithProfiler fails. (apache#2463)
1 parent a7b923c commit 2045a9d

File tree

1 file changed

+24
-6
lines changed
  • hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2

1 file changed

+24
-6
lines changed

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobsWithProfiler.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.apache.hadoop.mapreduce.*;
3636
import org.apache.hadoop.mapreduce.TaskAttemptID;
3737
import org.apache.hadoop.mapreduce.v2.api.records.JobId;
38+
import org.apache.hadoop.util.Shell;
3839
import org.apache.hadoop.yarn.api.records.ApplicationId;
3940
import org.apache.hadoop.yarn.conf.YarnConfiguration;
4041
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
@@ -43,6 +44,8 @@
4344
import org.slf4j.Logger;
4445
import org.slf4j.LoggerFactory;
4546

47+
import static org.junit.Assume.assumeFalse;
48+
4649
public class TestMRJobsWithProfiler {
4750

4851
private static final Logger LOG =
@@ -107,6 +110,8 @@ public static void tearDown() {
107110

108111
@Test (timeout = 150000)
109112
public void testDefaultProfiler() throws Exception {
113+
assumeFalse("The hprof agent has been removed since Java 9. Skipping.",
114+
Shell.isJavaVersionAtLeast(9));
110115
LOG.info("Starting testDefaultProfiler");
111116
testProfilerInternal(true);
112117
}
@@ -132,13 +137,21 @@ private void testProfilerInternal(boolean useDefault) throws Exception {
132137
sleepConf.setProfileTaskRange(false, String.valueOf(PROFILED_TASK_ID));
133138

134139
if (!useDefault) {
135-
// use hprof for map to profile.out
136-
sleepConf.set(MRJobConfig.TASK_MAP_PROFILE_PARAMS,
137-
"-agentlib:hprof=cpu=samples,heap=sites,force=n,thread=y,verbose=n,"
138-
+ "file=%s");
140+
if (Shell.isJavaVersionAtLeast(9)) {
141+
// use JDK Flight Recorder
142+
sleepConf.set(MRJobConfig.TASK_MAP_PROFILE_PARAMS,
143+
"-XX:StartFlightRecording=dumponexit=true,filename=%s");
144+
sleepConf.set(MRJobConfig.TASK_REDUCE_PROFILE_PARAMS,
145+
"-XX:StartFlightRecording=dumponexit=true,filename=%s");
146+
} else {
147+
// use hprof for map to profile.out
148+
sleepConf.set(MRJobConfig.TASK_MAP_PROFILE_PARAMS,
149+
"-agentlib:hprof=cpu=samples,heap=sites,force=n,thread=y,verbose=n,"
150+
+ "file=%s");
139151

140-
// use Xprof for reduce to stdout
141-
sleepConf.set(MRJobConfig.TASK_REDUCE_PROFILE_PARAMS, "-Xprof");
152+
// use Xprof for reduce to stdout
153+
sleepConf.set(MRJobConfig.TASK_REDUCE_PROFILE_PARAMS, "-Xprof");
154+
}
142155
}
143156

144157
sleepJob.setConf(sleepConf);
@@ -211,6 +224,11 @@ private void testProfilerInternal(boolean useDefault) throws Exception {
211224

212225
Assert.assertEquals(4, taLogDirs.size()); // all 4 attempts found
213226

227+
// Skip checking the contents because the JFR dumps binary files
228+
if (Shell.isJavaVersionAtLeast(9)) {
229+
return;
230+
}
231+
214232
for (Map.Entry<TaskAttemptID,Path> dirEntry : taLogDirs.entrySet()) {
215233
final TaskAttemptID tid = dirEntry.getKey();
216234
final Path profilePath = new Path(dirEntry.getValue(),

0 commit comments

Comments
 (0)