HDFS-10260. TestFsDatasetImpl#testCleanShutdownOfVolume often fails. Contributed by Rushabh Shah.
(cherry picked from commit af9b000535
)
This commit is contained in:
parent
50d06acb09
commit
a4db3729be
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hdfs.server.datanode.fsdataset.impl;
|
package org.apache.hadoop.hdfs.server.datanode.fsdataset.impl;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
@ -556,8 +557,8 @@ public class TestFsDatasetImpl {
|
||||||
out.hflush();
|
out.hflush();
|
||||||
|
|
||||||
ExtendedBlock block = DFSTestUtil.getFirstBlock(fs, filePath);
|
ExtendedBlock block = DFSTestUtil.getFirstBlock(fs, filePath);
|
||||||
FsVolumeImpl volume = (FsVolumeImpl) dataNode.getFSDataset().getVolume(
|
final FsVolumeImpl volume = (FsVolumeImpl) dataNode.getFSDataset().
|
||||||
block);
|
getVolume(block);
|
||||||
File finalizedDir = volume.getFinalizedDir(cluster.getNamesystem()
|
File finalizedDir = volume.getFinalizedDir(cluster.getNamesystem()
|
||||||
.getBlockPoolId());
|
.getBlockPoolId());
|
||||||
|
|
||||||
|
@ -572,9 +573,11 @@ public class TestFsDatasetImpl {
|
||||||
// Invoke the synchronous checkDiskError method
|
// Invoke the synchronous checkDiskError method
|
||||||
dataNode.getFSDataset().checkDataDir();
|
dataNode.getFSDataset().checkDataDir();
|
||||||
// Sleep for 1 second so that datanode can interrupt and cluster clean up
|
// Sleep for 1 second so that datanode can interrupt and cluster clean up
|
||||||
Thread.sleep(1000);
|
GenericTestUtils.waitFor(new Supplier<Boolean>() {
|
||||||
assertEquals("There are active threads still referencing volume: "
|
@Override public Boolean get() {
|
||||||
+ volume.getBasePath(), 0, volume.getReferenceCount());
|
return volume.getReferenceCount() == 0;
|
||||||
|
}
|
||||||
|
}, 100, 10);
|
||||||
LocatedBlock lb = DFSTestUtil.getAllBlocks(fs, filePath).get(0);
|
LocatedBlock lb = DFSTestUtil.getAllBlocks(fs, filePath).get(0);
|
||||||
DatanodeInfo info = lb.getLocations()[0];
|
DatanodeInfo info = lb.getLocations()[0];
|
||||||
|
|
||||||
|
@ -583,7 +586,7 @@ public class TestFsDatasetImpl {
|
||||||
Assert.fail("This is not a valid code path. "
|
Assert.fail("This is not a valid code path. "
|
||||||
+ "out.close should have thrown an exception.");
|
+ "out.close should have thrown an exception.");
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Assert.assertTrue(ioe.getMessage().contains(info.toString()));
|
GenericTestUtils.assertExceptionContains(info.toString(), ioe);
|
||||||
}
|
}
|
||||||
finalizedDir.setWritable(true);
|
finalizedDir.setWritable(true);
|
||||||
finalizedDir.setExecutable(true);
|
finalizedDir.setExecutable(true);
|
||||||
|
|
Loading…
Reference in New Issue