You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by rb...@apache.org on 2016/12/22 04:46:28 UTC

hive git commit: HIVE-15471: LLAP UI: NPE when getting thread metrics (Rajesh Balamohan, reviewed by Gopal V)

Repository: hive
Updated Branches:
  refs/heads/master 7299c080f -> 597ca1bdc


HIVE-15471: LLAP UI: NPE when getting thread metrics (Rajesh Balamohan, reviewed by Gopal V)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/597ca1bd
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/597ca1bd
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/597ca1bd

Branch: refs/heads/master
Commit: 597ca1bdcd7d662be9cafb5238b6ae402a2972f1
Parents: 7299c08
Author: Rajesh Balamohan <rb...@apache.org>
Authored: Thu Dec 22 10:16:12 2016 +0530
Committer: Rajesh Balamohan <rb...@apache.org>
Committed: Thu Dec 22 10:16:12 2016 +0530

----------------------------------------------------------------------
 .../llap/metrics/LlapDaemonExecutorMetrics.java    | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/597ca1bd/llap-server/src/java/org/apache/hadoop/hive/llap/metrics/LlapDaemonExecutorMetrics.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/metrics/LlapDaemonExecutorMetrics.java b/llap-server/src/java/org/apache/hadoop/hive/llap/metrics/LlapDaemonExecutorMetrics.java
index 1110683..92c8913 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/metrics/LlapDaemonExecutorMetrics.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/metrics/LlapDaemonExecutorMetrics.java
@@ -50,6 +50,7 @@ import java.lang.management.ThreadMXBean;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import com.google.common.collect.Maps;
 import org.apache.hadoop.hive.llap.daemon.impl.ContainerRunnerImpl;
 import org.apache.hadoop.metrics2.MetricsCollector;
 import org.apache.hadoop.metrics2.MetricsInfo;
@@ -82,6 +83,8 @@ public class LlapDaemonExecutorMetrics implements MetricsSource {
   private long maxTimeLost = Long.MIN_VALUE;
   private long maxTimeToKill = Long.MIN_VALUE;
 
+  private final Map<String, Integer> executorNames;
+
   final MutableGaugeLong[] executorThreadCpuTime;
   final MutableGaugeLong[] executorThreadUserTime;
   @Metric
@@ -152,6 +155,7 @@ public class LlapDaemonExecutorMetrics implements MetricsSource {
           "ops", "latency", interval);
     }
 
+    this.executorNames = Maps.newHashMap();
     for (int i = 0; i < numExecutors; i++) {
       MetricsInfo mic = new LlapDaemonCustomMetricsInfo(ExecutorThreadCPUTime.name() + "_" + i,
           ExecutorThreadCPUTime.description());
@@ -161,6 +165,7 @@ public class LlapDaemonExecutorMetrics implements MetricsSource {
       this.userMetricsInfoMap.put(i, miu);
       this.executorThreadCpuTime[i] = registry.newGauge(mic, 0L);
       this.executorThreadUserTime[i] = registry.newGauge(miu, 0L);
+      this.executorNames.put(ContainerRunnerImpl.THREAD_NAME_FORMAT_PREFIX + i, i);
     }
   }
 
@@ -304,13 +309,15 @@ public class LlapDaemonExecutorMetrics implements MetricsSource {
       final ThreadInfo[] infos = threadMXBean.getThreadInfo(ids);
       for (int i = 0; i < ids.length; i++) {
         ThreadInfo threadInfo = infos[i];
+        if (threadInfo == null) {
+          continue;
+        }
         String threadName = threadInfo.getThreadName();
         long threadId = ids[i];
-        for (int j = 0; j < numExecutors; j++) {
-          if (threadName.equals(ContainerRunnerImpl.THREAD_NAME_FORMAT_PREFIX + j)) {
-            executorThreadCpuTime[j].set(threadMXBean.getThreadCpuTime(threadId));
-            executorThreadUserTime[j].set(threadMXBean.getThreadUserTime(threadId));
-          }
+        Integer id = executorNames.get(threadName);
+        if (id != null) {
+          executorThreadCpuTime[id].set(threadMXBean.getThreadCpuTime(threadId));
+          executorThreadUserTime[id].set(threadMXBean.getThreadUserTime(threadId));
         }
       }