@Override protected void processOptions(LinkedList<String> args) throws IOException { name = StringUtils.popOptionWithArgument("-n", args); String v = StringUtils.popOptionWithArgument("-v", args); if (v != null) { value = XAttrCodec.decodeValue(v); } xname = StringUtils.popOptionWithArgument("-x", args); if (name != null && xname != null) { throw new HadoopIllegalArgumentException( "Can not specify both '-n name' and '-x name' option."); } if (name == null && xname == null) { throw new HadoopIllegalArgumentException( "Must specify '-n name' or '-x name' option."); } if (args.isEmpty()) { throw new HadoopIllegalArgumentException("<path> is missing."); } if (args.size() > 1) { throw new HadoopIllegalArgumentException("Too many arguments."); } }
private int addSpanReceiver(List<String> args) throws IOException { String className = StringUtils.popOptionWithArgument("-class", args); if (className == null) { System.err.println("You must specify the classname with -class.");
@Override public int run(String[] argv) throws Exception { List<String> args = new LinkedList<>(Arrays.asList(argv)); String keytabName = popOptionWithArgument(ARG_KEYTAB, args); if (keytabName != null) { keytab = new File(keytabName); principal = popOptionWithArgument(ARG_PRINCIPAL, args); String outf = popOptionWithArgument(ARG_OUTPUT, args); String mkl = popOptionWithArgument(ARG_KEYLEN, args); if (mkl != null) { minKeyLength = Integer.parseInt(mkl); while (null != (resource = popOptionWithArgument(ARG_RESOURCE, args))) {
@Override protected void processOptions(LinkedList<String> args) throws IOException { name = StringUtils.popOptionWithArgument("-n", args); String en = StringUtils.popOptionWithArgument("-e", args); if (en != null) { try { encoding = XAttrCodec.valueOf(StringUtils.toUpperCase(en)); } catch (IllegalArgumentException e) { throw new IllegalArgumentException( "Invalid/unsupported encoding option specified: " + en); } Preconditions.checkArgument(encoding != null, "Invalid/unsupported encoding option specified: " + en); } boolean r = StringUtils.popOption("-R", args); setRecursive(r); dump = StringUtils.popOption("-d", args); if (!dump && name == null) { throw new HadoopIllegalArgumentException( "Must specify '-n name' or '-d' option."); } if (args.isEmpty()) { throw new HadoopIllegalArgumentException("<path> is missing."); } if (args.size() > 1) { throw new HadoopIllegalArgumentException("Too many arguments."); } }
@Override protected void processOptions(LinkedList<String> args) { this.timestamp = StringUtils.popOptionWithArgument("-" + OPTION_USE_TIMESTAMP, args); CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE, OPTION_USE_TIMESTAMP, OPTION_CHANGE_ONLY_ACCESS_TIME, OPTION_CHANGE_ONLY_MODIFICATION_TIME); cf.parse(args); this.changeModTime = cf.getOpt(OPTION_CHANGE_ONLY_MODIFICATION_TIME); this.changeAccessTime = cf.getOpt(OPTION_CHANGE_ONLY_ACCESS_TIME); this.doNotCreate = cf.getOpt(OPTION_DO_NOT_CREATE_FILE); }
return 0; String hostPort = StringUtils.popOptionWithArgument("-host", args); if (hostPort == null) { System.err.println("You must specify a host with -host."); return 1; String servicePrincipal = StringUtils.popOptionWithArgument("-principal", args); if (servicePrincipal != null) {
@Override public int run(Configuration conf, List<String> args) throws IOException { final String path = StringUtils.popOptionWithArgument("-path", args); if (!args.isEmpty()) { System.err.println("Can't understand argument: " + args.get(0)); return 1; } Path p = new Path(path); HdfsAdmin admin = new HdfsAdmin(p.toUri(), conf); try { admin.provisionEncryptionZoneTrash(p); System.out.println("Created a trash directory for " + path); } catch (IOException ioe) { System.err.println(prettifyException(ioe)); return 2; } return 0; } }
@Override public int run(Configuration conf, List<String> args) throws IOException { final String path = StringUtils.popOptionWithArgument("-path", args); if (path == null) { System.err.println("You must specify a path with -path."); StringUtils.popOptionWithArgument("-keyName", args); if (keyName == null) { System.err.println("You must specify a key name with -keyName.");
@Override public int run(Configuration conf, List<String> args) throws IOException { final String path = StringUtils.popOptionWithArgument("-path", args); if (path == null) { System.err.println("Please specify the path from which " + "the storage policy will be unset.\nUsage: " + getLongUsage()); return 1; } Path p = new Path(path); final FileSystem fs = FileSystem.get(p.toUri(), conf); try { fs.unsetStoragePolicy(p); System.out.println("Unset storage policy from " + path); } catch (Exception e) { System.err.println(AdminHelper.prettifyException(e)); return 2; } return 0; } }
@Override public int run(Configuration conf, List<String> args) throws IOException { final String path = StringUtils.popOptionWithArgument("-path", args); if (!args.isEmpty()) { System.err.println("Can't understand argument: " + args.get(0)); return 1; } Path p = new Path(path); final HdfsAdmin admin = new HdfsAdmin(p.toUri(), conf); try { final FileEncryptionInfo fei = admin.getFileEncryptionInfo(p); if (fei == null) { System.err.println("No FileEncryptionInfo found for path " + path); return 2; } System.out.println(fei.toStringStable()); } catch (IOException e) { System.err.println(prettifyException(e)); return 3; } return 0; } }
@Override public int run(Configuration conf, List<String> args) throws IOException { final String path = StringUtils.popOptionWithArgument("-path", args); if (path == null) { System.err.println("Please specify the path for setting the storage " + "policy.\nUsage: " + getLongUsage()); return 1; } final String policyName = StringUtils.popOptionWithArgument("-policy", args); if (policyName == null) { System.err.println("Please specify the policy name.\nUsage: " + getLongUsage()); return 1; } Path p = new Path(path); final FileSystem fs = FileSystem.get(p.toUri(), conf); try { fs.setStoragePolicy(p, policyName); System.out.println("Set storage policy " + policyName + " on " + path); } catch (Exception e) { System.err.println(AdminHelper.prettifyException(e)); return 2; } return 0; } }
@Override public int run(Configuration conf, List<String> args) throws IOException { final String path = StringUtils.popOptionWithArgument("-path", args); if (path == null) { System.err.println("Please specify the path for setting the storage " + "policy.\nUsage: " + getLongUsage()); return 1; } final DistributedFileSystem dfs = AdminHelper.getDFS(conf); try { dfs.satisfyStoragePolicy(new Path(path)); System.out.println("Scheduled blocks to move based on the current" + " storage policy on " + path); } catch (Exception e) { System.err.println(AdminHelper.prettifyException(e)); return 2; } return 0; } }
/** Constructor */ SetSpaceQuotaCommand(String[] args, int pos, Configuration conf) { super(conf); CommandFormat c = new CommandFormat(2, Integer.MAX_VALUE); List<String> parameters = c.parse(args, pos); String str = parameters.remove(0).trim(); try { quota = StringUtils.TraditionalBinaryPrefix.string2long(str); } catch (NumberFormatException nfe) { throw new IllegalArgumentException("\"" + str + "\" is not a valid value for a quota."); } String storageTypeString = StringUtils.popOptionWithArgument("-storageType", parameters); if (storageTypeString != null) { try { this.type = StorageType.parseStorageType(storageTypeString); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Storage type " + storageTypeString + " is not available. Available storage types are " + StorageType.getTypesSupportingQuota()); } } this.args = parameters.toArray(new String[parameters.size()]); }
@Override public int run(Configuration conf, List<String> args) throws IOException { final String ecPolicyName = StringUtils.popOptionWithArgument("-policy", args); if (ecPolicyName == null) { System.err.println("Please specify the policy name.\nUsage: " + getLongUsage()); return 1; } if (args.size() > 0) { System.err.println(getName() + ": Too many arguments"); return 1; } final DistributedFileSystem dfs = AdminHelper.getDFS(conf); try { dfs.disableErasureCodingPolicy(ecPolicyName); System.out.println("Erasure coding policy " + ecPolicyName + " is disabled"); } catch (IOException e) { System.err.println(AdminHelper.prettifyException(e)); return 2; } return 0; } }
@Override public int run(Configuration conf, List<String> args) throws IOException { final String ecPolicyName = StringUtils.popOptionWithArgument( "-policy", args); if (ecPolicyName == null) { System.err.println("Please specify the policy name.\nUsage: " + getLongUsage()); return 1; } if (args.size() > 0) { System.err.println(getName() + ": Too many arguments"); return 1; } final DistributedFileSystem dfs = AdminHelper.getDFS(conf); try { dfs.removeErasureCodingPolicy(ecPolicyName); System.out.println("Erasure coding policy " + ecPolicyName + "is removed"); } catch (IOException e) { System.err.println(AdminHelper.prettifyException(e)); return 2; } return 0; } }
@Override public int run(Configuration conf, List<String> args) throws IOException { final String path = StringUtils.popOptionWithArgument("-path", args); if (path == null) { System.err.println("Please specify the path with -path.\nUsage: " + getLongUsage()); return 1; } if (args.size() > 0) { System.err.println(getName() + ": Too many arguments"); return 1; } final Path p = new Path(path); final DistributedFileSystem dfs = AdminHelper.getDFS(p.toUri(), conf); try { ErasureCodingPolicy ecPolicy = dfs.getErasureCodingPolicy(p); if (ecPolicy != null) { System.out.println(ecPolicy.getName()); } else { System.out.println("The erasure coding policy of " + path + " is " + "unspecified"); } } catch (Exception e) { System.err.println(AdminHelper.prettifyException(e)); return 2; } return 0; } }
@Override public int run(Configuration conf, List<String> args) throws IOException { final String ecPolicyName = StringUtils.popOptionWithArgument("-policy", args); if (ecPolicyName == null) { System.err.println("Please specify the policy name.\nUsage: " + getLongUsage()); return 1; } if (args.size() > 0) { System.err.println(getName() + ": Too many arguments"); return 1; } final DistributedFileSystem dfs = AdminHelper.getDFS(conf); try { dfs.enableErasureCodingPolicy(ecPolicyName); System.out.println("Erasure coding policy " + ecPolicyName + " is enabled"); } catch (IOException e) { System.err.println(AdminHelper.prettifyException(e)); return 2; } return 0; } }
@Override public int run(Configuration conf, List<String> args) throws IOException { final String path = StringUtils.popOptionWithArgument("-path", args); final boolean start = StringUtils.popOption("-start", args); final boolean cancel = StringUtils.popOption("-cancel", args);
@Override public int run(Configuration conf, List<String> args) throws IOException { final String filePath = StringUtils.popOptionWithArgument("-policyFile", args); if (filePath == null) { System.err.println("Please specify the path with -policyFile.\nUsage: "
@Override public int run(Configuration conf, List<String> args) throws IOException { final String path = StringUtils.popOptionWithArgument("-path", args); if (path == null) { System.err.println("Please specify a path.\nUsage: " + getLongUsage());