Github user StephanEwen commented on a diff in the pull request:
https://github.com/apache/flink/pull/750#discussion_r40334026
--- Diff:
flink-clients/src/main/java/org/apache/flink/client/program/Client.java ---
@@ -452,6 +453,73 @@ public void cancel(JobID jobId) throws Exception {
}
}
+ /**
+ * Stops a program on Flink cluster whose job-manager is configured in
this client's configuration.
+ * Stopping works only for streaming programs. Be aware, that the
program might continue to run for
+ * a while after sending the stop command, because after sources
stopped to emit data all operators
+ * need to finish processing.
+ *
+ * @param jobId
+ * the job ID of the streaming program to stop
+ * @throws ProgramStopException
+ * If the job ID is invalid (ie, is unknown or refers to a
batch job) or if sending the stop signal
+ * failed. That might be due to an I/O problem, ie, the
job-manager is unreachable.
+ */
+ public void stop(JobID jobId) throws Exception {
+ final FiniteDuration timeout =
AkkaUtils.getTimeout(configuration);
+ final FiniteDuration lookupTimeout =
AkkaUtils.getLookupTimeout(configuration);
+
+ ActorSystem actorSystem;
+ try {
+ actorSystem =
JobClient.startJobClientActorSystem(configuration);
+ } catch (Exception e) {
+ throw new ProgramStopException("Could not start client
actor system.", e);
+ }
+
+ try {
+ ActorGateway jobManagerGateway;
+
+ LeaderRetrievalService leaderRetrievalService;
+
+ try {
+ leaderRetrievalService =
LeaderRetrievalUtils.createLeaderRetrievalService(configuration);
+ } catch (Exception e) {
+ throw new ProgramInvocationException("Could not
create the leader retrieval service.", e);
+ }
+
+ try {
+ jobManagerGateway =
LeaderRetrievalUtils.retrieveLeaderGateway(
+ leaderRetrievalService,
+ actorSystem,
+ lookupTimeout);
+ } catch (LeaderRetrievalException e) {
+ throw new ProgramInvocationException("Failed to
retrieve JobManager gateway", e);
+ }
+
+ Future<Object> response;
+ try {
+ response = jobManagerGateway.ask(new
StopJob(jobId), timeout);
+ } catch (Exception e) {
+ throw new ProgramInvocationException("Failed to
query the job manager gateway.", e);
+ }
+
+ Object result = Await.result(response, timeout);
+
+ if (result instanceof
JobManagerMessages.StoppingSuccess) {
+ LOG.debug("Job stopping with ID " + jobId + "
succeeded.");
+ } else if (result instanceof
JobManagerMessages.StoppingFailure) {
+ Throwable t =
((JobManagerMessages.StoppingFailure) result).cause();
+ LOG.debug("Job stopping with ID " + jobId + "
failed.", t);
--- End diff --
This should be logged on INFO level...
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---