tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject git commit: TAJO-1034: Reduce Explicit Use of JVM Internal Class. (Jihun Kang via hyunsik)
Date Mon, 15 Sep 2014 03:18:35 GMT
Repository: tajo
Updated Branches:
  refs/heads/master b0d69d232 -> 3a3850a29


TAJO-1034: Reduce Explicit Use of JVM Internal Class. (Jihun Kang via hyunsik)


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

Branch: refs/heads/master
Commit: 3a3850a296e8fc4b08be410bc089b68ede681e82
Parents: b0d69d2
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Mon Sep 15 12:03:39 2014 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Mon Sep 15 12:03:39 2014 +0900

----------------------------------------------------------------------
 CHANGES                                         |  2 ++
 .../tajo/worker/WorkerHeartbeatService.java     | 21 +++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/3a3850a2/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index b8ab3b3..ab72cb4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -31,6 +31,8 @@ Release 0.9.0 - unreleased
 
   IMPROVEMENT
 
+    TAJO-1034: Reduce Explicit Use of JVM Internal Class. (Jihun Kang via hyunsik)
+
     TAJO-1027: Upgrade Hive to 0.13.0 and 0.13.1. (jaehwa)
 
     TAJO-1028: JDBC should support SET command.(Hyoungjun Kim)

http://git-wip-us.apache.org/repos/asf/tajo/blob/3a3850a2/tajo-core/src/main/java/org/apache/tajo/worker/WorkerHeartbeatService.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/worker/WorkerHeartbeatService.java b/tajo-core/src/main/java/org/apache/tajo/worker/WorkerHeartbeatService.java
index b337754..47f2261 100644
--- a/tajo-core/src/main/java/org/apache/tajo/worker/WorkerHeartbeatService.java
+++ b/tajo-core/src/main/java/org/apache/tajo/worker/WorkerHeartbeatService.java
@@ -27,7 +27,6 @@ import org.apache.hadoop.service.AbstractService;
 import org.apache.tajo.conf.TajoConf;
 import org.apache.tajo.ipc.TajoMasterProtocol;
 import org.apache.tajo.ipc.TajoResourceTrackerProtocol;
-import org.apache.tajo.pullserver.TajoPullServerService;
 import org.apache.tajo.rpc.CallFuture;
 import org.apache.tajo.rpc.NettyClientBase;
 import org.apache.tajo.rpc.RpcConnectionPool;
@@ -278,10 +277,22 @@ public class WorkerHeartbeatService extends AbstractService {
   }
 
   public static int getTotalMemoryMB() {
-    com.sun.management.OperatingSystemMXBean bean =
-        (com.sun.management.OperatingSystemMXBean)
-            java.lang.management.ManagementFactory.getOperatingSystemMXBean();
-    long max = bean.getTotalPhysicalMemorySize();
+    javax.management.MBeanServer mBeanServer = java.lang.management.ManagementFactory.getPlatformMBeanServer();
+    long max = 0;
+    Object maxObject = null;
+    try {
+      javax.management.ObjectName osName = new javax.management.ObjectName("java.lang:type=OperatingSystem");
+      if (!System.getProperty("java.vendor").startsWith("IBM")) {
+        maxObject = mBeanServer.getAttribute(osName, "TotalPhysicalMemorySize");
+      } else {
+        maxObject = mBeanServer.getAttribute(osName, "TotalPhysicalMemory");
+      }
+    } catch (Throwable t) {
+      LOG.error(t.getMessage(), t);
+    }
+    if (maxObject != null) {
+      max = ((Long)maxObject).longValue();
+    }
     return ((int) (max / (1024 * 1024)));
   }
 }


Mime
View raw message