HDFS-11280. Allow WebHDFS to reuse HTTP connections to NN. Contributed by Zheng Shao.

This commit is contained in:
Haohui Mai 2016-12-30 22:17:49 -08:00
parent d7b80f1b02
commit 0ff9efcf37
1 changed files with 9 additions and 2 deletions

View File

@ -663,7 +663,9 @@ public class WebHdfsFileSystem extends FileSystem
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 {
@ -895,7 +897,9 @@ public class WebHdfsFileSystem extends FileSystem
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();
}
}
@ -942,6 +946,9 @@ public class WebHdfsFileSystem extends FileSystem
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();
}
}