HDFS-13662. TestBlockReaderLocal#testStatisticsForErasureCodingRead is flaky

(cherry picked from commit 533138718c)
This commit is contained in:
Xiao Chen 2018-10-16 19:32:12 -07:00
parent 83769b63d4
commit 08b415d170
1 changed files with 7 additions and 3 deletions

View File

@ -28,6 +28,7 @@ import java.nio.ByteBuffer;
import java.util.UUID;
import java.util.concurrent.TimeoutException;
import org.apache.hadoop.fs.BlockLocation;
import org.apache.hadoop.fs.ChecksumException;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
@ -827,9 +828,12 @@ public class TestBlockReaderLocal {
Path ecFile = new Path(ecDir, "file2");
DFSTestUtil.createFile(fs, ecFile, length, repl, randomSeed);
// Shutdown one DataNode so that erasure coding decoding process can kick
// in.
cluster.shutdownDataNode(0);
// Shutdown a DataNode that holds a data block, to trigger EC decoding.
final BlockLocation[] locs = fs.getFileBlockLocations(ecFile, 0, length);
final String[] nodes = locs[0].getNames();
cluster.stopDataNode(nodes[0]);
try (HdfsDataInputStream in = (HdfsDataInputStream) fs.open(ecFile)) {
IOUtils.readFully(in, buf, 0, length);