|
@@ -239,6 +239,29 @@ public class TestWebHdfsDataLocality {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testExcludeWrongDataNode() throws Exception {
|
|
|
+ final Configuration conf = WebHdfsTestUtil.createConf();
|
|
|
+ final String[] racks = {RACK0};
|
|
|
+ final String[] hosts = {"DataNode1"};
|
|
|
+ final int nDataNodes = hosts.length;
|
|
|
+
|
|
|
+ final MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
|
|
|
+ .hosts(hosts).numDataNodes(nDataNodes).racks(racks).build();
|
|
|
+ try {
|
|
|
+ cluster.waitActive();
|
|
|
+ final NameNode namenode = cluster.getNameNode();
|
|
|
+ NamenodeWebHdfsMethods.chooseDatanode(
|
|
|
+ namenode, "/path", PutOpParam.Op.CREATE, 0,
|
|
|
+ DFSConfigKeys.DFS_BLOCK_SIZE_DEFAULT,
|
|
|
+ "DataNode2", LOCALHOST, null);
|
|
|
+ } catch (Exception e) {
|
|
|
+ Assert.fail("Failed to exclude DataNode2" + e.getMessage());
|
|
|
+ } finally {
|
|
|
+ cluster.shutdown();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testChooseDatanodeBeforeNamesystemInit() throws Exception {
|
|
|
NameNode nn = mock(NameNode.class);
|