Search in sources :

Example 1 with StoppingFailure

use of org.apache.flink.runtime.messages.JobManagerMessages.StoppingFailure 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

FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 InvalidProgramException (org.apache.flink.api.common.InvalidProgramException)1 JobID (org.apache.flink.api.common.JobID)1 CliArgsException (org.apache.flink.client.cli.CliArgsException)1 StopOptions (org.apache.flink.client.cli.StopOptions)1 ProgramInvocationException (org.apache.flink.client.program.ProgramInvocationException)1 ProgramMissingJobException (org.apache.flink.client.program.ProgramMissingJobException)1 ProgramParametrizationException (org.apache.flink.client.program.ProgramParametrizationException)1 IllegalConfigurationException (org.apache.flink.configuration.IllegalConfigurationException)1 ActorGateway (org.apache.flink.runtime.instance.ActorGateway)1 StopJob (org.apache.flink.runtime.messages.JobManagerMessages.StopJob)1 StoppingFailure (org.apache.flink.runtime.messages.JobManagerMessages.StoppingFailure)1