HDFS-13337. Backport HDFS-4275 to branch-2.9. Contributed by Xiao Liang.

This commit is contained in:
Inigo Goiri 2018-04-03 13:55:44 -07:00
parent b8d8c25a18
commit 4276a858f8

View File

@ -126,6 +126,7 @@ public class TestBlockRecovery {
private DataNode spyDN;
private BlockRecoveryWorker recoveryWorker;
private Configuration conf;
private boolean tearDownDone;
private final static long RECOVERY_ID = 3000L;
private final static String CLUSTER_ID = "testClusterID";
private final static String POOL_ID = "BP-TEST";
@ -156,6 +157,7 @@ public class TestBlockRecovery {
*/
@Before
public void startUp() throws IOException, URISyntaxException {
tearDownDone = false;
conf = new HdfsConfiguration();
conf.set(DFSConfigKeys.DFS_DATANODE_DATA_DIR_KEY, DATA_DIR);
conf.set(DFSConfigKeys.DFS_DATANODE_ADDRESS_KEY, "0.0.0.0:0");
@ -252,7 +254,7 @@ public Boolean get() {
*/
@After
public void tearDown() throws IOException {
if (dn != null) {
if (!tearDownDone && dn != null) {
try {
dn.shutdown();
} catch(Exception e) {
@ -263,6 +265,7 @@ public void tearDown() throws IOException {
Assert.assertTrue(
"Cannot delete data-node dirs", FileUtil.fullyDelete(dir));
}
tearDownDone = true;
}
}