@@ -1985,11 +1985,26 @@ public class Connection {
1985
1985
private long lastContact ;
1986
1986
private int dataLength ;
1987
1987
private Socket socket ;
1988
+
1988
1989
// Cache the remote host & port info so that even if the socket is
1989
1990
// disconnected, we can say where it used to connect to.
1990
- private String hostAddress ;
1991
- private int remotePort ;
1992
- private InetAddress addr ;
1991
+
1992
+ /**
1993
+ * Client Host IP address from where the socket connection is being established to the Server.
1994
+ */
1995
+ private final String hostAddress ;
1996
+ /**
1997
+ * Client remote port used for the given socket connection.
1998
+ */
1999
+ private final int remotePort ;
2000
+ /**
2001
+ * Address to which the socket is connected to.
2002
+ */
2003
+ private final InetAddress addr ;
2004
+ /**
2005
+ * Client Host address from where the socket connection is being established to the Server.
2006
+ */
2007
+ private final String hostName ;
1993
2008
1994
2009
IpcConnectionContextProto connectionContext ;
1995
2010
String protocolName ;
@@ -2033,8 +2048,12 @@ public Connection(SocketChannel channel, long lastContact,
2033
2048
this .isOnAuxiliaryPort = isOnAuxiliaryPort ;
2034
2049
if (addr == null ) {
2035
2050
this .hostAddress = "*Unknown*" ;
2051
+ this .hostName = this .hostAddress ;
2036
2052
} else {
2053
+ // host IP address
2037
2054
this .hostAddress = addr .getHostAddress ();
2055
+ // host name for the IP address
2056
+ this .hostName = addr .getHostName ();
2038
2057
}
2039
2058
this .remotePort = socket .getPort ();
2040
2059
this .responseQueue = new LinkedList <RpcCall >();
@@ -2050,7 +2069,7 @@ public Connection(SocketChannel channel, long lastContact,
2050
2069
2051
2070
@ Override
2052
2071
public String toString () {
2053
- return getHostAddress () + ":" + remotePort ;
2072
+ return hostName + ":" + remotePort + " / " + hostAddress + ":" + remotePort ;
2054
2073
}
2055
2074
2056
2075
boolean setShouldClose () {
@@ -2463,19 +2482,18 @@ public int readAndProcess() throws IOException, InterruptedException {
2463
2482
return -1 ;
2464
2483
}
2465
2484
2466
- if (!RpcConstants .HEADER .equals (dataLengthBuffer )) {
2467
- LOG .warn ("Incorrect RPC Header length from {}:{} "
2468
- + "expected length: {} got length: {}" ,
2469
- hostAddress , remotePort , RpcConstants . HEADER , dataLengthBuffer );
2485
+ if (!RpcConstants .HEADER .equals (dataLengthBuffer )) {
2486
+ LOG .warn ("Incorrect RPC Header length from {}:{} / {}:{}. Expected: {}. Actual: {}" ,
2487
+ hostName , remotePort , hostAddress , remotePort , RpcConstants . HEADER ,
2488
+ dataLengthBuffer );
2470
2489
setupBadVersionResponse (version );
2471
2490
return -1 ;
2472
2491
}
2473
2492
if (version != CURRENT_VERSION ) {
2474
2493
//Warning is ok since this is not supposed to happen.
2475
- LOG .warn ("Version mismatch from " +
2476
- hostAddress + ":" + remotePort +
2477
- " got version " + version +
2478
- " expected version " + CURRENT_VERSION );
2494
+ LOG .warn ("Version mismatch from {}:{} / {}:{}. "
2495
+ + "Expected version: {}. Actual version: {} " , hostName ,
2496
+ remotePort , hostAddress , remotePort , CURRENT_VERSION , version );
2479
2497
setupBadVersionResponse (version );
2480
2498
return -1 ;
2481
2499
}
0 commit comments