@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 String getShortUsage() { return "[" + getName() + " -policy <policy>]\n"; }
@Override public String getLongUsage() { TableListing listing = AdminHelper.getOptionDescriptionListing(); listing.addRow("<policy>", "The name of the erasure coding policy"); return getShortUsage() + "\n" + "Enable the erasure coding policy.\n\n" + listing.toString(); }