Repository: phoenix Updated Branches: refs/heads/4.10-HBase-0.98 0e87092d5 -> f2611e78e
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/f2611e78 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/f2611e78 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/f2611e78 Branch: refs/heads/4.10-HBase-0.98 Commit: f2611e78ec43c02b4b8c316a3f66a8d3c7379f0a Parents: 0e87092 Author: Samarth Jain <[email protected]> Authored: Wed May 24 09:24:28 2017 -0700 Committer: Samarth Jain <[email protected]> Committed: Wed May 24 09:24:28 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/f2611e78/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 14e31d2..76f6393 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 @@ -223,6 +223,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; @@ -431,7 +432,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) { @@ -2398,7 +2399,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/f2611e78/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(); + } }
