@Override public int run(String[] args) throws IOException { if (args.length == 0) { AdminHelper.printUsage(false, "cacheadmin", COMMANDS); ToolRunner.printGenericCommandUsage(System.err); return 1; } AdminHelper.Command command = AdminHelper.determineCommand(args[0], COMMANDS); if (command == null) { System.err.println("Can't understand command '" + args[0] + "'"); if (!args[0].startsWith("-")) { System.err.println("Command names must start with dashes."); } AdminHelper.printUsage(false, "cacheadmin", COMMANDS); ToolRunner.printGenericCommandUsage(System.err); return 1; } List<String> argsList = new LinkedList<String>(); for (int j = 1; j < args.length; j++) { argsList.add(args[j]); } try { return command.run(getConf(), argsList); } catch (IllegalArgumentException e) { System.err.println(AdminHelper.prettifyException(e)); return -1; } }
@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; } }
@Override public String getLongUsage() { final TableListing listing = AdminHelper.getOptionDescriptionListing(); listing.addRow("<path>", "The path to the root of the encryption zone. "); return getShortUsage() + "\n" + "Provision a trash directory for an encryption zone.\n\n" + listing.toString(); }
@Override public int run(String[] args) throws IOException { if (args.length == 0) { AdminHelper.printUsage(false, "crypto", COMMANDS); ToolRunner.printGenericCommandUsage(System.err); return 1; } final AdminHelper.Command command = AdminHelper.determineCommand(args[0], COMMANDS); if (command == null) { System.err.println("Can't understand command '" + args[0] + "'"); if (!args[0].startsWith("-")) { System.err.println("Command names must start with dashes."); } AdminHelper.printUsage(false, "crypto", COMMANDS); ToolRunner.printGenericCommandUsage(System.err); return 1; } final List<String> argsList = new LinkedList<String>(); for (int j = 1; j < args.length; j++) { argsList.add(args[j]); } try { return command.run(getConf(), argsList); } catch (IllegalArgumentException e) { System.err.println(prettifyException(e)); return -1; } }
null : Integer.parseInt(modeString, 8); String limitString = StringUtils.popOptionWithArgument("-limit", args); Long limit = AdminHelper.parseLimitString(limitString); String replicationString = StringUtils.popOptionWithArgument("-defaultReplication", args); Long maxTtl; try { maxTtl = AdminHelper.parseTtlString(maxTtlString); } catch (IOException e) { System.err.println( return 1; DistributedFileSystem dfs = AdminHelper.getDFS(conf); try { dfs.modifyCachePool(info); } catch (IOException e) { System.err.println(AdminHelper.prettifyException(e)); return 2;
/** * Disallow snapshot on a directory. * Usage: hdfs dfsadmin -disallowSnapshot snapshotDir * @param argv List of of command line parameters. * @exception IOException */ public void disallowSnapshot(String[] argv) throws IOException { Path p = new Path(argv[1]); final DistributedFileSystem dfs = AdminHelper.getDFS(p.toUri(), getConf()); try { dfs.disallowSnapshot(p); } catch (SnapshotException e) { throw new RemoteException(e.getClass().getName(), e.getMessage()); } System.out.println("Disallowing snapshot on " + argv[1] + " succeeded"); }
@Override public int run(Configuration conf, List<String> args) throws IOException { final FileSystem fs = FileSystem.get(conf); try { Collection<? extends BlockStoragePolicySpi> policies = fs.getAllStoragePolicies(); System.out.println("Block Storage Policies:"); for (BlockStoragePolicySpi policy : policies) { if (policy != null) { System.out.println("\t" + policy); } } } catch (IOException e) { System.err.println(AdminHelper.prettifyException(e)); return 2; } return 0; } }
.determineCommand("-" + commandName, commands); if (command == null) { System.err.print("Unknown command '" + commandName + "'.\n");
Long limit = AdminHelper.parseLimitString(limitString); if (limit != null) { info.setLimit(limit); Long maxTtl = AdminHelper.parseTtlString(maxTtlString); if (maxTtl != null) { info.setMaxRelativeExpiryMs(maxTtl); return 1; DistributedFileSystem dfs = AdminHelper.getDFS(conf); try { dfs.addCachePool(info); } catch (IOException e) { System.err.println(AdminHelper.prettifyException(e)); return 2;
@Override public int run(String[] args) throws IOException { if (args.length == 0) { AdminHelper.printUsage(false, "crypto", COMMANDS); return 1; } final AdminHelper.Command command = AdminHelper.determineCommand(args[0], COMMANDS); if (command == null) { System.err.println("Can't understand command '" + args[0] + "'"); if (!args[0].startsWith("-")) { System.err.println("Command names must start with dashes."); } AdminHelper.printUsage(false, "crypto", COMMANDS); return 1; } final List<String> argsList = new LinkedList<String>(); for (int j = 1; j < args.length; j++) { argsList.add(args[j]); } try { return command.run(getConf(), argsList); } catch (IllegalArgumentException e) { System.err.println(prettifyException(e)); return -1; } }
/** * Allow snapshot on a directory. * Usage: hdfs dfsadmin -allowSnapshot snapshotDir * @param argv List of of command line parameters. * @exception IOException */ public void allowSnapshot(String[] argv) throws IOException { Path p = new Path(argv[1]); final DistributedFileSystem dfs = AdminHelper.getDFS(p.toUri(), getConf()); try { dfs.allowSnapshot(p); } catch (SnapshotException e) { throw new RemoteException(e.getClass().getName(), e.getMessage()); } System.out.println("Allowing snapshot on " + argv[1] + " succeeded"); }
@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; } }
.determineCommand("-" + commandName, commands); if (command == null) { System.err.print("Unknown command '" + commandName + "'.\n");
@Override public int run(Configuration conf, List<String> args) throws IOException { if (args.size() > 0) { System.err.println(getName() + ": Too many arguments"); return 1; } final DistributedFileSystem dfs = AdminHelper.getDFS(conf); try { final Collection<ErasureCodingPolicyInfo> policies = dfs.getAllErasureCodingPolicies(); if (policies.isEmpty()) { System.out.println("There is no erasure coding policies in the " + "cluster."); } else { System.out.println("Erasure Coding Policies:"); for (ErasureCodingPolicyInfo policy : policies) { if (policy != null) { System.out.println(policy); } } } } catch (IOException e) { System.err.println(AdminHelper.prettifyException(e)); return 2; } return 0; } }
null : Integer.parseInt(modeString, 8); String limitString = StringUtils.popOptionWithArgument("-limit", args); Long limit = AdminHelper.parseLimitString(limitString); String maxTtlString = StringUtils.popOptionWithArgument("-maxTtl", args); Long maxTtl; try { maxTtl = AdminHelper.parseTtlString(maxTtlString); } catch (IOException e) { System.err.println( return 1; DistributedFileSystem dfs = AdminHelper.getDFS(conf); try { dfs.modifyCachePool(info); } catch (IOException e) { System.err.println(AdminHelper.prettifyException(e)); return 2;
@Override public int run(String[] args) throws Exception { if (args.length == 0) { AdminHelper.printUsage(false, "storagepolicies", COMMANDS); ToolRunner.printGenericCommandUsage(System.err); return 1; } final AdminHelper.Command command = AdminHelper.determineCommand(args[0], COMMANDS); if (command == null) { System.err.println("Can't understand command '" + args[0] + "'"); if (!args[0].startsWith("-")) { System.err.println("Command names must start with dashes."); } AdminHelper.printUsage(false, "storagepolicies", COMMANDS); ToolRunner.printGenericCommandUsage(System.err); return 1; } final List<String> argsList = new LinkedList<>(); argsList.addAll(Arrays.asList(args).subList(1, args.length)); try { return command.run(getConf(), argsList); } catch (IllegalArgumentException e) { System.err.println(AdminHelper.prettifyException(e)); return -1; } }
@Override public String getLongUsage() { final TableListing listing = AdminHelper.getOptionDescriptionListing(); listing.addRow("<file>", "The path of the xml file which defines the EC policies to add"); return getShortUsage() + "\n" + "Add a list of user defined erasure coding policies.\n" + listing.toString(); }
@Override public int run(String[] args) throws IOException { if (args.length == 0) { AdminHelper.printUsage(false, "crypto", COMMANDS); return 1; } final AdminHelper.Command command = AdminHelper.determineCommand(args[0], COMMANDS); if (command == null) { System.err.println("Can't understand command '" + args[0] + "'"); if (!args[0].startsWith("-")) { System.err.println("Command names must start with dashes."); } AdminHelper.printUsage(false, "crypto", COMMANDS); return 1; } final List<String> argsList = new LinkedList<String>(); for (int j = 1; j < args.length; j++) { argsList.add(args[j]); } try { return command.run(getConf(), argsList); } catch (IllegalArgumentException e) { System.err.println(prettifyException(e)); return -1; } }
@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."); return 1; } final String keyName = StringUtils.popOptionWithArgument("-keyName", args); if (keyName == null) { System.err.println("You must specify a key name with -keyName."); return 1; } if (!args.isEmpty()) { System.err.println("Can't understand argument: " + args.get(0)); return 1; } final DistributedFileSystem dfs = AdminHelper.getDFS(conf); try { dfs.createEncryptionZone(new Path(path), keyName); System.out.println("Added encryption zone " + path); } catch (IOException e) { System.err.println(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 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; } }