Search in sources :

Example 6 with CliArgsException

use of org.apache.flink.client.cli.CliArgsException in project flink by apache.

the class CliFrontend method stop.

/**
	 * Executes the STOP action.
	 * 
	 * @param args Command line arguments for the stop action.
	 */
protected int stop(String[] args) {
    LOG.info("Running 'stop' command.");
    StopOptions options;
    try {
        options = CliFrontendParser.parseStopCommand(args);
    } catch (CliArgsException e) {
        return handleArgException(e);
    } catch (Throwable t) {
        return handleError(t);
    }
    // evaluate help flag
    if (options.isPrintHelp()) {
        CliFrontendParser.printHelpForStop();
        return 0;
    }
    String[] stopArgs = options.getArgs();
    JobID jobId;
    if (stopArgs.length > 0) {
        String jobIdString = stopArgs[0];
        try {
            jobId = new JobID(StringUtils.hexStringToByte(jobIdString));
        } catch (Exception e) {
            return handleError(e);
        }
    } else {
        return handleArgException(new CliArgsException("Missing JobID"));
    }
    try {
        ActorGateway jobManager = getJobManagerGateway(options);
        Future<Object> response = jobManager.ask(new StopJob(jobId), clientTimeout);
        final Object rc = Await.result(response, clientTimeout);
        if (rc instanceof StoppingFailure) {
            throw new Exception("Stopping the job with ID " + jobId + " failed.", ((StoppingFailure) rc).cause());
        }
        return 0;
    } catch (Throwable t) {
        return handleError(t);
    }
}
Also used : StopOptions(org.apache.flink.client.cli.StopOptions) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) StoppingFailure(org.apache.flink.runtime.messages.JobManagerMessages.StoppingFailure) CliArgsException(org.apache.flink.client.cli.CliArgsException) StopJob(org.apache.flink.runtime.messages.JobManagerMessages.StopJob) JobID(org.apache.flink.api.common.JobID) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) ProgramMissingJobException(org.apache.flink.client.program.ProgramMissingJobException) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException) ProgramParametrizationException(org.apache.flink.client.program.ProgramParametrizationException) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) CliArgsException(org.apache.flink.client.cli.CliArgsException) IOException(java.io.IOException)

Aggregations

CliArgsException (org.apache.flink.client.cli.CliArgsException)6 FileNotFoundException (java.io.FileNotFoundException)5 IOException (java.io.IOException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 InvalidProgramException (org.apache.flink.api.common.InvalidProgramException)4 ProgramInvocationException (org.apache.flink.client.program.ProgramInvocationException)4 ProgramMissingJobException (org.apache.flink.client.program.ProgramMissingJobException)4 ProgramParametrizationException (org.apache.flink.client.program.ProgramParametrizationException)4 IllegalConfigurationException (org.apache.flink.configuration.IllegalConfigurationException)4 JobID (org.apache.flink.api.common.JobID)3 ActorGateway (org.apache.flink.runtime.instance.ActorGateway)3 CancelJobWithSavepoint (org.apache.flink.runtime.messages.JobManagerMessages.CancelJobWithSavepoint)3 PackagedProgram (org.apache.flink.client.program.PackagedProgram)2 DisposeSavepoint (org.apache.flink.runtime.messages.JobManagerMessages.DisposeSavepoint)2 TriggerSavepoint (org.apache.flink.runtime.messages.JobManagerMessages.TriggerSavepoint)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Comparator (java.util.Comparator)1 Date (java.util.Date)1 CancelOptions (org.apache.flink.client.cli.CancelOptions)1 InfoOptions (org.apache.flink.client.cli.InfoOptions)1