Repository: spark
Updated Branches:
  refs/heads/master ea841efc5 -> 49549d5a1


[SPARK-7031] [THRIFTSERVER] let thrift server take SPARK_DAEMON_MEMORY and 
SPARK_DAEMON_JAVA_OPTS

We should let Thrift Server take these two parameters as it is a daemon. And it 
is better to read driver-related configs as an app submited by spark-submit.

https://issues.apache.org/jira/browse/SPARK-7031

Author: WangTaoTheTonic <wangtao...@huawei.com>

Closes #5609 from WangTaoTheTonic/SPARK-7031 and squashes the following commits:

8d3fc16 [WangTaoTheTonic] indent
035069b [WangTaoTheTonic] better code style
d3ddfb6 [WangTaoTheTonic] revert the unnecessary changes in suite
624e652 [WangTaoTheTonic] fix break tests
0565831 [WangTaoTheTonic] fix failed tests
4fb25ed [WangTaoTheTonic] let thrift server take SPARK_DAEMON_MEMORY and 
SPARK_DAEMON_JAVA_OPTS


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

Branch: refs/heads/master
Commit: 49549d5a1a867c3ba25f5e4aec351d4102444bc0
Parents: ea841ef
Author: WangTaoTheTonic <wangtao...@huawei.com>
Authored: Sun May 3 00:47:47 2015 +0100
Committer: Sean Owen <so...@cloudera.com>
Committed: Sun May 3 00:47:47 2015 +0100

----------------------------------------------------------------------
 .../launcher/SparkSubmitCommandBuilder.java      | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/49549d5a/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java
----------------------------------------------------------------------
diff --git 
a/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java
 
b/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java
index a73c9c8..7d387d4 100644
--- 
a/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java
+++ 
b/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java
@@ -190,6 +190,10 @@ class SparkSubmitCommandBuilder extends 
AbstractCommandBuilder {
       firstNonEmptyValue(SparkLauncher.DRIVER_EXTRA_CLASSPATH, conf, props) : 
null;
 
     List<String> cmd = buildJavaCommand(extraClassPath);
+    // Take Thrift Server as daemon
+    if (isThriftServer(mainClass)) {
+      addOptionString(cmd, System.getenv("SPARK_DAEMON_JAVA_OPTS"));
+    }
     addOptionString(cmd, System.getenv("SPARK_SUBMIT_OPTS"));
     addOptionString(cmd, System.getenv("SPARK_JAVA_OPTS"));
 
@@ -201,7 +205,11 @@ class SparkSubmitCommandBuilder extends 
AbstractCommandBuilder {
       // - SPARK_DRIVER_MEMORY env variable
       // - SPARK_MEM env variable
       // - default value (512m)
-      String memory = 
firstNonEmpty(firstNonEmptyValue(SparkLauncher.DRIVER_MEMORY, conf, props),
+      // Take Thrift Server as daemon
+      String tsMemory =
+        isThriftServer(mainClass) ? System.getenv("SPARK_DAEMON_MEMORY") : 
null;
+      String memory = firstNonEmpty(tsMemory,
+        firstNonEmptyValue(SparkLauncher.DRIVER_MEMORY, conf, props),
         System.getenv("SPARK_DRIVER_MEMORY"), System.getenv("SPARK_MEM"), 
DEFAULT_MEM);
       cmd.add("-Xms" + memory);
       cmd.add("-Xmx" + memory);
@@ -292,6 +300,15 @@ class SparkSubmitCommandBuilder extends 
AbstractCommandBuilder {
       (!userMaster.equals("yarn-cluster") && deployMode == null);
   }
 
+  /**
+   * Return whether the given main class represents a thrift server.
+   */
+  private boolean isThriftServer(String mainClass) {
+    return (mainClass != null &&
+      
mainClass.equals("org.apache.spark.sql.hive.thriftserver.HiveThriftServer2"));
+  }
+
+
   private class OptionParser extends SparkSubmitOptionParser {
 
     @Override


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to