hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject [14/46] hive git commit: HIVE-16072: LLAP: Add some additional jvm metrics for hadoop-metrics2 (Prasanth Jayachandran reviewed by Siddharth Seth)
Date Mon, 13 Mar 2017 19:42:15 GMT
HIVE-16072: LLAP: Add some additional jvm metrics for hadoop-metrics2 (Prasanth Jayachandran
reviewed by Siddharth Seth)


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

Branch: refs/heads/hive-14535
Commit: bfe930c5c3ee03180a0d78aaa12f83af13973b44
Parents: 1321293
Author: Prasanth Jayachandran <prasanthj@apache.org>
Authored: Wed Mar 8 14:46:37 2017 -0800
Committer: Prasanth Jayachandran <prasanthj@apache.org>
Committed: Wed Mar 8 14:46:37 2017 -0800

----------------------------------------------------------------------
 .../hive/llap/daemon/impl/LlapDaemon.java       |   7 +-
 .../hive/llap/metrics/LlapDaemonJvmInfo.java    |  60 ++++++++++
 .../hive/llap/metrics/LlapDaemonJvmMetrics.java | 116 +++++++++++++++++++
 3 files changed, 182 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/bfe930c5/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/LlapDaemon.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/LlapDaemon.java
b/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/LlapDaemon.java
index eb05f4c..6a5adc9 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/LlapDaemon.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/LlapDaemon.java
@@ -53,6 +53,7 @@ import org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.Terminate
 import org.apache.hadoop.hive.llap.daemon.services.impl.LlapWebServices;
 import org.apache.hadoop.hive.llap.io.api.LlapProxy;
 import org.apache.hadoop.hive.llap.metrics.LlapDaemonExecutorMetrics;
+import org.apache.hadoop.hive.llap.metrics.LlapDaemonJvmMetrics;
 import org.apache.hadoop.hive.llap.metrics.LlapMetricsSystem;
 import org.apache.hadoop.hive.llap.metrics.MetricsUtils;
 import org.apache.hadoop.hive.llap.registry.impl.LlapRegistryService;
@@ -231,8 +232,10 @@ public class LlapDaemon extends CompositeService implements ContainerRunner,
Lla
     LlapMetricsSystem.initialize("LlapDaemon");
     this.pauseMonitor = new JvmPauseMonitor(daemonConf);
     pauseMonitor.start();
-    String displayName = "LlapDaemonExecutorMetrics-" + hostName;
+    String displayNameJvm = "LlapDaemonJvmMetrics-" + hostName;
     String sessionId = MetricsUtils.getUUID();
+    LlapDaemonJvmMetrics.create(displayNameJvm, sessionId);
+    String displayName = "LlapDaemonExecutorMetrics-" + hostName;
     daemonConf.set("llap.daemon.metrics.sessionid", sessionId);
     String[] strIntervals = HiveConf.getTrimmedStringsVar(daemonConf,
         HiveConf.ConfVars.LLAP_DAEMON_TASK_PREEMPTION_METRICS_INTERVALS);
@@ -253,6 +256,8 @@ public class LlapDaemon extends CompositeService implements ContainerRunner,
Lla
     this.metrics.setCacheMemoryPerInstance(ioMemoryBytes);
     this.metrics.setJvmMaxMemory(maxJvmMemory);
     this.metrics.setWaitQueueSize(waitQueueSize);
+    // TODO: Has to be reverted in HIVE-15644
+    //this.metrics.getJvmMetrics().setPauseMonitor(pauseMonitor);
     this.llapDaemonInfoBean = MBeans.register("LlapDaemon", "LlapDaemonInfo", this);
     LOG.info("Started LlapMetricsSystem with displayName: " + displayName +
         " sessionId: " + sessionId);

