@Override protected void processOptions(LinkedList<String> args) throws IOException { CommandFormat cf = new CommandFormat(1, 1, "f"); cf.parse(args); follow = cf.getOpt("f"); }
@Override protected void processOptions(LinkedList<String> args) { CommandFormat cf = new CommandFormat(1, 1, "e", "d", "f", "s", "z", "w", "r"); cf.parse(args); String[] opts = cf.getOpts().toArray(new String[0]); switch (opts.length) { case 0: throw new IllegalArgumentException("No test flag given"); case 1: flag = opts[0].charAt(0); break; default: throw new IllegalArgumentException("Only one test flag is allowed"); } }
@Override protected void processOptions(LinkedList<String> args) throws IOException { CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE, "f", "p", "l", "d"); cf.addOptionWithValue("t"); cf.parse(args); setNumberThreads(cf.getOptValue("t")); setOverwrite(cf.getOpt("f")); setPreserve(cf.getOpt("p")); setLazyPersist(cf.getOpt("l")); setDirectWrite(cf.getOpt("d")); getRemoteDestination(args); // should have a -r option setRecursive(true); }
@Override protected void processOptions(LinkedList<String> args) { CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE); cf.parse(args); }
@Override protected void processOptions(LinkedList<String> args) throws IOException { cf.parse(args); setRecursive(cf.getOpt("R")); boolean bothRemoveOptions = cf.getOpt("b") && cf.getOpt("k"); boolean bothModifyOptions = cf.getOpt("m") && cf.getOpt("x"); boolean oneRemoveOption = cf.getOpt("b") || cf.getOpt("k"); boolean oneModifyOption = cf.getOpt("m") || cf.getOpt("x"); boolean setOption = cf.getOpt("-set"); boolean hasExpectedOptions = cf.getOpt("b") || cf.getOpt("k") || cf.getOpt("m") || cf.getOpt("x") || cf.getOpt("-set"); "Missing either <acl_spec> or <path>"); aclEntries = AclEntry.parseAclSpec(args.removeFirst(), !cf.getOpt("x")); if (aclEntries.isEmpty()) { throw new HadoopIllegalArgumentException(
/** Parse parameters starting from the given position * Consider using the variant that directly takes a List * * @param args an array of input arguments * @param pos the position at which starts to parse * @return a list of parameters */ public List<String> parse(String[] args, int pos) { List<String> parameters = new ArrayList<String>(Arrays.asList(args)); parameters.subList(0, pos).clear(); parse(parameters); return parameters; }
/** * Constructor a S3Guard tool with HDFS configuration. * @param conf Configuration. * @param opts any boolean options to support */ protected S3GuardTool(Configuration conf, String...opts) { super(conf); commandFormat = new CommandFormat(0, Integer.MAX_VALUE, opts); // For metadata store URI commandFormat.addOptionWithValue(META_FLAG); // DDB region. commandFormat.addOptionWithValue(REGION_FLAG); }
if (commands.getOpt(LIST)) { mode = Mode.LIST; if (commands.getOpt(ABORT)) { if (mode != null) { throw invalidArgs(err); String expectVal = commands.getOptValue(EXPECT); if (expectVal != null) { if (mode != null) { if (commands.getOpt(VERBOSE)) { verbose = true; if (commands.getOpt(FORCE)) { force = true;
@Override protected void processPath(PathData item) throws IOException { if (cf.getOpt("b")) { item.fs.removeAcl(item.path); } else if (cf.getOpt("k")) { item.fs.removeDefaultAcl(item.path); } else if (cf.getOpt("m")) { List<AclEntry> entries = getAclEntries(item); if (!entries.isEmpty()) { item.fs.modifyAclEntries(item.path, entries); } } else if (cf.getOpt("x")) { List<AclEntry> entries = getAclEntries(item); if (!entries.isEmpty()) { item.fs.removeAclEntries(item.path, entries); } } else if (cf.getOpt("-set")) { List<AclEntry> entries = getAclEntries(item); if (!entries.isEmpty()) { item.fs.setAcl(item.path, entries); } } }
protected void addAgeOptions() { CommandFormat format = getCommandFormat(); format.addOptionWithValue(DAYS_FLAG); format.addOptionWithValue(HOURS_FLAG); format.addOptionWithValue(MINUTES_FLAG); format.addOptionWithValue(SECONDS_FLAG); }
private long getDeltaComponent(TimeUnit unit, String arg) { String raw = getCommandFormat().getOptValue(arg); if (raw == null || raw.isEmpty()) { return 0; } Long parsed = Long.parseLong(raw); return unit.toMillis(parsed); }
@Override protected void processOptions(LinkedList<String> args) throws IOException { CommandFormat cf = new CommandFormat(1, 1); cf.parse(args); }
if (commands.getOpt(UNGUARDED_FLAG)) { throw badState("S3Guard is enabled for %s", fsUri); if (commands.getOpt(AUTH_FLAG) && !authMode) { throw badState("S3Guard is enabled for %s," + " but not in authoritative mode", fsUri); if (commands.getOpt(NONAUTH_FLAG) && authMode) { throw badState("S3Guard is enabled in authoritative mode for %s", fsUri); if (commands.getOpt(GUARDED_FLAG)) { throw badState("S3Guard is not enabled for %s", fsUri); if (commands.getOpt(MAGIC_FLAG) && !magic) { throw badState("The magic committer is not enabled for %s", fsUri); .getOptValue(ENCRYPTION_FLAG); if (StringUtils.isNotEmpty(desiredEncryption) && !desiredEncryption.equalsIgnoreCase(encryption)) {
Init(Configuration conf) { super(conf); // read capacity. getCommandFormat().addOptionWithValue(READ_FLAG); // write capacity. getCommandFormat().addOptionWithValue(WRITE_FLAG); // tag getCommandFormat().addOptionWithValue(TAG_FLAG); }
List<String> paths = parseArgs(args); String readCap = getCommandFormat().getOptValue(READ_FLAG); if (readCap != null && !readCap.isEmpty()) { int readCapacity = Integer.parseInt(readCap); getConf().setInt(S3GUARD_DDB_TABLE_CAPACITY_READ_KEY, readCapacity); String writeCap = getCommandFormat().getOptValue(WRITE_FLAG); if (writeCap != null && !writeCap.isEmpty()) { int writeCapacity = Integer.parseInt(writeCap); String tags = getCommandFormat().getOptValue(TAG_FLAG); if (tags != null && !tags.isEmpty()) { String[] stringList = tags.split(";");
@Override protected void processOptions(LinkedList<String> args) throws IOException { CommandFormat cf = new CommandFormat( 1, Integer.MAX_VALUE, "-ignore-fail-on-non-empty"); cf.parse(args); ignoreNonEmpty = cf.getOpt("-ignore-fail-on-non-empty"); }
@Override protected void processOptions(LinkedList<String> args) { CommandFormat cf = new CommandFormat(1, 1, "e", "d", "f", "s", "z"); cf.parse(args); String[] opts = cf.getOpts().toArray(new String[0]); switch (opts.length) { case 0: throw new IllegalArgumentException("No test flag given"); case 1: flag = opts[0].charAt(0); break; default: throw new IllegalArgumentException("Only one test flag is allowed"); } }
@Override protected void processOptions(LinkedList<String> args) throws IOException { CommandFormat cf = new CommandFormat(0, 0); cf.parse(args); }
@Override protected void processOptions(LinkedList<String> args) { CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE, OPTION_QUOTA, OPTION_HUMAN, OPTION_HEADER, OPTION_QUOTA_AND_USAGE, OPTION_EXCLUDE_SNAPSHOT, OPTION_ECPOLICY); cf.addOptionWithValue(OPTION_TYPE); cf.parse(args); if (args.isEmpty()) { // default path is the current working directory args.add("."); showQuotas = cf.getOpt(OPTION_QUOTA); humanReadable = cf.getOpt(OPTION_HUMAN); showQuotasAndUsageOnly = cf.getOpt(OPTION_QUOTA_AND_USAGE); excludeSnapshots = cf.getOpt(OPTION_EXCLUDE_SNAPSHOT); displayECPolicy = cf.getOpt(OPTION_ECPOLICY); String types = cf.getOptValue(OPTION_TYPE); if (cf.getOpt(OPTION_HEADER)) { StringBuilder headString = new StringBuilder(); if (showQuotabyType) {
SetCapacity(Configuration conf) { super(conf); // read capacity. getCommandFormat().addOptionWithValue(READ_FLAG); // write capacity. getCommandFormat().addOptionWithValue(WRITE_FLAG); }