You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by tillrohrmann <gi...@git.apache.org> on 2018/02/08 16:03:18 UTC

[GitHub] flink pull request #5432: [FLINK-8609] [flip6] Enable Flip-6 job mode in Cli...

GitHub user tillrohrmann opened a pull request:

    https://github.com/apache/flink/pull/5432

    [FLINK-8609] [flip6] Enable Flip-6 job mode in CliFrontend

    ## What is the purpose of the change
    
    This commit allows to deploy detached job mode clusters via the
    CliFrontend. In order to do that, it first extracts the JobGraph
    from the PackagedProgram and then uses the ClusterDescriptor to
    deploy the job mode cluster.
    
    This PR is based on #5431.
    
    ## Brief change log
    
    - Extract `JobGraph` from `PackagedProgram` in `CliFrontend`
    - Deploy job mode cluster if flip-6 is enabled
    
    ## Verifying this change
    
    - Tested manually
    
    ## Does this pull request potentially affect one of the following parts:
    
      - Dependencies (does it add or upgrade a dependency): (no)
      - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
      - The serializers: (no)
      - The runtime per-record code paths (performance sensitive): (no)
      - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes)
      - The S3 file system connector: (no)
    
    ## Documentation
    
      - Does this pull request introduce a new feature? (no)
      - If yes, how is the feature documented? (not applicable)


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/tillrohrmann/flink enableJobMode

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/5432.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #5432
    
----
commit db57b574b0a2bacfa5aa164082c1eeb8f5258ed8
Author: Till Rohrmann <tr...@...>
Date:   2018-02-08T13:34:54Z

    [FLINK-8608] [flip6] Implement MiniDispatcher for job mode
    
    The MiniDispatcher is responsible for submitting the single job with which
    a job mode cluster is started. Once the job has completed and if the cluster
    has been started in detached mode, the MiniDispatcher will terminate.
    
    In order to reduce code duplication, the MiniDispatcher is a sub class of the
    Dispatcher which is started with a single job submitted job graph store.

commit be2d9dfa515b1577f6d7a67b726d9e704281a1cc
Author: Till Rohrmann <tr...@...>
Date:   2018-02-06T15:47:28Z

    [FLINK-8609] [flip6] Enable Flip-6 job mode in CliFrontend
    
    This commit allows to deploy detached job mode clusters via the
    CliFrontend. In order to do that, it first extracts the JobGraph
    from the PackagedProgram and then uses the ClusterDescriptor to
    deploy the job mode cluster.

----


---

[GitHub] flink pull request #5432: [FLINK-8609] [flip6] Enable Flip-6 job mode in Cli...