http://git-wip-us.apache.org/repos/asf/hive/blob/bfe930c5/llap-server/src/java/org/apache/hadoop/hive/llap/metrics/LlapDaemonJvmInfo.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/metrics/LlapDaemonJvmInfo.java
b/llap-server/src/java/org/apache/hadoop/hive/llap/metrics/LlapDaemonJvmInfo.java
new file mode 100644
index 0000000..efbddaa
--- /dev/null
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/metrics/LlapDaemonJvmInfo.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.llap.metrics;
+
+import org.apache.hadoop.metrics2.MetricsInfo;
+
+import com.google.common.base.Objects;
+
+/**
+ * Llap daemon JVM info. These are some additional metrics that are not exposed via
+ * {@link org.apache.hadoop.metrics.jvm.JvmMetrics}
+ *
+ * NOTE: These metrics are for sinks supported by hadoop-metrics2. There is already a /jmx
endpoint
+ * that gives all these info.
+ */
+public enum LlapDaemonJvmInfo implements MetricsInfo {
+  LlapDaemonJVMMetrics("Llap daemon JVM related metrics"),
+  LlapDaemonDirectBufferCount("Total number of direct byte buffers"),
+  LlapDaemonDirectBufferTotalCapacity("Estimate of total capacity of all allocated direct
byte buffers in bytes"),
+  LlapDaemonDirectBufferMemoryUsed("Estimate of memory that JVM is using for the allocated
buffers in bytes"),
+  LlapDaemonMappedBufferCount("Total number of mapped byte buffers"),
+  LlapDaemonMappedBufferTotalCapacity("Estimate of total capacity of all mapped byte buffers
in bytes"),
+  LlapDaemonMappedBufferMemoryUsed("Estimate of memory that JVM is using for mapped byte
buffers in bytes"),
+  LlapDaemonOpenFileDescriptorCount("Number of open file descriptors"),
+  LlapDaemonMaxFileDescriptorCount("Maximum number of file descriptors"),
+  ;
+
+  private final String desc;
+
+  LlapDaemonJvmInfo(String desc) {
+    this.desc = desc;
+  }
+
+  @Override
+  public String description() {
+    return desc;
+  }
+
+  @Override
+  public String toString() {
+    return Objects.toStringHelper(this)
+      .add("name", name()).add("description", desc)
+      .toString();
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/bfe930c5/llap-server/src/java/org/apache/hadoop/hive/llap/metrics/LlapDaemonJvmMetrics.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/metrics/LlapDaemonJvmMetrics.java
b/llap-server/src/java/org/apache/hadoop/hive/llap/metrics/LlapDaemonJvmMetrics.java
new file mode 100644
index 0000000..cfb8729
--- /dev/null
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/metrics/LlapDaemonJvmMetrics.java
@@ -0,0 +1,116 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.llap.metrics;
+
+import static org.apache.hadoop.hive.llap.metrics.LlapDaemonJvmInfo.LlapDaemonDirectBufferCount;
+import static org.apache.hadoop.hive.llap.metrics.LlapDaemonJvmInfo.LlapDaemonDirectBufferMemoryUsed;
+import static org.apache.hadoop.hive.llap.metrics.LlapDaemonJvmInfo.LlapDaemonDirectBufferTotalCapacity;
+import static org.apache.hadoop.hive.llap.metrics.LlapDaemonJvmInfo.LlapDaemonJVMMetrics;
+import static org.apache.hadoop.hive.llap.metrics.LlapDaemonJvmInfo.LlapDaemonMappedBufferCount;
+import static org.apache.hadoop.hive.llap.metrics.LlapDaemonJvmInfo.LlapDaemonMappedBufferMemoryUsed;
+import static org.apache.hadoop.hive.llap.metrics.LlapDaemonJvmInfo.LlapDaemonMappedBufferTotalCapacity;
+import static org.apache.hadoop.hive.llap.metrics.LlapDaemonJvmInfo.LlapDaemonMaxFileDescriptorCount;
+import static org.apache.hadoop.hive.llap.metrics.LlapDaemonJvmInfo.LlapDaemonOpenFileDescriptorCount;
+import static org.apache.hadoop.metrics2.impl.MsInfo.ProcessName;
+import static org.apache.hadoop.metrics2.impl.MsInfo.SessionId;
+
+import java.lang.management.BufferPoolMXBean;
+import java.lang.management.ManagementFactory;
+import java.lang.management.OperatingSystemMXBean;
+import java.util.List;
+
+import org.apache.hadoop.metrics2.MetricsCollector;
+import org.apache.hadoop.metrics2.MetricsRecordBuilder;
+import org.apache.hadoop.metrics2.MetricsSource;
+import org.apache.hadoop.metrics2.MetricsSystem;
+import org.apache.hadoop.metrics2.annotation.Metrics;
+import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+
+import com.sun.management.UnixOperatingSystemMXBean;
+
+/**
+ * Class to report LLAP Daemon's JVM metrics to the hadoop metrics2 API.
+ */
+@Metrics(about = "LlapDaemon JVM Metrics", context = "jvm")
+public class LlapDaemonJvmMetrics implements MetricsSource {
+  private final String name;
+  private final String sessionId;
+  private final MetricsRegistry registry;
+
+  private LlapDaemonJvmMetrics(String displayName, String sessionId) {
+    this.name = displayName;
+    this.sessionId = sessionId;
+    this.registry = new MetricsRegistry("LlapDaemonJvmRegistry");
+    this.registry.tag(ProcessName, MetricsUtils.METRICS_PROCESS_NAME).tag(SessionId, sessionId);
+  }
+
+  public static LlapDaemonJvmMetrics create(String displayName, String sessionId) {
+    MetricsSystem ms = LlapMetricsSystem.instance();
+    return ms.register(displayName, "LlapDaemon JVM Metrics", new LlapDaemonJvmMetrics(displayName,
sessionId));
+  }
+
+  @Override
+  public void getMetrics(MetricsCollector collector, boolean b) {
+    MetricsRecordBuilder rb = collector.addRecord(LlapDaemonJVMMetrics)
+        .setContext("jvm")
+        .tag(ProcessName, MetricsUtils.METRICS_PROCESS_NAME)
+        .tag(SessionId, sessionId);
+    getJvmMetrics(rb);
+  }
+
+  private void getJvmMetrics(final MetricsRecordBuilder rb) {
+    List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
+    long directBufferCount = 0;
+    long directBufferTotalCapacity = 0;
+    long directBufferMemoryUsed = 0;
+    long mappedBufferCount = 0;
+    long mappedBufferTotalCapacity = 0;
+    long mappedBufferMemoryUsed = 0;
+    for (BufferPoolMXBean pool : pools) {
+      if (pool.getName().equals("direct")) {
+        directBufferCount = pool.getCount();
+        directBufferTotalCapacity = pool.getTotalCapacity();
+        directBufferMemoryUsed = pool.getMemoryUsed();
+      } else if (pool.getName().equals("mapped")) {
+        mappedBufferCount = pool.getCount();
+        mappedBufferTotalCapacity = pool.getTotalCapacity();
+        mappedBufferMemoryUsed = pool.getMemoryUsed();
+      }
+    }
+
+    OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
+    long openFileHandles = 0;
+    long maxFileHandles = 0;
+    if(os instanceof UnixOperatingSystemMXBean){
+      openFileHandles = ((UnixOperatingSystemMXBean) os).getOpenFileDescriptorCount();
+      maxFileHandles = ((UnixOperatingSystemMXBean) os).getMaxFileDescriptorCount();
+    }
+    rb.addGauge(LlapDaemonDirectBufferCount, directBufferCount)
+      .addGauge(LlapDaemonDirectBufferTotalCapacity, directBufferTotalCapacity)
+      .addGauge(LlapDaemonDirectBufferMemoryUsed, directBufferMemoryUsed)
+      .addGauge(LlapDaemonMappedBufferCount, mappedBufferCount)
+      .addGauge(LlapDaemonMappedBufferTotalCapacity, mappedBufferTotalCapacity)
+      .addGauge(LlapDaemonMappedBufferMemoryUsed, mappedBufferMemoryUsed)
+      .addGauge(LlapDaemonOpenFileDescriptorCount, openFileHandles)
+      .addGauge(LlapDaemonMaxFileDescriptorCount, maxFileHandles);
+  }
+
+  public String getName() {
+    return name;
+  }
+}


Mime
View raw message