HBASE-24686 [LOG] Log improvement in Connection#close (#2219)

Signed-off-by: Pankaj Kumar <pankajkumar@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
Signed-off-by: Sean Busbey <busbey@apache.org>
This commit is contained in:
mokai 2020-08-21 21:19:02 +08:00 committed by Viraj Jasani
parent 4667a971b1
commit a914f2efeb
No known key found for this signature in database
GPG Key ID: B3D6C0B41C8ADFD5
1 changed files with 14 additions and 0 deletions

View File

@ -192,6 +192,10 @@ class AsyncConnectionImpl implements AsyncConnection {
if (closed) {
return;
}
LOG.info("Connection has been closed by {}.", Thread.currentThread().getName());
if(LOG.isDebugEnabled()){
logCallStack(Thread.currentThread().getStackTrace());
}
IOUtils.closeQuietly(clusterStatusListener);
IOUtils.closeQuietly(rpcClient);
IOUtils.closeQuietly(registry);
@ -202,6 +206,16 @@ class AsyncConnectionImpl implements AsyncConnection {
closed = true;
}
private void logCallStack(StackTraceElement[] stackTraceElements) {
StringBuilder stackBuilder = new StringBuilder("Call stack:");
for (StackTraceElement element : stackTraceElements) {
stackBuilder.append("\n at ");
stackBuilder.append(element);
}
stackBuilder.append("\n");
LOG.debug(stackBuilder.toString());
}
@Override
public boolean isClosed() {
return closed;