hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject hadoop git commit: HDFS-2484. checkLease should throw FileNotFoundException when file does not exist. Contributed by Rakesh R.
Date Wed, 06 May 2015 23:24:37 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 28b40aca9 -> 193615c4b


HDFS-2484. checkLease should throw FileNotFoundException when file does not exist. Contributed
by Rakesh R.


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

Branch: refs/heads/branch-2
Commit: 193615c4b2ffe1e7cebbf4caa7e3f877fa86c231
Parents: 28b40ac
Author: Konstantin V Shvachko <shv@apache.org>
Authored: Wed May 6 16:06:04 2015 -0700
Committer: Konstantin V Shvachko <shv@apache.org>
Committed: Wed May 6 16:11:12 2015 -0700

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt         |  3 +++
 .../hadoop/hdfs/server/namenode/FSNamesystem.java   |  2 +-
 .../org/apache/hadoop/hdfs/TestFileCreation.java    |  5 ++---
 .../test/java/org/apache/hadoop/hdfs/TestLease.java | 16 +++++++++++++++-
 4 files changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/193615c4/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index 739456f..19fd4d5 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -311,6 +311,9 @@ Release 2.8.0 - UNRELEASED
     HDFS-8310. Fix TestCLI.testAll "help: help for find" on Windows.
     (Kiran Kumar M R via Xiaoyu Yao)
 
+    HDFS-2484. checkLease should throw FileNotFoundException when file does
+    not exist. (Rakesh R via shv)
+
 Release 2.7.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/193615c4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
index 035fdb4..b1b2782 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
@@ -3447,7 +3447,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
     final String ident = src + " (inode " + fileId + ")";
     if (inode == null) {
       Lease lease = leaseManager.getLease(holder);
-      throw new LeaseExpiredException(
+      throw new FileNotFoundException(
           "No lease on " + ident + ": File does not exist. "
           + (lease != null ? lease.toString()
               : "Holder " + holder + " does not have any open files."));

http://git-wip-us.apache.org/repos/asf/hadoop/blob/193615c4/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileCreation.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileCreation.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileCreation.java
index f56ff9e..f732ace 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileCreation.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileCreation.java
@@ -78,7 +78,6 @@ import org.apache.hadoop.hdfs.server.datanode.DataNodeTestUtils;
 import org.apache.hadoop.hdfs.server.datanode.SimulatedFSDataset;
 import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi;
 import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
-import org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException;
 import org.apache.hadoop.hdfs.server.namenode.LeaseManager;
 import org.apache.hadoop.hdfs.server.namenode.NameNode;
 import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter;
@@ -1212,8 +1211,8 @@ public class TestFileCreation {
         cluster.getNameNodeRpc()
             .complete(f.toString(), client.clientName, null, someOtherFileId);
         fail();
-      } catch(LeaseExpiredException e) {
-        FileSystem.LOG.info("Caught Expected LeaseExpiredException: ", e);
+      } catch(FileNotFoundException e) {
+        FileSystem.LOG.info("Caught Expected FileNotFoundException: ", e);
       }
     } finally {
       IOUtils.closeStream(dfs);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/193615c4/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLease.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLease.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLease.java
index 88dbd5e..90dc0a7 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLease.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLease.java
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.spy;
 
 import java.io.DataOutputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.security.PrivilegedExceptionAction;
 
@@ -50,6 +51,7 @@ import org.apache.hadoop.io.EnumSetWritable;
 import org.apache.hadoop.ipc.RemoteException;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.token.SecretManager.InvalidToken;
+import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.util.Time;
 import org.junit.Assert;
 import org.junit.Test;
@@ -321,8 +323,20 @@ public class TestLease {
 
       Assert.assertTrue(!hasLease(cluster, a));
       Assert.assertTrue(!hasLease(cluster, b));
-      
+
+      Path fileA = new Path(dir, "fileA");
+      FSDataOutputStream fileA_out = fs.create(fileA);
+      fileA_out.writeBytes("something");
+      Assert.assertTrue("Failed to get the lease!", hasLease(cluster, fileA));
+
       fs.delete(dir, true);
+      try {
+        fileA_out.hflush();
+        Assert.fail("Should validate file existence!");
+      } catch (FileNotFoundException e) {
+        // expected
+        GenericTestUtils.assertExceptionContains("File does not exist", e);
+      }
     } finally {
       if (cluster != null) {cluster.shutdown();}
     }


Mime
View raw message