Author: shv
Date: Mon Apr 12 21:34:32 2010
New Revision: 933426
URL: http://svn.apache.org/viewvc?rev=933426&view=rev
Log:
HDFS-1072. Fix TestReadWhileWriting failure. Contributed by Erik Steffl.
Modified:
hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestReadWhileWriting.java
Modified:
hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
URL:
http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=933426&r1=933425&r2=933426&view=diff
==============================================================================
---
hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
(original)
+++
hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
Mon Apr 12 21:34:32 2010
@@ -1206,12 +1206,21 @@ public class FSNamesystem implements FSC
"Failed to close file " + src +
". Lease recovery is in progress. Try again later.");
- } else
- throw new AlreadyBeingCreatedException("failed to create file " +
- src + " for " + holder + " on client " + clientMachine +
- ", because this file is already being created by " +
- pendingFile.getClientName() +
- " on " + pendingFile.getClientMachine());
+ } else {
+ if(pendingFile.getLastBlock().getBlockUCState() ==
+ BlockUCState.UNDER_RECOVERY) {
+ throw new RecoveryInProgressException(
+ "Recovery in progress, file [" + src + "], " +
+ "lease owner [" + lease.getHolder() + "]");
+ } else {
+ throw new AlreadyBeingCreatedException(
+ "Failed to create file [" + src + "] for [" + holder +
+ "] on client [" + clientMachine +
+ "], because this file is already being created by [" +
+ pendingFile.getClientName() + "] on [" +
+ pendingFile.getClientMachine() + "]");
+ }
+ }
}
try {
Modified:
hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestReadWhileWriting.java
URL:
http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestReadWhileWriting.java?rev=933426&r1=933425&r2=933426&view=diff
==============================================================================
---
hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestReadWhileWriting.java
(original)
+++
hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestReadWhileWriting.java
Mon Apr 12 21:34:32 2010
@@ -45,7 +45,10 @@ public class TestReadWhileWriting {
private static final String DIR = "/"
+ TestReadWhileWriting.class.getSimpleName() + "/";
private static final int BLOCK_SIZE = 8192;
- private static final long LEASE_LIMIT = 500;
+ // soft limit is short and hard limit is long, to test that
+ // another thread can lease file after soft limit expired
+ private static final long SOFT_LEASE_LIMIT = 500;
+ private static final long HARD_LEASE_LIMIT = 1000*600;
/** Test reading while writing. */
@Test
@@ -59,7 +62,7 @@ public class TestReadWhileWriting {
final MiniDFSCluster cluster = new MiniDFSCluster(conf, 3, true, null);
try {
//change the lease limits.
- cluster.setLeasePeriod(LEASE_LIMIT, LEASE_LIMIT);
+ cluster.setLeasePeriod(SOFT_LEASE_LIMIT, HARD_LEASE_LIMIT);
//wait for the cluster
cluster.waitActive();
@@ -89,7 +92,7 @@ public class TestReadWhileWriting {
//c. On M1, append another half block of data. Close file on M1.
{
//sleep to let the lease is expired.
- Thread.sleep(2*LEASE_LIMIT);
+ Thread.sleep(2*SOFT_LEASE_LIMIT);
final DistributedFileSystem dfs =
(DistributedFileSystem)FileSystem.newInstance(conf);
final FSDataOutputStream out = append(dfs, p);