Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.1 b0c89849d -> 90b954b52
PHOENIX-3826 Improve logging when HConnection is established(Loknath Priyatham Teja Singamsetty) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/90b954b5 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/90b954b5 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/90b954b5 Branch: refs/heads/4.x-HBase-1.1 Commit: 90b954b52bf83efe0ee10ff6d0705c546af954c0 Parents: b0c8984 Author: Samarth Jain <[email protected]> Authored: Wed May 24 09:22:21 2017 -0700 Committer: Samarth Jain <[email protected]> Committed: Wed May 24 09:22:21 2017 -0700 ---------------------------------------------------------------------- .../apache/phoenix/query/ConnectionQueryServicesImpl.java | 5 +++-- .../src/main/java/org/apache/phoenix/util/LogUtil.java | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/90b954b5/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java index 7a6d344..e26893c 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java @@ -225,6 +225,7 @@ import org.apache.phoenix.util.ByteUtil; import org.apache.phoenix.util.Closeables; import org.apache.phoenix.util.ConfigUtil; import org.apache.phoenix.util.JDBCUtil; +import org.apache.phoenix.util.LogUtil; import org.apache.phoenix.util.MetaDataUtil; import org.apache.phoenix.util.PhoenixContextExecutor; import org.apache.phoenix.util.PhoenixRuntime; @@ -434,7 +435,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement QueryServicesOptions.DEFAULT_TRANSACTIONS_ENABLED); this.connection = HBaseFactoryProvider.getHConnectionFactory().createConnection(this.config); GLOBAL_HCONNECTIONS_COUNTER.increment(); - logger.info("HConnnection established. Details: " + connection + " " + Throwables.getStackTraceAsString(new Exception())); + logger.info("HConnection established. Stacktrace for informational purposes: " + connection + " " + LogUtil.getCallerStackTrace()); // only initialize the tx service client if needed and if we succeeded in getting a connection // to HBase if (transactionsEnabled) { @@ -2406,7 +2407,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement boolean success = false; try { GLOBAL_QUERY_SERVICES_COUNTER.increment(); - logger.info("An instance of ConnectionQueryServices was created: " + Throwables.getStackTraceAsString(new Exception())); + logger.info("An instance of ConnectionQueryServices was created."); openConnection(); hConnectionEstablished = true; boolean isDoNotUpgradePropSet = UpgradeUtil.isNoUpgradeSet(props); http://git-wip-us.apache.org/repos/asf/phoenix/blob/90b954b5/phoenix-core/src/main/java/org/apache/phoenix/util/LogUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/LogUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/LogUtil.java index 21dec13..7ebdbb4 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/LogUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/LogUtil.java @@ -50,4 +50,14 @@ public class LogUtil { return con.getCustomTracingAnnotations().toString(); } } + + public static String getCallerStackTrace() { + StackTraceElement[] st = Thread.currentThread().getStackTrace(); + StringBuilder sb = new StringBuilder(); + for (StackTraceElement element : st) { + sb.append(element.toString()); + sb.append("\n"); + } + return sb.toString(); + } }
