Repository: hive Updated Branches: refs/heads/master cdaf35674 -> 1cb307336
HIVE-11984: Add HS2 open operation metrics (Jimmy, reviewed by Szehon) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/1cb30733 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/1cb30733 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/1cb30733 Branch: refs/heads/master Commit: 1cb307336c32104f00351a7aa1282c3fdc7f12d0 Parents: cdaf356 Author: Jimmy Xiang <jxi...@cloudera.com> Authored: Mon Sep 28 15:24:44 2015 -0700 Committer: Jimmy Xiang <jxi...@cloudera.com> Committed: Wed Sep 30 07:49:02 2015 -0700 ---------------------------------------------------------------------- .../hive/common/metrics/common/MetricsConstant.java | 1 + .../apache/hive/service/cli/operation/Operation.java | 13 ++++++++++++- .../hive/service/cli/operation/OperationManager.java | 11 +++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/1cb30733/common/src/java/org/apache/hadoop/hive/common/metrics/common/MetricsConstant.java ---------------------------------------------------------------------- diff --git a/common/src/java/org/apache/hadoop/hive/common/metrics/common/MetricsConstant.java b/common/src/java/org/apache/hadoop/hive/common/metrics/common/MetricsConstant.java index d1ebe12..13c3cf9 100644 --- a/common/src/java/org/apache/hadoop/hive/common/metrics/common/MetricsConstant.java +++ b/common/src/java/org/apache/hadoop/hive/common/metrics/common/MetricsConstant.java @@ -27,6 +27,7 @@ public class MetricsConstant { public static String JVM_EXTRA_SLEEP = "jvm.pause.extraSleepTime"; public static String OPEN_CONNECTIONS = "open_connections"; + public static String OPEN_OPERATIONS = "open_operations"; public static String JDO_ACTIVE_TRANSACTIONS = "active_jdo_transactions"; public static String JDO_ROLLBACK_TRANSACTIONS = "rollbacked_jdo_transactions"; http://git-wip-us.apache.org/repos/asf/hive/blob/1cb30733/service/src/java/org/apache/hive/service/cli/operation/Operation.java ---------------------------------------------------------------------- diff --git a/service/src/java/org/apache/hive/service/cli/operation/Operation.java b/service/src/java/org/apache/hive/service/cli/operation/Operation.java index 19153b6..0ab38c9 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/Operation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/Operation.java @@ -25,6 +25,9 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hive.common.metrics.common.Metrics; +import org.apache.hadoop.hive.common.metrics.common.MetricsConstant; +import org.apache.hadoop.hive.common.metrics.common.MetricsFactory; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.ql.processors.CommandProcessorResponse; import org.apache.hadoop.hive.ql.session.OperationLog; @@ -251,9 +254,17 @@ public abstract class Operation { */ protected abstract void runInternal() throws HiveSQLException; - public void run() throws HiveSQLException { + public final void run() throws HiveSQLException { beforeRun(); try { + Metrics metrics = MetricsFactory.getInstance(); + if (metrics != null) { + try { + metrics.incrementCounter(MetricsConstant.OPEN_OPERATIONS); + } catch (Exception e) { + LOG.warn("Error Reporting open operation to Metrics system", e); + } + } runInternal(); } finally { afterRun(); http://git-wip-us.apache.org/repos/asf/hive/blob/1cb30733/service/src/java/org/apache/hive/service/cli/operation/OperationManager.java ---------------------------------------------------------------------- diff --git a/service/src/java/org/apache/hive/service/cli/operation/OperationManager.java b/service/src/java/org/apache/hive/service/cli/operation/OperationManager.java index 304a525..e29b4b6 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/OperationManager.java +++ b/service/src/java/org/apache/hive/service/cli/operation/OperationManager.java @@ -26,6 +26,9 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hive.common.metrics.common.Metrics; +import org.apache.hadoop.hive.common.metrics.common.MetricsConstant; +import org.apache.hadoop.hive.common.metrics.common.MetricsFactory; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; import org.apache.hadoop.hive.metastore.api.FieldSchema; @@ -209,6 +212,14 @@ public class OperationManager extends AbstractService { if (operation == null) { throw new HiveSQLException("Operation does not exist!"); } + Metrics metrics = MetricsFactory.getInstance(); + if (metrics != null) { + try { + metrics.decrementCounter(MetricsConstant.OPEN_OPERATIONS); + } catch (Exception e) { + LOG.warn("Error Reporting close operation to Metrics system", e); + } + } operation.close(); }