From e6514c6a3b5287c08585aa9cc3ce893c1cc777a8 Mon Sep 17 00:00:00 2001
From: Tsuyoshi Ozawa
Date: Mon, 5 Oct 2015 08:15:06 +0900
Subject: [PATCH] HADOOP-11098. [JDK8] Max Non Heap Memory default changed
between JDK7 and 8.
(cherry picked from commit 30e2f836a26490a24c7ddea754dd19f95b24bbc8)
---
hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++
.../apache/hadoop/metrics2/source/JvmMetrics.java | 15 +++++++++++++--
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++
.../src/main/webapps/hdfs/dfshealth.html | 4 ++--
4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 3f933b26b03..c15d26c4d3d 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -608,6 +608,9 @@ Release 2.8.0 - UNRELEASED
HADOOP-8437. getLocalPathForWrite should throw IOException for invalid
paths. (Brahma Reddy Battula via zxu)
+ HADOOP-11098. [JDK8] Max Non Heap Memory default changed between JDK7
+ and 8. (ozawa)
+
OPTIMIZATIONS
HADOOP-12051. ProtobufRpcEngine.invoke() should use Exception.toString()
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 c62caf39510..164aa9340c1 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
@@ -60,6 +60,7 @@ public class JvmMetrics implements MetricsSource {
}
static final float M = 1024*1024;
+ static public final float MEMORY_MAX_UNLIMITED_MB = -1;
final MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
final List gcBeans =
@@ -106,13 +107,23 @@ public class JvmMetrics implements MetricsSource {
Runtime runtime = Runtime.getRuntime();
rb.addGauge(MemNonHeapUsedM, memNonHeap.getUsed() / M)
.addGauge(MemNonHeapCommittedM, memNonHeap.getCommitted() / M)
- .addGauge(MemNonHeapMaxM, memNonHeap.getMax() / M)
+ .addGauge(MemNonHeapMaxM, calculateMaxMemoryUsage(memNonHeap))
.addGauge(MemHeapUsedM, memHeap.getUsed() / M)
.addGauge(MemHeapCommittedM, memHeap.getCommitted() / M)
- .addGauge(MemHeapMaxM, memHeap.getMax() / M)
+ .addGauge(MemHeapMaxM, calculateMaxMemoryUsage(memHeap))
.addGauge(MemMaxM, runtime.maxMemory() / M);
}
+ private float calculateMaxMemoryUsage(MemoryUsage memHeap) {
+ long max = memHeap.getMax() ;
+
+ if (max == -1) {
+ return MEMORY_MAX_UNLIMITED_MB;
+ }
+
+ return max / M;
+ }
+
private void getGcUsage(MetricsRecordBuilder rb) {
long count = 0;
long timeMillis = 0;
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index 68baf11d492..3484c7afe3f 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -1142,6 +1142,9 @@ Release 2.8.0 - UNRELEASED
HDFS-9193. Fix incorrect references the usages of the DN in dfshealth.js.
(Chang Li via wheat9)
+ HADOOP-11098. [JDK8] Max Non Heap Memory default changed between JDK7
+ and 8 (ozawa).
+
Release 2.7.2 - UNRELEASED
INCOMPATIBLE CHANGES
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html
index ad3ac0d637f..4460f9798a3 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html
@@ -150,11 +150,11 @@
{/fs}
{#mem.HeapMemoryUsage}
-Heap Memory used {used|fmt_bytes} of {committed|fmt_bytes} Heap Memory. Max Heap Memory is {max|fmt_bytes}.
+Heap Memory used {used|fmt_bytes} of {committed|fmt_bytes} Heap Memory. Max Heap Memory is {@eq key=max value="-1" type="number"}<unbonded>{:else}{max|fmt_bytes}{/eq}.
{/mem.HeapMemoryUsage}
{#mem.NonHeapMemoryUsage}
-Non Heap Memory used {used|fmt_bytes} of {committed|fmt_bytes} Commited Non Heap Memory. Max Non Heap Memory is {max|fmt_bytes}.
+Non Heap Memory used {used|fmt_bytes} of {committed|fmt_bytes} Commited Non Heap Memory. Max Non Heap Memory is {@eq key=max value="-1" type="number"}<unbonded>{:else}{max|fmt_bytes}{/eq}.
{/mem.NonHeapMemoryUsage}
{#nn}