diff --git a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/SimpleTcpServer.java b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/SimpleTcpServer.java index 99d1d6f083..f7ab52e3d5 100644 --- a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/SimpleTcpServer.java +++ b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/oncrpc/SimpleTcpServer.java @@ -81,6 +81,7 @@ public ChannelPipeline getPipeline() throws Exception { }); server.setOption("child.tcpNoDelay", true); server.setOption("child.keepAlive", true); + server.setOption("reuseAddress", true); // Listen to TCP port ch = server.bind(new InetSocketAddress(port)); diff --git a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/portmap/Portmap.java b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/portmap/Portmap.java index 2b887914f9..94d76d08fd 100644 --- a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/portmap/Portmap.java +++ b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/portmap/Portmap.java @@ -109,12 +109,14 @@ public ChannelPipeline getPipeline() throws Exception { RpcUtil.STAGE_RPC_TCP_RESPONSE); } }); + tcpServer.setOption("reuseAddress", true); udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory( Executors.newCachedThreadPool())); udpServer.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER, handler, RpcUtil.STAGE_RPC_UDP_RESPONSE)); + udpServer.setOption("reuseAddress", true); tcpChannel = tcpServer.bind(tcpAddress); udpChannel = udpServer.bind(udpAddress);