HDFS-2484. checkLease should throw FileNotFoundException when file does not exist. Contributed by Rakesh R.
This commit is contained in:
parent
b72507810a
commit
c75cfa29cf
@ -635,6 +635,9 @@ Release 2.8.0 - UNRELEASED
|
|||||||
HDFS-8310. Fix TestCLI.testAll "help: help for find" on Windows.
|
HDFS-8310. Fix TestCLI.testAll "help: help for find" on Windows.
|
||||||
(Kiran Kumar M R via Xiaoyu Yao)
|
(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
|
Release 2.7.1 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -3451,7 +3451,7 @@ private INodeFile checkLease(String src, String holder, INode inode,
|
|||||||
final String ident = src + " (inode " + fileId + ")";
|
final String ident = src + " (inode " + fileId + ")";
|
||||||
if (inode == null) {
|
if (inode == null) {
|
||||||
Lease lease = leaseManager.getLease(holder);
|
Lease lease = leaseManager.getLease(holder);
|
||||||
throw new LeaseExpiredException(
|
throw new FileNotFoundException(
|
||||||
"No lease on " + ident + ": File does not exist. "
|
"No lease on " + ident + ": File does not exist. "
|
||||||
+ (lease != null ? lease.toString()
|
+ (lease != null ? lease.toString()
|
||||||
: "Holder " + holder + " does not have any open files."));
|
: "Holder " + holder + " does not have any open files."));
|
||||||
|
@ -78,7 +78,6 @@
|
|||||||
import org.apache.hadoop.hdfs.server.datanode.SimulatedFSDataset;
|
import org.apache.hadoop.hdfs.server.datanode.SimulatedFSDataset;
|
||||||
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi;
|
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
|
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.LeaseManager;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter;
|
import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter;
|
||||||
@ -1212,8 +1211,8 @@ public void testFileIdMismatch() throws IOException {
|
|||||||
cluster.getNameNodeRpc()
|
cluster.getNameNodeRpc()
|
||||||
.complete(f.toString(), client.clientName, null, someOtherFileId);
|
.complete(f.toString(), client.clientName, null, someOtherFileId);
|
||||||
fail();
|
fail();
|
||||||
} catch(LeaseExpiredException e) {
|
} catch(FileNotFoundException e) {
|
||||||
FileSystem.LOG.info("Caught Expected LeaseExpiredException: ", e);
|
FileSystem.LOG.info("Caught Expected FileNotFoundException: ", e);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeStream(dfs);
|
IOUtils.closeStream(dfs);
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.PrivilegedExceptionAction;
|
import java.security.PrivilegedExceptionAction;
|
||||||
|
|
||||||
@ -50,6 +51,7 @@
|
|||||||
import org.apache.hadoop.ipc.RemoteException;
|
import org.apache.hadoop.ipc.RemoteException;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
import org.apache.hadoop.security.token.SecretManager.InvalidToken;
|
import org.apache.hadoop.security.token.SecretManager.InvalidToken;
|
||||||
|
import org.apache.hadoop.test.GenericTestUtils;
|
||||||
import org.apache.hadoop.util.Time;
|
import org.apache.hadoop.util.Time;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -322,7 +324,19 @@ public void testLease() throws Exception {
|
|||||||
Assert.assertTrue(!hasLease(cluster, a));
|
Assert.assertTrue(!hasLease(cluster, a));
|
||||||
Assert.assertTrue(!hasLease(cluster, b));
|
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);
|
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 {
|
} finally {
|
||||||
if (cluster != null) {cluster.shutdown();}
|
if (cluster != null) {cluster.shutdown();}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user