/** Constructor */
 SetQuotaCommand(String[] args, int pos, FileSystem fs) {
   super(fs);
   CommandFormat c = new CommandFormat(NAME, 2, Integer.MAX_VALUE);
   List<String> parameters = c.parse(args, pos);
   this.quota = Long.parseLong(parameters.remove(0));
   this.args = parameters.toArray(new String[parameters.size()]);
 }
 /** Constructor */
 SetSpaceQuotaCommand(String[] args, int pos, FileSystem fs) {
   super(fs);
   CommandFormat c = new CommandFormat(NAME, 2, Integer.MAX_VALUE);
   List<String> parameters = c.parse(args, pos);
   String str = parameters.remove(0).trim();
   quota = StringUtils.TraditionalBinaryPrefix.string2long(str);
   this.args = parameters.toArray(new String[parameters.size()]);
 }
 public static void testCommandFormat() throws Exception {
   // This should go to TestFsShell.java when it is added.
   CommandFormat cf;
   cf = new CommandFormat("copyToLocal", 2, 2, "crc", "ignoreCrc");
   assertEquals(cf.parse(new String[] {"-get", "file", "-"}, 1).get(1), "-");
   try {
     cf.parse(new String[] {"-get", "file", "-ignoreCrc", "/foo"}, 1);
     fail("Expected parsing to fail as it should stop at first non-option");
   } catch (Exception e) {
     // Expected
   }
   cf = new CommandFormat("tail", 1, 1, "f");
   assertEquals(cf.parse(new String[] {"-tail", "fileName"}, 1).get(0), "fileName");
   assertEquals(cf.parse(new String[] {"-tail", "-f", "fileName"}, 1).get(0), "fileName");
   cf = new CommandFormat("setrep", 2, 2, "R", "w");
   assertEquals(cf.parse(new String[] {"-setrep", "-R", "2", "/foo/bar"}, 1).get(1), "/foo/bar");
   cf = new CommandFormat("put", 2, 10000);
   assertEquals(cf.parse(new String[] {"-put", "-", "dest"}, 1).get(1), "dest");
 }
 /** Constructor */
 ClearQuotaCommand(String[] args, int pos, FileSystem fs) {
   super(fs);
   CommandFormat c = new CommandFormat(NAME, 1, Integer.MAX_VALUE);
   List<String> parameters = c.parse(args, pos);
   this.args = parameters.toArray(new String[parameters.size()]);
 }
Example #5
0
 /**
  * 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;
 }