Skip to content

Commit 49549d5

Browse files
WangTaoTheTonicsrowen
authored andcommitted
[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 <[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
1 parent ea841ef commit 49549d5

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ private List<String> buildSparkSubmitCommand(Map<String, String> env) throws IOE
190190
firstNonEmptyValue(SparkLauncher.DRIVER_EXTRA_CLASSPATH, conf, props) : null;
191191

192192
List<String> cmd = buildJavaCommand(extraClassPath);
193+
// Take Thrift Server as daemon
194+
if (isThriftServer(mainClass)) {
195+
addOptionString(cmd, System.getenv("SPARK_DAEMON_JAVA_OPTS"));
196+
}
193197
addOptionString(cmd, System.getenv("SPARK_SUBMIT_OPTS"));
194198
addOptionString(cmd, System.getenv("SPARK_JAVA_OPTS"));
195199

@@ -201,7 +205,11 @@ private List<String> buildSparkSubmitCommand(Map<String, String> env) throws IOE
201205
// - SPARK_DRIVER_MEMORY env variable
202206
// - SPARK_MEM env variable
203207
// - default value (512m)
204-
String memory = firstNonEmpty(firstNonEmptyValue(SparkLauncher.DRIVER_MEMORY, conf, props),
208+
// Take Thrift Server as daemon
209+
String tsMemory =
210+
isThriftServer(mainClass) ? System.getenv("SPARK_DAEMON_MEMORY") : null;
211+
String memory = firstNonEmpty(tsMemory,
212+
firstNonEmptyValue(SparkLauncher.DRIVER_MEMORY, conf, props),
205213
System.getenv("SPARK_DRIVER_MEMORY"), System.getenv("SPARK_MEM"), DEFAULT_MEM);
206214
cmd.add("-Xms" + memory);
207215
cmd.add("-Xmx" + memory);
@@ -292,6 +300,15 @@ private boolean isClientMode(Properties userProps) {
292300
(!userMaster.equals("yarn-cluster") && deployMode == null);
293301
}
294302

303+
/**
304+
* Return whether the given main class represents a thrift server.
305+
*/
306+
private boolean isThriftServer(String mainClass) {
307+
return (mainClass != null &&
308+
mainClass.equals("org.apache.spark.sql.hive.thriftserver.HiveThriftServer2"));
309+
}
310+
311+
295312
private class OptionParser extends SparkSubmitOptionParser {
296313

297314
@Override

0 commit comments

Comments
 (0)