Skip to content

Commit 4b610c8

Browse files
author
Steve Vaughan Jr
committed
HADOOP-18365. Update the remote address when a change is detected
Avoid reconnecting to the old address after detecting that the address has been updated.
1 parent 0f36539 commit 4b610c8

File tree

1 file changed

+12
-1
lines changed
  • hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc

1 file changed

+12
-1
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,8 @@ private synchronized boolean updateAddress() throws IOException {
645645
LOG.warn("Address change detected. Old: " + server.toString() +
646646
" New: " + currentAddr.toString());
647647
server = currentAddr;
648+
// Update the remote address so that reconnections are with the updated address. This avoids thrashing.
649+
remoteId.setAddress(currentAddr);
648650
UserGroupInformation ticket = remoteId.getTicket();
649651
this.setName("IPC Client (" + socketFactory.hashCode()
650652
+ ") connection to " + server.toString() + " from "
@@ -1753,7 +1755,16 @@ public ConnectionId(InetSocketAddress address, Class<?> protocol,
17531755
InetSocketAddress getAddress() {
17541756
return address;
17551757
}
1756-
1758+
1759+
/**
1760+
* Used to update the remote address when an address change is detected.
1761+
*
1762+
* @param address the new address
1763+
*/
1764+
private void setAddress(InetSocketAddress address) {
1765+
this.address = address;
1766+
}
1767+
17571768
Class<?> getProtocol() {
17581769
return protocol;
17591770
}

0 commit comments

Comments
 (0)