Skip to content

Commit e17b7ef

Browse files
committed
MAPREDUCE-7284. TestCombineFileInputFormat#testMissingBlocks fails (#2136)
(cherry picked from commit 3e7b65c)
1 parent 5f5d7ec commit e17b7ef

File tree

1 file changed

+7
-19
lines changed
  • hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/lib/input

1 file changed

+7
-19
lines changed

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/lib/input/TestCombineFileInputFormat.java

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,22 +1625,15 @@ public void testSplitPlacementForCompressedFiles() throws Exception {
16251625
*/
16261626
@Test
16271627
public void testMissingBlocks() throws Exception {
1628-
String namenode = null;
1629-
MiniDFSCluster dfs = null;
1630-
FileSystem fileSys = null;
1631-
String testName = "testMissingBlocks";
1632-
try {
1633-
Configuration conf = new Configuration();
1634-
conf.set("fs.hdfs.impl", MissingBlockFileSystem.class.getName());
1635-
conf.setBoolean("dfs.replication.considerLoad", false);
1636-
dfs = new MiniDFSCluster.Builder(conf).racks(rack1).hosts(hosts1)
1637-
.build();
1628+
final Configuration conf = new Configuration();
1629+
conf.set("fs.hdfs.impl", MissingBlockFileSystem.class.getName());
1630+
conf.setBoolean("dfs.replication.considerLoad", false);
1631+
try (MiniDFSCluster dfs = new MiniDFSCluster.Builder(conf)
1632+
.racks(rack1).hosts(hosts1).build()) {
16381633
dfs.waitActive();
16391634

1640-
namenode = (dfs.getFileSystem()).getUri().getHost() + ":" +
1641-
(dfs.getFileSystem()).getUri().getPort();
1642-
1643-
fileSys = dfs.getFileSystem();
1635+
final FileSystem fileSys =
1636+
MissingBlockFileSystem.newInstance(dfs.getURI(), conf);
16441637
if (!fileSys.mkdirs(inDir)) {
16451638
throw new IOException("Mkdirs failed to create " + inDir.toString());
16461639
}
@@ -1672,11 +1665,6 @@ public void testMissingBlocks() throws Exception {
16721665
assertEquals(0, fileSplit.getOffset(1));
16731666
assertEquals(BLOCKSIZE, fileSplit.getLength(1));
16741667
assertEquals(hosts1[0], fileSplit.getLocations()[0]);
1675-
1676-
} finally {
1677-
if (dfs != null) {
1678-
dfs.shutdown();
1679-
}
16801668
}
16811669
}
16821670

0 commit comments

Comments
 (0)