From 181437cccf3aa39e56783e581478fde63583b827 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Tue, 12 Jan 2016 10:46:22 -0800 Subject: [PATCH] HADOOP-12653. Use SO_REUSEADDR to avoid getting "Address already in use" when using kerberos and attempting to bind to any port on the local IP address (cmccabe) (cherry picked from commit 30c7dfd8ba87fe1b455ad6c05c0a6cd6486f55b7) --- hadoop-common-project/hadoop-common/CHANGES.txt | 4 ++++ .../src/main/java/org/apache/hadoop/ipc/Client.java | 1 + 2 files changed, 5 insertions(+) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index f1b5f36ec2f..75f459e84b7 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -18,6 +18,10 @@ Release 2.9.0 - UNRELEASED HADOOP-12663. Remove Hard-Coded Values From FileSystem.java. (BELUGA BEHR via stevel) + HADOOP-12653. Use SO_REUSEADDR to avoid getting "Address already in use" + when using kerberos and attempting to bind to any port on the local IP + address (cmccabe) + BUG FIXES HADOOP-12655. TestHttpServer.testBindAddress bind port range is wider diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java index 8100237824b..1d460994027 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java @@ -625,6 +625,7 @@ public class Client { // If host name is a valid local address then bind socket to it InetAddress localAddr = NetUtils.getLocalInetAddress(host); if (localAddr != null) { + this.socket.setReuseAddress(true); this.socket.bind(new InetSocketAddress(localAddr, 0)); } }