/** * Prints custom cli options. * @param formatter The formatter to use for printing * @param runOptions True if the run options should be printed, False to print only general options */ private static void printCustomCliOptions( Collection<CustomCommandLine<?>> customCommandLines, HelpFormatter formatter, boolean runOptions) { // prints options from all available command-line classes for (CustomCommandLine cli: customCommandLines) { formatter.setSyntaxPrefix(" Options for " + cli.getId() + " mode:"); Options customOpts = new Options(); cli.addGeneralOptions(customOpts); if (runOptions) { cli.addRunOptions(customOpts); } formatter.printHelp(" ", customOpts); System.out.println(); } }
/** * Gets the custom command-line for the arguments. * @param commandLine The input to the command-line. * @return custom command-line which is active (may only be one at a time) */ public CustomCommandLine<?> getActiveCustomCommandLine(CommandLine commandLine) { for (CustomCommandLine<?> cli : customCommandLines) { if (cli.isActive(commandLine)) { return cli; } } throw new IllegalStateException("No command-line ran."); }
final ClusterDescriptor<T> clusterDescriptor = activeCommandLine.createClusterDescriptor(commandLine); final T clusterId = activeCommandLine.getClusterId(commandLine);
default CommandLine parseCommandLineOptions(String[] args, boolean stopAtNonOptions) throws CliArgsException { final Options options = new Options(); addGeneralOptions(options); addRunOptions(options); return CliFrontendParser.parse(options, args, stopAtNonOptions); } }
RunOptions runOptions, PackagedProgram program) throws ProgramInvocationException, FlinkException { final ClusterDescriptor<T> clusterDescriptor = customCommandLine.createClusterDescriptor(commandLine); final T clusterId = customCommandLine.getClusterId(commandLine); final ClusterSpecification clusterSpecification = customCommandLine.getClusterSpecification(commandLine); client = clusterDescriptor.deployJobCluster( clusterSpecification, final ClusterSpecification clusterSpecification = customCommandLine.getClusterSpecification(commandLine); client = clusterDescriptor.deploySessionCluster(clusterSpecification);
private static Options collectCommandLineOptions(List<CustomCommandLine<?>> commandLines) { final Options customOptions = new Options(); for (CustomCommandLine<?> customCommandLine : commandLines) { customCommandLine.addRunOptions(customOptions); } return CliFrontendParser.mergeOptions( CliFrontendParser.getRunCommandOptions(), customOptions); }
public ClusterDescriptor<T> createClusterDescriptor() throws Exception { return activeCommandLine.createClusterDescriptor(commandLine); }
/** * Updates the associated configuration with the given command line options * * @param options Command line options */ protected ClusterClient retrieveClient(CommandLineOptions options) { CustomCommandLine customCLI = getActiveCustomCommandLine(options.getCommandLine()); try { ClusterClient client = customCLI.retrieveCluster(options.getCommandLine(), config); logAndSysout("Using address " + client.getJobManagerAddress() + " to connect to JobManager."); return client; } catch (Exception e) { LOG.error("Couldn't retrieve {} cluster.", customCLI.getId(), e); throw new IllegalConfigurationException("Couldn't retrieve client for cluster", e); } }
private static ClusterSpecification createClusterSpecification(CustomCommandLine<?> activeCommandLine, CommandLine commandLine) { try { return activeCommandLine.getClusterSpecification(commandLine); } catch (FlinkException e) { throw new SqlExecutionException("Could not create cluster specification for the given deployment.", e); } }
activeCommandLine = findActiveCommandLine(availableCommandLines, commandLine); runOptions = createRunOptions(commandLine); clusterId = activeCommandLine.getClusterId(commandLine); clusterSpec = createClusterSpecification(activeCommandLine, commandLine);
private static Options buildGeneralOptions(Options options) { options.addOption(HELP_OPTION); // backwards compatibility: ignore verbose flag (-v) options.addOption(new Option("v", "verbose", false, "This option is deprecated.")); // add general options of all CLIs for (CustomCommandLine customCLI : CliFrontend.getCustomCommandLineList()) { customCLI.addGeneralOptions(options); } return options; }
public CliFrontend( Configuration configuration, List<CustomCommandLine<?>> customCommandLines) throws Exception { this.configuration = Preconditions.checkNotNull(configuration); this.customCommandLines = Preconditions.checkNotNull(customCommandLines); try { FileSystem.initialize(this.configuration); } catch (IOException e) { throw new Exception("Error while setting the default " + "filesystem scheme from configuration.", e); } this.customCommandLineOptions = new Options(); for (CustomCommandLine<?> customCommandLine : customCommandLines) { customCommandLine.addGeneralOptions(customCommandLineOptions); customCommandLine.addRunOptions(customCommandLineOptions); } this.clientTimeout = AkkaUtils.getClientTimeout(this.configuration); this.defaultParallelism = configuration.getInteger(CoreOptions.DEFAULT_PARALLELISM); }
RunOptions runOptions, PackagedProgram program) throws ProgramInvocationException, FlinkException { final ClusterDescriptor<T> clusterDescriptor = customCommandLine.createClusterDescriptor(commandLine); final T clusterId = customCommandLine.getClusterId(commandLine); final ClusterSpecification clusterSpecification = customCommandLine.getClusterSpecification(commandLine); client = clusterDescriptor.deployJobCluster( clusterSpecification, final ClusterSpecification clusterSpecification = customCommandLine.getClusterSpecification(commandLine); client = clusterDescriptor.deploySessionCluster(clusterSpecification);
/** * Prints custom cli options. * @param formatter The formatter to use for printing * @param runOptions True if the run options should be printed, False to print only general options */ private static void printCustomCliOptions( Collection<CustomCommandLine<?>> customCommandLines, HelpFormatter formatter, boolean runOptions) { // prints options from all available command-line classes for (CustomCommandLine cli: customCommandLines) { formatter.setSyntaxPrefix(" Options for " + cli.getId() + " mode:"); Options customOpts = new Options(); cli.addGeneralOptions(customOpts); if (runOptions) { cli.addRunOptions(customOpts); } formatter.printHelp(" ", customOpts); System.out.println(); } }
default CommandLine parseCommandLineOptions(String[] args, boolean stopAtNonOptions) throws CliArgsException { final Options options = new Options(); addGeneralOptions(options); addRunOptions(options); return CliFrontendParser.parse(options, args, stopAtNonOptions); } }
RunOptions runOptions, PackagedProgram program) throws ProgramInvocationException, FlinkException { final ClusterDescriptor<T> clusterDescriptor = customCommandLine.createClusterDescriptor(commandLine); final T clusterId = customCommandLine.getClusterId(commandLine); final ClusterSpecification clusterSpecification = customCommandLine.getClusterSpecification(commandLine); client = clusterDescriptor.deployJobCluster( clusterSpecification, final ClusterSpecification clusterSpecification = customCommandLine.getClusterSpecification(commandLine); client = clusterDescriptor.deploySessionCluster(clusterSpecification);
final ClusterDescriptor<T> clusterDescriptor = activeCommandLine.createClusterDescriptor(commandLine); final T clusterId = activeCommandLine.getClusterId(commandLine);
@SuppressWarnings("unchecked") private static <T> CustomCommandLine<T> findActiveCommandLine(List<CustomCommandLine<?>> availableCommandLines, CommandLine commandLine) { for (CustomCommandLine<?> cli : availableCommandLines) { if (cli.isActive(commandLine)) { return (CustomCommandLine<T>) cli; } } throw new SqlExecutionException("Could not find a matching deployment."); }
/** * Prints custom cli options. * @param formatter The formatter to use for printing * @param runOptions True if the run options should be printed, False to print only general options */ private static void printCustomCliOptions( Collection<CustomCommandLine<?>> customCommandLines, HelpFormatter formatter, boolean runOptions) { // prints options from all available command-line classes for (CustomCommandLine cli: customCommandLines) { formatter.setSyntaxPrefix(" Options for " + cli.getId() + " mode:"); Options customOpts = new Options(); cli.addGeneralOptions(customOpts); if (runOptions) { cli.addRunOptions(customOpts); } formatter.printHelp(" ", customOpts); System.out.println(); } }
default CommandLine parseCommandLineOptions(String[] args, boolean stopAtNonOptions) throws CliArgsException { final Options options = new Options(); addGeneralOptions(options); addRunOptions(options); return CliFrontendParser.parse(options, args, stopAtNonOptions); } }