Search in sources :

Example 1 with SavepointOptions

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

the class CliFrontend method savepoint.

/**
	 * Executes the SAVEPOINT action.
	 *
	 * @param args Command line arguments for the cancel action.
	 */
protected int savepoint(String[] args) {
    LOG.info("Running 'savepoint' command.");
    SavepointOptions options;
    try {
        options = CliFrontendParser.parseSavepointCommand(args);
    } catch (CliArgsException e) {
        return handleArgException(e);
    } catch (Throwable t) {
        return handleError(t);
    }
    // evaluate help flag
    if (options.isPrintHelp()) {
        CliFrontendParser.printHelpForSavepoint();
        return 0;
    }
    if (options.isDispose()) {
        // Discard
        return disposeSavepoint(options);
    } else {
        // Trigger
        String[] cleanedArgs = options.getArgs();
        JobID jobId;
        if (cleanedArgs.length >= 1) {
            String jobIdString = cleanedArgs[0];
            try {
                jobId = new JobID(StringUtils.hexStringToByte(jobIdString));
            } catch (Exception e) {
                return handleArgException(new IllegalArgumentException("Error: The value for the Job ID is not a valid ID."));
            }
        } else {
            return handleArgException(new IllegalArgumentException("Error: The value for the Job ID is not a valid ID. " + "Specify a Job ID to trigger a savepoint."));
        }
        String savepointDirectory = null;
        if (cleanedArgs.length >= 2) {
            savepointDirectory = cleanedArgs[1];
        }
        // Print superfluous arguments
        if (cleanedArgs.length >= 3) {
            logAndSysout("Provided more arguments than required. Ignoring not needed arguments.");
        }
        return triggerSavepoint(options, jobId, savepointDirectory);
    }
}
Also used : SavepointOptions(org.apache.flink.client.cli.SavepointOptions) CliArgsException(org.apache.flink.client.cli.CliArgsException) 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 SavepointOptions (org.apache.flink.client.cli.SavepointOptions)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