hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sur...@apache.org
Subject svn commit: r1167430 - in /hadoop/common/branches/branch-0.20-security: CHANGES.txt src/test/org/apache/hadoop/hdfs/AppendTestUtil.java src/test/org/apache/hadoop/hdfs/server/namenode/TestDFSConcurrentFileOperations.java
Date Sat, 10 Sep 2011 01:14:45 GMT
Author: suresh
Date: Sat Sep 10 01:14:45 2011
New Revision: 1167430

URL: http://svn.apache.org/viewvc?rev=1167430&view=rev
Log:
HDFS-1252. Fix TestDFSConcurrentFileOperations. Contributed by Todd Lipcon.

Modified:
    hadoop/common/branches/branch-0.20-security/CHANGES.txt
    hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/AppendTestUtil.java
    hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/server/namenode/TestDFSConcurrentFileOperations.java

Modified: hadoop/common/branches/branch-0.20-security/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/CHANGES.txt?rev=1167430&r1=1167429&r2=1167430&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20-security/CHANGES.txt Sat Sep 10 01:14:45 2011
@@ -122,6 +122,9 @@ Release 0.20.205.0 - unreleased
     HDFS-1186. DNs should interrupt writers at start of recovery.
     (Todd Lipcon via suresh)
 
+    HDFS-1252. Fix TestDFSConcurrentFileOperations.
+    (Todd Lipcon via suresh).
+
   IMPROVEMENTS
 
     MAPREDUCE-2187. Reporter sends progress during sort/merge. (Anupam Seth via

Modified: hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/AppendTestUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/AppendTestUtil.java?rev=1167430&r1=1167429&r2=1167430&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/AppendTestUtil.java
(original)
+++ hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/AppendTestUtil.java
Sat Sep 10 01:14:45 2011
@@ -38,7 +38,7 @@ import org.apache.hadoop.hdfs.protocol.F
 import org.apache.hadoop.security.UserGroupInformation;
 
 /** Utilities for append-related tests */ 
-class AppendTestUtil {
+public class AppendTestUtil {
   /** For specifying the random number generator seed,
    *  change the following value:
    */
@@ -95,7 +95,7 @@ class AppendTestUtil {
     return DFSTestUtil.getFileSystemAs(ugi, conf);
   }
 
-  static void write(OutputStream out, int offset, int length) throws IOException {
+  public static void write(OutputStream out, int offset, int length) throws IOException {
     final byte[] bytes = new byte[length];
     for(int i = 0; i < length; i++) {
       bytes[i] = (byte)(offset + i);
@@ -103,7 +103,7 @@ class AppendTestUtil {
     out.write(bytes);
   }
   
-  static void check(FileSystem fs, Path p, long length) throws IOException {
+  public static void check(FileSystem fs, Path p, long length) throws IOException {
     int i = -1;
     try {
       final FileStatus status = fs.getFileStatus(p);

Modified: hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/server/namenode/TestDFSConcurrentFileOperations.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/server/namenode/TestDFSConcurrentFileOperations.java?rev=1167430&r1=1167429&r2=1167430&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/server/namenode/TestDFSConcurrentFileOperations.java
(original)
+++ hadoop/common/branches/branch-0.20-security/src/test/org/apache/hadoop/hdfs/server/namenode/TestDFSConcurrentFileOperations.java
Sat Sep 10 01:14:45 2011
@@ -23,6 +23,7 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.AppendTestUtil;
 import org.apache.hadoop.hdfs.DFSTestUtil;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.hdfs.protocol.Block;
@@ -73,6 +74,7 @@ public class TestDFSConcurrentFileOperat
     Configuration conf = new Configuration();
     
     conf.setLong("dfs.block.size", blockSize);
+    conf.setBoolean("dfs.support.append", true);
     
     init(conf);
     
@@ -81,23 +83,10 @@ public class TestDFSConcurrentFileOperat
     Path srcPath = new Path(src);
     Path dstPath = new Path(dst);
     FSDataOutputStream fos = fs.create(srcPath);
-    
-    fos.write(DFSTestUtil.generateSequentialBytes(0, writeSize));
+   
+    AppendTestUtil.write(fos, 0, writeSize);
     fos.sync();
     
-    LocatedBlocks blocks;
-    int i = 0;
-    do {
-      blocks = cluster
-        .getNameNode()
-        .getNamesystem()
-        .getBlockLocations(src, 0, writeSize);
-    } while (blocks.getLocatedBlocks().isEmpty() && ++i < 1000);
-    
-    assertTrue("failed to get block for file", i < 1000);
-
-    Block block = blocks.get(blocks.getLocatedBlocks().size()-1).getBlock();
-    
     // renaming a file out from under a client will cause close to fail
     // and result in the lease remaining while the blocks are finalized on
     // the DNs
@@ -110,7 +99,8 @@ public class TestDFSConcurrentFileOperat
       //expected
     }
 
-    // simulate what lease recovery does--tries to update block and finalize
-    cluster.getDataNodes().get(0).updateBlock(block, block, true);
+    FileSystem fs2 = AppendTestUtil.createHdfsWithDifferentUsername(conf);
+    AppendTestUtil.recoverFile(cluster, fs2, dstPath);
+    AppendTestUtil.check(fs2, dstPath, writeSize);
   }
 }



Mime
View raw message