HDFS-9634. webhdfs client side exceptions don't provide enough details. Contributed by Eric Payne.
This commit is contained in:
parent
446987e20a
commit
3616c7b855
@ -24,6 +24,7 @@
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@ -502,6 +503,7 @@ abstract class AbstractRunner<T> {
|
|||||||
new ExcludeDatanodesParam("");
|
new ExcludeDatanodesParam("");
|
||||||
|
|
||||||
private boolean checkRetry;
|
private boolean checkRetry;
|
||||||
|
private String redirectHost;
|
||||||
|
|
||||||
protected AbstractRunner(final HttpOpParam.Op op, boolean redirected) {
|
protected AbstractRunner(final HttpOpParam.Op op, boolean redirected) {
|
||||||
this.op = op;
|
this.op = op;
|
||||||
@ -553,7 +555,7 @@ public T run() throws IOException {
|
|||||||
*/
|
*/
|
||||||
protected HttpURLConnection connect(URL url) throws IOException {
|
protected HttpURLConnection connect(URL url) throws IOException {
|
||||||
//redirect hostname and port
|
//redirect hostname and port
|
||||||
String redirectHost = null;
|
redirectHost = null;
|
||||||
|
|
||||||
|
|
||||||
// resolve redirects for a DN operation unless already resolved
|
// resolve redirects for a DN operation unless already resolved
|
||||||
@ -658,6 +660,19 @@ private T runWithRetry() throws IOException {
|
|||||||
throw it;
|
throw it;
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) {
|
} 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);
|
shouldRetry(ioe, retry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2624,6 +2624,9 @@ Release 2.7.3 - UNRELEASED
|
|||||||
HDFS-9569. Log the name of the fsimage being loaded for better
|
HDFS-9569. Log the name of the fsimage being loaded for better
|
||||||
supportability. (Yongjun Zhang)
|
supportability. (Yongjun Zhang)
|
||||||
|
|
||||||
|
HDFS-9634. webhdfs client side exceptions don't provide enough details
|
||||||
|
(Eric Payne via kihwal)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
@ -115,7 +115,7 @@ public void testConnectTimeout() throws Exception {
|
|||||||
fs.listFiles(new Path("/"), false);
|
fs.listFiles(new Path("/"), false);
|
||||||
fail("expected timeout");
|
fail("expected timeout");
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
assertEquals("connect timed out", e.getMessage());
|
assertEquals(fs.getUri().getAuthority() + ": connect timed out", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ public void testReadTimeout() throws Exception {
|
|||||||
fs.listFiles(new Path("/"), false);
|
fs.listFiles(new Path("/"), false);
|
||||||
fail("expected timeout");
|
fail("expected timeout");
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
assertEquals("Read timed out", e.getMessage());
|
assertEquals(fs.getUri().getAuthority() + ": Read timed out", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public void testAuthUrlConnectTimeout() throws Exception {
|
|||||||
fs.getDelegationToken("renewer");
|
fs.getDelegationToken("renewer");
|
||||||
fail("expected timeout");
|
fail("expected timeout");
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
assertEquals("connect timed out", e.getMessage());
|
assertEquals(fs.getUri().getAuthority() + ": connect timed out", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ public void testAuthUrlReadTimeout() throws Exception {
|
|||||||
fs.getDelegationToken("renewer");
|
fs.getDelegationToken("renewer");
|
||||||
fail("expected timeout");
|
fail("expected timeout");
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
assertEquals("Read timed out", e.getMessage());
|
assertEquals(fs.getUri().getAuthority() + ": Read timed out", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ public void testRedirectConnectTimeout() throws Exception {
|
|||||||
fs.getFileChecksum(new Path("/file"));
|
fs.getFileChecksum(new Path("/file"));
|
||||||
fail("expected timeout");
|
fail("expected timeout");
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
assertEquals("connect timed out", e.getMessage());
|
assertEquals(fs.getUri().getAuthority() + ": connect timed out", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ public void testRedirectReadTimeout() throws Exception {
|
|||||||
fs.getFileChecksum(new Path("/file"));
|
fs.getFileChecksum(new Path("/file"));
|
||||||
fail("expected timeout");
|
fail("expected timeout");
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
assertEquals("Read timed out", e.getMessage());
|
assertEquals(fs.getUri().getAuthority() + ": Read timed out", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ public void testTwoStepWriteConnectTimeout() throws Exception {
|
|||||||
os = fs.create(new Path("/file"));
|
os = fs.create(new Path("/file"));
|
||||||
fail("expected timeout");
|
fail("expected timeout");
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
assertEquals("connect timed out", e.getMessage());
|
assertEquals(fs.getUri().getAuthority() + ": connect timed out", e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.cleanup(LOG, os);
|
IOUtils.cleanup(LOG, os);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user