You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by kk...@apache.org on 2019/12/14 12:40:53 UTC

[flink] branch release-1.10 updated (fc0a19d -> 295e7d9)

This is an automated email from the ASF dual-hosted git repository.

kkloudas pushed a change to branch release-1.10
in repository https://gitbox.apache.org/repos/asf/flink.git.


    from fc0a19d  [FLINK-15240][hive] is_generic key is missing for Flink table stored in HiveCatalog
     new 1288731  [hotfix] Leverage autoCloseable to simplify CliFrontend.runClusterAction()
     new a50decf  [FLINK-15179] Introduce generic ExecutorCLI
     new 903e31e  [FLINK-15179] Remove StandaloneSessionClusterExecutor so ExecutorCLI supports list()/cancel()
     new a0f1def  [FLINK-15179] Make Kubernetes Session CLI use the ExecutorCLI
     new 09acfab  [FLINK-15179] Assume Deployment.target=kubernetes-session when in KubernetesSessionCli
     new 426a875  [FLINK-15179] Annotate KubernetesSessionCli as internal
     new 295e7d9  [FLINK-15260] Uniformize Kubernetes executor name with the rest

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../client/cli/AbstractCustomCommandLine.java      |   8 +-
 .../org/apache/flink/client/cli/CliFrontend.java   |  42 +--
 .../org/apache/flink/client/cli/ExecutorCLI.java   | 122 ++++++++
 .../flink/client/deployment/ClusterDescriptor.java |   3 +
 .../client/deployment/StandaloneClientFactory.java |   4 +-
 .../deployment/StandaloneClusterDescriptor.java    |   2 +-
 .../StandaloneSessionClusterExecutor.java          |  38 ---
 .../StandaloneSessionClusterExecutorFactory.java   |  44 ---
 ...org.apache.flink.core.execution.ExecutorFactory |   1 -
 .../apache/flink/client/cli/ExecutorCLITest.java   | 125 +++++++++
 .../deployment/ClusterClientServiceLoaderTest.java |   4 +-
 .../flink-bin/kubernetes-bin/kubernetes-session.sh |   2 +-
 .../kubernetes/cli/FlinkKubernetesCustomCli.java   | 306 ---------------------
 .../flink/kubernetes/cli/KubernetesCliOptions.java |  95 -------
 .../flink/kubernetes/cli/KubernetesSessionCli.java | 194 +++++++++++++
 .../KubernetesSessionClusterExecutor.java          |   2 +-
 ...mCliTest.java => KubernetesSessionCliTest.java} | 161 +++++------
 17 files changed, 535 insertions(+), 618 deletions(-)
 create mode 100644 flink-clients/src/main/java/org/apache/flink/client/cli/ExecutorCLI.java
 delete mode 100644 flink-clients/src/main/java/org/apache/flink/client/deployment/executors/StandaloneSessionClusterExecutor.java
 delete mode 100644 flink-clients/src/main/java/org/apache/flink/client/deployment/executors/StandaloneSessionClusterExecutorFactory.java
 create mode 100644 flink-clients/src/test/java/org/apache/flink/client/cli/ExecutorCLITest.java
 delete mode 100644 flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/FlinkKubernetesCustomCli.java
 delete mode 100644 flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesCliOptions.java
 create mode 100644 flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java
 rename flink-kubernetes/src/test/java/org/apache/flink/kubernetes/{FlinkKubernetesCustomCliTest.java => KubernetesSessionCliTest.java} (63%)


[flink] 01/07: [hotfix] Leverage autoCloseable to simplify CliFrontend.runClusterAction()

Posted by kk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kkloudas pushed a commit to branch release-1.10
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 1288731042dfd5e8997177dc2ff94d3e6007622e
Author: Kostas Kloudas <kk...@gmail.com>
AuthorDate: Wed Dec 11 09:59:27 2019 +0100

    [hotfix] Leverage autoCloseable to simplify CliFrontend.runClusterAction()
---
 .../org/apache/flink/client/cli/CliFrontend.java   | 29 +++++-----------------
 .../flink/client/deployment/ClusterDescriptor.java |  3 +++
 .../deployment/StandaloneClusterDescriptor.java    |  2 +-
 3 files changed, 10 insertions(+), 24 deletions(-)

