@@ -542,8 +542,11 @@ private synchronized boolean shouldAuthenticateOverKrb() throws IOException {
542542
543543 private synchronized AuthMethod setupSaslConnection (final InputStream in2 ,
544544 final OutputStream out2 ) throws IOException , InterruptedException {
545+ // Do not use Client.conf here! We must use ConnectionId.conf, since the
546+ // Client object is cached and shared between all RPC clients, even those
547+ // for separate services.
545548 saslRpcClient = new SaslRpcClient (remoteId .getTicket (),
546- remoteId .getProtocol (), remoteId .getAddress (), conf );
549+ remoteId .getProtocol (), remoteId .getAddress (), remoteId . conf );
547550 return saslRpcClient .saslConnect (in2 , out2 );
548551 }
549552
@@ -1480,21 +1483,31 @@ public static class ConnectionId {
14801483 private final boolean doPing ; //do we need to send ping message
14811484 private final int pingInterval ; // how often sends ping to the server in msecs
14821485 private String saslQop ; // here for testing
1486+ private final Configuration conf ; // used to get the expected kerberos principal name
14831487
14841488 ConnectionId (InetSocketAddress address , Class <?> protocol ,
1485- UserGroupInformation ticket , int rpcTimeout , int maxIdleTime ,
1486- RetryPolicy connectionRetryPolicy , int maxRetriesOnSocketTimeouts ,
1487- boolean tcpNoDelay , boolean doPing , int pingInterval ) {
1489+ UserGroupInformation ticket , int rpcTimeout ,
1490+ RetryPolicy connectionRetryPolicy , Configuration conf ) {
14881491 this .protocol = protocol ;
14891492 this .address = address ;
14901493 this .ticket = ticket ;
14911494 this .rpcTimeout = rpcTimeout ;
1492- this .maxIdleTime = maxIdleTime ;
14931495 this .connectionRetryPolicy = connectionRetryPolicy ;
1494- this .maxRetriesOnSocketTimeouts = maxRetriesOnSocketTimeouts ;
1495- this .tcpNoDelay = tcpNoDelay ;
1496- this .doPing = doPing ;
1497- this .pingInterval = pingInterval ;
1496+
1497+ this .maxIdleTime = conf .getInt (
1498+ CommonConfigurationKeysPublic .IPC_CLIENT_CONNECTION_MAXIDLETIME_KEY ,
1499+ CommonConfigurationKeysPublic .IPC_CLIENT_CONNECTION_MAXIDLETIME_DEFAULT );
1500+ this .maxRetriesOnSocketTimeouts = conf .getInt (
1501+ CommonConfigurationKeysPublic .IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SOCKET_TIMEOUTS_KEY ,
1502+ CommonConfigurationKeysPublic .IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SOCKET_TIMEOUTS_DEFAULT );
1503+ this .tcpNoDelay = conf .getBoolean (
1504+ CommonConfigurationKeysPublic .IPC_CLIENT_TCPNODELAY_KEY ,
1505+ CommonConfigurationKeysPublic .IPC_CLIENT_TCPNODELAY_DEFAULT );
1506+ this .doPing = conf .getBoolean (
1507+ CommonConfigurationKeys .IPC_CLIENT_PING_KEY ,
1508+ CommonConfigurationKeys .IPC_CLIENT_PING_DEFAULT );
1509+ this .pingInterval = (doPing ? Client .getPingInterval (conf ) : 0 );
1510+ this .conf = conf ;
14981511 }
14991512
15001513 InetSocketAddress getAddress () {
@@ -1572,19 +1585,8 @@ static ConnectionId getConnectionId(InetSocketAddress addr,
15721585 max , retryInterval , TimeUnit .MILLISECONDS );
15731586 }
15741587
1575- boolean doPing =
1576- conf .getBoolean (CommonConfigurationKeys .IPC_CLIENT_PING_KEY , true );
15771588 return new ConnectionId (addr , protocol , ticket , rpcTimeout ,
1578- conf .getInt (CommonConfigurationKeysPublic .IPC_CLIENT_CONNECTION_MAXIDLETIME_KEY ,
1579- CommonConfigurationKeysPublic .IPC_CLIENT_CONNECTION_MAXIDLETIME_DEFAULT ),
1580- connectionRetryPolicy ,
1581- conf .getInt (
1582- CommonConfigurationKeysPublic .IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SOCKET_TIMEOUTS_KEY ,
1583- CommonConfigurationKeysPublic .IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SOCKET_TIMEOUTS_DEFAULT ),
1584- conf .getBoolean (CommonConfigurationKeysPublic .IPC_CLIENT_TCPNODELAY_KEY ,
1585- CommonConfigurationKeysPublic .IPC_CLIENT_TCPNODELAY_DEFAULT ),
1586- doPing ,
1587- (doPing ? Client .getPingInterval (conf ) : 0 ));
1589+ connectionRetryPolicy , conf );
15881590 }
15891591
15901592 static boolean isEqual (Object a , Object b ) {
0 commit comments