HDFS-11280. Allow WebHDFS to reuse HTTP connections to NN. Contributed by Zheng Shao.
This commit is contained in:
parent
165d01a73e
commit
b811a1c14d
@ -659,7 +659,9 @@ protected HttpURLConnection connect(URL url) throws IOException {
|
||||
url = new URL(conn.getHeaderField("Location"));
|
||||
redirectHost = url.getHost() + ":" + url.getPort();
|
||||
} finally {
|
||||
conn.disconnect();
|
||||
// Don't call conn.disconnect() to allow connection reuse
|
||||
// See http://tinyurl.com/java7-http-keepalive
|
||||
conn.getInputStream().close();
|
||||
}
|
||||
}
|
||||
try {
|
||||
@ -891,7 +893,9 @@ final T getResponse(HttpURLConnection conn) throws IOException {
|
||||
LOG.debug("Response decoding failure.", e);
|
||||
throw ioe;
|
||||
} finally {
|
||||
conn.disconnect();
|
||||
// Don't call conn.disconnect() to allow connection reuse
|
||||
// See http://tinyurl.com/java7-http-keepalive
|
||||
conn.getInputStream().close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -938,6 +942,9 @@ public void close() throws IOException {
|
||||
try {
|
||||
validateResponse(op, conn, true);
|
||||
} finally {
|
||||
// This is a connection to DataNode. Let's disconnect since
|
||||
// there is little chance that the connection will be reused
|
||||
// any time soonl
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user