|
@@ -42,6 +42,11 @@ public class TestPipes extends TestCase {
|
|
private static final Log LOG =
|
|
private static final Log LOG =
|
|
LogFactory.getLog(TestPipes.class.getName());
|
|
LogFactory.getLog(TestPipes.class.getName());
|
|
|
|
|
|
|
|
+ static void cleanup(FileSystem fs, Path p) throws IOException {
|
|
|
|
+ FileUtil.fullyDelete(fs, p);
|
|
|
|
+ assertFalse("output not cleaned up", fs.exists(p));
|
|
|
|
+ }
|
|
|
|
+
|
|
public void testPipes() throws IOException {
|
|
public void testPipes() throws IOException {
|
|
if (System.getProperty("compile.c++") == null) {
|
|
if (System.getProperty("compile.c++") == null) {
|
|
LOG.info("compile.c++ is not defined, so skipping TestPipes");
|
|
LOG.info("compile.c++ is not defined, so skipping TestPipes");
|
|
@@ -49,7 +54,6 @@ public class TestPipes extends TestCase {
|
|
}
|
|
}
|
|
MiniDFSCluster dfs = null;
|
|
MiniDFSCluster dfs = null;
|
|
MiniMRCluster mr = null;
|
|
MiniMRCluster mr = null;
|
|
- FileSystem fs = null;
|
|
|
|
Path cppExamples = new Path(System.getProperty("install.c++.examples"));
|
|
Path cppExamples = new Path(System.getProperty("install.c++.examples"));
|
|
Path inputPath = new Path("/testing/in");
|
|
Path inputPath = new Path("/testing/in");
|
|
Path outputPath = new Path("/testing/out");
|
|
Path outputPath = new Path("/testing/out");
|
|
@@ -57,20 +61,19 @@ public class TestPipes extends TestCase {
|
|
final int numSlaves = 2;
|
|
final int numSlaves = 2;
|
|
Configuration conf = new Configuration();
|
|
Configuration conf = new Configuration();
|
|
dfs = new MiniDFSCluster(conf, numSlaves, true, null);
|
|
dfs = new MiniDFSCluster(conf, numSlaves, true, null);
|
|
- fs = dfs.getFileSystem();
|
|
|
|
- mr = new MiniMRCluster(numSlaves, fs.getName(), 1);
|
|
|
|
- writeInputFile(fs, inputPath);
|
|
|
|
- runProgram(mr, fs, new Path(cppExamples, "bin/wordcount-simple"),
|
|
|
|
|
|
+ mr = new MiniMRCluster(numSlaves, dfs.getFileSystem().getName(), 1);
|
|
|
|
+ writeInputFile(dfs.getFileSystem(), inputPath);
|
|
|
|
+ runProgram(mr, dfs, new Path(cppExamples, "bin/wordcount-simple"),
|
|
inputPath, outputPath, 3, 2, twoSplitOutput);
|
|
inputPath, outputPath, 3, 2, twoSplitOutput);
|
|
- FileUtil.fullyDelete(fs, outputPath);
|
|
|
|
- assertFalse("output not cleaned up", fs.exists(outputPath));
|
|
|
|
- runProgram(mr, fs, new Path(cppExamples, "bin/wordcount-simple"),
|
|
|
|
|
|
+ cleanup(dfs.getFileSystem(), outputPath);
|
|
|
|
+
|
|
|
|
+ runProgram(mr, dfs, new Path(cppExamples, "bin/wordcount-simple"),
|
|
inputPath, outputPath, 3, 0, noSortOutput);
|
|
inputPath, outputPath, 3, 0, noSortOutput);
|
|
- FileUtil.fullyDelete(fs, outputPath);
|
|
|
|
- assertFalse("output not cleaned up", fs.exists(outputPath));
|
|
|
|
- runProgram(mr, fs, new Path(cppExamples, "bin/wordcount-part"),
|
|
|
|
|
|
+ cleanup(dfs.getFileSystem(), outputPath);
|
|
|
|
+
|
|
|
|
+ runProgram(mr, dfs, new Path(cppExamples, "bin/wordcount-part"),
|
|
inputPath, outputPath, 3, 2, fixedPartitionOutput);
|
|
inputPath, outputPath, 3, 2, fixedPartitionOutput);
|
|
- runNonPipedProgram(mr, fs, new Path(cppExamples, "bin/wordcount-nopipe"));
|
|
|
|
|
|
+ runNonPipedProgram(mr, dfs, new Path(cppExamples,"bin/wordcount-nopipe"));
|
|
mr.waitUntilIdle();
|
|
mr.waitUntilIdle();
|
|
} finally {
|
|
} finally {
|
|
mr.shutdown();
|
|
mr.shutdown();
|
|
@@ -126,25 +129,28 @@ public class TestPipes extends TestCase {
|
|
out.close();
|
|
out.close();
|
|
}
|
|
}
|
|
|
|
|
|
- private void runProgram(MiniMRCluster mr, FileSystem fs,
|
|
|
|
|
|
+ private void runProgram(MiniMRCluster mr, MiniDFSCluster dfs,
|
|
Path program, Path inputPath, Path outputPath,
|
|
Path program, Path inputPath, Path outputPath,
|
|
int numMaps, int numReduces, String[] expectedResults
|
|
int numMaps, int numReduces, String[] expectedResults
|
|
) throws IOException {
|
|
) throws IOException {
|
|
Path wordExec = new Path("/testing/bin/application");
|
|
Path wordExec = new Path("/testing/bin/application");
|
|
- FileUtil.fullyDelete(fs, wordExec.getParent());
|
|
|
|
- fs.copyFromLocalFile(program, wordExec);
|
|
|
|
JobConf job = mr.createJobConf();
|
|
JobConf job = mr.createJobConf();
|
|
job.setNumMapTasks(numMaps);
|
|
job.setNumMapTasks(numMaps);
|
|
job.setNumReduceTasks(numReduces);
|
|
job.setNumReduceTasks(numReduces);
|
|
- Submitter.setExecutable(job, fs.makeQualified(wordExec).toString());
|
|
|
|
- Submitter.setIsJavaRecordReader(job, true);
|
|
|
|
- Submitter.setIsJavaRecordWriter(job, true);
|
|
|
|
- job.setInputPath(inputPath);
|
|
|
|
- job.setOutputPath(outputPath);
|
|
|
|
- RunningJob result = Submitter.submitJob(job);
|
|
|
|
- assertTrue("pipes job failed", result.isSuccessful());
|
|
|
|
|
|
+ {
|
|
|
|
+ FileSystem fs = dfs.getFileSystem();
|
|
|
|
+ FileUtil.fullyDelete(fs, wordExec.getParent());
|
|
|
|
+ fs.copyFromLocalFile(program, wordExec);
|
|
|
|
+ Submitter.setExecutable(job, fs.makeQualified(wordExec).toString());
|
|
|
|
+ Submitter.setIsJavaRecordReader(job, true);
|
|
|
|
+ Submitter.setIsJavaRecordWriter(job, true);
|
|
|
|
+ job.setInputPath(inputPath);
|
|
|
|
+ job.setOutputPath(outputPath);
|
|
|
|
+ RunningJob result = Submitter.submitJob(job);
|
|
|
|
+ assertTrue("pipes job failed", result.isSuccessful());
|
|
|
|
+ }
|
|
List<String> results = new ArrayList<String>();
|
|
List<String> results = new ArrayList<String>();
|
|
- for (Path p:fs.listPaths(outputPath)) {
|
|
|
|
|
|
+ for (Path p:dfs.getFileSystem().listPaths(outputPath)) {
|
|
results.add(TestMiniMRWithDFS.readOutput(p, job));
|
|
results.add(TestMiniMRWithDFS.readOutput(p, job));
|
|
}
|
|
}
|
|
assertEquals("number of reduces is wrong",
|
|
assertEquals("number of reduces is wrong",
|
|
@@ -163,7 +169,7 @@ public class TestPipes extends TestCase {
|
|
* @param program the program to run
|
|
* @param program the program to run
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
- private void runNonPipedProgram(MiniMRCluster mr, FileSystem dfs,
|
|
|
|
|
|
+ private void runNonPipedProgram(MiniMRCluster mr, MiniDFSCluster dfs,
|
|
Path program) throws IOException {
|
|
Path program) throws IOException {
|
|
JobConf job = mr.createJobConf();
|
|
JobConf job = mr.createJobConf();
|
|
job.setInputFormat(WordCountInputFormat.class);
|
|
job.setInputFormat(WordCountInputFormat.class);
|
|
@@ -174,8 +180,11 @@ public class TestPipes extends TestCase {
|
|
Path outDir = new Path(testDir, "output");
|
|
Path outDir = new Path(testDir, "output");
|
|
Path wordExec = new Path("/testing/bin/application");
|
|
Path wordExec = new Path("/testing/bin/application");
|
|
Path jobXml = new Path(testDir, "job.xml");
|
|
Path jobXml = new Path(testDir, "job.xml");
|
|
- FileUtil.fullyDelete(dfs, wordExec.getParent());
|
|
|
|
- dfs.copyFromLocalFile(program, wordExec);
|
|
|
|
|
|
+ {
|
|
|
|
+ FileSystem fs = dfs.getFileSystem();
|
|
|
|
+ FileUtil.fullyDelete(fs, wordExec.getParent());
|
|
|
|
+ fs.copyFromLocalFile(program, wordExec);
|
|
|
|
+ }
|
|
DataOutputStream out = local.create(new Path(inDir, "part0"));
|
|
DataOutputStream out = local.create(new Path(inDir, "part0"));
|
|
out.writeBytes("i am a silly test\n");
|
|
out.writeBytes("i am a silly test\n");
|
|
out.writeBytes("you are silly\n");
|
|
out.writeBytes("you are silly\n");
|
|
@@ -193,7 +202,7 @@ public class TestPipes extends TestCase {
|
|
"-input", inDir.toString(),
|
|
"-input", inDir.toString(),
|
|
"-output", outDir.toString(),
|
|
"-output", outDir.toString(),
|
|
"-program",
|
|
"-program",
|
|
- dfs.makeQualified(wordExec).toString(),
|
|
|
|
|
|
+ dfs.getFileSystem().makeQualified(wordExec).toString(),
|
|
"-reduces", "2"});
|
|
"-reduces", "2"});
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
assertTrue("got exception: " + StringUtils.stringifyException(e), false);
|
|
assertTrue("got exception: " + StringUtils.stringifyException(e), false);
|