From 72be041d1cb1e1d8b36d80f8997012149390fb7e Mon Sep 17 00:00:00 2001 From: mokai Date: Fri, 21 Aug 2020 21:19:02 +0800 Subject: [PATCH] HBASE-24686 [LOG] Log improvement in Connection#close (#2219) Signed-off-by: Pankaj Kumar Signed-off-by: Viraj Jasani Signed-off-by: Sean Busbey --- .../hadoop/hbase/client/AsyncConnectionImpl.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java index 3ebc679caa7f..896b7dcc2f6a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java @@ -201,6 +201,10 @@ public void close() { if (!closed.compareAndSet(false, true)) { 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); @@ -214,6 +218,16 @@ public void close() { } } + 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 AsyncTableRegionLocator getRegionLocator(TableName tableName) { return new AsyncTableRegionLocatorImpl(tableName, this);