use of java.io.InputStreamReader in project hadoop by apache.
the class MapReduceTestUtil method readOutput.
// Return output of MR job by reading from the given output directory
public static String readOutput(Path outDir, Configuration conf) throws IOException {
FileSystem fs = outDir.getFileSystem(conf);
StringBuffer result = new StringBuffer();
Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir, new Utils.OutputFileUtils.OutputFilesFilter()));
for (Path outputFile : fileList) {
LOG.info("Path" + ": " + outputFile);
BufferedReader file = new BufferedReader(new InputStreamReader(fs.open(outputFile)));
String line = file.readLine();
while (line != null) {
result.append(line);
result.append("\n");
line = file.readLine();
}
file.close();
}
return result.toString();
}
use of java.io.InputStreamReader in project hadoop by apache.
the class TestMRJobClient method testListAttemptIds.
/**
* print AttemptIds list
*/
private void testListAttemptIds(String jobId, Configuration conf) throws Exception {
CLI jc = createJobClient();
ByteArrayOutputStream out = new ByteArrayOutputStream();
int exitCode = runTool(conf, jc, new String[] { "-list-attempt-ids" }, out);
assertEquals("Exit code", -1, exitCode);
exitCode = runTool(conf, jc, new String[] { "-list-attempt-ids", jobId, "MAP", "completed" }, out);
assertEquals("Exit code", 0, exitCode);
String line;
BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray())));
int counter = 0;
while ((line = br.readLine()) != null) {
LOG.info("line = " + line);
counter++;
}
assertEquals(1, counter);
}
use of java.io.InputStreamReader in project hadoop by apache.
the class TestMRJobClient method checkHistoryJSONOutput.
private void checkHistoryJSONOutput(String jobId, ByteArrayOutputStream out) throws IOException, JSONException {
BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray())));
String line = org.apache.commons.io.IOUtils.toString(br);
br.close();
JSONObject json = new JSONObject(line);
assertEquals(jobId, json.getString("hadoopJob"));
out.reset();
}
use of java.io.InputStreamReader in project hadoop by apache.
the class TestMRJobClient method checkHistoryHumanOutput.
private void checkHistoryHumanOutput(String jobId, ByteArrayOutputStream out) throws IOException, JSONException {
BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray())));
br.readLine();
String line = br.readLine();
br.close();
assertEquals("Hadoop job: " + jobId, line);
out.reset();
}
use of java.io.InputStreamReader in project hadoop by apache.
the class TestMRJobClient method testListTrackers.
/**
* print tracker list
*/
private void testListTrackers(Configuration conf) throws Exception {
CLI jc = createJobClient();
ByteArrayOutputStream out = new ByteArrayOutputStream();
int exitCode = runTool(conf, jc, new String[] { "-list-active-trackers", "second parameter" }, out);
assertEquals("Exit code", -1, exitCode);
exitCode = runTool(conf, jc, new String[] { "-list-active-trackers" }, out);
assertEquals("Exit code", 0, exitCode);
String line;
BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray())));
int counter = 0;
while ((line = br.readLine()) != null) {
LOG.info("line = " + line);
counter++;
}
assertEquals(2, counter);
}
Aggregations