HBASE-8360 In HBaseClient#cancelConnections we should close fully the connection
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1469952 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
efc32c83ba
commit
e946c2871f
|
@ -26,6 +26,7 @@ import java.lang.reflect.Method;
|
|||
import java.lang.reflect.Proxy;
|
||||
import java.lang.reflect.UndeclaredThrowableException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -653,7 +654,8 @@ public class HConnectionManager {
|
|||
@Override
|
||||
public void newDead(ServerName sn) {
|
||||
clearCaches(sn);
|
||||
rpcEngine.getClient().cancelConnections(sn.getHostname(), sn.getPort(), null);
|
||||
rpcEngine.getClient().cancelConnections(sn.getHostname(), sn.getPort(),
|
||||
new SocketException(sn.getServerName() + " is dead: closing its connection."));
|
||||
}
|
||||
}, conf, listenerClass);
|
||||
}
|
||||
|
|
|
@ -1370,15 +1370,18 @@ public class HBaseClient {
|
|||
if (connection.isAlive() &&
|
||||
connection.getRemoteAddress().getPort() == port &&
|
||||
connection.getRemoteAddress().getHostName().equals(hostname)) {
|
||||
if (connection.shouldCloseConnection.compareAndSet(false, true)) {
|
||||
LOG.info("The server on " + hostname + ":" + port +
|
||||
" is dead - stopping the connection " + connection.remoteId);
|
||||
connection.closeConnection();
|
||||
" is dead - closing the connection " + connection.remoteId);
|
||||
connection.closeException = ioe;
|
||||
connection.close();
|
||||
// We could do a connection.interrupt(), but it's safer not to do it, as the
|
||||
// interrupted exception behavior is not defined nor enforced enough.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Get a connection from the pool, or create a new one and add it to the
|
||||
* pool. Connections to a given host/port are reused. */
|
||||
|
|
Loading…
Reference in New Issue