Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,15 @@ private List<String> buildSparkSubmitCommand(Map<String, String> env)
}

private void checkJavaOptions(String javaOptions) {
if (!isEmpty(javaOptions) && javaOptions.contains("Xmx")) {
String msg = String.format("Not allowed to specify max heap(Xmx) memory settings through " +
"java options (was %s). Use the corresponding --driver-memory or " +
"spark.driver.memory configuration instead.", javaOptions);
throw new IllegalArgumentException(msg);
if (!isEmpty(javaOptions)) {
for (String javaOption: CommandBuilderUtils.parseOptionString(javaOptions)) {
if (javaOption.startsWith("-Xmx")) {
String msg = String.format("Not allowed to specify max heap(Xmx) memory settings " +
"through java options (was %s). Use the corresponding --driver-memory or " +
"spark.driver.memory configuration instead.", javaOptions);
throw new IllegalArgumentException(msg);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,36 @@ public void testCliHelpAndNoArg() throws Exception {
cmd.contains("org.apache.spark.deploy.SparkSubmit"));
}

@Test(expected = IllegalArgumentException.class)
public void testCheckJavaOptionsThrowException() throws Exception {
Map<String, String> env = new HashMap<>();
List<String> sparkSubmitArgs = Arrays.asList(
parser.MASTER,
"local",
parser.DRIVER_CLASS_PATH,
"/driverCp",
parser.DRIVER_JAVA_OPTIONS,
"-Xmx64g -Dprop=Other -Dprop1=\"-Xmx -Xmx\" -Dprop2=\"-Xmx '-Xmx\" " +
"-Dprop3='-Xmx -Xmx' -Dprop4='-Xmx \"-Xmx'",
SparkLauncher.NO_RESOURCE);
buildCommand(sparkSubmitArgs, env);
}

@Test
public void testCheckJavaOptions() throws Exception {
Map<String, String> env = new HashMap<>();
List<String> sparkSubmitArgs = Arrays.asList(
parser.MASTER,
"local",
parser.DRIVER_CLASS_PATH,
"/driverCp",
parser.DRIVER_JAVA_OPTIONS,
"-Dprop=-Xmx -Dprop1=\"-Xmx -Xmx\" -Dprop2=\"-Xmx '-Xmx\" " +
"-Dprop3='-Xmx -Xmx' -Dprop4='-Xmx \"-Xmx'",
SparkLauncher.NO_RESOURCE);
buildCommand(sparkSubmitArgs, env);
}

@Test
public void testCliKillAndStatus() throws Exception {
List<String> params = Arrays.asList("driver-20160531171222-0000");
Expand Down