* @param pos ignore anything before this pos in cmd
* @throws IOException
*/
private void setReplication(String[] cmd, int pos) throws IOException {
final int minArgs = 2; // We need the replication and at least one path.
CommandFormat c =
new CommandFormat("setrep", minArgs, SETREP_MAX_PATHS, "R", "w");
short rep = 0;
List<String> dsts = null;
try {
List<String> parameters = c.parse(cmd, pos);
rep = Short.parseShort(parameters.get(0));
dsts = parameters.subList(1, parameters.size());
} catch (NumberFormatException nfe) {
System.err.println("Illegal replication, a positive integer expected");
throw nfe;
}
catch(IllegalArgumentException iae) {
System.err.println("Usage: java FsShell " + SETREP_SHORT_USAGE);
throw iae;
}
if (rep < 1) {
System.err.println("Cannot set replication to: " + rep);
throw new IllegalArgumentException("replication must be >= 1");
}
List<Path> waitList = c.getOpt("w")? new ArrayList<Path>(): null;
for (String dst: dsts) {
setReplication(rep, dst, c.getOpt("R"), waitList);
}
if (waitList != null) {
waitForReplication(waitList, rep);
}