HDFS-8577. Avoid retrying to recover lease on a file which does not exist (Contributed by J.Andreina)
This commit is contained in:
parent
e59f6fad6a
commit
2eae130ab9
@ -1002,6 +1002,9 @@ Release 2.8.0 - UNRELEASED
|
|||||||
HDFS-8706. Fix typo in datanode startup options in HDFSCommands.html.
|
HDFS-8706. Fix typo in datanode startup options in HDFSCommands.html.
|
||||||
(Brahma Reddy Battula via Arpit Agarwal)
|
(Brahma Reddy Battula via Arpit Agarwal)
|
||||||
|
|
||||||
|
HDFS-8577. Avoid retrying to recover lease on a file which does not exist
|
||||||
|
(J.Andreina via vinayakumarb)
|
||||||
|
|
||||||
Release 2.7.2 - UNRELEASED
|
Release 2.7.2 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
@ -254,6 +255,11 @@ int run(List<String> args) throws IOException {
|
|||||||
IOException ioe = null;
|
IOException ioe = null;
|
||||||
try {
|
try {
|
||||||
recovered = dfs.recoverLease(new Path(pathStr));
|
recovered = dfs.recoverLease(new Path(pathStr));
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
System.err.println("recoverLease got exception: " + e.getMessage());
|
||||||
|
System.err.println("Giving up on recoverLease for " + pathStr +
|
||||||
|
" after 1 try");
|
||||||
|
return 1;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ioe = e;
|
ioe = e;
|
||||||
}
|
}
|
||||||
@ -262,8 +268,8 @@ int run(List<String> args) throws IOException {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (ioe != null) {
|
if (ioe != null) {
|
||||||
System.err.println("recoverLease got exception: ");
|
System.err.println("recoverLease got exception: " +
|
||||||
ioe.printStackTrace();
|
ioe.getMessage());
|
||||||
} else {
|
} else {
|
||||||
System.err.println("recoverLease returned false.");
|
System.err.println("recoverLease returned false.");
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
import static org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil.*;
|
import static org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.FsDatasetTestUtil.*;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class TestDebugAdmin {
|
public class TestDebugAdmin {
|
||||||
private MiniDFSCluster cluster;
|
private MiniDFSCluster cluster;
|
||||||
@ -116,4 +117,11 @@ public void testVerifyBlockChecksumCommand() throws Exception {
|
|||||||
"-block", blockFile.getAbsolutePath()})
|
"-block", blockFile.getAbsolutePath()})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(timeout = 60000)
|
||||||
|
public void testRecoverLeaseforFileNotFound() throws Exception {
|
||||||
|
assertTrue(runCmd(new String[] {
|
||||||
|
"recoverLease", "-path", "/foo", "-retries", "2" }).contains(
|
||||||
|
"Giving up on recoverLease for /foo after 1 try"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user