|
@@ -19,11 +19,13 @@
|
|
package org.apache.hadoop.mapred;
|
|
package org.apache.hadoop.mapred;
|
|
|
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
|
+import org.apache.hadoop.fs.FileSystem;
|
|
import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.mapreduce.MRJobConfig;
|
|
import org.apache.hadoop.mapreduce.MRJobConfig;
|
|
import org.apache.hadoop.mapreduce.jobhistory.EventType;
|
|
import org.apache.hadoop.mapreduce.jobhistory.EventType;
|
|
import org.apache.hadoop.mapreduce.jobhistory.TestJobHistoryEventHandler;
|
|
import org.apache.hadoop.mapreduce.jobhistory.TestJobHistoryEventHandler;
|
|
import org.apache.hadoop.mapreduce.v2.MiniMRYarnCluster;
|
|
import org.apache.hadoop.mapreduce.v2.MiniMRYarnCluster;
|
|
|
|
+import org.apache.hadoop.test.GenericTestUtils;
|
|
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntities;
|
|
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntities;
|
|
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
|
|
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
@@ -145,21 +147,21 @@ public class TestMRTimelineEventHandling {
|
|
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
|
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
|
conf.setBoolean(MRJobConfig.MAPREDUCE_JOB_EMIT_TIMELINE_DATA, false);
|
|
conf.setBoolean(MRJobConfig.MAPREDUCE_JOB_EMIT_TIMELINE_DATA, false);
|
|
MiniMRYarnCluster cluster = null;
|
|
MiniMRYarnCluster cluster = null;
|
|
|
|
+ FileSystem fs = null;
|
|
|
|
+ Path inDir = new Path(GenericTestUtils.getTempPath("input"));
|
|
|
|
+ Path outDir = new Path(GenericTestUtils.getTempPath("output"));
|
|
try {
|
|
try {
|
|
|
|
+ fs = FileSystem.get(conf);
|
|
cluster = new MiniMRYarnCluster(
|
|
cluster = new MiniMRYarnCluster(
|
|
TestJobHistoryEventHandler.class.getSimpleName(), 1);
|
|
TestJobHistoryEventHandler.class.getSimpleName(), 1);
|
|
cluster.init(conf);
|
|
cluster.init(conf);
|
|
cluster.start();
|
|
cluster.start();
|
|
conf.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS,
|
|
conf.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS,
|
|
MiniYARNCluster.getHostname() + ":"
|
|
MiniYARNCluster.getHostname() + ":"
|
|
- + cluster.getApplicationHistoryServer().getPort());
|
|
|
|
|
|
+ + cluster.getApplicationHistoryServer().getPort());
|
|
TimelineStore ts = cluster.getApplicationHistoryServer()
|
|
TimelineStore ts = cluster.getApplicationHistoryServer()
|
|
.getTimelineStore();
|
|
.getTimelineStore();
|
|
|
|
|
|
- String localPathRoot = System.getProperty("test.build.data",
|
|
|
|
- "build/test/data");
|
|
|
|
- Path inDir = new Path(localPathRoot, "input");
|
|
|
|
- Path outDir = new Path(localPathRoot, "output");
|
|
|
|
RunningJob job =
|
|
RunningJob job =
|
|
UtilsForTests.runJobSucceed(new JobConf(conf), inDir, outDir);
|
|
UtilsForTests.runJobSucceed(new JobConf(conf), inDir, outDir);
|
|
Assert.assertEquals(JobStatus.SUCCEEDED,
|
|
Assert.assertEquals(JobStatus.SUCCEEDED,
|
|
@@ -181,6 +183,7 @@ public class TestMRTimelineEventHandling {
|
|
if (cluster != null) {
|
|
if (cluster != null) {
|
|
cluster.stop();
|
|
cluster.stop();
|
|
}
|
|
}
|
|
|
|
+ deletePaths(fs, inDir, outDir);
|
|
}
|
|
}
|
|
|
|
|
|
conf = new YarnConfiguration();
|
|
conf = new YarnConfiguration();
|
|
@@ -194,15 +197,10 @@ public class TestMRTimelineEventHandling {
|
|
cluster.start();
|
|
cluster.start();
|
|
conf.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS,
|
|
conf.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS,
|
|
MiniYARNCluster.getHostname() + ":"
|
|
MiniYARNCluster.getHostname() + ":"
|
|
- + cluster.getApplicationHistoryServer().getPort());
|
|
|
|
|
|
+ + cluster.getApplicationHistoryServer().getPort());
|
|
TimelineStore ts = cluster.getApplicationHistoryServer()
|
|
TimelineStore ts = cluster.getApplicationHistoryServer()
|
|
.getTimelineStore();
|
|
.getTimelineStore();
|
|
|
|
|
|
- String localPathRoot = System.getProperty("test.build.data",
|
|
|
|
- "build/test/data");
|
|
|
|
- Path inDir = new Path(localPathRoot, "input");
|
|
|
|
- Path outDir = new Path(localPathRoot, "output");
|
|
|
|
-
|
|
|
|
conf.setBoolean(MRJobConfig.MAPREDUCE_JOB_EMIT_TIMELINE_DATA, false);
|
|
conf.setBoolean(MRJobConfig.MAPREDUCE_JOB_EMIT_TIMELINE_DATA, false);
|
|
RunningJob job =
|
|
RunningJob job =
|
|
UtilsForTests.runJobSucceed(new JobConf(conf), inDir, outDir);
|
|
UtilsForTests.runJobSucceed(new JobConf(conf), inDir, outDir);
|
|
@@ -225,6 +223,20 @@ public class TestMRTimelineEventHandling {
|
|
if (cluster != null) {
|
|
if (cluster != null) {
|
|
cluster.stop();
|
|
cluster.stop();
|
|
}
|
|
}
|
|
|
|
+ deletePaths(fs, inDir, outDir);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /** Delete input paths recursively. Paths should not be null. */
|
|
|
|
+ private void deletePaths(FileSystem fs, Path... paths) {
|
|
|
|
+ if (fs == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (Path path : paths) {
|
|
|
|
+ try {
|
|
|
|
+ fs.delete(path, true);
|
|
|
|
+ } catch (Exception ignored) {
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|