Skip to content

Commit

Permalink
[SPARK-7031] [THRIFTSERVER] let thrift server take SPARK_DAEMON_MEMOR…
Browse files Browse the repository at this point in the history
…Y 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 <[email protected]>

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
  • Loading branch information
WangTaoTheTonic authored and srowen committed May 2, 2015
1 parent ea841ef commit 49549d5
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ private List<String> buildSparkSubmitCommand(Map<String, String> env) throws IOE
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"));

Expand All @@ -201,7 +205,11 @@ private List<String> buildSparkSubmitCommand(Map<String, String> env) throws IOE
// - 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);
Expand Down Expand Up @@ -292,6 +300,15 @@ private boolean isClientMode(Properties userProps) {
(!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
Expand Down

0 comments on commit 49549d5

Please sign in to comment.