Posted by tillrohrmann <gi...@git.apache.org>.
Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5432#discussion_r168195242
  
    --- Diff: flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java ---
    @@ -210,51 +225,72 @@ protected void run(String[] args) throws Exception {
     
     			final ClusterClient<T> client;
     
    -			if (clusterId != null) {
    -				client = clusterDescriptor.retrieve(clusterId);
    -			} else {
    -				final ClusterSpecification clusterSpecification = customCommandLine.getClusterSpecification(commandLine);
    -				client = clusterDescriptor.deploySessionCluster(clusterSpecification);
    -			}
    +			// directly deploy the job if the cluster is started in job mode and detached
    +			if (flip6 && clusterId == null && runOptions.getDetachedMode()) {
    +				int parallelism = runOptions.getParallelism() == -1 ? defaultParallelism : runOptions.getParallelism();
     
    -			try {
    -				client.setPrintStatusDuringExecution(runOptions.getStdoutLogging());
    -				client.setDetached(runOptions.getDetachedMode());
    -				LOG.debug("Client slots is set to {}", client.getMaxSlots());
    -
    -				LOG.debug(runOptions.getSavepointRestoreSettings().toString());
    -
    -				int userParallelism = runOptions.getParallelism();
    -				LOG.debug("User parallelism is set to {}", userParallelism);
    -				if (client.getMaxSlots() != -1 && userParallelism == -1) {
    -					logAndSysout("Using the parallelism provided by the remote cluster ("
    -						+ client.getMaxSlots() + "). "
    -						+ "To use another parallelism, set it at the ./bin/flink client.");
    -					userParallelism = client.getMaxSlots();
    -				} else if (ExecutionConfig.PARALLELISM_DEFAULT == userParallelism) {
    -					userParallelism = defaultParallelism;
    -				}
    +				final JobGraph jobGraph = createJobGraph(configuration, program, parallelism);
     
    -				executeProgram(program, client, userParallelism);
    -			} finally {
    -				if (clusterId == null && !client.isDetached()) {
    -					// terminate the cluster only if we have started it before and if it's not detached
    -					try {
    -						clusterDescriptor.terminateCluster(client.getClusterId());
    -					} catch (FlinkException e) {
    -						LOG.info("Could not properly terminate the Flink cluster.", e);
    -					}
    -				}
    +				final ClusterSpecification clusterSpecification = customCommandLine.getClusterSpecification(commandLine);
    +				client = clusterDescriptor.deployJobCluster(
    +					clusterSpecification,
    +					jobGraph,
    +					runOptions.getDetachedMode());
    +
    +				logAndSysout("Job has been submitted with JobID " + jobGraph.getJobID());
     
     				try {
     					client.shutdown();
     				} catch (Exception e) {
     					LOG.info("Could not properly shut down the client.", e);
     				}
    +			} else {
    +				if (clusterId != null) {
    +					client = clusterDescriptor.retrieve(clusterId);
    +				} else {
    +					// also in job mode we have to deploy a session cluster because the job
    +					// might consist of multiple parts (e.g. when using collect)
    +					final ClusterSpecification clusterSpecification = customCommandLine.getClusterSpecification(commandLine);
    +					client = clusterDescriptor.deploySessionCluster(clusterSpecification);
    +				}
    +
    +				try {
    +					client.setPrintStatusDuringExecution(runOptions.getStdoutLogging());
    +					client.setDetached(runOptions.getDetachedMode());
    +					LOG.debug("Client slots is set to {}", client.getMaxSlots());
    +
    +					LOG.debug(runOptions.getSavepointRestoreSettings().toString());
    --- End diff --
    
    True, will improve it.


---

[GitHub] flink pull request #5432: [FLINK-8609] [flip6] Enable Flip-6 job mode in Cli...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/flink/pull/5432


---

[GitHub] flink pull request #5432: [FLINK-8609] [flip6] Enable Flip-6 job mode in Cli...

Posted by GJL <gi...@git.apache.org>.
Github user GJL commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5432#discussion_r168173010
  
    --- Diff: flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java ---
    @@ -210,51 +225,72 @@ protected void run(String[] args) throws Exception {
     
     			final ClusterClient<T> client;
     
    -			if (clusterId != null) {
    -				client = clusterDescriptor.retrieve(clusterId);
    -			} else {
    -				final ClusterSpecification clusterSpecification = customCommandLine.getClusterSpecification(commandLine);
    -				client = clusterDescriptor.deploySessionCluster(clusterSpecification);
    -			}
    +			// directly deploy the job if the cluster is started in job mode and detached
    +			if (flip6 && clusterId == null && runOptions.getDetachedMode()) {
    +				int parallelism = runOptions.getParallelism() == -1 ? defaultParallelism : runOptions.getParallelism();
     
    -			try {
    -				client.setPrintStatusDuringExecution(runOptions.getStdoutLogging());
    -				client.setDetached(runOptions.getDetachedMode());
    -				LOG.debug("Client slots is set to {}", client.getMaxSlots());
    -
    -				LOG.debug(runOptions.getSavepointRestoreSettings().toString());
    -
    -				int userParallelism = runOptions.getParallelism();
    -				LOG.debug("User parallelism is set to {}", userParallelism);
    -				if (client.getMaxSlots() != -1 && userParallelism == -1) {
    -					logAndSysout("Using the parallelism provided by the remote cluster ("
    -						+ client.getMaxSlots() + "). "
    -						+ "To use another parallelism, set it at the ./bin/flink client.");
    -					userParallelism = client.getMaxSlots();
    -				} else if (ExecutionConfig.PARALLELISM_DEFAULT == userParallelism) {
    -					userParallelism = defaultParallelism;
    -				}
    +				final JobGraph jobGraph = createJobGraph(configuration, program, parallelism);
     
    -				executeProgram(program, client, userParallelism);
    -			} finally {
    -				if (clusterId == null && !client.isDetached()) {
    -					// terminate the cluster only if we have started it before and if it's not detached
    -					try {
    -						clusterDescriptor.terminateCluster(client.getClusterId());
    -					} catch (FlinkException e) {
    -						LOG.info("Could not properly terminate the Flink cluster.", e);
    -					}
    -				}
    +				final ClusterSpecification clusterSpecification = customCommandLine.getClusterSpecification(commandLine);
    +				client = clusterDescriptor.deployJobCluster(
    +					clusterSpecification,
    +					jobGraph,
    +					runOptions.getDetachedMode());
    +
    +				logAndSysout("Job has been submitted with JobID " + jobGraph.getJobID());
     
     				try {
     					client.shutdown();
     				} catch (Exception e) {
     					LOG.info("Could not properly shut down the client.", e);
     				}
    +			} else {
    +				if (clusterId != null) {
    +					client = clusterDescriptor.retrieve(clusterId);
    +				} else {
    +					// also in job mode we have to deploy a session cluster because the job
    +					// might consist of multiple parts (e.g. when using collect)
    +					final ClusterSpecification clusterSpecification = customCommandLine.getClusterSpecification(commandLine);
    +					client = clusterDescriptor.deploySessionCluster(clusterSpecification);
    +				}
    +
    +				try {
    +					client.setPrintStatusDuringExecution(runOptions.getStdoutLogging());
    +					client.setDetached(runOptions.getDetachedMode());
    +					LOG.debug("Client slots is set to {}", client.getMaxSlots());
    +
    +					LOG.debug(runOptions.getSavepointRestoreSettings().toString());
    --- End diff --
    
    Maybe `.debug("{}", runOptions.getSavepointRestoreSettings())` to save the `toString()` invocation.


---