hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wan...@apache.org
Subject [33/50] [abbrv] hadoop git commit: HDFS-10293. StripedFileTestUtil#readAll flaky. Contributed by Mingliang Liu.
Date Sat, 16 Apr 2016 00:08:13 GMT
HDFS-10293. StripedFileTestUtil#readAll flaky. Contributed by Mingliang Liu.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/55e19b7f
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/55e19b7f
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/55e19b7f

Branch: refs/heads/YARN-3368
Commit: 55e19b7f0c1243090dff2d08ed785cefd420b009
Parents: 89a8387
Author: Jing Zhao <jing9@apache.org>
Authored: Fri Apr 15 10:53:40 2016 -0700
Committer: Jing Zhao <jing9@apache.org>
Committed: Fri Apr 15 10:53:40 2016 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hdfs/StripedFileTestUtil.java | 21 ++++++--------------
 1 file changed, 6 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/55e19b7f/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/StripedFileTestUtil.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/StripedFileTestUtil.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/StripedFileTestUtil.java
index 0f0221c..6d0dfa8 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/StripedFileTestUtil.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/StripedFileTestUtil.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.hdfs.protocol.LocatedStripedBlock;
 import org.apache.hadoop.hdfs.server.namenode.ErasureCodingPolicyManager;
 import org.apache.hadoop.hdfs.util.StripedBlockUtil;
 import org.apache.hadoop.hdfs.web.WebHdfsFileSystem.WebHdfsInputStream;
+import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.io.erasurecode.CodecUtil;
 import org.apache.hadoop.io.erasurecode.rawcoder.RawErasureEncoder;
 import org.junit.Assert;
@@ -85,16 +86,6 @@ public class StripedFileTestUtil {
     return (byte) (pos % mod + 1);
   }
 
-  static int readAll(FSDataInputStream in, byte[] buf) throws IOException {
-    int readLen = 0;
-    int ret;
-    while ((ret = in.read(buf, readLen, buf.length - readLen)) >= 0 &&
-        readLen <= buf.length) {
-      readLen += ret;
-    }
-    return readLen;
-  }
-
   static void verifyLength(FileSystem fs, Path srcPath, int fileLength)
       throws IOException {
     FileStatus status = fs.getFileStatus(srcPath);
@@ -214,11 +205,11 @@ public class StripedFileTestUtil {
   static void assertSeekAndRead(FSDataInputStream fsdis, int pos,
       int writeBytes) throws IOException {
     fsdis.seek(pos);
-    byte[] buf = new byte[writeBytes];
-    int readLen = StripedFileTestUtil.readAll(fsdis, buf);
-    assertEquals(readLen, writeBytes - pos);
-    for (int i = 0; i < readLen; i++) {
-      assertEquals("Byte at " + i + " should be the same", StripedFileTestUtil.getByte(pos
+ i), buf[i]);
+    byte[] buf = new byte[writeBytes - pos];
+    IOUtils.readFully(fsdis, buf, 0, buf.length);
+    for (int i = 0; i < buf.length; i++) {
+      assertEquals("Byte at " + i + " should be the same",
+          StripedFileTestUtil.getByte(pos + i), buf[i]);
     }
   }
 


Mime
View raw message