Repository: asterixdb
Updated Branches:
  refs/heads/master 3c764a421 -> 206381e6d


Make Xmx small on 32bit JVM

There can be issues with the default memory parameter settings
if run on a 32Bit JVM, as the maximum RAM can be large due to
PAE or using 32bit JVM on a 64bit OS, therefore leading to an
-Xmx setting that is too large to address.

This makes the maximum 1GB by default on 32bit JVMs, as there
is a related issue on Windows where 32 bit processes are
limited to about 1.5G per process.

Change-Id: I025174fc2ca53e8d15ed53fac31b43bea3ddf281
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1521
Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mb...@apache.org>
Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu>


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

Branch: refs/heads/master
Commit: 206381e6d2aef1b5d85a0a96619a9ce57fe6f217
Parents: 3c764a4
Author: Ian Maxon <ima...@apache.org>
Authored: Mon Feb 27 16:09:03 2017 -0800
Committer: Ian Maxon <ima...@apache.org>
Committed: Tue Feb 28 12:08:14 2017 -0800

----------------------------------------------------------------------
 .../hyracks/control/nc/service/NCService.java   | 25 +++++++++++---------
 1 file changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/206381e6/hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCService.java
----------------------------------------------------------------------
diff --git 
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCService.java
 
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCService.java
index 5a03d3c..9b00cc2 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCService.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-nc-service/src/main/java/org/apache/hyracks/control/nc/service/NCService.java
@@ -111,7 +111,7 @@ public class NCService {
         return cList;
     }
 
-    private static void configEnvironment(Map<String,String> env) {
+    private static void configEnvironment(Map<String, String> env) {
         String jvmargs = IniUtils.getString(ini, nodeSection, "jvm.args", 
null);
         if (jvmargs != null) {
             LOGGER.info("Using JAVA_OPTS from conf file (jvm.args)");
@@ -122,7 +122,11 @@ public class NCService {
             } else {
                 LOGGER.info("Using default JAVA_OPTS");
                 long ramSize = ((com.sun.management.OperatingSystemMXBean) 
osMXBean).getTotalPhysicalMemorySize();
-                jvmargs = "-Xmx" + (int) Math.ceil(0.6 * ramSize / (1024 * 
1024)) + "m";
+                int proportionalRamSize = (int) Math.ceil(0.6 * ramSize / 
(1024 * 1024));
+                //if under 32bit JVM, use less than 1GB heap by default. 
otherwise use proportional ramsize.
+                int heapSize = 
"32".equals(System.getProperty("sun.arch.data.model"))
+                        ? (proportionalRamSize <= 1024 ? proportionalRamSize : 
1024) : proportionalRamSize;
+                jvmargs = "-Xmx" + heapSize + "m";
             }
         }
         env.put("JAVA_OPTS", jvmargs);
@@ -132,10 +136,11 @@ public class NCService {
     /**
      * Attempts to launch the "real" NCDriver, based on the configuration
      * information gathered so far.
+     *
      * @return true if the process was successfully launched and has now
-     * exited with a 0 (normal) exit code. false if some configuration error
-     * prevented the process from being launched or the process returned
-     * a non-0 (abnormal) exit code.
+     *         exited with a 0 (normal) exit code. false if some configuration 
error
+     *         prevented the process from being launched or the process 
returned
+     *         a non-0 (abnormal) exit code.
      */
     private static boolean launchNCProcess() {
         try {
@@ -149,13 +154,11 @@ public class NCService {
             }
 
             // Logfile
-            if (! "-".equals(config.logdir)) {
+            if (!"-".equals(config.logdir)) {
                 pb.redirectErrorStream(true);
                 File log = new File(config.logdir);
-                if (! log.mkdirs()) {
-                    if (! log.isDirectory()) {
-                        throw new IOException(config.logdir + ": cannot 
create");
-                    }
+                if (!log.mkdirs() && !log.isDirectory()) {
+                    throw new IOException(config.logdir + ": cannot create");
                     // If the directory IS there, all is well
                 }
                 File logfile = new File(config.logdir, "nc-" + ncId + ".log");
@@ -202,7 +205,7 @@ public class NCService {
         try {
             ObjectInputStream ois = new ObjectInputStream(is);
             String magic = ois.readUTF();
-            if (! ServiceConstants.NC_SERVICE_MAGIC_COOKIE.equals(magic)) {
+            if (!ServiceConstants.NC_SERVICE_MAGIC_COOKIE.equals(magic)) {
                 LOGGER.severe("Connection used incorrect magic cookie");
                 return false;
             }

Reply via email to