/** * Returns the URL represented by <code>str</code>. * * @param str the URL string * @return The URL in <code>str</code> is well-formed * @throws ParseException if the URL in <code>str</code> is not well-formed */ public static URL createURL(String str) throws ParseException { try { return new URL(str); } catch (MalformedURLException e) { throw new ParseException("Unable to parse the URL: " + str); } }
/** * Returns the class whose name is <code>classname</code>. * * @param classname the class name * @return The class if it is found * @throws ParseException if the class could not be found */ public static Class<?> createClass(String classname) throws ParseException { try { return Class.forName(classname); } catch (ClassNotFoundException e) { throw new ParseException("Unable to find the class: " + classname); } }
private void printAndExit(String reason) throws ParseException { if (reason != null) { System.err.println(reason); } HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("schemaTool", cmdLineOptions); if (reason != null) { throw new ParseException(reason); } else { System.exit(0); } }
@Override public void process(Config conf, CommandLine commandLine) throws ParseException { for (String s : commandLine.getOptionValues("D")) { String[] keyval = s.split("=", 2); if (keyval.length != 2) throw new ParseException("Invalid option value `" + s + "'"); conf.putAll((Map) yaml.load(keyval[0] + ": " + keyval[1])); } } }
static DLSN parseDLSN(String dlsnStr) throws ParseException { if (dlsnStr.equals("InitialDLSN")) { return DLSN.InitialDLSN; } String[] parts = dlsnStr.split(","); if (parts.length != 3) { throw new ParseException("Invalid dlsn : " + dlsnStr); } try { return new DLSN(Long.parseLong(parts[0]), Long.parseLong(parts[1]), Long.parseLong(parts[2])); } catch (Exception nfe) { throw new ParseException("Invalid dlsn : " + dlsnStr); } }
@Override protected void parseCommandLine(CommandLine cmdline) throws ParseException { super.parseCommandLine(cmdline); if (!cmdline.hasOption("s")) { throw new ParseException("No stream name provided."); } streamName = cmdline.getOptionValue("s"); }
@Override protected void parseCommandLine(CommandLine cmdline) throws ParseException { super.parseCommandLine(cmdline); if (!cmdline.hasOption("d")) { throw new ParseException("No DLSN provided"); } String[] dlsnStrs = cmdline.getOptionValue("d").split(","); if (dlsnStrs.length != 3) { throw new ParseException("Invalid DLSN : " + cmdline.getOptionValue("d")); } dlsn = new DLSN(Long.parseLong(dlsnStrs[0]), Long.parseLong(dlsnStrs[1]), Long.parseLong(dlsnStrs[2])); }
@Override protected void parseCommandLine(CommandLine cmdline) throws ParseException { super.parseCommandLine(cmdline); if (!cmdline.hasOption("s")) { throw new ParseException("No stream to set ACL"); } stream = cmdline.getOptionValue("s"); }
@Override protected void parseCommandLine(CommandLine cmdline) throws ParseException { super.parseCommandLine(cmdline); if (!cmdline.hasOption("e")) { throw new ParseException("No action 'enable/disable' provided"); } enabled = Boolean.parseBoolean(cmdline.getOptionValue("e")); }
@Override protected void parseCommandLine(CommandLine cmdline) throws ParseException { super.parseCommandLine(cmdline); dryrun = cmdline.hasOption("d"); verbose = cmdline.hasOption("v"); force = !dryrun && cmdline.hasOption("f"); if (!cmdline.hasOption("l")) { throw new ParseException("No streams provided to repair"); } String streamsList = cmdline.getOptionValue("l"); Collections.addAll(streams, streamsList.split(",")); }
@Override protected void parseCommandLine(CommandLine cmdline) throws ParseException { super.parseCommandLine(cmdline); if (!cmdline.hasOption("s")) { throw new ParseException("No stream to set ACL"); } stream = cmdline.getOptionValue("s"); }
@Override public void process(Config conf, CommandLine commandLine) throws ParseException { try { for (String f : commandLine.getOptionValues("conf")) { Map m = loadConf(f); if (m == null) throw new ParseException("Empty configuration file " + f); conf.putAll(m); } } catch (IOException e) { throw new ParseException(e.getMessage()); } } }
@Override protected void parseCommandLine(CommandLine cmdline) throws ParseException { super.parseCommandLine(cmdline); if (!cmdline.hasOption("l")) { throw new ParseException("No ledger provided."); } ledgerId = Long.parseLong(cmdline.getOptionValue("l")); }
protected void parseCommandLine(CommandLine cmdline) throws ParseException { if (!cmdline.hasOption("H")) { throw new ParseException("No proxy address provided"); } address = DLSocketAddress.parseSocketAddress(cmdline.getOptionValue("H")); }
@Override protected void parseCommandLine(CommandLine cmdline) throws ParseException { super.parseCommandLine(cmdline); if (cmdline.hasOption("r")) { streamPrefix = cmdline.getOptionValue("r"); } if (cmdline.hasOption("e")) { streamExpression = cmdline.getOptionValue("e"); } if (null == streamPrefix || null == streamExpression) { throw new ParseException("Please specify stream prefix & expression."); } }
@Override protected void parseCommandLine(CommandLine cmdline) throws ParseException { super.parseCommandLine(cmdline); dryrun = cmdline.hasOption("d"); verbose = cmdline.hasOption("v"); if (cmdline.hasOption("cy")) { try { concurrency = Integer.parseInt(cmdline.getOptionValue("cy")); } catch (NumberFormatException nfe) { throw new ParseException("Invalid concurrency value : " + cmdline.getOptionValue("cy")); } } }
@Override protected void parseCommandLine(CommandLine cmdline) throws ParseException { super.parseCommandLine(cmdline); if (cmdline.hasOption("t")) { concurrency = Integer.parseInt(cmdline.getOptionValue("t")); if (concurrency <= 0) { throw new ParseException("Invalid concurrency value : " + concurrency + ": it must be greater or equal to 0."); } } if (cmdline.hasOption("ap")) { allocationPoolPath = cmdline.getOptionValue("ap"); if (!allocationPoolPath.startsWith(".") || !allocationPoolPath.contains("allocation")) { throw new ParseException("Invalid allocation pool path : " + allocationPoolPath + ": it must starts with a '.' and must contains 'allocation'"); } } }
protected void parseCommandLine(CommandLine cmdline) throws ParseException { super.parseCommandLine(cmdline); if (!cmdline.hasOption("u")) { throw new ParseException("No proxy serverset provided."); } uri = URI.create(cmdline.getOptionValue("u")); if (cmdline.hasOption("sp")) { String sourceProxyStr = cmdline.getOptionValue("sp"); try { DLSocketAddress.parseSocketAddress(sourceProxyStr); } catch (IllegalArgumentException iae) { throw new ParseException("Invalid source proxy " + sourceProxyStr + " : " + iae.getMessage()); } this.source = sourceProxyStr; } }
@Override public void process(Config conf, CommandLine commandLine) throws ParseException { try { List<File> jarFiles = validateFiles(commandLine.getOptionValue("libjars")); Map<String, String> jars = new HashMap<>(jarFiles.size()); List<String> names = new ArrayList<>(jarFiles.size()); for (File f : jarFiles) { jars.put(f.getName(), f.getAbsolutePath()); names.add(f.getName()); } conf.put(TOPOLOGY_LIB_PATH, jars); conf.put(TOPOLOGY_LIB_NAME, names); } catch (IOException e) { throw new ParseException(e.getMessage()); } } }
@Override protected void parseCommandLine(CommandLine cmdline) throws ParseException { super.parseCommandLine(cmdline); String[] args = cmdline.getArgs(); if (args.length < 1) { throw new ParseException("Must specify at least start dlsn."); } if (args.length >= 1) { startDLSN = parseDLSN(args[0]); } if (args.length >= 2) { endDLSN = parseDLSN(args[1]); } }