[ 
https://issues.apache.org/jira/browse/FLINK-1818?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14521839#comment-14521839
 ] 

ASF GitHub Bot commented on FLINK-1818:
---------------------------------------

Github user mxm commented on a diff in the pull request:

    https://github.com/apache/flink/pull/642#discussion_r29447974
  
    --- Diff: 
flink-clients/src/main/java/org/apache/flink/client/program/Client.java ---
    @@ -420,6 +428,60 @@ public JobSubmissionResult run(JobGraph jobGraph, 
boolean wait) throws ProgramIn
                }
        }
     
    +
    +   /**
    +    * Executes the CANCEL action.
    +    *
    +    * @param args Command line arguments for the cancel action.
    +    */
    +
    +
    +   protected int cancel(JobID jobId){
    +           LOG.info("Executing 'cancel' command.");
    +
    +           final FiniteDuration timeout = 
AkkaUtils.getTimeout(configuration);
    +
    +           try {
    +                   String address = 
configuration.getString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, null);
    +                   Option<Tuple2<String, Object>> remoting =
    +                                   new Some<Tuple2<String, Object>>(new 
Tuple2<String, Object>("", 0));
    +
    +                   // start a remote actor system to listen on an 
arbitrary port
    +                   ActorSystem actorSystem = 
AkkaUtils.createActorSystem(configuration, remoting);
    +
    +
    +                   ActorRef jobManager = 
JobManager.getJobManagerRemoteReference(address, actorSystem, timeout);
    +                   Future<Object> response = Patterns.ask(jobManager, new 
JobManagerMessages.CancelJob(jobId), new Timeout(AkkaUtils.INF_TIMEOUT()));
    +
    +                   try {
    +                           Await.result(response, timeout);
    +                           return 0;
    +                   }
    +                   catch (Exception e) {
    +                           throw new Exception("Canceling the job with ID 
" + jobId + " failed.", e);
    +                   }
    +           }
    +           catch (Throwable t) {
    +                   return handleError(t);
    +           }
    --- End diff --
    
    I would handle the error explicitly here and print a stacktrace and info 
message. Creating a new method is not necessary because it is not used 
elsewhere. You might want to return a boolean which returns true if the 
cancellation succeeded (CancellationSuccess received) or failed (otherwise).


> Provide API to cancel running job
> ---------------------------------
>
>                 Key: FLINK-1818
>                 URL: https://issues.apache.org/jira/browse/FLINK-1818
>             Project: Flink
>          Issue Type: Improvement
>          Components: Java API
>    Affects Versions: 0.9
>            Reporter: Robert Metzger
>            Assignee: niraj rai
>              Labels: starter
>
> http://apache-flink-incubator-mailing-list-archive.1008284.n3.nabble.com/Canceling-a-Cluster-Job-from-Java-td4897.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to