Refine search
/** * Get list of disabled rules. * * @return Excluded rules */ public Set<String> getExcludedRules() { return cmd.hasOption(Messages.EXCEPT_OPT) ? new HashSet<>(Arrays.asList(cmd.getOptionValues(Messages.EXCEPT_OPT))) : new HashSet<>(); }
public Set<String> getOnlySpecificRules() { return cmd.hasOption(Messages.ONLY_OPT) ? new HashSet<>(Arrays.asList(cmd.getOptionValues(Messages.ONLY_OPT))) : new HashSet<>(); }
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; }
public static void setShellEnv(CommandLine cliParser, MasterContext jstormContext) { if (cliParser.hasOption(JOYConstants.SHELL_ENV)) { String envs[] = cliParser.getOptionValues(JOYConstants.SHELL_ENV); for (String env : envs) { env = env.trim(); int index = env.indexOf(JOYConstants.EQUAL); if (index == -1) { jstormContext.getShellEnv().put(env, JOYConstants.EMPTY); continue; } String key = env.substring(0, index); String val = JOYConstants.EMPTY; if (index < (env.length() - 1)) { val = env.substring(index + 1); } jstormContext.getShellEnv().put(key, val); } } }
/** * 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)); } } } }
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));
public static void main(String[] args) { if (args == null || args.length < 3) { System.out.println("Invalid parameter"); usage(); return; } String topologyName = args[0]; try { String[] str2 = Arrays.copyOfRange(args, 1, args.length); CommandLineParser parser = new GnuParser(); Options r = buildGeneralOptions(new Options()); CommandLine commandLine = parser.parse(r, str2, true); String pathConf = null; String pathJar = null; if (commandLine.hasOption("conf")) { pathConf = (commandLine.getOptionValues("conf"))[0]; } if (commandLine.hasOption("jar")) { pathJar = (commandLine.getOptionValues("jar"))[0]; } if (pathConf != null || pathJar != null) updateTopology(topologyName, pathJar, pathConf); } catch (Exception e) { e.printStackTrace(); } } }
private Supplier<String> parsePasswordSupplier(CommandLine commandLine, String option, Supplier<String> defaultSupplier) { if (commandLine.hasOption(option)) { String[] values = commandLine.getOptionValues(option); if (values.length == 1) { return PasswordUtil.passwordSupplier(values[0]); } else { return PasswordUtil.passwordSupplier("Provided " + option + " exhausted, please don't specify " + option + ", specify one value to be used for all NiFi instances, or specify one value for each NiFi instance.", values); } } else { return defaultSupplier; } }
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"); } }
for (Opt opt : opts) { if (opt.noValue) { ret.put(opt.shortName, cl.hasOption(opt.shortName)); } else { Object current = null; String[] strings = cl.getOptionValues(opt.shortName); if (strings != null) { for (String val : strings) {
allExtractors.put(entry.getKey(), new MetricExtractor((m, unit) -> value, "")); if (commandLine.hasOption("r")) { reportIntervalSecs = Long.parseLong(commandLine.getOptionValue("r")); reportIntervalSecs = ((reportIntervalSecs + 1) / 10) * 10; if (commandLine.hasOption("w")) { long window = Long.parseLong(commandLine.getOptionValue("w")); windowLength = (int) ((window + 1) / reportIntervalSecs); if (commandLine.hasOption("reporter")) { for (String reporterString: commandLine.getOptionValues("reporter")) { Matcher m = REPORTER_PATTERN.matcher(reporterString); if (!m.matches()) {
if (cmd.hasOption(flinkJar.getOpt())) { String userPath = cmd.getOptionValue(flinkJar.getOpt()); if (!userPath.startsWith("file://")) { if (cmd.hasOption(shipPath.getOpt())) { String[] shipPaths = cmd.getOptionValues(this.shipPath.getOpt()); for (String shipPath : shipPaths) { File shipDir = new File(shipPath); if (cmd.hasOption(queue.getOpt())) { yarnClusterDescriptor.setQueue(cmd.getOptionValue(queue.getOpt()));
public static void checkAndSetOptions(CommandLine cliParser, JstormClientContext jstormClientContext) { if (cliParser.hasOption(JOYConstants.DEBUG)) { jstormClientContext.debugFlag = true; if (cliParser.hasOption(JOYConstants.KEEP_CONTAINERS_ACROSS_APPLICATION_ATTEMPTS)) { jstormClientContext.keepContainers = true; if (cliParser.hasOption(JOYConstants.LOG_PROPERTIES)) { String log4jPath = cliParser.getOptionValue(JOYConstants.LOG_PROPERTIES); try { if (cliParser.hasOption(JOYConstants.SHELL_ARGS)) { jstormClientContext.shellArgs = cliParser.getOptionValues(JOYConstants.SHELL_ARGS);
public boolean process_stage2(CliSessionState ss) { ss.getConf(); if (commandLine.hasOption('H')) { printUsage(); return false; } ss.setIsSilent(commandLine.hasOption('S')); ss.database = commandLine.getOptionValue("database"); ss.execString = commandLine.getOptionValue('e'); ss.fileName = commandLine.getOptionValue('f'); ss.setIsVerbose(commandLine.hasOption('v')); String[] initFiles = commandLine.getOptionValues('i'); if (null != initFiles) { ss.initFiles = Arrays.asList(initFiles); } if (ss.execString != null && ss.fileName != null) { System.err.println("The '-e' and '-f' options cannot be specified simultaneously"); printUsage(); return false; } if (commandLine.hasOption("hiveconf")) { Properties confProps = commandLine.getOptionProperties("hiveconf"); for (String propKey : confProps.stringPropertyNames()) { ss.cmdProperties.setProperty(propKey, confProps.getProperty(propKey)); } } return true; }
if (cmd.hasOption("conf")) { String confFilePath = cmd.getOptionValue("conf"); Properties prop = new Properties(); if (cmd.hasOption("jobconf")) { String[] optionValues = cmd.getOptionValues("jobconf"); for (String optionValue : optionValues) { String[] keyValuePair = optionValue.split("="); if (cmd.hasOption("D")) { String[] optionValues = cmd.getOptionValues("D"); for (String optionValue : optionValues) { String[] keyValuePair = optionValue.split("=");
if (cmd.hasOption("conf")) { String confFilePath = cmd.getOptionValue("conf"); Properties prop = new Properties(); if (cmd.hasOption("jobconf")) { String[] optionValues = cmd.getOptionValues("jobconf"); for (String optionValue : optionValues) { String[] keyValuePair = optionValue.split("="); if (cmd.hasOption("D")) { String[] optionValues = cmd.getOptionValues("D"); for (String optionValue : optionValues) { String[] keyValuePair = optionValue.split("=");
protected void configureReader(final ChronicleReader chronicleReader, final CommandLine commandLine) { final Consumer<String> messageSink = commandLine.hasOption('l') ? s -> System.out.println(s.replaceAll("\n", "")) : System.out::println; withBasePath(Paths.get(commandLine.getOptionValue('d'))); if (commandLine.hasOption('i')) { stream(commandLine.getOptionValues('i')).forEach(chronicleReader::withInclusionRegex); if (commandLine.hasOption('e')) { stream(commandLine.getOptionValues('e')).forEach(chronicleReader::withExclusionRegex); if (commandLine.hasOption('f')) {
CommandLine cli = parser.parse(opts, args); if (cli.hasOption("h")) { final HelpFormatter fmt = new HelpFormatter(); fmt.printHelp(AlluxioFuse.class.getName(), opts); if (cli.hasOption("o")) { String[] fopts = cli.getOptionValues("o");
if (commandLine.hasOption(GLOBAL_PORT_SEQUENCE_ARG)) { globalOrderExpressions = Arrays.stream(commandLine.getOptionValues(GLOBAL_PORT_SEQUENCE_ARG)).flatMap(s -> Arrays.stream(s.split(","))).map(String::trim); if (commandLine.hasOption(HOSTNAMES_ARG)) { instanceDefinitions = Collections.unmodifiableList( InstanceDefinition.createDefinitions(globalOrderExpressions, Arrays.stream(commandLine.getOptionValues(HOSTNAMES_ARG)).flatMap(s -> Arrays.stream(s.split(",")).map(String::trim)), parsePasswordSupplier(commandLine, KEY_STORE_PASSWORD_ARG, passwordUtil.passwordSupplier()), parsePasswordSupplier(commandLine, KEY_PASSWORD_ARG, commandLine.hasOption(DIFFERENT_KEY_AND_KEYSTORE_PASSWORDS_ARG) ? passwordUtil.passwordSupplier() : null), parsePasswordSupplier(commandLine, TRUST_STORE_PASSWORD_ARG, passwordUtil.passwordSupplier()))); } else { String[] clientDnValues = commandLine.getOptionValues(CLIENT_CERT_DN_ARG); if (clientDnValues != null) { clientDns = Collections.unmodifiableList(Arrays.stream(clientDnValues).collect(Collectors.toList())); clientPasswordsGenerated = commandLine.getOptionValues(CLIENT_CERT_PASSWORD_ARG) == null; overwrite = commandLine.hasOption(OVERWRITE_ARG);
try { cmd = parser.parse(options, args); if (cmd.hasOption("t")) { executeTime = Double.valueOf(cmd.getOptionValue("t")); if (cmd.hasOption("parallel")) { for (String stringParallel : cmd.getOptionValues("parallel")) { Matcher m = MULTI_PATTERN.matcher(stringParallel); if (!m.matches()) { if (cmd.hasOption("throughput")) { for (String stringThroughput : cmd.getOptionValues("throughput")) { Matcher m = MULTI_PATTERN.matcher(stringThroughput); if (!m.matches()) { if (cmd.hasOption("imbalance")) { for (String stringImbalance : cmd.getOptionValues("imbalance")) {