HDFS-9634. webhdfs client side exceptions don't provide enough details. Contributed by Eric Payne.
(cherry picked from commit 7b70500484574a565dd8cd5c7d8b5bc7c6d91154) Conflicts: hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
This commit is contained in:
parent
ca29933405
commit
e160ddfb8d
|
@ -22,6 +22,9 @@ Release 2.7.3 - UNRELEASED
|
|||
HDFS-9415. Document dfs.cluster.administrators and
|
||||
dfs.permissions.superusergroup. (Xiaobing Zhou via Arpit Agarwal)
|
||||
|
||||
HDFS-9634. webhdfs client side exceptions don't provide enough details
|
||||
(Eric Payne via kihwal)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
BUG FIXES
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.io.EOFException;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.MalformedURLException;
|
||||
|
@ -474,6 +475,7 @@ public class WebHdfsFileSystem extends FileSystem
|
|||
protected ExcludeDatanodesParam excludeDatanodes = new ExcludeDatanodesParam("");
|
||||
|
||||
private boolean checkRetry;
|
||||
private String redirectHost;
|
||||
|
||||
protected AbstractRunner(final HttpOpParam.Op op, boolean redirected) {
|
||||
this.op = op;
|
||||
|
@ -524,7 +526,7 @@ public class WebHdfsFileSystem extends FileSystem
|
|||
*/
|
||||
protected HttpURLConnection connect(URL url) throws IOException {
|
||||
//redirect hostname and port
|
||||
String redirectHost = null;
|
||||
redirectHost = null;
|
||||
|
||||
|
||||
// resolve redirects for a DN operation unless already resolved
|
||||
|
@ -630,6 +632,19 @@ public class WebHdfsFileSystem extends FileSystem
|
|||
throw it;
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
// Attempt to include the redirected node in the exception. If the
|
||||
// attempt to recreate the exception fails, just use the original.
|
||||
String node = redirectHost;
|
||||
if (node == null) {
|
||||
node = url.getAuthority();
|
||||
}
|
||||
try {
|
||||
ioe = ioe.getClass().getConstructor(String.class)
|
||||
.newInstance(node + ": " + ioe.getMessage());
|
||||
} catch (NoSuchMethodException | SecurityException
|
||||
| InstantiationException | IllegalAccessException
|
||||
| IllegalArgumentException | InvocationTargetException e) {
|
||||
}
|
||||
shouldRetry(ioe, retry);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ public class TestWebHdfsTimeouts {
|
|||
fs.listFiles(new Path("/"), false);
|
||||
fail("expected timeout");
|
||||
} catch (SocketTimeoutException e) {
|
||||
assertEquals("connect timed out", e.getMessage());
|
||||
assertEquals(fs.getUri().getAuthority() + ": connect timed out", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class TestWebHdfsTimeouts {
|
|||
fs.listFiles(new Path("/"), false);
|
||||
fail("expected timeout");
|
||||
} catch (SocketTimeoutException e) {
|
||||
assertEquals("Read timed out", e.getMessage());
|
||||
assertEquals(fs.getUri().getAuthority() + ": Read timed out", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ public class TestWebHdfsTimeouts {
|
|||
fs.getDelegationToken("renewer");
|
||||
fail("expected timeout");
|
||||
} catch (SocketTimeoutException e) {
|
||||
assertEquals("connect timed out", e.getMessage());
|
||||
assertEquals(fs.getUri().getAuthority() + ": connect timed out", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ public class TestWebHdfsTimeouts {
|
|||
fs.getDelegationToken("renewer");
|
||||
fail("expected timeout");
|
||||
} catch (SocketTimeoutException e) {
|
||||
assertEquals("Read timed out", e.getMessage());
|
||||
assertEquals(fs.getUri().getAuthority() + ": Read timed out", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ public class TestWebHdfsTimeouts {
|
|||
fs.getFileChecksum(new Path("/file"));
|
||||
fail("expected timeout");
|
||||
} catch (SocketTimeoutException e) {
|
||||
assertEquals("connect timed out", e.getMessage());
|
||||
assertEquals(fs.getUri().getAuthority() + ": connect timed out", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ public class TestWebHdfsTimeouts {
|
|||
fs.getFileChecksum(new Path("/file"));
|
||||
fail("expected timeout");
|
||||
} catch (SocketTimeoutException e) {
|
||||
assertEquals("Read timed out", e.getMessage());
|
||||
assertEquals(fs.getUri().getAuthority() + ": Read timed out", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ public class TestWebHdfsTimeouts {
|
|||
os = fs.create(new Path("/file"));
|
||||
fail("expected timeout");
|
||||
} catch (SocketTimeoutException e) {
|
||||
assertEquals("connect timed out", e.getMessage());
|
||||
assertEquals(fs.getUri().getAuthority() + ": connect timed out", e.getMessage());
|
||||
} finally {
|
||||
IOUtils.cleanup(LOG, os);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue