flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tillrohrmann <...@git.apache.org>
Subject [GitHub] flink pull request: [FLINK-1616] [client] Overhaul of the client.
Date Wed, 04 Mar 2015 10:08:50 GMT
Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/451#discussion_r25763642
  
    --- Diff: flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java ---
    @@ -601,452 +482,295 @@ public int compare(ExecutionGraph o1, ExecutionGraph o2) {
     	}
     	
     	/**
    -	 * Executes the cancel action.
    +	 * Executes the CANCEL action.
     	 * 
     	 * @param args Command line arguments for the cancel action.
     	 */
     	protected int cancel(String[] args) {
    -		// Parse command line options
    -		CommandLine line;
    +		LOG.info("Running 'cancel' command.");
    +
    +		CancelOptions options;
     		try {
    -			line = parser.parse(CANCEL_OPTIONS, args, false);
    -			evaluateGeneralOptions(line);
    -		}
    -		catch (MissingOptionException e) {
    -			return handleArgException(e);
    -		}
    -		catch (MissingArgumentException e) {
    -			return handleArgException(e);
    +			options = CliFrontendParser.parseCancelCommand(args);
     		}
    -		catch (UnrecognizedOptionException e) {
    +		catch (CliArgsException e) {
     			return handleArgException(e);
     		}
    -		catch (Exception e) {
    -			return handleError(e);
    +		catch (Throwable t) {
    +			return handleError(t);
     		}
    -		
    -		if (printHelp) {
    -			printHelpForCancel();
    +
    +		// evaluate help flag
    +		if (options.isPrintHelp()) {
    +			CliFrontendParser.printHelpForCancel();
     			return 0;
     		}
     		
    -		String[] cleanedArgs = line.getArgs();
    +		String[] cleanedArgs = options.getArgs();
     		JobID jobId;
     
     		if (cleanedArgs.length > 0) {
     			String jobIdString = cleanedArgs[0];
     			try {
     				jobId = new JobID(StringUtils.hexStringToByte(jobIdString));
    -			} catch (Exception e) {
    +			}
    +			catch (Exception e) {
    +				LOG.error("Error: The value for the Job ID is not a valid ID.");
     				System.out.println("Error: The value for the Job ID is not a valid ID.");
     				return 1;
     			}
    -		} else {
    +		}
    +		else {
    +			LOG.error("Missing JobID in the command line arguments.");
     			System.out.println("Error: Specify a Job ID to cancel a job.");
     			return 1;
     		}
     		
     		try {
    -			ActorRef jobManager = getJobManager(line, getGlobalConfiguration());
    -
    -			if (jobManager == null) {
    -				return 1;
    -			}
    -
    -			final Future<Object> response = Patterns.ask(jobManager, new CancelJob(jobId),
    -					new Timeout(getAkkaTimeout()));
    +			ActorRef jobManager = getJobManager(options);
    +			Future<Object> response = Patterns.ask(jobManager, new CancelJob(jobId), new
Timeout(askTimeout));
     
     			try {
    -				Await.ready(response, getAkkaTimeout());
    -			} catch (Exception exception) {
    -				throw new IOException("Canceling the job with job ID " + jobId + " failed.",
    -						exception);
    +				Await.result(response, askTimeout);
    --- End diff --
    
    ```Await.ready``` should be sufficient, because we don't do anything with the return value.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message