HDFS-9476. TestDFSUpgradeFromImage#testUpgradeFromRel1BBWImage occasionally fail. Contributed by Masatake Iwasaki.

This commit is contained in:
Akira Ajisaka 2016-06-02 18:52:47 +09:00
parent 16b1cc7af9
commit 69555fca06

View File

@ -173,7 +173,7 @@ private void verifyChecksum(String path, long checksum) throws IOException {
private static FSInputStream dfsOpenFileWithRetries(DistributedFileSystem dfs, private static FSInputStream dfsOpenFileWithRetries(DistributedFileSystem dfs,
String pathName) throws IOException { String pathName) throws IOException {
IOException exc = null; IOException exc = null;
for (int tries = 0; tries < 10; tries++) { for (int tries = 0; tries < 30; tries++) {
try { try {
return dfs.dfs.open(pathName); return dfs.dfs.open(pathName);
} catch (IOException e) { } catch (IOException e) {
@ -184,6 +184,7 @@ private static FSInputStream dfsOpenFileWithRetries(DistributedFileSystem dfs,
throw exc; throw exc;
} }
try { try {
LOG.info("Open failed. " + tries + " times. Retrying.");
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException ignored) {} } catch (InterruptedException ignored) {}
} }
@ -570,8 +571,17 @@ static void recoverAllLeases(DFSClient dfs,
String pathStr = path.toString(); String pathStr = path.toString();
HdfsFileStatus status = dfs.getFileInfo(pathStr); HdfsFileStatus status = dfs.getFileInfo(pathStr);
if (!status.isDir()) { if (!status.isDir()) {
dfs.recoverLease(pathStr); for (int retries = 10; retries > 0; retries--) {
if (dfs.recoverLease(pathStr)) {
return; return;
} else {
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
}
}
throw new IOException("Failed to recover lease of " + path);
} }
byte prev[] = HdfsFileStatus.EMPTY_NAME; byte prev[] = HdfsFileStatus.EMPTY_NAME;
DirectoryListing dirList; DirectoryListing dirList;