@@ -109,35 +109,48 @@ public List<String> buildCommand(Map<String, String> env) throws IOException {
109
109
}
110
110
111
111
private List <String > createSparkSubmitCommand (Map <String , String > env ) throws IOException {
112
- List <String > sparkSubmitArgs = new ArrayList <String >(classArgs );
112
+ final List <String > sparkSubmitArgs = new ArrayList <String >();
113
+ final List <String > appArgs = new ArrayList <String >();
113
114
114
- // This is a workaround for the fact that the constants in SparkSubmitOptionParser are not
115
- // static. The parser itself is never used, we just don't want to hardcode the value of that
116
- // option here.
115
+ // This parser exists for two reasons:
116
+ // - to expose the command line args constants, since they're not static
117
+ // - to special-case the HELP command line argument, and allow it to be propagated to
118
+ // the app being launched.
117
119
SparkSubmitOptionParser parser = new SparkSubmitOptionParser () {
118
120
119
121
@ Override
120
122
protected boolean handle (String opt , String value ) {
121
- throw new UnsupportedOperationException ();
123
+ if (opt .equals (HELP )) {
124
+ appArgs .add (opt );
125
+ } else {
126
+ sparkSubmitArgs .add (opt );
127
+ sparkSubmitArgs .add (value );
128
+ }
129
+ return true ;
122
130
}
123
131
124
132
@ Override
125
133
protected boolean handleUnknown (String opt ) {
126
- throw new UnsupportedOperationException ();
134
+ appArgs .add (opt );
135
+ return true ;
127
136
}
128
137
129
138
@ Override
130
139
protected void handleExtraArgs (List <String > extra ) {
131
- throw new UnsupportedOperationException ( );
140
+ appArgs . addAll ( extra );
132
141
}
133
142
134
143
};
135
144
145
+ parser .parse (classArgs );
136
146
sparkSubmitArgs .add (parser .CLASS );
137
147
sparkSubmitArgs .add (className );
138
148
139
149
SparkSubmitCommandBuilder builder = new SparkSubmitCommandBuilder (true , sparkSubmitArgs );
140
150
builder .setAppResource ("spark-internal" );
151
+ for (String arg : appArgs ) {
152
+ builder .addAppArgs (arg );
153
+ }
141
154
return builder .buildCommand (env );
142
155
}
143
156
0 commit comments