HDFS-11280. Allow WebHDFS to reuse HTTP connections to NN. Contributed by Zheng Shao.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/a605ff36 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/a605ff36 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/a605ff36 Branch: refs/heads/YARN-2915 Commit: a605ff36a53a3d1283c3f6d81eb073e4a2942143 Parents: 5ed63e3 Author: Haohui Mai <[email protected]> Authored: Wed Jan 4 21:01:23 2017 -0800 Committer: Haohui Mai <[email protected]> Committed: Wed Jan 4 21:01:23 2017 -0800 ---------------------------------------------------------------------- .../java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/a605ff36/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java index d4fa009..135eef7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java @@ -659,6 +659,8 @@ public class WebHdfsFileSystem extends FileSystem url = new URL(conn.getHeaderField("Location")); redirectHost = url.getHost() + ":" + url.getPort(); } finally { + // TODO: consider not calling conn.disconnect() to allow connection reuse + // See http://tinyurl.com/java7-http-keepalive conn.disconnect(); } } @@ -891,7 +893,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(); } } @@ -938,6 +942,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(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
