Skip to content

Commit e98915a

Browse files
authored
[FLINK-37638][clients] Avoid duplicate call on getEffectiveConfiguration
1 parent 9302545 commit e98915a

File tree

2 files changed

+23
-42
lines changed

2 files changed

+23
-42
lines changed

Diff for: flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java

+21-37
Original file line numberDiff line numberDiff line change
@@ -187,32 +187,28 @@ protected void run(String[] args) throws Exception {
187187
final CustomCommandLine activeCommandLine =
188188
validateAndGetActiveCommandLine(checkNotNull(commandLine));
189189

190-
if (isDeploymentTargetApplication(activeCommandLine, commandLine)) {
190+
final Configuration effectiveConfiguration =
191+
getEffectiveConfiguration(activeCommandLine, commandLine);
192+
193+
if (isDeploymentTargetApplication(effectiveConfiguration)) {
191194
final ApplicationDeployer deployer =
192195
new ApplicationClusterDeployer(clusterClientServiceLoader);
193196

194197
final ProgramOptions programOptions;
195-
final Configuration effectiveConfiguration;
196198

197199
// No need to set a jarFile path for PyFlink job.
198200
if (ProgramOptionsUtils.isPythonEntryPoint(commandLine)) {
199201
programOptions = ProgramOptionsUtils.createPythonProgramOptions(commandLine);
200-
effectiveConfiguration =
201-
getEffectiveConfiguration(
202-
activeCommandLine,
203-
commandLine,
204-
programOptions,
205-
Collections.emptyList());
202+
updateEffectiveConfiguration(
203+
effectiveConfiguration, programOptions, Collections.emptyList());
206204
} else {
207205
programOptions = new ProgramOptions(commandLine);
208206
programOptions.validate();
209207
final URI uri = PackagedProgramUtils.resolveURI(programOptions.getJarFilePath());
210-
effectiveConfiguration =
211-
getEffectiveConfiguration(
212-
activeCommandLine,
213-
commandLine,
214-
programOptions,
215-
Collections.singletonList(uri.toString()));
208+
updateEffectiveConfiguration(
209+
effectiveConfiguration,
210+
programOptions,
211+
Collections.singletonList(uri.toString()));
216212
}
217213

218214
final ApplicationConfiguration applicationConfiguration =
@@ -225,9 +221,7 @@ protected void run(String[] args) throws Exception {
225221

226222
final List<URL> jobJars = getJobJarAndDependencies(programOptions);
227223

228-
final Configuration effectiveConfiguration =
229-
getEffectiveConfiguration(
230-
activeCommandLine, commandLine, programOptions, jobJars);
224+
updateEffectiveConfiguration(effectiveConfiguration, programOptions, jobJars);
231225

232226
LOG.debug("Effective executor configuration: {}", effectiveConfiguration);
233227

@@ -238,12 +232,7 @@ protected void run(String[] args) throws Exception {
238232
}
239233
}
240234

241-
protected boolean isDeploymentTargetApplication(
242-
final CustomCommandLine activeCustomCommandLine, final CommandLine commandLine)
243-
throws FlinkException {
244-
final Configuration effectiveConfiguration =
245-
getEffectiveConfiguration(activeCustomCommandLine, commandLine);
246-
235+
protected boolean isDeploymentTargetApplication(final Configuration effectiveConfiguration) {
247236
final String executionTarget =
248237
effectiveConfiguration
249238
.getOptional(DeploymentOptions.TARGET)
@@ -300,15 +289,10 @@ private Configuration getEffectiveConfiguration(
300289
return effectiveConfiguration;
301290
}
302291

303-
private <T> Configuration getEffectiveConfiguration(
304-
final CustomCommandLine activeCustomCommandLine,
305-
final CommandLine commandLine,
292+
private <T> void updateEffectiveConfiguration(
293+
final Configuration effectiveConfiguration,
306294
final ProgramOptions programOptions,
307-
final List<T> jobJars)
308-
throws FlinkException {
309-
310-
final Configuration effectiveConfiguration =
311-
getEffectiveConfiguration(activeCustomCommandLine, commandLine);
295+
final List<T> jobJars) {
312296

313297
final ExecutionConfigAccessor executionParameters =
314298
ExecutionConfigAccessor.fromProgramOptions(programOptions, jobJars);
@@ -318,7 +302,6 @@ private <T> Configuration getEffectiveConfiguration(
318302
LOG.debug(
319303
"Effective configuration after Flink conf, custom commandline, and program options: {}",
320304
effectiveConfiguration);
321-
return effectiveConfiguration;
322305
}
323306

324307
/**
@@ -354,11 +337,12 @@ protected void info(String[] args) throws Exception {
354337
validateAndGetActiveCommandLine(checkNotNull(commandLine));
355338

356339
final Configuration effectiveConfiguration =
357-
getEffectiveConfiguration(
358-
activeCommandLine,
359-
commandLine,
360-
programOptions,
361-
getJobJarAndDependencies(programOptions));
340+
getEffectiveConfiguration(activeCommandLine, commandLine);
341+
342+
updateEffectiveConfiguration(
343+
effectiveConfiguration,
344+
programOptions,
345+
getJobJarAndDependencies(programOptions));
362346

363347
program = buildProgram(programOptions, effectiveConfiguration);
364348

Diff for: flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendRunTest.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.apache.flink.configuration.CoreOptions;
2929
import org.apache.flink.core.execution.RecoveryClaimMode;
3030
import org.apache.flink.runtime.jobgraph.SavepointRestoreSettings;
31-
import org.apache.flink.util.FlinkException;
3231

3332
import org.apache.commons.cli.CommandLine;
3433
import org.junit.jupiter.api.AfterAll;
@@ -376,10 +375,8 @@ protected void run(String[] args) throws Exception {
376375
}
377376

378377
@Override
379-
protected boolean isDeploymentTargetApplication(
380-
CustomCommandLine activeCustomCommandLine, CommandLine commandLine)
381-
throws FlinkException {
382-
application = super.isDeploymentTargetApplication(activeCustomCommandLine, commandLine);
378+
protected boolean isDeploymentTargetApplication(Configuration effectiveConfiguration) {
379+
application = super.isDeploymentTargetApplication(effectiveConfiguration);
383380
return application;
384381
}
385382

0 commit comments

Comments
 (0)