Refine search
@Override public boolean isActive(CommandLine commandLine) { String jobManagerOption = commandLine.getOptionValue(addressOption.getOpt(), null); boolean yarnJobManager = ID.equals(jobManagerOption); boolean yarnAppId = commandLine.hasOption(applicationId.getOpt()); return yarnJobManager || yarnAppId || (isYarnPropertiesFileMode(commandLine) && yarnApplicationIdFromYarnProperties != null); }
public static SavepointRestoreSettings createSavepointRestoreSettings(CommandLine commandLine) { if (commandLine.hasOption(SAVEPOINT_PATH_OPTION.getOpt())) { String savepointPath = commandLine.getOptionValue(SAVEPOINT_PATH_OPTION.getOpt()); boolean allowNonRestoredState = commandLine.hasOption(SAVEPOINT_ALLOW_NON_RESTORED_OPTION.getOpt()); return SavepointRestoreSettings.forPath(savepointPath, allowNonRestoredState); } else { return SavepointRestoreSettings.none(); } }
@Override @Nullable public ApplicationId getClusterId(CommandLine commandLine) { if (commandLine.hasOption(applicationId.getOpt())) { return ConverterUtils.toApplicationId(commandLine.getOptionValue(applicationId.getOpt())); } else if (isYarnPropertiesFileMode(commandLine)) { return yarnApplicationIdFromYarnProperties; } else { return null; } }
/** * Parse command line. */ public static CommandLine parseCommandLine(Options options, String[] args) throws ParseException { CommandLineParser parser = new DefaultParser(); CommandLine cli = parser.parse(options, args); if (cli.hasOption(StressTestUtils.HELP_OPT.getOpt())) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp( MRStressTest.class.getSimpleName(), OPTIONS); System.exit(0); } return cli; }
/** * Override configuration settings by specified command line options. * * @param commandLine containing the overriding values * @return Effective configuration with the overridden configuration settings */ protected Configuration applyCommandLineOptionsToConfiguration(CommandLine commandLine) throws FlinkException { final Configuration resultingConfiguration = new Configuration(configuration); if (commandLine.hasOption(addressOption.getOpt())) { String addressWithPort = commandLine.getOptionValue(addressOption.getOpt()); InetSocketAddress jobManagerAddress = ClientUtils.parseHostPortAddress(addressWithPort); setJobManagerAddressInConfig(resultingConfiguration, jobManagerAddress); } if (commandLine.hasOption(zookeeperNamespaceOption.getOpt())) { String zkNamespace = commandLine.getOptionValue(zookeeperNamespaceOption.getOpt()); resultingConfiguration.setString(HighAvailabilityOptions.HA_CLUSTER_ID, zkNamespace); } return resultingConfiguration; } }
private static List<URL> checkUrls(CommandLine line, Option option) { if (line.hasOption(option.getOpt())) { final String[] urls = line.getOptionValues(option.getOpt()); return Arrays.stream(urls) .distinct() .map((url) -> { try { return Path.fromLocalFile(new File(url).getAbsoluteFile()).toUri().toURL(); } catch (Exception e) { throw new SqlClientException("Invalid path for option '" + option.getLongOpt() + "': " + url, e); } }) .collect(Collectors.toList()); } return null; }
protected ProgramOptions(CommandLine line) throws CliArgsException { super(line); String[] args = line.hasOption(ARGS_OPTION.getOpt()) ? line.getOptionValues(ARGS_OPTION.getOpt()) : line.getArgs(); if (line.hasOption(JAR_OPTION.getOpt())) { this.jarFilePath = line.getOptionValue(JAR_OPTION.getOpt()); if (line.hasOption(CLASSPATH_OPTION.getOpt())) { for (String path : line.getOptionValues(CLASSPATH_OPTION.getOpt())) { try { classpaths.add(new URL(path)); this.entryPointClass = line.hasOption(CLASS_OPTION.getOpt()) ? line.getOptionValue(CLASS_OPTION.getOpt()) : null; if (line.hasOption(PARALLELISM_OPTION.getOpt())) { String parString = line.getOptionValue(PARALLELISM_OPTION.getOpt()); try { parallelism = Integer.parseInt(parString); stdoutLogging = !line.hasOption(LOGGING_OPTION.getOpt()); detachedMode = line.hasOption(DETACHED_OPTION.getOpt()) || line.hasOption( YARN_DETACHED_OPTION.getOpt()); shutdownOnAttachedExit = line.hasOption(SHUTDOWN_IF_ATTACHED_OPTION.getOpt());
private boolean isYarnPropertiesFileMode(CommandLine commandLine) { boolean canApplyYarnProperties = !commandLine.hasOption(addressOption.getOpt()); if (canApplyYarnProperties) { for (Option option : commandLine.getOptions()) { if (allOptions.hasOption(option.getOpt())) { if (!isDetachedOption(option)) { // don't resume from properties file if yarn options have been specified canApplyYarnProperties = false; break; } } } } return canApplyYarnProperties; }
/** * Add configurations provided with {@link #CONFIG_OPT} to {@link Configuration}. */ public static void populateConfigFromCli(Configuration configuration, CommandLine cli) { String stressorClass = cli.getOptionValue(STRESSOR_OPT.getOpt(), DEFAULT_STRESSOR_CLASS.getName()); configuration.set(STRESSOR_CLASS, stressorClass); if (cli.hasOption(CONFIG_OPT.getOpt())) { for (String arg : cli.getOptionValues(CONFIG_OPT.getOpt())) { List<String> tokens = Splitter.on(":").limit(2).splitToList(arg); if (tokens.size() < 2) { throw new IllegalArgumentException("Configurations must be of the form <key>:<value>"); } configuration.set(tokens.get(0), tokens.get(1)); } } } }
private void parseCommandLine(String[] args) throws ParseException { CommandLine cl = new GnuParser().parse(OPTIONS, args); listFSRoot = cl.hasOption(LIST_FS_ROOT.getOpt()); jdoqlQuery = cl.getOptionValue(EXECUTE_JDOQL.getOpt()); updateLocationParams = cl.getOptionValues(UPDATE_LOCATION.getOpt()); dryRun = cl.hasOption(DRY_RUN.getOpt()); serdePropKey = cl.getOptionValue(SERDE_PROP_KEY.getOpt()); tablePropKey = cl.getOptionValue(TABLE_PROP_KEY.getOpt()); help = cl.hasOption(HELP.getOpt()); int commandCount = (isListFSRoot() ? 1 : 0) + (isExecuteJDOQL() ? 1 : 0) + (isUpdateLocation() ? 1 : 0); if (commandCount != 1) { throw new IllegalArgumentException("exectly one of -listFSRoot, -executeJDOQL, -updateLocation must be set"); } if (updateLocationParams != null && updateLocationParams.length != 2) { throw new IllegalArgumentException("HiveMetaTool:updateLocation takes in 2 arguments but was passed " + updateLocationParams.length + " arguments"); } if ((dryRun || serdePropKey != null || tablePropKey != null) && !isUpdateLocation()) { throw new IllegalArgumentException("-dryRun, -serdePropKey, -tablePropKey may be used only for the " + "-updateLocation command"); } }
if (commandLine.hasOption(zookeeperNamespaceOption.getOpt())) { String zkNamespace = commandLine.getOptionValue(zookeeperNamespaceOption.getOpt()); effectiveConfiguration.setString(HA_CLUSTER_ID, zkNamespace); if (commandLine.hasOption(zookeeperNamespace.getOpt())){ zooKeeperNamespace = commandLine.getOptionValue(zookeeperNamespace.getOpt()); } else { zooKeeperNamespace = effectiveConfiguration.getString(HA_CLUSTER_ID, applicationId.toString()); if (commandLine.hasOption(jmMemory.getOpt())) { String jmMemoryVal = commandLine.getOptionValue(jmMemory.getOpt()); if (!MemorySize.MemoryUnit.hasUnit(jmMemoryVal)) { jmMemoryVal += "m"; if (commandLine.hasOption(tmMemory.getOpt())) { String tmMemoryVal = commandLine.getOptionValue(tmMemory.getOpt()); if (!MemorySize.MemoryUnit.hasUnit(tmMemoryVal)) { tmMemoryVal += "m"; if (commandLine.hasOption(slots.getOpt())) { effectiveConfiguration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, Integer.parseInt(commandLine.getOptionValue(slots.getOpt())));
/** * @throws ParseException If any args syntax constraint is violated and the dump was not able to * proceed. * @throws DumpException Human readable error executing the dump command. */ private int doDump(InputStream input, PrintStream out, PrintStream err, String[] args) throws ParseException, DumpException { CommandLine parsedArgs = mParser.parse(mGlobalOptions.options, args, true /* stopAtNonOption */); if (parsedArgs.hasOption(mGlobalOptions.optionHelp.getOpt())) { dumpUsage(out); return 0; } else if (parsedArgs.hasOption(mGlobalOptions.optionListPlugins.getOpt())) { dumpAvailablePlugins(out); return 0; } else if (!parsedArgs.getArgList().isEmpty()) { dumpPluginOutput(input, out, err, parsedArgs); return 0; } else { // Didn't understand the options, spit out help but use a non-success exit code. dumpUsage(err); return 1; } }
if (cmdLine.hasOption(HELP_OPT.getOpt())) { printHelpAndExit(options, 0); if (cmdLine.hasOption(HTTPD_PORT.getOpt())) { String portValue = cmdLine.getOptionValue(HTTPD_PORT.getOpt()); if (portValue.matches("\\d+")) { port = Integer.parseInt(portValue); if (cmdLine.hasOption(CRAWLER_NAMES.getOpt())) { String crawlerNames = cmdLine.getOptionValue(CRAWLER_NAMES.getOpt()); crawlers = crawlerNames.split(",");