From d89fd7b84fb00a3d1505beaeae120f0425b5c6ec Mon Sep 17 00:00:00 2001 From: Suresh Srinivas Date: Tue, 14 May 2013 15:09:55 +0000 Subject: [PATCH] HADOOP-9560. metrics2#JvmMetrics should have max memory size of JVM. Contributed by Tsuyoshi Ozawa. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1482372 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../java/org/apache/hadoop/metrics2/source/JvmMetrics.java | 4 +++- .../org/apache/hadoop/metrics2/source/JvmMetricsInfo.java | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 29973aface4..c55f1621737 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -615,6 +615,9 @@ Release 2.0.5-beta - UNRELEASED and RandomAccessFile) in SecureIOUtils so as to help YARN-578. (Omkar Vinit Joshi via vinodkv) + HADOOP-9560. metrics2#JvmMetrics should have max memory size of JVM. + (Tsuyoshi Ozawa via suresh) + OPTIMIZATIONS HADOOP-9150. Avoid unnecessary DNS resolution attempts for logical URIs diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetrics.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetrics.java index f436a667f90..a59fff347b3 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetrics.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetrics.java @@ -98,10 +98,12 @@ public class JvmMetrics implements MetricsSource { private void getMemoryUsage(MetricsRecordBuilder rb) { MemoryUsage memNonHeap = memoryMXBean.getNonHeapMemoryUsage(); MemoryUsage memHeap = memoryMXBean.getHeapMemoryUsage(); + Runtime runtime = Runtime.getRuntime(); rb.addGauge(MemNonHeapUsedM, memNonHeap.getUsed() / M) .addGauge(MemNonHeapCommittedM, memNonHeap.getCommitted() / M) .addGauge(MemHeapUsedM, memHeap.getUsed() / M) - .addGauge(MemHeapCommittedM, memHeap.getCommitted() / M); + .addGauge(MemHeapCommittedM, memHeap.getCommitted() / M) + .addGauge(MemMaxM, runtime.maxMemory() / M); } private void getGcUsage(MetricsRecordBuilder rb) { diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetricsInfo.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetricsInfo.java index 83729b190de..e2f61e2d08e 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetricsInfo.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/source/JvmMetricsInfo.java @@ -34,6 +34,7 @@ public enum JvmMetricsInfo implements MetricsInfo { MemNonHeapCommittedM("Non-heap memory committed in MB"), MemHeapUsedM("Heap memory used in MB"), MemHeapCommittedM("Heap memory committed in MB"), + MemMaxM("Max memory size in MB"), GcCount("Total GC count"), GcTimeMillis("Total GC time in milliseconds"), ThreadsNew("Number of new threads"),