Github user vanzin commented on a diff in the pull request:
https://github.com/apache/spark/pull/14201#discussion_r70870174
--- Diff:
launcher/src/main/java/org/apache/spark/launcher/SparkLauncher.java ---
@@ -359,6 +364,82 @@ public SparkLauncher setVerbose(boolean verbose) {
}
/**
+ * Sets the working directory of the driver process.
+ * @param dir The directory to set as the driver's working directory.
+ * @return This launcher.
+ */
+ public SparkLauncher directory(File dir) {
+ builder.workingDir = dir;
+ return this;
+ }
+
+ /**
+ * Specifies that stderr in the driver should be redirected to stdout.
+ * @return This launcher.
+ */
+ public SparkLauncher redirectError() {
+ builder.redirectErrorStream = true;
+ return this;
+ }
+
+ /**
+ * Redirects error output to the specified Redirect.
+ * @param to The method of redirection.
+ * @return This launcher.
+ */
+ public SparkLauncher redirectError(ProcessBuilder.Redirect to) {
+ builder.errorStream = to;
+ return this;
+ }
+
+ /**
+ * Redirects standard output to the specified Redirect.
+ * @param to The method of redirection.
+ * @return This launcher.
+ */
+ public SparkLauncher redirectOutput(ProcessBuilder.Redirect to) {
+ builder.outputStream = to;
+ return this;
+ }
+
+ /**
+ * Redirects error output to the specified File.
+ * @param errFile The file to which stderr is written.
+ * @return This launcher.
+ */
+ public SparkLauncher redirectError(File errFile) {
+ builder.errorStream = ProcessBuilder.Redirect.to(errFile);
+ return this;
+ }
+
+ /**
+ * Redirects error output to the specified File.
+ * @param outFile The file to which stdout is written.
+ * @return This launcher.
+ */
+ public SparkLauncher redirectOutput(File outFile) {
+ builder.outputStream = ProcessBuilder.Redirect.to(outFile);
+ return this;
+ }
+
+ /**
+ * Sets all output to be logged and redirected to a logger with the
specified name.
+ * @param loggerName The name of the logger to log stdout and stderr.
+ * @return This launcher.
+ */
+ public SparkLauncher redirectToLog(String loggerName) {
+ try {
+ // NOTE: the below ordering is important, so builder.redirectToLog
is only set to true iff
+ // the preceding put() finishes without exception.
+ builder.getEffectiveConfig().put(CHILD_PROCESS_LOGGER_NAME,
loggerName);
--- End diff --
`setConf` instead of `builder.getEffectiveConfig().put`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]