You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by su...@apache.org on 2016/08/08 20:29:00 UTC
hive git commit: HIVE-13813: Add Metrics for the number of Hive
operations waiting for compile (Chao Sun, reviewed by Jimmy Xiang)
Repository: hive
Updated Branches:
refs/heads/master 043870139 -> a92abf56e
HIVE-13813: Add Metrics for the number of Hive operations waiting for compile (Chao Sun, reviewed by Jimmy Xiang)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/a92abf56
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/a92abf56
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/a92abf56
Branch: refs/heads/master
Commit: a92abf56e3d1a785db80edc84d3e082858c1a648
Parents: 0438701
Author: Chao Sun <su...@apache.org>
Authored: Mon Aug 8 13:28:04 2016 -0700
Committer: Chao Sun <su...@apache.org>
Committed: Mon Aug 8 13:28:49 2016 -0700
----------------------------------------------------------------------
.../common/metrics/common/MetricsConstant.java | 4 ++++
.../java/org/apache/hadoop/hive/ql/Driver.java | 21 ++++++++++++++++++++
2 files changed, 25 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/a92abf56/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 b0d2b85..9dc96f9 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
@@ -57,4 +57,8 @@ public class MetricsConstant {
public static final String DELETE_TOTAL_PARTITIONS = "delete_total_count_partitions";
public static final String DIRECTSQL_ERRORS = "directsql_errors";
+
+ // The number of Hive operations that are waiting to enter the compile block
+ public static final String WAITING_COMPILE_OPS = "waiting_compile_ops";
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hive/blob/a92abf56/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
index e1494da..183ed82 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
@@ -39,6 +39,9 @@ import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.hive.common.ValidTxnList;
+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.conf.HiveVariableSource;
@@ -1195,6 +1198,17 @@ public class Driver implements CommandProcessor {
private static final ReentrantLock globalCompileLock = new ReentrantLock();
private int compileInternal(String command) {
int ret;
+
+ Metrics metrics = MetricsFactory.getInstance();
+ if (metrics != null) {
+ try {
+ metrics.incrementCounter(MetricsConstant.WAITING_COMPILE_OPS, 1);
+ } catch (IOException e) {
+ // This won't happen if we are using the newer CodaHale metrics. Same for below.
+ LOG.warn("Error while incrementing metrics counter.", e);
+ }
+ }
+
final ReentrantLock compileLock = tryAcquireCompileLock(isParallelEnabled,
command);
if (compileLock == null) {
@@ -1202,6 +1216,13 @@ public class Driver implements CommandProcessor {
}
try {
+ if (metrics != null) {
+ try {
+ metrics.decrementCounter(MetricsConstant.WAITING_COMPILE_OPS, 1);
+ } catch (IOException e) {
+ LOG.warn("Error while decrementing metrics counter.", e);
+ }
+ }
ret = compile(command);
} finally {
compileLock.unlock();