diff --git a/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java b/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java
index 3566772..4b5a1a0 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java
@@ -852,33 +852,16 @@ public class CliFrontend {
 	 */
 	private <ClusterID> void runClusterAction(CustomCommandLine activeCommandLine, CommandLine commandLine, ClusterAction<ClusterID> clusterAction) throws FlinkException {
 		final Configuration executorConfig = activeCommandLine.applyCommandLineOptionsToConfiguration(commandLine);
-
 		final ClusterClientFactory<ClusterID> clusterClientFactory = clusterClientServiceLoader.getClusterClientFactory(executorConfig);
-		final ClusterDescriptor<ClusterID> clusterDescriptor = clusterClientFactory.createClusterDescriptor(executorConfig);
-		final ClusterID clusterId = clusterClientFactory.getClusterId(executorConfig);
 
+		final ClusterID clusterId = clusterClientFactory.getClusterId(executorConfig);
 		if (clusterId == null) {
-			throw new FlinkException("No cluster id was specified. Please specify a cluster to which " +
-				"you would like to connect.");
-		} else {
-			try {
-				final ClusterClient<ClusterID> clusterClient = clusterDescriptor.retrieve(clusterId).getClusterClient();
+			throw new FlinkException("No cluster id was specified. Please specify a cluster to which you would like to connect.");
+		}
 
-				try {
-					clusterAction.runAction(clusterClient);
-				} finally {
-					try {
-						clusterClient.close();
-					} catch (Exception e) {
-						LOG.info("Could not properly shut down the cluster client.", e);
-					}
-				}
-			} finally {
-				try {
-					clusterDescriptor.close();
-				} catch (Exception e) {
-					LOG.info("Could not properly close the cluster descriptor.", e);
-				}
+		try (final ClusterDescriptor<ClusterID> clusterDescriptor = clusterClientFactory.createClusterDescriptor(executorConfig)) {
+			try (final ClusterClient<ClusterID> clusterClient = clusterDescriptor.retrieve(clusterId).getClusterClient()) {
+				clusterAction.runAction(clusterClient);
 			}
 		}
 	}
diff --git a/flink-clients/src/main/java/org/apache/flink/client/deployment/ClusterDescriptor.java b/flink-clients/src/main/java/org/apache/flink/client/deployment/ClusterDescriptor.java
index ca5db45..0378161 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/deployment/ClusterDescriptor.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/deployment/ClusterDescriptor.java
@@ -73,4 +73,7 @@ public interface ClusterDescriptor<T> extends AutoCloseable {
 	 * @throws FlinkException if the cluster could not be terminated
 	 */
 	void killCluster(T clusterId) throws FlinkException;
+
+	@Override
+	void close();
 }
diff --git a/flink-clients/src/main/java/org/apache/flink/client/deployment/StandaloneClusterDescriptor.java b/flink-clients/src/main/java/org/apache/flink/client/deployment/StandaloneClusterDescriptor.java
index a79ff2f..1d47b05 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/deployment/StandaloneClusterDescriptor.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/deployment/StandaloneClusterDescriptor.java
@@ -74,7 +74,7 @@ public class StandaloneClusterDescriptor implements ClusterDescriptor<Standalone
 	}
 
 	@Override
-	public void close() throws Exception {
+	public void close() {
 		// nothing to do
 	}
 }


[flink] 07/07: [FLINK-15260] Uniformize Kubernetes executor name with the rest

Posted by kk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kkloudas pushed a commit to branch release-1.10
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 295e7d981039c75e47b942ab4db91de35172d05b
Author: Kostas Kloudas <kk...@gmail.com>
AuthorDate: Sat Dec 14 13:37:43 2019 +0100

    [FLINK-15260] Uniformize Kubernetes executor name with the rest
---
 .../flink/kubernetes/executors/KubernetesSessionClusterExecutor.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/executors/KubernetesSessionClusterExecutor.java b/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/executors/KubernetesSessionClusterExecutor.java
index 671ea88..227c535 100644
--- a/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/executors/KubernetesSessionClusterExecutor.java
+++ b/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/executors/KubernetesSessionClusterExecutor.java
@@ -29,7 +29,7 @@ import org.apache.flink.kubernetes.KubernetesClusterClientFactory;
 @Internal
 public class KubernetesSessionClusterExecutor extends AbstractSessionClusterExecutor<String, KubernetesClusterClientFactory> {
 
-	public static final String NAME = "kubernetes-session-cluster";
+	public static final String NAME = "kubernetes-session-executor";
 
 	public KubernetesSessionClusterExecutor() {
 		super(new KubernetesClusterClientFactory());


[flink] 06/07: [FLINK-15179] Annotate KubernetesSessionCli as internal

Posted by kk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kkloudas pushed a commit to branch release-1.10
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 426a875a020b7f39e9edd7810e58f6aa491f8fe1
Author: Kostas Kloudas <kk...@gmail.com>
AuthorDate: Thu Dec 12 14:19:01 2019 +0100

    [FLINK-15179] Annotate KubernetesSessionCli as internal
---
 .../main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java b/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java
index a46de6f..568ff2e 100644
--- a/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java
+++ b/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java
@@ -18,6 +18,7 @@
 
 package org.apache.flink.kubernetes.cli;
 
+import org.apache.flink.annotation.Internal;
 import org.apache.flink.api.java.tuple.Tuple2;
 import org.apache.flink.client.cli.AbstractCustomCommandLine;
 import org.apache.flink.client.cli.CliArgsException;
@@ -50,6 +51,7 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
 /**
  * Kubernetes customized commandline.
  */
+@Internal
 public class KubernetesSessionCli {
 
 	private static final Logger LOG = LoggerFactory.getLogger(KubernetesSessionCli.class);


[flink] 04/07: [FLINK-15179] Make Kubernetes Session CLI use the ExecutorCLI

Posted by kk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kkloudas pushed a commit to branch release-1.10
in repository https://gitbox.apache.org/repos/asf/flink.git

commit a0f1def4f8ebecd4b5c677766571d7fa9bd2415b
Author: Kostas Kloudas <kk...@gmail.com>
AuthorDate: Tue Dec 10 18:31:56 2019 +0100

    [FLINK-15179] Make Kubernetes Session CLI use the ExecutorCLI
---
 .../client/cli/AbstractCustomCommandLine.java      |   4 +-
 .../org/apache/flink/client/cli/CliFrontend.java   |  13 -
 .../flink-bin/kubernetes-bin/kubernetes-session.sh |   2 +-
 .../kubernetes/cli/FlinkKubernetesCustomCli.java   | 306 ---------------------
 .../flink/kubernetes/cli/KubernetesCliOptions.java |  95 -------
 .../flink/kubernetes/cli/KubernetesSessionCli.java | 189 +++++++++++++
 ...mCliTest.java => KubernetesSessionCliTest.java} | 150 +++++-----
 7 files changed, 254 insertions(+), 505 deletions(-)

diff --git a/flink-clients/src/main/java/org/apache/flink/client/cli/AbstractCustomCommandLine.java b/flink-clients/src/main/java/org/apache/flink/client/cli/AbstractCustomCommandLine.java
index b3fd269..ab539e5 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/cli/AbstractCustomCommandLine.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/cli/AbstractCustomCommandLine.java
@@ -105,7 +105,7 @@ public abstract class AbstractCustomCommandLine implements CustomCommandLine {
 		formatter.printHelp(" ", options);
 	}
 
-	protected static int handleCliArgsException(CliArgsException e, Logger logger) {
+	public static int handleCliArgsException(CliArgsException e, Logger logger) {
 		logger.error("Could not parse the command line arguments.", e);
 
 		System.out.println(e.getMessage());
@@ -114,7 +114,7 @@ public abstract class AbstractCustomCommandLine implements CustomCommandLine {
 		return 1;
 	}
 
-	protected static int handleError(Throwable t, Logger logger) {
+	public static int handleError(Throwable t, Logger logger) {
 		logger.error("Error while running the Flink session.", t);
 
 		System.err.println();
diff --git a/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java b/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java
index 0c4a98b..3a45813 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java
@@ -1057,19 +1057,6 @@ public class CliFrontend {
 			LOG.warn("Could not load CLI class {}.", flinkYarnSessionCLI, e);
 		}
 
-		//	Command line interface of the kubernetes session, with a special initialization here
-		//  to prefix all options with k/kubernetes.
-		final String kubeSessionCLI = "org.apache.flink.kubernetes.cli.FlinkKubernetesCustomCli";
-		try {
-			customCommandLines.add(
-				loadCustomCommandLine(kubeSessionCLI,
-					configuration,
-					"k",
-					"kubernetes"));
-		} catch (NoClassDefFoundError | Exception e) {
-			LOG.warn("Could not load CLI class {}.", kubeSessionCLI, e);
-		}
-
 		customCommandLines.add(new ExecutorCLI(configuration));
 
 		//	Tips: DefaultCLI must be added at last, because getActiveCustomCommandLine(..) will get the
diff --git a/flink-dist/src/main/flink-bin/kubernetes-bin/kubernetes-session.sh b/flink-dist/src/main/flink-bin/kubernetes-bin/kubernetes-session.sh
index 9e37d06..afa920f 100644
--- a/flink-dist/src/main/flink-bin/kubernetes-bin/kubernetes-session.sh
+++ b/flink-dist/src/main/flink-bin/kubernetes-bin/kubernetes-session.sh
@@ -36,4 +36,4 @@ log_setting="-Dlog.file="$log" -Dlog4j.configuration=file:"$FLINK_CONF_DIR"/log4
 
 export FLINK_CONF_DIR
 
-$JAVA_RUN $JVM_ARGS -classpath "$CC_CLASSPATH" $log_setting org.apache.flink.kubernetes.cli.FlinkKubernetesCustomCli "$@"
+$JAVA_RUN $JVM_ARGS -classpath "$CC_CLASSPATH" $log_setting org.apache.flink.kubernetes.cli.KubernetesSessionCli "$@"
diff --git a/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/FlinkKubernetesCustomCli.java b/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/FlinkKubernetesCustomCli.java
deleted file mode 100644
index 9176e9a..0000000
--- a/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/FlinkKubernetesCustomCli.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.kubernetes.cli;
-
-import org.apache.flink.api.java.tuple.Tuple2;
-import org.apache.flink.client.cli.AbstractCustomCommandLine;
-import org.apache.flink.client.cli.CliArgsException;
-import org.apache.flink.client.deployment.ClusterClientFactory;
-import org.apache.flink.client.deployment.ClusterClientServiceLoader;
-import org.apache.flink.client.deployment.ClusterDescriptor;
-import org.apache.flink.client.deployment.DefaultClusterClientServiceLoader;
-import org.apache.flink.client.program.ClusterClient;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.configuration.DeploymentOptions;
-import org.apache.flink.configuration.GlobalConfiguration;
-import org.apache.flink.configuration.JobManagerOptions;
-import org.apache.flink.configuration.MemorySize;
-import org.apache.flink.configuration.TaskManagerOptions;
-import org.apache.flink.kubernetes.configuration.KubernetesConfigOptions;
-import org.apache.flink.kubernetes.executors.KubernetesSessionClusterExecutor;
-import org.apache.flink.kubernetes.kubeclient.FlinkKubeClient;
-import org.apache.flink.kubernetes.kubeclient.KubeClientFactory;
-import org.apache.flink.runtime.security.SecurityUtils;
-import org.apache.flink.util.FlinkException;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.Properties;
-
-import static org.apache.flink.client.cli.CliFrontendParser.DETACHED_OPTION;
-import static org.apache.flink.configuration.HighAvailabilityOptions.HA_CLUSTER_ID;
-import static org.apache.flink.kubernetes.cli.KubernetesCliOptions.CLUSTER_ID_OPTION;
-import static org.apache.flink.kubernetes.cli.KubernetesCliOptions.DYNAMIC_PROPERTY_OPTION;
-import static org.apache.flink.kubernetes.cli.KubernetesCliOptions.HELP_OPTION;
-import static org.apache.flink.kubernetes.cli.KubernetesCliOptions.IMAGE_OPTION;
-
-/**
- * Kubernetes customized commandline.
- */
-public class FlinkKubernetesCustomCli extends AbstractCustomCommandLine {
-
-	private static final Logger LOG = LoggerFactory.getLogger(FlinkKubernetesCustomCli.class);
-
-	private static final long CLIENT_POLLING_INTERVAL_MS = 3000L;
-
-	private static final String KUBERNETES_CLUSTER_HELP = "Available commands:\n" +
-		"help - show these commands\n" +
-		"stop - stop the kubernetes cluster\n" +
-		"quit - quit attach mode";
-
-	private static final String ID = "kubernetes-cluster";
-
-	// Options with short prefix(k) or long prefix(kubernetes)
-	private final Option imageOption;
-	private final Option clusterIdOption;
-	private final Option jobManagerMemoryOption;
-	private final Option taskManagerMemoryOption;
-	private final Option taskManagerSlotsOption;
-	private final Option dynamicPropertiesOption;
-	private final Option helpOption;
-
-	private final ClusterClientServiceLoader clusterClientServiceLoader;
-
-	public FlinkKubernetesCustomCli(Configuration configuration, String shortPrefix, String longPrefix) {
-		this(configuration, new DefaultClusterClientServiceLoader(), shortPrefix, longPrefix);
-	}
-
-	public FlinkKubernetesCustomCli(
-			Configuration configuration,
-			ClusterClientServiceLoader clusterClientServiceLoader,
-			String shortPrefix,
-			String longPrefix) {
-		super(configuration);
-
-		this.clusterClientServiceLoader = clusterClientServiceLoader;
-
-		this.imageOption = KubernetesCliOptions.getOptionWithPrefix(IMAGE_OPTION, shortPrefix, longPrefix);
-		this.clusterIdOption = KubernetesCliOptions.getOptionWithPrefix(CLUSTER_ID_OPTION, shortPrefix, longPrefix);
-		this.dynamicPropertiesOption = KubernetesCliOptions.getOptionWithPrefix(
-			DYNAMIC_PROPERTY_OPTION, shortPrefix, longPrefix);
-
-		this.jobManagerMemoryOption = KubernetesCliOptions.getOptionWithPrefix(
-			KubernetesCliOptions.JOB_MANAGER_MEMORY_OPTION, shortPrefix, longPrefix);
-		this.taskManagerMemoryOption = KubernetesCliOptions.getOptionWithPrefix(
-			KubernetesCliOptions.TASK_MANAGER_MEMORY_OPTION, shortPrefix, longPrefix);
-		this.taskManagerSlotsOption = KubernetesCliOptions.getOptionWithPrefix(
-			KubernetesCliOptions.TASK_MANAGER_SLOTS_OPTION, shortPrefix, longPrefix);
-
-		this.helpOption = KubernetesCliOptions.getOptionWithPrefix(HELP_OPTION, shortPrefix, longPrefix);
-	}
-
-	/**
-	 * active if commandline contains option -m kubernetes-cluster or -kid.
-	 */
-	@Override
-	public boolean isActive(CommandLine commandLine) {
-		final String jobManagerOption = commandLine.getOptionValue(addressOption.getOpt(), null);
-		final boolean k8sJobManager = ID.equals(jobManagerOption);
-		final boolean k8sClusterId = commandLine.hasOption(clusterIdOption.getOpt());
-		return k8sJobManager || k8sClusterId;
-	}
-
-	@Override
-	public void addRunOptions(Options baseOptions) {
-		baseOptions.addOption(DETACHED_OPTION)
-			.addOption(imageOption)
-			.addOption(clusterIdOption)
-			.addOption(jobManagerMemoryOption)
-			.addOption(taskManagerMemoryOption)
-			.addOption(taskManagerSlotsOption)
-			.addOption(dynamicPropertiesOption)
-			.addOption(helpOption);
-	}
-
-	@Override
-	public void addGeneralOptions(Options baseOptions) {
-		baseOptions.addOption(clusterIdOption);
-	}
-
-	@Override
-	public String getId() {
-		return ID;
-	}
-
-	@Override
-	public Configuration applyCommandLineOptionsToConfiguration(CommandLine commandLine) {
-		final Configuration effectiveConfiguration = new Configuration(configuration);
-
-		effectiveConfiguration.setString(DeploymentOptions.TARGET, KubernetesSessionClusterExecutor.NAME);
-
-		if (commandLine.hasOption(clusterIdOption.getOpt())) {
-			final String clusterId = commandLine.getOptionValue(clusterIdOption.getOpt());
-			effectiveConfiguration.setString(KubernetesConfigOptions.CLUSTER_ID, clusterId);
-			effectiveConfiguration.setString(HA_CLUSTER_ID, clusterId);
-		}
-
-		if (commandLine.hasOption(imageOption.getOpt())) {
-			effectiveConfiguration.setString(KubernetesConfigOptions.CONTAINER_IMAGE,
-				commandLine.getOptionValue(imageOption.getOpt()));
-		}
-
-		if (commandLine.hasOption(jobManagerMemoryOption.getOpt())) {
-			String jmMemoryVal = commandLine.getOptionValue(jobManagerMemoryOption.getOpt());
-			if (!MemorySize.MemoryUnit.hasUnit(jmMemoryVal)) {
-				jmMemoryVal += "m";
-			}
-			effectiveConfiguration.setString(JobManagerOptions.JOB_MANAGER_HEAP_MEMORY, jmMemoryVal);
-		}
-
-		if (commandLine.hasOption(taskManagerMemoryOption.getOpt())) {
-			String tmMemoryVal = commandLine.getOptionValue(taskManagerMemoryOption.getOpt());
-			if (!MemorySize.MemoryUnit.hasUnit(tmMemoryVal)) {
-				tmMemoryVal += "m";
-			}
-			effectiveConfiguration.setString(TaskManagerOptions.TOTAL_PROCESS_MEMORY, tmMemoryVal);
-		}
-
-		if (commandLine.hasOption(taskManagerSlotsOption.getOpt())) {
-			effectiveConfiguration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS,
-				Integer.parseInt(commandLine.getOptionValue(taskManagerSlotsOption.getOpt())));
-		}
-
-		final Properties dynamicProperties = commandLine.getOptionProperties(dynamicPropertiesOption.getOpt());
-		for (String key : dynamicProperties.stringPropertyNames()) {
-			effectiveConfiguration.setString(key, dynamicProperties.getProperty(key));
-		}
-
-		return effectiveConfiguration;
-	}
-
-	private int run(String[] args) throws CliArgsException, FlinkException {
-		final CommandLine cmd = parseCommandLineOptions(args, true);
-
-		if (cmd.hasOption(HELP_OPTION.getOpt())) {
-			printUsage();
-			return 0;
-		}
-
-		final Configuration configuration = applyCommandLineOptionsToConfiguration(cmd);
-		final ClusterClientFactory<String> kubernetesClusterClientFactory =
-			clusterClientServiceLoader.getClusterClientFactory(configuration);
-
-		final ClusterDescriptor<String> kubernetesClusterDescriptor =
-			kubernetesClusterClientFactory.createClusterDescriptor(configuration);
-
-		try {
-			final ClusterClient<String> clusterClient;
-			String clusterId = kubernetesClusterClientFactory.getClusterId(configuration);
-			final boolean detached = cmd.hasOption(DETACHED_OPTION.getOpt());
-			final FlinkKubeClient kubeClient = KubeClientFactory.fromConfiguration(configuration);
-
-			// Retrieve or create a session cluster.
-			if (clusterId != null && kubeClient.getInternalService(clusterId) != null) {
-				clusterClient = kubernetesClusterDescriptor.retrieve(clusterId).getClusterClient();
-			} else {
-				clusterClient = kubernetesClusterDescriptor
-						.deploySessionCluster(
-								kubernetesClusterClientFactory.getClusterSpecification(configuration))
-						.getClusterClient();
-				clusterId = clusterClient.getClusterId();
-			}
-
-			try {
-				if (!detached) {
-					Tuple2<Boolean, Boolean> continueRepl = new Tuple2<>(true, false);
-					try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
-						while (continueRepl.f0) {
-							continueRepl = repStep(in);
-						}
-					} catch (Exception e) {
-						LOG.warn("Exception while running the interactive command line interface.", e);
-					}
-					if (continueRepl.f1) {
-						kubernetesClusterDescriptor.killCluster(clusterId);
-					}
-				}
-				clusterClient.close();
-				kubeClient.close();
-			} catch (Exception e) {
-				LOG.info("Could not properly shutdown cluster client.", e);
-			}
-		} finally {
-			try {
-				kubernetesClusterDescriptor.close();
-			} catch (Exception e) {
-				LOG.info("Could not properly close the kubernetes cluster descriptor.", e);
-			}
-		}
-
-		return 0;
-	}
-
-	/**
-	 * Check whether need to continue or kill the cluster.
-	 * @param in input buffer reader
-	 * @return f0, whether need to continue read from input. f1, whether need to kill the cluster.
-	 */
-	private Tuple2<Boolean, Boolean> repStep(BufferedReader in) throws IOException, InterruptedException {
-		final long startTime = System.currentTimeMillis();
-		while ((System.currentTimeMillis() - startTime) < CLIENT_POLLING_INTERVAL_MS
-			&& (!in.ready())) {
-			Thread.sleep(200L);
-		}
-		//------------- handle interactive command by user. ----------------------
-
-		if (in.ready()) {
-			final String command = in.readLine();
-			switch (command) {
-				case "quit":
-					return new Tuple2<>(false, false);
-				case "stop":
-					return new Tuple2<>(false, true);
-
-				case "help":
-					System.err.println(KUBERNETES_CLUSTER_HELP);
-					break;
-				default:
-					System.err.println("Unknown command '" + command + "'. Showing help:");
-					System.err.println(KUBERNETES_CLUSTER_HELP);
-					break;
-			}
-		}
-
-		return new Tuple2<>(true, false);
-	}
-
-	public static void main(String[] args) {
-		final Configuration configuration = GlobalConfiguration.loadConfiguration();
-
-		int retCode;
-
-		try {
-			final FlinkKubernetesCustomCli cli = new FlinkKubernetesCustomCli(configuration, "", "");
-			retCode = SecurityUtils.getInstalledContext().runSecured(() -> cli.run(args));
-		} catch (CliArgsException e) {
-			retCode = handleCliArgsException(e, LOG);
-		} catch (Exception e) {
-			retCode = handleError(e, LOG);
-		}
-
-		System.exit(retCode);
-	}
-}
diff --git a/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesCliOptions.java b/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesCliOptions.java
deleted file mode 100644
index c95e04c..0000000
--- a/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesCliOptions.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.kubernetes.cli;
-
-import org.apache.commons.cli.Option;
-
-/**
- * Options for kubernetes cli and entrypoint.
- */
-public class KubernetesCliOptions {
-
-	public static Option getOptionWithPrefix(Option option, String shortPrefix, String longPrefix) {
-		if (shortPrefix.isEmpty() && longPrefix.isEmpty()) {
-			return option;
-		}
-		return Option.builder(shortPrefix + option.getOpt())
-			.longOpt(option.getLongOpt() == null ? null : longPrefix + option.getLongOpt())
-			.required(option.isRequired())
-			.hasArg(option.hasArg())
-			.numberOfArgs(option.getArgs())
-			.argName(option.getArgName())
-			.desc(option.getDescription())
-			.valueSeparator()
-			.build();
-	}
-
-	public static final Option CLUSTER_ID_OPTION = Option.builder("id")
-		.longOpt("clusterId")
-		.required(false)
-		.hasArg(true)
-		.desc("The cluster id used for identifying the unique flink cluster. If it's not set, the client will generate " +
-			"a random UUID name.")
-		.build();
-
-	public static final Option IMAGE_OPTION = Option.builder("i")
-		.longOpt("image")
-		.required(false)
-		.hasArg(true)
-		.argName("image-name")
-		.desc("Image to use for Flink containers")
-		.build();
-
-	public static final Option JOB_MANAGER_MEMORY_OPTION = Option.builder("jm")
-		.longOpt("jobManagerMemory")
-		.required(false)
-		.hasArg(true)
-		.desc("Memory for JobManager Container with optional unit (default: MB)")
-		.build();
-
-	public static final Option TASK_MANAGER_MEMORY_OPTION = Option.builder("tm")
-		.longOpt("taskManagerMemory")
-		.required(false)
-		.hasArg(true)
-		.desc("Memory per TaskManager Container with optional unit (default: MB)")
-		.build();
-
-	public static final Option TASK_MANAGER_SLOTS_OPTION = Option.builder("s")
-		.longOpt("slots")
-		.required(false)
-		.hasArg(true)
-		.desc("Number of slots per TaskManager")
-		.build();
-
-	public static final Option DYNAMIC_PROPERTY_OPTION = Option.builder("D")
-		.argName("property=value")
-		.numberOfArgs(2)
-		.valueSeparator()
-		.desc("use value for given property")
-		.build();
-
-	public static final Option HELP_OPTION = Option.builder("h")
-		.longOpt("help")
-		.hasArg(false)
-		.desc("Help for Kubernetes session CLI.")
-		.build();
-
-	/** This class is not meant to be instantiated. */
-	private KubernetesCliOptions() {}
-}
diff --git a/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java b/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java
new file mode 100644
index 0000000..8211e48
--- /dev/null
+++ b/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.kubernetes.cli;
+
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.client.cli.AbstractCustomCommandLine;
+import org.apache.flink.client.cli.CliArgsException;
+import org.apache.flink.client.cli.ExecutorCLI;
+import org.apache.flink.client.deployment.ClusterClientFactory;
+import org.apache.flink.client.deployment.ClusterClientServiceLoader;
+import org.apache.flink.client.deployment.ClusterDescriptor;
+import org.apache.flink.client.deployment.DefaultClusterClientServiceLoader;
+import org.apache.flink.client.program.ClusterClient;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.DeploymentOptions;
+import org.apache.flink.configuration.GlobalConfiguration;
+import org.apache.flink.configuration.UnmodifiableConfiguration;
+import org.apache.flink.kubernetes.kubeclient.FlinkKubeClient;
+import org.apache.flink.kubernetes.kubeclient.KubeClientFactory;
+import org.apache.flink.runtime.security.SecurityUtils;
+import org.apache.flink.util.FlinkException;
+
+import org.apache.commons.cli.CommandLine;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * Kubernetes customized commandline.
+ */
+public class KubernetesSessionCli {
+
+	private static final Logger LOG = LoggerFactory.getLogger(KubernetesSessionCli.class);
+
+	private static final long CLIENT_POLLING_INTERVAL_MS = 3000L;
+
+	private static final String KUBERNETES_CLUSTER_HELP = "Available commands:\n" +
+		"help - show these commands\n" +
+		"stop - stop the kubernetes cluster\n" +
+		"quit - quit attach mode";
+
+	private final Configuration baseConfiguration;
+
+	private final ExecutorCLI cli;
+	private final ClusterClientServiceLoader clusterClientServiceLoader;
+
+	public KubernetesSessionCli(Configuration configuration) {
+		this(configuration, new DefaultClusterClientServiceLoader());
+	}
+
+	public KubernetesSessionCli(Configuration configuration, ClusterClientServiceLoader clusterClientServiceLoader) {
+		this.baseConfiguration = new UnmodifiableConfiguration(checkNotNull(configuration));
+		this.clusterClientServiceLoader = checkNotNull(clusterClientServiceLoader);
+		this.cli = new ExecutorCLI(baseConfiguration);
+	}
+
+	public Configuration getEffectiveConfiguration(String[] args) throws CliArgsException {
+		final CommandLine commandLine = cli.parseCommandLineOptions(args, true);
+		return cli.applyCommandLineOptionsToConfiguration(commandLine);
+	}
+
+	private int run(String[] args) throws FlinkException, CliArgsException {
+		final Configuration configuration = getEffectiveConfiguration(args);
+
+		final ClusterClientFactory<String> kubernetesClusterClientFactory =
+			clusterClientServiceLoader.getClusterClientFactory(configuration);
+
+		final ClusterDescriptor<String> kubernetesClusterDescriptor =
+			kubernetesClusterClientFactory.createClusterDescriptor(configuration);
+
+		try {
+			final ClusterClient<String> clusterClient;
+			String clusterId = kubernetesClusterClientFactory.getClusterId(configuration);
+			final boolean detached = !configuration.get(DeploymentOptions.ATTACHED);
+			final FlinkKubeClient kubeClient = KubeClientFactory.fromConfiguration(configuration);
+
+			// Retrieve or create a session cluster.
+			if (clusterId != null && kubeClient.getInternalService(clusterId) != null) {
+				clusterClient = kubernetesClusterDescriptor.retrieve(clusterId).getClusterClient();
+			} else {
+				clusterClient = kubernetesClusterDescriptor
+						.deploySessionCluster(
+								kubernetesClusterClientFactory.getClusterSpecification(configuration))
+						.getClusterClient();
+				clusterId = clusterClient.getClusterId();
+			}
+
+			try {
+				if (!detached) {
+					Tuple2<Boolean, Boolean> continueRepl = new Tuple2<>(true, false);
+					try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
+						while (continueRepl.f0) {
+							continueRepl = repStep(in);
+						}
+					} catch (Exception e) {
+						LOG.warn("Exception while running the interactive command line interface.", e);
+					}
+					if (continueRepl.f1) {
+						kubernetesClusterDescriptor.killCluster(clusterId);
+					}
+				}
+				clusterClient.close();
+				kubeClient.close();
+			} catch (Exception e) {
+				LOG.info("Could not properly shutdown cluster client.", e);
+			}
+		} finally {
+			try {
+				kubernetesClusterDescriptor.close();
+			} catch (Exception e) {
+				LOG.info("Could not properly close the kubernetes cluster descriptor.", e);
+			}
+		}
+
+		return 0;
+	}
+
+	/**
+	 * Check whether need to continue or kill the cluster.
+	 * @param in input buffer reader
+	 * @return f0, whether need to continue read from input. f1, whether need to kill the cluster.
+	 */
+	private Tuple2<Boolean, Boolean> repStep(BufferedReader in) throws IOException, InterruptedException {
+		final long startTime = System.currentTimeMillis();
+		while ((System.currentTimeMillis() - startTime) < CLIENT_POLLING_INTERVAL_MS
+			&& (!in.ready())) {
+			Thread.sleep(200L);
+		}
+		//------------- handle interactive command by user. ----------------------
+
+		if (in.ready()) {
+			final String command = in.readLine();
+			switch (command) {
+				case "quit":
+					return new Tuple2<>(false, false);
+				case "stop":
+					return new Tuple2<>(false, true);
+
+				case "help":
+					System.err.println(KUBERNETES_CLUSTER_HELP);
+					break;
+				default:
+					System.err.println("Unknown command '" + command + "'. Showing help:");
+					System.err.println(KUBERNETES_CLUSTER_HELP);
+					break;
+			}
+		}
+
+		return new Tuple2<>(true, false);
+	}
+
+	public static void main(String[] args) {
+		final Configuration configuration = GlobalConfiguration.loadConfiguration();
+
+		int retCode;
+
+		try {
+			final KubernetesSessionCli cli = new KubernetesSessionCli(configuration);
+			retCode = SecurityUtils.getInstalledContext().runSecured(() -> cli.run(args));
+		} catch (CliArgsException e) {
+			retCode = AbstractCustomCommandLine.handleCliArgsException(e, LOG);
+		} catch (Exception e) {
+			retCode = AbstractCustomCommandLine.handleError(e, LOG);
+		}
+
+		System.exit(retCode);
+	}
+}
diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/FlinkKubernetesCustomCliTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesSessionCliTest.java
similarity index 62%
rename from flink-kubernetes/src/test/java/org/apache/flink/kubernetes/FlinkKubernetesCustomCliTest.java
rename to flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesSessionCliTest.java
index e1d3e22..bcadfc9 100644
--- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/FlinkKubernetesCustomCliTest.java
+++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesSessionCliTest.java
@@ -26,12 +26,10 @@ import org.apache.flink.configuration.Configuration;
 import org.apache.flink.configuration.DeploymentOptions;
 import org.apache.flink.configuration.JobManagerOptions;
 import org.apache.flink.configuration.TaskManagerOptions;
-import org.apache.flink.kubernetes.cli.FlinkKubernetesCustomCli;
+import org.apache.flink.kubernetes.cli.KubernetesSessionCli;
+import org.apache.flink.kubernetes.configuration.KubernetesConfigOptions;
+import org.apache.flink.kubernetes.executors.KubernetesSessionClusterExecutor;
 
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.DefaultParser;
-import org.apache.commons.cli.Options;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -43,29 +41,21 @@ import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
 /**
- * Tests for the {@link FlinkKubernetesCustomCli}.
+ * Tests for the {@link KubernetesSessionCli}.
  */
-public class FlinkKubernetesCustomCliTest {
+public class KubernetesSessionCliTest {
 
 	@Test
 	public void testDynamicProperties() throws Exception {
 
-		final FlinkKubernetesCustomCli cli = new FlinkKubernetesCustomCli(
-			new Configuration(),
-			"",
-			"");
-		Options options = new Options();
-		cli.addGeneralOptions(options);
-		cli.addRunOptions(options);
-
-		final CommandLineParser parser = new DefaultParser();
-		final CommandLine cmd = parser.parse(options, new String[]{
-			"run",
-			"-D", "akka.ask.timeout=5 min",
-			"-D", "env.java.opts=-DappName=foobar"
-		});
-
-		final Configuration executorConfig = cli.applyCommandLineOptionsToConfiguration(cmd);
+		final KubernetesSessionCli cli = new KubernetesSessionCli(new Configuration());
+		final String[] args = new String[] {
+			"-e", KubernetesSessionClusterExecutor.NAME,
+			"-Dakka.ask.timeout=5 min",
+			"-Denv.java.opts=-DappName=foobar"
+		};
+
+		final Configuration executorConfig = cli.getEffectiveConfiguration(args);
 		final ClusterClientFactory<String> clientFactory = getClusterClientFactory(executorConfig);
 
 		Assert.assertNotNull(clientFactory);
@@ -79,14 +69,13 @@ public class FlinkKubernetesCustomCliTest {
 
 	@Test
 	public void testCorrectSettingOfMaxSlots() throws Exception {
-		String[] params =
-			new String[] {"-ks", "3"};
-
-		final FlinkKubernetesCustomCli cli = createFlinkKubernetesCustomCliWithTmTotalMemory(1234);
+		final String[] params = new String[] {
+				"-e", KubernetesSessionClusterExecutor.NAME,
+				"-D" + TaskManagerOptions.NUM_TASK_SLOTS.key() + "=3"};
 
-		final CommandLine commandLine = cli.parseCommandLineOptions(params, true);
+		final KubernetesSessionCli cli = createFlinkKubernetesCustomCliWithTmTotalMemory(1234);
 
-		final Configuration executorConfig = cli.applyCommandLineOptionsToConfiguration(commandLine);
+		final Configuration executorConfig = cli.getEffectiveConfiguration(params);
 		final ClusterClientFactory<String> clientFactory = getClusterClientFactory(executorConfig);
 		final ClusterSpecification clusterSpecification = clientFactory.getClusterSpecification(executorConfig);
 
@@ -97,12 +86,14 @@ public class FlinkKubernetesCustomCliTest {
 
 	@Test
 	public void testResumeFromKubernetesID() throws Exception {
-		final FlinkKubernetesCustomCli cli = createFlinkKubernetesCustomCliWithTmTotalMemory(1024);
+		final KubernetesSessionCli cli = createFlinkKubernetesCustomCliWithTmTotalMemory(1024);
 
 		final String clusterId = "my-test-CLUSTER_ID";
-		final CommandLine commandLine = cli.parseCommandLineOptions(new String[] {"-kid", clusterId}, true);
+		final String[] args = new String[] {
+				"-e", KubernetesSessionClusterExecutor.NAME,
+				"-D" + KubernetesConfigOptions.CLUSTER_ID.key() + "=" + clusterId};
 
-		final Configuration executorConfig = cli.applyCommandLineOptionsToConfiguration(commandLine);
+		final Configuration executorConfig = cli.getEffectiveConfiguration(args);
 		final ClusterClientFactory clientFactory = getClusterClientFactory(executorConfig);
 
 		assertEquals(clusterId, clientFactory.getClusterId(executorConfig));
@@ -123,16 +114,16 @@ public class FlinkKubernetesCustomCliTest {
 		configuration.setString(TaskManagerOptions.TOTAL_PROCESS_MEMORY, taskManagerMemory + "m");
 		configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, slotsPerTaskManager);
 
-		final String[] args = {"-kjm", String.valueOf(jobManagerMemory) + "m", "-ktm", String.valueOf(taskManagerMemory) +
-			"m", "-ks", String.valueOf(slotsPerTaskManager)};
-		final FlinkKubernetesCustomCli cli = new FlinkKubernetesCustomCli(
-			configuration,
-			"k",
-			"kubernetes");
+		final String[] args = {
+				"-e", KubernetesSessionClusterExecutor.NAME,
+				"-D" + JobManagerOptions.JOB_MANAGER_HEAP_MEMORY.key() + "=" + jobManagerMemory + "m",
+				"-D" + TaskManagerOptions.TOTAL_PROCESS_MEMORY.key() + "=" + taskManagerMemory + "m",
+				"-D" + TaskManagerOptions.NUM_TASK_SLOTS.key() + "=" + slotsPerTaskManager
+		};
 
-		CommandLine commandLine = cli.parseCommandLineOptions(args, false);
+		final KubernetesSessionCli cli = new KubernetesSessionCli(configuration);
 
-		Configuration executorConfig = cli.applyCommandLineOptionsToConfiguration(commandLine);
+		Configuration executorConfig = cli.getEffectiveConfiguration(args);
 		ClusterClientFactory<String> clientFactory = getClusterClientFactory(executorConfig);
 		ClusterSpecification clusterSpecification = clientFactory.getClusterSpecification(executorConfig);
 
@@ -155,15 +146,10 @@ public class FlinkKubernetesCustomCliTest {
 		final int slotsPerTaskManager = 42;
 		configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, slotsPerTaskManager);
 
-		final String[] args = {};
-		final FlinkKubernetesCustomCli cli = new FlinkKubernetesCustomCli(
-			configuration,
-			"",
-			"kubernetes");
-
-		CommandLine commandLine = cli.parseCommandLineOptions(args, false);
+		final String[] args = {"-e", KubernetesSessionClusterExecutor.NAME};
+		final KubernetesSessionCli cli = new KubernetesSessionCli(configuration);
 
-		Configuration executorConfig = cli.applyCommandLineOptionsToConfiguration(commandLine);
+		Configuration executorConfig = cli.getEffectiveConfiguration(args);
 		ClusterClientFactory<String> clientFactory = getClusterClientFactory(executorConfig);
 		ClusterSpecification clusterSpecification = clientFactory.getClusterSpecification(executorConfig);
 
@@ -173,33 +159,19 @@ public class FlinkKubernetesCustomCliTest {
 	}
 
 	/**
-	 * Tests the specifying heap memory without unit for job manager and task manager.
-	 */
-	@Test
-	public void testHeapMemoryPropertyWithoutUnit() throws Exception {
-		final String[] args = new String[] { "-kjm", "1024", "-ktm", "2048" };
-		final FlinkKubernetesCustomCli cli = createFlinkKubernetesCustomCliWithTmTotalMemory(1024);
-
-		final CommandLine commandLine = cli.parseCommandLineOptions(args, false);
-
-		final Configuration executorConfig = cli.applyCommandLineOptionsToConfiguration(commandLine);
-		final ClusterClientFactory<String> clientFactory = getClusterClientFactory(executorConfig);
-		final ClusterSpecification clusterSpecification = clientFactory.getClusterSpecification(executorConfig);
-
-		assertThat(clusterSpecification.getMasterMemoryMB(), is(1024));
-		assertThat(clusterSpecification.getTaskManagerMemoryMB(), is(2048));
-	}
-
-	/**
 	 * Tests the specifying heap memory with unit (MB) for job manager and task manager.
 	 */
 	@Test
 	public void testHeapMemoryPropertyWithUnitMB() throws Exception {
-		final String[] args = new String[] { "-kjm", "1024m", "-ktm", "2048m" };
-		final FlinkKubernetesCustomCli cli = createFlinkKubernetesCustomCliWithTmTotalMemory(1024);
-		final CommandLine commandLine = cli.parseCommandLineOptions(args, false);
+		final String[] args = new String[] {
+				"-e", KubernetesSessionClusterExecutor.NAME,
+				"-D" + JobManagerOptions.JOB_MANAGER_HEAP_MEMORY.key() + "=1024m",
+				"-D" + TaskManagerOptions.TOTAL_PROCESS_MEMORY.key() + "=2048m"
+		};
 
-		final Configuration executorConfig = cli.applyCommandLineOptionsToConfiguration(commandLine);
+		final KubernetesSessionCli cli = createFlinkKubernetesCustomCliWithTmTotalMemory(1024);
+
+		final Configuration executorConfig = cli.getEffectiveConfiguration(args);
 		final ClusterClientFactory<String> clientFactory = getClusterClientFactory(executorConfig);
 		final ClusterSpecification clusterSpecification = clientFactory.getClusterSpecification(executorConfig);
 
@@ -212,16 +184,20 @@ public class FlinkKubernetesCustomCliTest {
 	 */
 	@Test
 	public void testHeapMemoryPropertyWithArbitraryUnit() throws Exception {
-		final String[] args = new String[] { "-kjm", "1g", "-ktm", "2g" };
-		final FlinkKubernetesCustomCli cli = createFlinkKubernetesCustomCliWithTmTotalMemory(1024);
-		final CommandLine commandLine = cli.parseCommandLineOptions(args, false);
+		final String[] args = new String[] {
+				"-e", KubernetesSessionClusterExecutor.NAME,
+				"-D" + JobManagerOptions.JOB_MANAGER_HEAP_MEMORY.key() + "=1g",
+				"-D" + TaskManagerOptions.TOTAL_PROCESS_MEMORY.key() + "=3g"
+		};
+
+		final KubernetesSessionCli cli = createFlinkKubernetesCustomCliWithTmTotalMemory(1024);
 
-		final Configuration executorConfig = cli.applyCommandLineOptionsToConfiguration(commandLine);
+		final Configuration executorConfig = cli.getEffectiveConfiguration(args);
 		final ClusterClientFactory<String> clientFactory = getClusterClientFactory(executorConfig);
 		final ClusterSpecification clusterSpecification = clientFactory.getClusterSpecification(executorConfig);
 
 		assertThat(clusterSpecification.getMasterMemoryMB(), is(1024));
-		assertThat(clusterSpecification.getTaskManagerMemoryMB(), is(2048));
+		assertThat(clusterSpecification.getTaskManagerMemoryMB(), is(3072));
 	}
 
 	/**
@@ -230,17 +206,13 @@ public class FlinkKubernetesCustomCliTest {
 	@Test
 	public void testHeapMemoryPropertyWithOldConfigKey() throws Exception {
 		Configuration configuration = new Configuration();
+		configuration.set(DeploymentOptions.TARGET, KubernetesSessionClusterExecutor.NAME);
 		configuration.setInteger(JobManagerOptions.JOB_MANAGER_HEAP_MEMORY_MB, 2048);
 		configuration.setInteger(TaskManagerOptions.TASK_MANAGER_HEAP_MEMORY_MB, 4096);
 
-		final FlinkKubernetesCustomCli cli = new FlinkKubernetesCustomCli(
-			configuration,
-			"k",
-			"kubernetes");
-
-		final CommandLine commandLine = cli.parseCommandLineOptions(new String[0], false);
+		final KubernetesSessionCli cli = new KubernetesSessionCli(configuration);
 
-		final Configuration executorConfig = cli.applyCommandLineOptionsToConfiguration(commandLine);
+		final Configuration executorConfig = cli.getEffectiveConfiguration(new String[]{});
 		final ClusterClientFactory<String> clientFactory = getClusterClientFactory(executorConfig);
 		final ClusterSpecification clusterSpecification = clientFactory.getClusterSpecification(executorConfig);
 
@@ -253,11 +225,13 @@ public class FlinkKubernetesCustomCliTest {
 	 */
 	@Test
 	public void testHeapMemoryPropertyWithConfigDefaultValue() throws Exception {
-		final FlinkKubernetesCustomCli cli = createFlinkKubernetesCustomCliWithTmTotalMemory(1024);
+		final String[] args = new String[] {
+				"-e", KubernetesSessionClusterExecutor.NAME
+		};
 
-		final CommandLine commandLine = cli.parseCommandLineOptions(new String[0], false);
+		final KubernetesSessionCli cli = createFlinkKubernetesCustomCliWithTmTotalMemory(1024);
 
-		final Configuration executorConfig = cli.applyCommandLineOptionsToConfiguration(commandLine);
+		final Configuration executorConfig = cli.getEffectiveConfiguration(args);
 		final ClusterClientFactory<String> clientFactory = getClusterClientFactory(executorConfig);
 		final ClusterSpecification clusterSpecification = clientFactory.getClusterSpecification(executorConfig);
 
@@ -270,9 +244,9 @@ public class FlinkKubernetesCustomCliTest {
 		return clusterClientServiceLoader.getClusterClientFactory(executorConfig);
 	}
 
-	private FlinkKubernetesCustomCli createFlinkKubernetesCustomCliWithTmTotalMemory(int totalMemomory) {
+	private KubernetesSessionCli createFlinkKubernetesCustomCliWithTmTotalMemory(int totalMemory) {
 		Configuration configuration = new Configuration();
-		configuration.setString(TaskManagerOptions.TOTAL_PROCESS_MEMORY, totalMemomory + "m");
-		return new FlinkKubernetesCustomCli(configuration, "k", "kubernetes");
+		configuration.setString(TaskManagerOptions.TOTAL_PROCESS_MEMORY, totalMemory + "m");
+		return new KubernetesSessionCli(configuration);
 	}
 }


[flink] 02/07: [FLINK-15179] Introduce generic ExecutorCLI

Posted by kk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kkloudas pushed a commit to branch release-1.10
in repository https://gitbox.apache.org/repos/asf/flink.git

commit a50decf2e70e76157d00488398bee4568bc831ce
Author: Kostas Kloudas <kk...@gmail.com>
AuthorDate: Tue Dec 10 18:31:30 2019 +0100

    [FLINK-15179] Introduce generic ExecutorCLI
---
 .../org/apache/flink/client/cli/CliFrontend.java   |   2 +
 .../org/apache/flink/client/cli/ExecutorCLI.java   | 125 +++++++++++++++++++
 .../apache/flink/client/cli/ExecutorCLITest.java   | 135 +++++++++++++++++++++
 3 files changed, 262 insertions(+)

diff --git a/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java b/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java
index 4b5a1a0..0c4a98b 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java
@@ -1070,6 +1070,8 @@ public class CliFrontend {
 			LOG.warn("Could not load CLI class {}.", kubeSessionCLI, e);
 		}
 
+		customCommandLines.add(new ExecutorCLI(configuration));
+
 		//	Tips: DefaultCLI must be added at last, because getActiveCustomCommandLine(..) will get the
 		//	      active CustomCommandLine in order and DefaultCLI isActive always return true.
 		customCommandLines.add(new DefaultCLI(configuration));
diff --git a/flink-clients/src/main/java/org/apache/flink/client/cli/ExecutorCLI.java b/flink-clients/src/main/java/org/apache/flink/client/cli/ExecutorCLI.java
new file mode 100644
index 0000000..9beac1a
--- /dev/null
+++ b/flink-clients/src/main/java/org/apache/flink/client/cli/ExecutorCLI.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.client.cli;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.DeploymentOptions;
+import org.apache.flink.configuration.UnmodifiableConfiguration;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Properties;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * A generic implementation of the {@link CustomCommandLine} that only expects
+ * the execution.target parameter to be explicitly specified and simply forwards the
+ * rest of the options specified with -D to the corresponding {@link org.apache.flink.core.execution.Executor}
+ * for further parsing.
+ */
+@Internal
+public class ExecutorCLI implements CustomCommandLine {
+
+	private static final Logger LOG = LoggerFactory.getLogger(ExecutorCLI.class);
+
+	private static final String ID = "Executor-CLI";
+
+	private final Option executorOption = new Option("e", "executor", true,
+			"The name of the executor to be used for executing the given job, e.g. \"local-executor\"." +
+					" This is equivalent to the \"" + DeploymentOptions.TARGET.key() + "\" config option.");
+
+	/**
+	 * Dynamic properties allow the user to specify additional configuration values with -D, such as
+	 * <tt> -Dfs.overwrite-files=true  -Dtaskmanager.memory.shuffle.min=536346624</tt>.
+	 */
+	private final Option dynamicProperties = Option.builder("D")
+			.argName("property=value")
+			.numberOfArgs(2)
+			.valueSeparator('=')
+			.desc("use value for given property")
+			.build();
+
+	private final Configuration baseConfiguration;
+
+	public ExecutorCLI(final Configuration configuration) {
+		this.baseConfiguration = new UnmodifiableConfiguration(checkNotNull(configuration));
+	}
+
+	@Override
+	public boolean isActive(CommandLine commandLine) {
+		return baseConfiguration.getOptional(DeploymentOptions.TARGET).isPresent()
+				|| commandLine.hasOption(executorOption.getOpt());
+	}
+
+	@Override
+	public String getId() {
+		return ID;
+	}
+
+	@Override
+	public void addRunOptions(Options baseOptions) {
+		// nothing to add here
+	}
+
+	@Override
+	public void addGeneralOptions(Options baseOptions) {
+		baseOptions.addOption(executorOption);
+		baseOptions.addOption(dynamicProperties);
+	}
+
+	@Override
+	public Configuration applyCommandLineOptionsToConfiguration(final CommandLine commandLine) {
+		checkState(isActive(commandLine));
+
+		final Configuration effectiveConfiguration = new Configuration(baseConfiguration);
+
+		final String executorName = commandLine.getOptionValue(executorOption.getOpt());
+		if (executorName != null) {
+			effectiveConfiguration.setString(DeploymentOptions.TARGET, executorName);
+		}
+
+		encodeDynamicProperties(commandLine, effectiveConfiguration);
+
+		if (LOG.isDebugEnabled()) {
+			LOG.debug("Effective Configuration: {}", effectiveConfiguration);
+		}
+
+		return effectiveConfiguration;
+	}
+
+	private void encodeDynamicProperties(final CommandLine commandLine, final Configuration effectiveConfiguration) {
+		final Properties properties = commandLine.getOptionProperties(dynamicProperties.getOpt());
+		properties.stringPropertyNames()
+				.forEach(key -> {
+					final String value = properties.getProperty(key);
+					if (value != null) {
+						effectiveConfiguration.setString(key, value);
+					} else {
+						effectiveConfiguration.setString(key, "true");
+					}
+				});
+	}
+}
diff --git a/flink-clients/src/test/java/org/apache/flink/client/cli/ExecutorCLITest.java b/flink-clients/src/test/java/org/apache/flink/client/cli/ExecutorCLITest.java
new file mode 100644
index 0000000..7fac8ff
--- /dev/null
+++ b/flink-clients/src/test/java/org/apache/flink/client/cli/ExecutorCLITest.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.client.cli;
+
+import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.CoreOptions;
+import org.apache.flink.configuration.DeploymentOptions;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Options;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.configuration.ConfigOptions.key;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+/**
+ * Unit tests for the {@link ExecutorCLI}.
+ */
+public class ExecutorCLITest {
+
+	private Options testOptions;
+
+	@Before
+	public void initOptions() {
+		testOptions = new Options();
+
+		final ExecutorCLI cliUnderTest = new ExecutorCLI(new Configuration());
+		cliUnderTest.addGeneralOptions(testOptions);
+	}
+
+	@Test(expected = IllegalStateException.class)
+	public void testExceptionWithUnspecifiedExecutor() throws CliArgsException {
+		final ExecutorCLI cliUnderTest = new ExecutorCLI(new Configuration());
+
+		final String[] args = {"-Dtest=tsetD-"};
+		final CommandLine commandLine = CliFrontendParser.parse(testOptions, args, true);
+
+		cliUnderTest.applyCommandLineOptionsToConfiguration(commandLine);
+	}
+
+	@Test
+	public void testExecutorInBaseConfigIsPickedUp() throws CliArgsException {
+		final String expectedExecutorName = "test-executor";
+		final Configuration loadedConfig = new Configuration();
+		loadedConfig.set(DeploymentOptions.TARGET, expectedExecutorName);
+
+		final ExecutorCLI cliUnderTest = new ExecutorCLI(loadedConfig);
+		final CommandLine emptyCommandLine = CliFrontendParser.parse(testOptions, new String[0], true);
+
+		final Configuration configuration = cliUnderTest.applyCommandLineOptionsToConfiguration(emptyCommandLine);
+		assertEquals(expectedExecutorName, configuration.get(DeploymentOptions.TARGET));
+	}
+
+	@Test
+	public void testWithPreexistingConfigurationInConstructor() throws CliArgsException {
+		final Configuration loadedConfig = new Configuration();
+		loadedConfig.setInteger(CoreOptions.DEFAULT_PARALLELISM, 2);
+		loadedConfig.setBoolean(DeploymentOptions.ATTACHED, false);
+
+		final ConfigOption<List<Integer>> listOption = key("test.list")
+				.intType()
+				.asList()
+				.noDefaultValue();
+
+		final List<Integer> listValue = Arrays.asList(41, 42, 23);
+		final String encodedListValue = listValue
+				.stream()
+				.map(Object::toString)
+				.collect(Collectors.joining(";"));
+
+		final String[] args = {
+				"-e", "test-executor",
+				"-D" + listOption.key() + "=" + encodedListValue,
+				"-D" + CoreOptions.DEFAULT_PARALLELISM.key() + "=5"
+		};
+
+		final ExecutorCLI cliUnderTest = new ExecutorCLI(loadedConfig);
+		final CommandLine commandLine = CliFrontendParser.parse(testOptions, args, true);
+
+		final Configuration configuration = cliUnderTest.applyCommandLineOptionsToConfiguration(commandLine);
+
+		assertEquals("test-executor", configuration.getString(DeploymentOptions.TARGET));
+		assertEquals(5, configuration.getInteger(CoreOptions.DEFAULT_PARALLELISM));
+		assertFalse(configuration.getBoolean(DeploymentOptions.ATTACHED));
+		assertEquals(listValue, configuration.get(listOption));
+	}
+
+	@Test
+	public void testIsActiveLong() throws CliArgsException {
+		testIsActiveHelper("--executor");
+	}
+
+	@Test
+	public void testIsActiveShort() throws CliArgsException {
+		testIsActiveHelper("-e");
+	}
+
+	private void testIsActiveHelper(final String executorOption) throws CliArgsException {
+		final String expectedExecutorName = "test-executor";
+		final ConfigOption<Integer> configOption = key("test.int").intType().noDefaultValue();
+		final int expectedValue = 42;
+
+		final ExecutorCLI cliUnderTest = new ExecutorCLI(new Configuration());
+
+		final String[] args = {executorOption, expectedExecutorName, "-D" + configOption.key() + "=" + expectedValue};
+		final CommandLine commandLine = CliFrontendParser.parse(testOptions, args, true);
+
+		final Configuration configuration = cliUnderTest.applyCommandLineOptionsToConfiguration(commandLine);
+		assertEquals(expectedExecutorName, configuration.get(DeploymentOptions.TARGET));
+		assertEquals(expectedValue, configuration.getInteger(configOption));
+	}
+}


[flink] 05/07: [FLINK-15179] Assume Deployment.target=kubernetes-session when in KubernetesSessionCli

Posted by kk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kkloudas pushed a commit to branch release-1.10
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 09acfabf4f2ad5c70bd3756d174f393dea3839a9
Author: Kostas Kloudas <kk...@gmail.com>
AuthorDate: Thu Dec 12 14:16:24 2019 +0100

    [FLINK-15179] Assume Deployment.target=kubernetes-session when in KubernetesSessionCli
---
 .../main/java/org/apache/flink/client/cli/ExecutorCLI.java    |  3 ---
 .../java/org/apache/flink/client/cli/ExecutorCLITest.java     | 10 ----------
 .../org/apache/flink/kubernetes/cli/KubernetesSessionCli.java |  5 ++++-
 .../org/apache/flink/kubernetes/KubernetesSessionCliTest.java | 11 +++++++++++
 4 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/flink-clients/src/main/java/org/apache/flink/client/cli/ExecutorCLI.java b/flink-clients/src/main/java/org/apache/flink/client/cli/ExecutorCLI.java
index 9beac1a..dbcebd0 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/cli/ExecutorCLI.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/cli/ExecutorCLI.java
@@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory;
 import java.util.Properties;
 
 import static org.apache.flink.util.Preconditions.checkNotNull;
-import static org.apache.flink.util.Preconditions.checkState;
 
 /**
  * A generic implementation of the {@link CustomCommandLine} that only expects
@@ -92,8 +91,6 @@ public class ExecutorCLI implements CustomCommandLine {
 
 	@Override
 	public Configuration applyCommandLineOptionsToConfiguration(final CommandLine commandLine) {
-		checkState(isActive(commandLine));
-
 		final Configuration effectiveConfiguration = new Configuration(baseConfiguration);
 
 		final String executorName = commandLine.getOptionValue(executorOption.getOpt());
diff --git a/flink-clients/src/test/java/org/apache/flink/client/cli/ExecutorCLITest.java b/flink-clients/src/test/java/org/apache/flink/client/cli/ExecutorCLITest.java
index 7fac8ff..6eb9a02 100644
--- a/flink-clients/src/test/java/org/apache/flink/client/cli/ExecutorCLITest.java
+++ b/flink-clients/src/test/java/org/apache/flink/client/cli/ExecutorCLITest.java
@@ -51,16 +51,6 @@ public class ExecutorCLITest {
 		cliUnderTest.addGeneralOptions(testOptions);
 	}
 
-	@Test(expected = IllegalStateException.class)
-	public void testExceptionWithUnspecifiedExecutor() throws CliArgsException {
-		final ExecutorCLI cliUnderTest = new ExecutorCLI(new Configuration());
-
-		final String[] args = {"-Dtest=tsetD-"};
-		final CommandLine commandLine = CliFrontendParser.parse(testOptions, args, true);
-
-		cliUnderTest.applyCommandLineOptionsToConfiguration(commandLine);
-	}
-
 	@Test
 	public void testExecutorInBaseConfigIsPickedUp() throws CliArgsException {
 		final String expectedExecutorName = "test-executor";
diff --git a/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java b/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java
index 8211e48..a46de6f 100644
--- a/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java
+++ b/flink-kubernetes/src/main/java/org/apache/flink/kubernetes/cli/KubernetesSessionCli.java
@@ -31,6 +31,7 @@ import org.apache.flink.configuration.Configuration;
 import org.apache.flink.configuration.DeploymentOptions;
 import org.apache.flink.configuration.GlobalConfiguration;
 import org.apache.flink.configuration.UnmodifiableConfiguration;
+import org.apache.flink.kubernetes.executors.KubernetesSessionClusterExecutor;
 import org.apache.flink.kubernetes.kubeclient.FlinkKubeClient;
 import org.apache.flink.kubernetes.kubeclient.KubeClientFactory;
 import org.apache.flink.runtime.security.SecurityUtils;
@@ -77,7 +78,9 @@ public class KubernetesSessionCli {
 
 	public Configuration getEffectiveConfiguration(String[] args) throws CliArgsException {
 		final CommandLine commandLine = cli.parseCommandLineOptions(args, true);
-		return cli.applyCommandLineOptionsToConfiguration(commandLine);
+		final Configuration effectiveConfiguration = cli.applyCommandLineOptionsToConfiguration(commandLine);
+		effectiveConfiguration.set(DeploymentOptions.TARGET, KubernetesSessionClusterExecutor.NAME);
+		return effectiveConfiguration;
 	}
 
 	private int run(String[] args) throws FlinkException, CliArgsException {
diff --git a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesSessionCliTest.java b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesSessionCliTest.java
index bcadfc9..1626cc8 100644
--- a/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesSessionCliTest.java
+++ b/flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesSessionCliTest.java
@@ -18,6 +18,7 @@
 
 package org.apache.flink.kubernetes;
 
+import org.apache.flink.client.cli.CliArgsException;
 import org.apache.flink.client.deployment.ClusterClientFactory;
 import org.apache.flink.client.deployment.ClusterClientServiceLoader;
 import org.apache.flink.client.deployment.ClusterSpecification;
@@ -46,6 +47,16 @@ import static org.junit.Assert.assertTrue;
 public class KubernetesSessionCliTest {
 
 	@Test
+	public void testKubernetesSessionCliSetsDeploymentTargetCorrectly() throws CliArgsException {
+		final KubernetesSessionCli cli = new KubernetesSessionCli(new Configuration());
+
+		final String[] args = {};
+		final Configuration configuration = cli.getEffectiveConfiguration(args);
+
+		assertEquals(KubernetesSessionClusterExecutor.NAME, configuration.get(DeploymentOptions.TARGET));
+	}
+
+	@Test
 	public void testDynamicProperties() throws Exception {
 
 		final KubernetesSessionCli cli = new KubernetesSessionCli(new Configuration());


[flink] 03/07: [FLINK-15179] Remove StandaloneSessionClusterExecutor so ExecutorCLI supports list()/cancel()

Posted by kk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kkloudas pushed a commit to branch release-1.10
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 903e31eaa4ae09ac591873f727ec43d81b3e54e3
Author: Kostas Kloudas <kk...@gmail.com>
AuthorDate: Thu Dec 12 11:53:41 2019 +0100

    [FLINK-15179] Remove StandaloneSessionClusterExecutor so ExecutorCLI supports list()/cancel()
---
 .../client/cli/AbstractCustomCommandLine.java      |  4 +-
 .../client/deployment/StandaloneClientFactory.java |  4 +-
 .../StandaloneSessionClusterExecutor.java          | 38 -------------------
 .../StandaloneSessionClusterExecutorFactory.java   | 44 ----------------------
 ...org.apache.flink.core.execution.ExecutorFactory |  1 -
 .../deployment/ClusterClientServiceLoaderTest.java |  4 +-
 6 files changed, 6 insertions(+), 89 deletions(-)

diff --git a/flink-clients/src/main/java/org/apache/flink/client/cli/AbstractCustomCommandLine.java b/flink-clients/src/main/java/org/apache/flink/client/cli/AbstractCustomCommandLine.java
index 04307b1..b3fd269 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/cli/AbstractCustomCommandLine.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/cli/AbstractCustomCommandLine.java
@@ -18,7 +18,7 @@
 
 package org.apache.flink.client.cli;
 
-import org.apache.flink.client.deployment.executors.StandaloneSessionClusterExecutor;
+import org.apache.flink.client.deployment.executors.RemoteExecutor;
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.configuration.DeploymentOptions;
 import org.apache.flink.configuration.HighAvailabilityOptions;
@@ -76,7 +76,7 @@ public abstract class AbstractCustomCommandLine implements CustomCommandLine {
 	@Override
 	public Configuration applyCommandLineOptionsToConfiguration(CommandLine commandLine) throws FlinkException {
 		final Configuration resultingConfiguration = new Configuration(configuration);
-		resultingConfiguration.setString(DeploymentOptions.TARGET, StandaloneSessionClusterExecutor.NAME);
+		resultingConfiguration.setString(DeploymentOptions.TARGET, RemoteExecutor.NAME);
 
 		if (commandLine.hasOption(addressOption.getOpt())) {
 			String addressWithPort = commandLine.getOptionValue(addressOption.getOpt());
diff --git a/flink-clients/src/main/java/org/apache/flink/client/deployment/StandaloneClientFactory.java b/flink-clients/src/main/java/org/apache/flink/client/deployment/StandaloneClientFactory.java
index e5ec6f4..5a11995 100644
--- a/flink-clients/src/main/java/org/apache/flink/client/deployment/StandaloneClientFactory.java
+++ b/flink-clients/src/main/java/org/apache/flink/client/deployment/StandaloneClientFactory.java
@@ -19,7 +19,7 @@
 package org.apache.flink.client.deployment;
 
 import org.apache.flink.annotation.Internal;
-import org.apache.flink.client.deployment.executors.StandaloneSessionClusterExecutor;
+import org.apache.flink.client.deployment.executors.RemoteExecutor;
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.configuration.DeploymentOptions;
 
@@ -36,7 +36,7 @@ public class StandaloneClientFactory implements ClusterClientFactory<StandaloneC
 	@Override
 	public boolean isCompatibleWith(Configuration configuration) {
 		checkNotNull(configuration);
-		return StandaloneSessionClusterExecutor.NAME.equalsIgnoreCase(configuration.getString(DeploymentOptions.TARGET));
+		return RemoteExecutor.NAME.equalsIgnoreCase(configuration.getString(DeploymentOptions.TARGET));
 	}
 
 	@Override
diff --git a/flink-clients/src/main/java/org/apache/flink/client/deployment/executors/StandaloneSessionClusterExecutor.java b/flink-clients/src/main/java/org/apache/flink/client/deployment/executors/StandaloneSessionClusterExecutor.java
deleted file mode 100644
index 178ef50..0000000
--- a/flink-clients/src/main/java/org/apache/flink/client/deployment/executors/StandaloneSessionClusterExecutor.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.client.deployment.executors;
-
-import org.apache.flink.annotation.Internal;
-import org.apache.flink.client.deployment.AbstractSessionClusterExecutor;
-import org.apache.flink.client.deployment.StandaloneClientFactory;
-import org.apache.flink.client.deployment.StandaloneClusterId;
-import org.apache.flink.core.execution.Executor;
-
-/**
- * The {@link Executor} to be used when executing a job on an already running cluster.
- */
-@Internal
-public class StandaloneSessionClusterExecutor extends AbstractSessionClusterExecutor<StandaloneClusterId, StandaloneClientFactory> {
-
-	public static final String NAME = "standalone-session-executor";
-
-	public StandaloneSessionClusterExecutor() {
-		super(new StandaloneClientFactory());
-	}
-}
diff --git a/flink-clients/src/main/java/org/apache/flink/client/deployment/executors/StandaloneSessionClusterExecutorFactory.java b/flink-clients/src/main/java/org/apache/flink/client/deployment/executors/StandaloneSessionClusterExecutorFactory.java
deleted file mode 100644
index c6c6332..0000000
--- a/flink-clients/src/main/java/org/apache/flink/client/deployment/executors/StandaloneSessionClusterExecutorFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.client.deployment.executors;
-
-import org.apache.flink.annotation.Internal;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.configuration.DeploymentOptions;
-import org.apache.flink.core.execution.Executor;
-import org.apache.flink.core.execution.ExecutorFactory;
-
-import javax.annotation.Nonnull;
-
-/**
- * An {@link ExecutorFactory} for executing jobs on an existing (session) cluster.
- */
-@Internal
-public class StandaloneSessionClusterExecutorFactory implements ExecutorFactory {
-
-	@Override
-	public boolean isCompatibleWith(@Nonnull final Configuration configuration) {
-		return StandaloneSessionClusterExecutor.NAME.equalsIgnoreCase(configuration.get(DeploymentOptions.TARGET));
-	}
-
-	@Override
-	public Executor getExecutor(@Nonnull final Configuration configuration) {
-		return new StandaloneSessionClusterExecutor();
-	}
-}
diff --git a/flink-clients/src/main/resources/META-INF/services/org.apache.flink.core.execution.ExecutorFactory b/flink-clients/src/main/resources/META-INF/services/org.apache.flink.core.execution.ExecutorFactory
index 34acf11..a9c8e9a 100644
--- a/flink-clients/src/main/resources/META-INF/services/org.apache.flink.core.execution.ExecutorFactory
+++ b/flink-clients/src/main/resources/META-INF/services/org.apache.flink.core.execution.ExecutorFactory
@@ -13,6 +13,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-org.apache.flink.client.deployment.executors.StandaloneSessionClusterExecutorFactory
 org.apache.flink.client.deployment.executors.RemoteExecutorFactory
 org.apache.flink.client.deployment.executors.LocalExecutorFactory
\ No newline at end of file
diff --git a/flink-clients/src/test/java/org/apache/flink/client/deployment/ClusterClientServiceLoaderTest.java b/flink-clients/src/test/java/org/apache/flink/client/deployment/ClusterClientServiceLoaderTest.java
index b7a9953..3450729 100644
--- a/flink-clients/src/test/java/org/apache/flink/client/deployment/ClusterClientServiceLoaderTest.java
+++ b/flink-clients/src/test/java/org/apache/flink/client/deployment/ClusterClientServiceLoaderTest.java
@@ -18,7 +18,7 @@
 
 package org.apache.flink.client.deployment;
 
-import org.apache.flink.client.deployment.executors.StandaloneSessionClusterExecutor;
+import org.apache.flink.client.deployment.executors.RemoteExecutor;
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.configuration.DeploymentOptions;
 
@@ -58,7 +58,7 @@ public class ClusterClientServiceLoaderTest {
 	@Test
 	public void testStandaloneClusterClientFactoryDiscovery() {
 		final Configuration config = new Configuration();
-		config.setString(DeploymentOptions.TARGET, StandaloneSessionClusterExecutor.NAME);
+		config.setString(DeploymentOptions.TARGET, RemoteExecutor.NAME);
 
 		ClusterClientFactory<StandaloneClusterId> factory = serviceLoaderUnderTest.getClusterClientFactory(config);
 		assertTrue(factory instanceof StandaloneClientFactory);