From be3fdd1c40140e24df1a5414cf91537862b66e82 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Fri, 13 Jun 2014 06:39:57 +0000 Subject: [PATCH] HADOOP-10691. Improve the readability of 'hadoop fs -help'. Contributed by Lei Xu. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1602329 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-common/CHANGES.txt | 3 + .../java/org/apache/hadoop/fs/FsShell.java | 60 ++- .../apache/hadoop/fs/FsShellPermissions.java | 48 +-- .../apache/hadoop/fs/shell/AclCommands.java | 20 +- .../apache/hadoop/fs/shell/CopyCommands.java | 42 +-- .../org/apache/hadoop/fs/shell/Delete.java | 12 +- .../org/apache/hadoop/fs/shell/Display.java | 12 +- .../org/apache/hadoop/fs/shell/FsUsage.java | 24 +- .../java/org/apache/hadoop/fs/shell/Ls.java | 20 +- .../org/apache/hadoop/fs/shell/Mkdir.java | 2 +- .../apache/hadoop/fs/shell/MoveCommands.java | 6 +- .../hadoop/fs/shell/SetReplication.java | 8 +- .../java/org/apache/hadoop/fs/shell/Stat.java | 4 +- .../java/org/apache/hadoop/fs/shell/Tail.java | 2 +- .../java/org/apache/hadoop/fs/shell/Test.java | 3 +- .../org/apache/hadoop/fs/shell/Touchz.java | 4 +- .../apache/hadoop/fs/shell/XAttrCommands.java | 18 +- .../apache/hadoop}/tools/TableListing.java | 12 +- .../src/test/resources/testConf.xml | 352 +++++++++++------- .../apache/hadoop/hdfs/tools/CacheAdmin.java | 3 +- 20 files changed, 387 insertions(+), 268 deletions(-) rename {hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs => hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop}/tools/TableListing.java (99%) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 6a585458d8b..a19b63ea4f3 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -422,6 +422,9 @@ Release 2.5.0 - UNRELEASED HADOOP-6350. Documenting Hadoop metrics. (Akira Ajisaka via Arpit Agarwal) + HADOOP-10691. Improve the readability of 'hadoop fs -help'. + (Lei Xu via wang) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java index 4b72de30df7..db73f6d1703 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShell.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; +import org.apache.commons.lang.WordUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; @@ -31,6 +32,7 @@ import org.apache.hadoop.conf.Configured; import org.apache.hadoop.fs.shell.Command; import org.apache.hadoop.fs.shell.CommandFactory; import org.apache.hadoop.fs.shell.FsCommand; +import org.apache.hadoop.tools.TableListing; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; @@ -40,6 +42,8 @@ public class FsShell extends Configured implements Tool { static final Log LOG = LogFactory.getLog(FsShell.class); + private static final int MAX_LINE_WIDTH = 80; + private FileSystem fs; private Trash trash; protected CommandFactory commandFactory; @@ -117,7 +121,7 @@ public class FsShell extends Configured implements Tool { public static final String NAME = "usage"; public static final String USAGE = "[cmd ...]"; public static final String DESCRIPTION = - "Displays the usage for given command or all commands if none\n" + + "Displays the usage for given command or all commands if none " + "is specified."; @Override @@ -137,7 +141,7 @@ public class FsShell extends Configured implements Tool { public static final String NAME = "help"; public static final String USAGE = "[cmd ...]"; public static final String DESCRIPTION = - "Displays help for given command or all commands if none\n" + + "Displays help for given command or all commands if none " + "is specified."; @Override @@ -197,7 +201,7 @@ public class FsShell extends Configured implements Tool { for (String name : commandFactory.getNames()) { Command instance = commandFactory.getInstance(name); if (!instance.isDeprecated()) { - System.out.println("\t[" + instance.getUsage() + "]"); + out.println("\t[" + instance.getUsage() + "]"); instances.add(instance); } } @@ -217,20 +221,48 @@ public class FsShell extends Configured implements Tool { out.println(usagePrefix + " " + instance.getUsage()); } - // TODO: will eventually auto-wrap the text, but this matches the expected - // output for the hdfs tests... private void printInstanceHelp(PrintStream out, Command instance) { - boolean firstLine = true; + out.println(instance.getUsage() + " :"); + TableListing listing = null; + final String prefix = " "; for (String line : instance.getDescription().split("\n")) { - String prefix; - if (firstLine) { - prefix = instance.getUsage() + ":\t"; - firstLine = false; - } else { - prefix = "\t\t"; + if (line.matches("^[ \t]*[-<].*$")) { + String[] segments = line.split(":"); + if (segments.length == 2) { + if (listing == null) { + listing = createOptionTableListing(); + } + listing.addRow(segments[0].trim(), segments[1].trim()); + continue; + } } - System.out.println(prefix + line); - } + + // Normal literal description. + if (listing != null) { + for (String listingLine : listing.toString().split("\n")) { + out.println(prefix + listingLine); + } + listing = null; + } + + for (String descLine : WordUtils.wrap( + line, MAX_LINE_WIDTH, "\n", true).split("\n")) { + out.println(prefix + descLine); + } + } + + if (listing != null) { + for (String listingLine : listing.toString().split("\n")) { + out.println(prefix + listingLine); + } + } + } + + // Creates a two-row table, the first row is for the command line option, + // the second row is for the option description. + private TableListing createOptionTableListing() { + return new TableListing.Builder().addField("").addField("", true) + .wrapWidth(MAX_LINE_WIDTH).build(); } /** diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShellPermissions.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShellPermissions.java index 5ac10ceda7b..0a829298ca4 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShellPermissions.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FsShellPermissions.java @@ -63,18 +63,18 @@ public class FsShellPermissions extends FsCommand { public static final String NAME = "chmod"; public static final String USAGE = "[-R] PATH..."; public static final String DESCRIPTION = - "Changes permissions of a file.\n" + - "\tThis works similar to shell's chmod with a few exceptions.\n\n" + - "-R\tmodifies the files recursively. This is the only option\n" + - "\tcurrently supported.\n\n" + - "MODE\tMode is same as mode used for chmod shell command.\n" + - "\tOnly letters recognized are 'rwxXt'. E.g. +t,a+r,g-w,+rwx,o=r\n\n" + - "OCTALMODE Mode specifed in 3 or 4 digits. If 4 digits, the first may\n" + - "be 1 or 0 to turn the sticky bit on or off, respectively. Unlike " + - "shell command, it is not possible to specify only part of the mode\n" + - "\tE.g. 754 is same as u=rwx,g=rx,o=r\n\n" + - "\tIf none of 'augo' is specified, 'a' is assumed and unlike\n" + - "\tshell command, no umask is applied."; + "Changes permissions of a file. " + + "This works similar to the shell's chmod command with a few exceptions.\n" + + "-R: modifies the files recursively. This is the only option" + + " currently supported.\n" + + ": Mode is the same as mode used for the shell's command. " + + "The only letters recognized are 'rwxXt', e.g. +t,a+r,g-w,+rwx,o=r.\n" + + ": Mode specifed in 3 or 4 digits. If 4 digits, the first " + + "may be 1 or 0 to turn the sticky bit on or off, respectively. Unlike " + + "the shell command, it is not possible to specify only part of the " + + "mode, e.g. 754 is same as u=rwx,g=rx,o=r.\n\n" + + "If none of 'augo' is specified, 'a' is assumed and unlike the " + + "shell command, no umask is applied."; protected ChmodParser pp; @@ -121,18 +121,18 @@ public class FsShellPermissions extends FsCommand { public static final String NAME = "chown"; public static final String USAGE = "[-R] [OWNER][:[GROUP]] PATH..."; public static final String DESCRIPTION = - "Changes owner and group of a file.\n" + - "\tThis is similar to shell's chown with a few exceptions.\n\n" + - "\t-R\tmodifies the files recursively. This is the only option\n" + - "\tcurrently supported.\n\n" + - "\tIf only owner or group is specified then only owner or\n" + - "\tgroup is modified.\n\n" + - "\tThe owner and group names may only consist of digits, alphabet,\n"+ - "\tand any of " + allowedChars + ". The names are case sensitive.\n\n" + - "\tWARNING: Avoid using '.' to separate user name and group though\n" + - "\tLinux allows it. If user names have dots in them and you are\n" + - "\tusing local file system, you might see surprising results since\n" + - "\tshell command 'chown' is used for local files."; + "Changes owner and group of a file. " + + "This is similar to the shell's chown command with a few exceptions.\n" + + "-R: modifies the files recursively. This is the only option " + + "currently supported.\n\n" + + "If only the owner or group is specified, then only the owner or " + + "group is modified. " + + "The owner and group names may only consist of digits, alphabet, "+ + "and any of " + allowedChars + ". The names are case sensitive.\n\n" + + "WARNING: Avoid using '.' to separate user name and group though " + + "Linux allows it. If user names have dots in them and you are " + + "using local file system, you might see surprising results since " + + "the shell command 'chown' is used for local files."; ///allows only "allowedChars" above in names for owner and group static private final Pattern chownPattern = Pattern.compile( diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java index 5aa285c2965..206576cfa54 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/AclCommands.java @@ -59,8 +59,8 @@ class AclCommands extends FsCommand { public static String DESCRIPTION = "Displays the Access Control Lists" + " (ACLs) of files and directories. If a directory has a default ACL," + " then getfacl also displays the default ACL.\n" - + "-R: List the ACLs of all files and directories recursively.\n" - + ": File or directory to list.\n"; + + " -R: List the ACLs of all files and directories recursively.\n" + + " : File or directory to list.\n"; @Override protected void processOptions(LinkedList args) throws IOException { @@ -153,19 +153,19 @@ class AclCommands extends FsCommand { public static String DESCRIPTION = "Sets Access Control Lists (ACLs)" + " of files and directories.\n" + "Options:\n" - + "-b :Remove all but the base ACL entries. The entries for user," + + " -b :Remove all but the base ACL entries. The entries for user," + " group and others are retained for compatibility with permission " + "bits.\n" - + "-k :Remove the default ACL.\n" - + "-R :Apply operations to all files and directories recursively.\n" - + "-m :Modify ACL. New entries are added to the ACL, and existing" + + " -k :Remove the default ACL.\n" + + " -R :Apply operations to all files and directories recursively.\n" + + " -m :Modify ACL. New entries are added to the ACL, and existing" + " entries are retained.\n" - + "-x :Remove specified ACL entries. Other ACL entries are retained.\n" - + "--set :Fully replace the ACL, discarding all existing entries." + + " -x :Remove specified ACL entries. Other ACL entries are retained.\n" + + " --set :Fully replace the ACL, discarding all existing entries." + " The must include entries for user, group, and others" + " for compatibility with permission bits.\n" - + ": Comma separated list of ACL entries.\n" - + ": File or directory to modify.\n"; + + " : Comma separated list of ACL entries.\n" + + " : File or directory to modify.\n"; CommandFormat cf = new CommandFormat(0, Integer.MAX_VALUE, "b", "k", "R", "m", "x", "-set"); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java index c4589cfd484..44ff1014ac6 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java @@ -55,10 +55,10 @@ class CopyCommands { public static final String NAME = "getmerge"; public static final String USAGE = "[-nl] "; public static final String DESCRIPTION = - "Get all the files in the directories that\n" + - "match the source file pattern and merge and sort them to only\n" + + "Get all the files in the directories that " + + "match the source file pattern and merge and sort them to only " + "one file on local fs. is kept.\n" + - " -nl Add a newline character at the end of each file."; + "-nl: Add a newline character at the end of each file."; protected PathData dst = null; protected String delimiter = null; @@ -135,12 +135,12 @@ class CopyCommands { public static final String NAME = "cp"; public static final String USAGE = "[-f] [-p | -p[topx]] ... "; public static final String DESCRIPTION = - "Copy files that match the file pattern to a\n" + - "destination. When copying multiple files, the destination\n" + - "must be a directory. Passing -p preserves status\n" + - "[topx] (timestamps, ownership, permission, XAttr).\n" + - "If -p is specified with no , then preserves\n" + - "timestamps, ownership, permission. Passing -f\n" + + "Copy files that match the file pattern to a " + + "destination. When copying multiple files, the destination " + + "must be a directory. Passing -p preserves status " + + "[topx] (timestamps, ownership, permission, XAttr). " + + "If -p is specified with no , then preserves " + + "timestamps, ownership, permission. Passing -f " + "overwrites the destination if it already exists.\n"; @Override @@ -184,10 +184,10 @@ class CopyCommands { public static final String USAGE = "[-p] [-ignoreCrc] [-crc] ... "; public static final String DESCRIPTION = - "Copy files that match the file pattern \n" + - "to the local name. is kept. When copying multiple,\n" + - "files, the destination must be a directory. Passing\n" + - "-p preserves access and modification times,\n" + + "Copy files that match the file pattern " + + "to the local name. is kept. When copying multiple " + + "files, the destination must be a directory. Passing " + + "-p preserves access and modification times, " + "ownership and the mode.\n"; @Override @@ -211,11 +211,11 @@ class CopyCommands { public static final String NAME = "put"; public static final String USAGE = "[-f] [-p] ... "; public static final String DESCRIPTION = - "Copy files from the local file system\n" + - "into fs. Copying fails if the file already\n" + - "exists, unless the -f flag is given. Passing\n" + - "-p preserves access and modification times,\n" + - "ownership and the mode. Passing -f overwrites\n" + + "Copy files from the local file system " + + "into fs. Copying fails if the file already " + + "exists, unless the -f flag is given. Passing " + + "-p preserves access and modification times, " + + "ownership and the mode. Passing -f overwrites " + "the destination if it already exists.\n"; @Override @@ -278,9 +278,9 @@ class CopyCommands { public static final String NAME = "appendToFile"; public static final String USAGE = " ... "; public static final String DESCRIPTION = - "Appends the contents of all the given local files to the\n" + - "given dst file. The dst file will be created if it does\n" + - "not exist. If is -, then the input is read\n" + + "Appends the contents of all the given local files to the " + + "given dst file. The dst file will be created if it does " + + "not exist. If is -, then the input is read " + "from stdin."; private static final int DEFAULT_IO_LENGTH = 1024 * 1024; diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Delete.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Delete.java index ed190d37461..fcb0690d8d4 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Delete.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Delete.java @@ -51,13 +51,13 @@ class Delete { public static final String NAME = "rm"; public static final String USAGE = "[-f] [-r|-R] [-skipTrash] ..."; public static final String DESCRIPTION = - "Delete all files that match the specified file pattern.\n" + + "Delete all files that match the specified file pattern. " + "Equivalent to the Unix command \"rm \"\n" + - "-skipTrash option bypasses trash, if enabled, and immediately\n" + + "-skipTrash: option bypasses trash, if enabled, and immediately " + "deletes \n" + - " -f If the file does not exist, do not display a diagnostic\n" + - " message or modify the exit status to reflect an error.\n" + - " -[rR] Recursively deletes directories"; + "-f: If the file does not exist, do not display a diagnostic " + + "message or modify the exit status to reflect an error.\n" + + "-[rR]: Recursively deletes directories"; private boolean skipTrash = false; private boolean deleteDirs = false; @@ -147,7 +147,7 @@ class Delete { public static final String USAGE = "[--ignore-fail-on-non-empty] ..."; public static final String DESCRIPTION = - "Removes the directory entry specified by each directory argument,\n" + + "Removes the directory entry specified by each directory argument, " + "provided it is empty.\n"; private boolean ignoreNonEmpty = false; diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java index 79bb824c436..a72af7a01f9 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Display.java @@ -75,7 +75,7 @@ class Display extends FsCommand { public static final String NAME = "cat"; public static final String USAGE = "[-ignoreCrc] ..."; public static final String DESCRIPTION = - "Fetch all files that match the file pattern \n" + + "Fetch all files that match the file pattern " + "and display their content on stdout.\n"; private boolean verifyChecksum = true; @@ -170,11 +170,11 @@ class Display extends FsCommand { public static final String NAME = "checksum"; public static final String USAGE = " ..."; public static final String DESCRIPTION = - "Dump checksum information for files that match the file\n" + - "pattern to stdout. Note that this requires a round-trip\n" + - "to a datanode storing each block of the file, and thus is not\n" + - "efficient to run on a large number of files. The checksum of a\n" + - "file depends on its content, block size and the checksum\n" + + "Dump checksum information for files that match the file " + + "pattern to stdout. Note that this requires a round-trip " + + "to a datanode storing each block of the file, and thus is not " + + "efficient to run on a large number of files. The checksum of a " + + "file depends on its content, block size and the checksum " + "algorithm and parameters used for creating the file."; @Override diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/FsUsage.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/FsUsage.java index a99494573fd..f48ba160ba1 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/FsUsage.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/FsUsage.java @@ -57,12 +57,12 @@ class FsUsage extends FsCommand { public static final String NAME = "df"; public static final String USAGE = "[-h] [ ...]"; public static final String DESCRIPTION = - "Shows the capacity, free and used space of the filesystem.\n"+ - "If the filesystem has multiple partitions, and no path to a\n" + - "particular partition is specified, then the status of the root\n" + + "Shows the capacity, free and used space of the filesystem. "+ + "If the filesystem has multiple partitions, and no path to a " + + "particular partition is specified, then the status of the root " + "partitions will be shown.\n" + - " -h Formats the sizes of files in a human-readable fashion\n" + - " rather than a number of bytes.\n\n"; + "-h: Formats the sizes of files in a human-readable fashion " + + "rather than a number of bytes."; @Override protected void processOptions(LinkedList args) @@ -108,14 +108,14 @@ class FsUsage extends FsCommand { public static final String NAME = "du"; public static final String USAGE = "[-s] [-h] ..."; public static final String DESCRIPTION = - "Show the amount of space, in bytes, used by the files that\n" + + "Show the amount of space, in bytes, used by the files that " + "match the specified file pattern. The following flags are optional:\n" + - " -s Rather than showing the size of each individual file that\n" + - " matches the pattern, shows the total (summary) size.\n" + - " -h Formats the sizes of files in a human-readable fashion\n" + - " rather than a number of bytes.\n\n" + - "Note that, even without the -s option, this only shows size summaries\n" + - "one level deep into a directory.\n" + + "-s: Rather than showing the size of each individual file that" + + " matches the pattern, shows the total (summary) size.\n" + + "-h: Formats the sizes of files in a human-readable fashion" + + " rather than a number of bytes.\n\n" + + "Note that, even without the -s option, this only shows size summaries " + + "one level deep into a directory.\n\n" + "The output is in the form \n" + "\tsize\tname(full path)\n"; diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java index b2a1fbd806f..edc3b0a8948 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Ls.java @@ -49,16 +49,16 @@ class Ls extends FsCommand { public static final String NAME = "ls"; public static final String USAGE = "[-d] [-h] [-R] [ ...]"; public static final String DESCRIPTION = - "List the contents that match the specified file pattern. If\n" + - "path is not specified, the contents of /user/\n" + - "will be listed. Directory entries are of the form \n" + - "\tpermissions - userid groupid size_of_directory(in bytes) modification_date(yyyy-MM-dd HH:mm) directoryName \n" + - "and file entries are of the form \n" + - "\tpermissions number_of_replicas userid groupid size_of_file(in bytes) modification_date(yyyy-MM-dd HH:mm) fileName \n" + - " -d Directories are listed as plain files.\n" + - " -h Formats the sizes of files in a human-readable fashion\n" + - " rather than a number of bytes.\n" + - " -R Recursively list the contents of directories."; + "List the contents that match the specified file pattern. If " + + "path is not specified, the contents of /user/ " + + "will be listed. Directory entries are of the form:\n" + + "\tpermissions - userId groupId sizeOfDirectory(in bytes) modificationDate(yyyy-MM-dd HH:mm) directoryName\n\n" + + "and file entries are of the form:\n" + + "\tpermissions numberOfReplicas userId groupId sizeOfFile(in bytes) modificationDate(yyyy-MM-dd HH:mm) fileName\n" + + "-d: Directories are listed as plain files.\n" + + "-h: Formats the sizes of files in a human-readable fashion " + + "rather than a number of bytes.\n" + + "-R: Recursively list the contents of directories."; diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java index 050011582fd..74bad627596 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java @@ -44,7 +44,7 @@ class Mkdir extends FsCommand { public static final String USAGE = "[-p] ..."; public static final String DESCRIPTION = "Create a directory in specified location.\n" + - " -p Do not fail if the directory already exists"; + "-p: Do not fail if the directory already exists"; private boolean createParents; diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/MoveCommands.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/MoveCommands.java index ffb3483ef21..4e347efbdc8 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/MoveCommands.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/MoveCommands.java @@ -45,7 +45,7 @@ class MoveCommands { public static final String NAME = "moveFromLocal"; public static final String USAGE = " ... "; public static final String DESCRIPTION = - "Same as -put, except that the source is\n" + + "Same as -put, except that the source is " + "deleted after it's copied."; @Override @@ -87,8 +87,8 @@ class MoveCommands { public static final String NAME = "mv"; public static final String USAGE = " ... "; public static final String DESCRIPTION = - "Move files that match the specified file pattern \n" + - "to a destination . When moving multiple files, the\n" + + "Move files that match the specified file pattern " + + "to a destination . When moving multiple files, the " + "destination must be a directory."; @Override diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/SetReplication.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/SetReplication.java index 1f65fed913c..fab0349a360 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/SetReplication.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/SetReplication.java @@ -41,12 +41,12 @@ class SetReplication extends FsCommand { public static final String NAME = "setrep"; public static final String USAGE = "[-R] [-w] ..."; public static final String DESCRIPTION = - "Set the replication level of a file. If is a directory\n" + - "then the command recursively changes the replication factor of\n" + + "Set the replication level of a file. If is a directory " + + "then the command recursively changes the replication factor of " + "all files under the directory tree rooted at .\n" + - "The -w flag requests that the command wait for the replication\n" + + "-w: It requests that the command waits for the replication " + "to complete. This can potentially take a very long time.\n" + - "The -R flag is accepted for backwards compatibility. It has no effect."; + "-R: It is accepted for backwards compatibility. It has no effect."; protected short newRep = 0; protected List waitList = new LinkedList(); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Stat.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Stat.java index d6034390bba..652c92890d3 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Stat.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Stat.java @@ -51,8 +51,8 @@ class Stat extends FsCommand { public static final String NAME = "stat"; public static final String USAGE = "[format] ..."; public static final String DESCRIPTION = - "Print statistics about the file/directory at \n" + - "in the specified format. Format accepts filesize in blocks (%b), group name of owner(%g),\n" + + "Print statistics about the file/directory at " + + "in the specified format. Format accepts filesize in blocks (%b), group name of owner(%g), " + "filename (%n), block size (%o), replication (%r), user name of owner(%u), modification date (%y, %Y)\n"; protected static final SimpleDateFormat timeFmt; diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Tail.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Tail.java index e6139dbde9d..1d49bf14e6a 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Tail.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Tail.java @@ -43,7 +43,7 @@ class Tail extends FsCommand { public static final String USAGE = "[-f] "; public static final String DESCRIPTION = "Show the last 1KB of the file.\n" + - "\t\tThe -f option shows appended data as the file grows.\n"; + "-f: Shows appended data as the file grows.\n"; private long startingOffset = -1024; private boolean follow = false; diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Test.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Test.java index 31f16ea1540..4cfdb084d7e 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Test.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Test.java @@ -43,8 +43,7 @@ class Test extends FsCommand { " -e return 0 if exists.\n" + " -f return 0 if is a file.\n" + " -s return 0 if file is greater than zero bytes in size.\n" + - " -z return 0 if file is zero bytes in size.\n" + - "else, return 1."; + " -z return 0 if file is zero bytes in size, else return 1."; private char flag; diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Touchz.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Touchz.java index a37df995b20..7925a0f952a 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Touchz.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Touchz.java @@ -47,8 +47,8 @@ class Touch extends FsCommand { public static final String NAME = "touchz"; public static final String USAGE = " ..."; public static final String DESCRIPTION = - "Creates a file of zero length\n" + - "at with current time as the timestamp of that .\n" + + "Creates a file of zero length " + + "at with current time as the timestamp of that . " + "An error is returned if the file exists with non-zero length\n"; @Override diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/XAttrCommands.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/XAttrCommands.java index c6dafbcac65..44e970b88ff 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/XAttrCommands.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/XAttrCommands.java @@ -59,10 +59,10 @@ class XAttrCommands extends FsCommand { "-R: Recursively list the attributes for all files and directories.\n" + "-n name: Dump the named extended attribute value.\n" + "-d: Dump all extended attribute values associated with pathname.\n" + - "-e : Encode values after retrieving them.\n" + - "Valid encodings are \"text\", \"hex\", and \"base64\".\n" + - "Values encoded as text strings are enclosed in double quotes (\"),\n" + - " and values encoded as hexadecimal and base64 are prefixed with\n" + + "-e : Encode values after retrieving them." + + "Valid encodings are \"text\", \"hex\", and \"base64\". " + + "Values encoded as text strings are enclosed in double quotes (\")," + + " and values encoded as hexadecimal and base64 are prefixed with " + "0x and 0s, respectively.\n" + ": The file or directory.\n"; private final static Function enValueOfFunc = @@ -137,11 +137,11 @@ class XAttrCommands extends FsCommand { public static final String DESCRIPTION = "Sets an extended attribute name and value for a file or directory.\n" + "-n name: The extended attribute name.\n" + - "-v value: The extended attribute value. There are three different\n" + - "encoding methods for the value. If the argument is enclosed in double\n" + - "quotes, then the value is the string inside the quotes. If the\n" + - "argument is prefixed with 0x or 0X, then it is taken as a hexadecimal\n" + - "number. If the argument begins with 0s or 0S, then it is taken as a\n" + + "-v value: The extended attribute value. There are three different " + + "encoding methods for the value. If the argument is enclosed in double " + + "quotes, then the value is the string inside the quotes. If the " + + "argument is prefixed with 0x or 0X, then it is taken as a hexadecimal " + + "number. If the argument begins with 0s or 0S, then it is taken as a " + "base64 encoding.\n" + "-x name: Remove the extended attribute.\n" + ": The file or directory.\n"; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/TableListing.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tools/TableListing.java similarity index 99% rename from hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/TableListing.java rename to hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tools/TableListing.java index 46cc3c05971..bc2e2d49d7f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/TableListing.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/tools/TableListing.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hdfs.tools; +package org.apache.hadoop.tools; import java.util.ArrayList; import java.util.LinkedList; @@ -26,14 +26,14 @@ import org.apache.hadoop.classification.InterfaceAudience; /** * This class implements a "table listing" with column headers. - * + * * Example: - * + * * NAME OWNER GROUP MODE WEIGHT * pool1 andrew andrew rwxr-xr-x 100 * pool2 andrew andrew rwxr-xr-x 100 * pool3 andrew andrew rwxr-xr-x 100 - * + * */ @InterfaceAudience.Private public class TableListing { @@ -141,14 +141,14 @@ public class TableListing { /** * Add a new field to the Table under construction. - * + * * @param title Field title. * @param justification Right or left justification. Defaults to left. * @param wrap Width at which to auto-wrap the content of the cell. * Defaults to Integer.MAX_VALUE. * @return This Builder object */ - public Builder addField(String title, Justification justification, + public Builder addField(String title, Justification justification, boolean wrap) { columns.add(new Column(title, justification, wrap)); return this; diff --git a/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml b/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml index e87b86e15ea..fe6e30647c2 100644 --- a/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml +++ b/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml @@ -54,47 +54,55 @@ RegexpComparator - ^-ls \[-d\] \[-h\] \[-R\] \[<path> \.\.\.\]:( |\t)*List the contents that match the specified file pattern. If( )* + ^-ls \[-d\] \[-h\] \[-R\] \[<path> \.\.\.\] :( |\t)* RegexpComparator - ^( |\t)*path is not specified, the contents of /user/<currentUser>( )* + ^\s*List the contents that match the specified file pattern. If path is not RegexpComparator - ^( |\t)*path is not specified, the contents of /user/<currentUser>( )* + ^\s*specified, the contents of /user/<currentUser> will be listed. Directory entries( )* RegexpComparator - ^( |\t)*will be listed. Directory entries are of the form( )* + ^\s*are of the form:( )* RegexpComparator - ^( |\t)*permissions - userid groupid size_of_directory\(in bytes\) modification_date\(yyyy-MM-dd HH:mm\) directoryName( )* - - - RegexpComparator - ^( |\t)*and file entries are of the form( )* - - - RegexpComparator - ^( |\t)*permissions number_of_replicas userid groupid size_of_file\(in bytes\) modification_date\(yyyy-MM-dd HH:mm\) fileName( )* + ^\s*permissions - userId groupId sizeOfDirectory\(in bytes\)( )* RegexpComparator - ^( |\t)*-d\s+Directories are listed as plain files\. + ^\s*modificationDate\(yyyy-MM-dd HH:mm\) directoryName( )* RegexpComparator - ^( |\t)*-h\s+Formats the sizes of files in a human-readable fashion( )* + ^\s*and file entries are of the form:( )* RegexpComparator - ^( |\t)*rather than a number of bytes\.( )* + ^\s*permissions numberOfReplicas userId groupId sizeOfFile\(in bytes\)( )* RegexpComparator - ^( |\t)*-R\s+Recursively list the contents of directories\. + ^\s*modificationDate\(yyyy-MM-dd HH:mm\) fileName( )* + + + RegexpComparator + ^\s*-d\s+Directories are listed as plain files\.( )* + + + RegexpComparator + ^\s*-h\s+Formats the sizes of files in a human-readable fashion rather than a number( )* + + + RegexpComparator + ^\s*of bytes\.( )* + + + RegexpComparator + ^\s*-R\s+Recursively list the contents of directories\.( )* @@ -109,7 +117,11 @@ RegexpComparator - ^-lsr:\s+\(DEPRECATED\) Same as 'ls -R' + ^-lsr :\s* + + + RegexpComparator + ^\s+\(DEPRECATED\) Same as 'ls -R' @@ -125,23 +137,19 @@ RegexpComparator - ^-get( )*\[-p\]( )*\[-ignoreCrc\]( )*\[-crc\]( )*<src> \.\.\. <localdst>:( |\t)*Copy files that match the file pattern <src>( )* + ^-get( )*\[-p\]( )*\[-ignoreCrc\]( )*\[-crc\]( )*<src> \.\.\. <localdst> :\s* RegexpComparator - ^( |\t)*to the local name.( )*<src> is kept.( )*When copying multiple,( )* + \s*Copy files that match the file pattern <src> to the local name. <src> is kept.\s* RegexpComparator - ^( |\t)*files, the destination must be a directory.( )*Passing( )* + \s*When copying multiple files, the destination must be a directory. Passing -p\s* RegexpComparator - ^( |\t)*-p preserves access and modification times,( )* - - - RegexpComparator - ^( |\t)*ownership and the mode.( )* + ^( |\t)*preserves access and modification times, ownership and the mode.* @@ -156,35 +164,39 @@ RegexpComparator - ^-du \[-s\] \[-h\] <path> \.\.\.:\s+Show the amount of space, in bytes, used by the files that\s* + ^-du \[-s\] \[-h\] <path> \.\.\. :\s* RegexpComparator - ^\s*match the specified file pattern. The following flags are optional: + ^\s*Show the amount of space, in bytes, used by the files that match the specified\s* RegexpComparator - ^\s*-s\s*Rather than showing the size of each individual file that + ^\s*file pattern. The following flags are optional:\s* RegexpComparator - ^\s*matches the pattern, shows the total \(summary\) size. + ^\s*-s\s*Rather than showing the size of each individual file that matches the\s* RegexpComparator - ^\s*-h\s*Formats the sizes of files in a human-readable fashion + ^\s*pattern, shows the total \(summary\) size.\s* RegexpComparator - \s*rather than a number of bytes. + ^\s*-h\s*Formats the sizes of files in a human-readable fashion rather than a number\s* RegexpComparator - ^\s*Note that, even without the -s option, this only shows size summaries + \s*of bytes.\s* RegexpComparator - ^\s*one level deep into a directory. + ^\s*Note that, even without the -s option, this only shows size summaries one level\s* + + + RegexpComparator + ^\s*deep into a directory. RegexpComparator @@ -207,7 +219,11 @@ RegexpComparator - ^-dus:\s+\(DEPRECATED\) Same as 'du -s' + ^-dus : + + + RegexpComparator + ^\s*\(DEPRECATED\) Same as 'du -s' @@ -222,7 +238,11 @@ RegexpComparator - ^-count \[-q\] <path> \.\.\.:( |\t)*Count the number of directories, files and bytes under the paths( )* + ^-count \[-q\] <path> \.\.\. :\s* + + + RegexpComparator + ^\s*Count the number of directories, files and bytes under the paths( )* RegexpComparator @@ -253,15 +273,15 @@ RegexpComparator - ^-mv <src> \.\.\. <dst>:( |\t)*Move files that match the specified file pattern <src>( )* + ^-mv <src> \.\.\. <dst> :\s* RegexpComparator - ^( |\t)*to a destination <dst>. When moving multiple files, the( )* + \s*Move files that match the specified file pattern <src> to a destination <dst>.( )* RegexpComparator - ^( |\t)*destination must be a directory.( )* + ^( |\t)*When moving multiple files, the destination must be a directory.( )* @@ -276,31 +296,27 @@ RegexpComparator - ^-cp \[-f\] \[-p \| -p\[topx\]\] <src> \.\.\. <dst>:( |\t)*Copy files that match the file pattern <src> to a( )* + ^-cp \[-f\] \[-p \| -p\[topx\]\] <src> \.\.\. <dst> :\s* RegexpComparator - ^( |\t)*destination. When copying multiple files, the destination( )* + ^\s*Copy files that match the file pattern <src> to a destination. When copying( )* RegexpComparator - ^( |\t)*must be a directory.( )*Passing -p preserves status( )* + ^( |\t)*multiple files, the destination must be a directory.( )*Passing -p preserves status( )* RegexpComparator - ^( |\t)*\[topx\] \(timestamps, ownership, permission, XAttr\).( )* + ^( |\t)*\[topx\] \(timestamps, ownership, permission, XAttr\). If -p is specified with no( )* RegexpComparator - ^( |\t)*If -p is specified with no <arg>, then preserves( )* + ^( |\t)*<arg>, then preserves timestamps, ownership, permission. Passing -f overwrites( )* RegexpComparator - ^( |\t)*timestamps, ownership, permission. Passing -f( )* - - - RegexpComparator - ^( |\t)*overwrites the destination if it already exists.( )* + ^\s*the destination if it already exists.( )* @@ -315,31 +331,31 @@ RegexpComparator - ^-rm \[-f\] \[-r\|-R\] \[-skipTrash\] <src> \.\.\.:( |\t)*Delete all files that match the specified file pattern.( )* + ^-rm \[-f\] \[-r\|-R\] \[-skipTrash\] <src> \.\.\. :\s* RegexpComparator - ^( |\t)*Equivalent to the Unix command "rm <src>"( )* + ^\s*Delete all files that match the specified file pattern. Equivalent to the Unix( )* RegexpComparator - ^( |\t)*-skipTrash option bypasses trash, if enabled, and immediately( )* + ^\s*command "rm <src>"( )* RegexpComparator - ^( |\t)*deletes <src>( )* + ^\s*-skipTrash\s+option bypasses trash, if enabled, and immediately deletes <src>( )* RegexpComparator - ^\s+-f\s+If the file does not exist, do not display a diagnostic + ^\s+-f\s+If the file does not exist, do not display a diagnostic message or\s* RegexpComparator - ^\s+message or modify the exit status to reflect an error\. + ^\s+modify the exit status to reflect an error\.\s* RegexpComparator - ^\s+-\[rR\]\s+Recursively deletes directories + ^\s+-\[rR\]\s+Recursively deletes directories\s* @@ -354,11 +370,15 @@ RegexpComparator - ^-rmdir \[--ignore-fail-on-non-empty\] <dir> \.\.\.:\s+Removes the directory entry specified by each directory argument, + ^-rmdir \[--ignore-fail-on-non-empty\] <dir> \.\.\. :\s* RegexpComparator - \s+provided it is empty. + \s+Removes the directory entry specified by each directory argument, provided it is\s* + + + RegexpComparator + \s+empty\.\s* @@ -373,7 +393,11 @@ RegexpComparator - ^-rmr:\s+\(DEPRECATED\) Same as 'rm -r' + ^-rmr :\s* + + + RegexpComparator + ^\s*\(DEPRECATED\) Same as 'rm -r'\s* @@ -388,27 +412,23 @@ RegexpComparator - ^-put \[-f\] \[-p\] <localsrc> \.\.\. <dst>:\s+Copy files from the local file system + ^-put \[-f\] \[-p\] <localsrc> \.\.\. <dst> :\s* RegexpComparator - ^( |\t)*into fs.( )*Copying fails if the file already( )* + ^\s*Copy files from the local file system into fs.( )*Copying fails if the file already( )* RegexpComparator - ^( |\t)*exists, unless the -f flag is given.( )*Passing( )* + ^\s*exists, unless the -f flag is given.( )*Passing -p preserves access and( )* RegexpComparator - ^( |\t)*-p preserves access and modification times,( )* + ^\s*modification times, ownership and the mode. Passing -f overwrites the( )* RegexpComparator - ^( |\t)*ownership and the mode. Passing -f overwrites( )* - - - RegexpComparator - ^( |\t)*the destination if it already exists.( )* + ^( |\t)*destination if it already exists.( )* @@ -423,7 +443,11 @@ RegexpComparator - ^-copyFromLocal \[-f\] \[-p\] <localsrc> \.\.\. <dst>:\s+Identical to the -put command\. + ^-copyFromLocal \[-f\] \[-p\] <localsrc> \.\.\. <dst> :\s* + + + RegexpComparator + ^\s*Identical to the -put command\.\s* @@ -438,11 +462,11 @@ RegexpComparator - ^-moveFromLocal <localsrc> \.\.\. <dst>:\s+Same as -put, except that the source is + ^-moveFromLocal <localsrc> \.\.\. <dst> :\s* RegexpComparator - ^( |\t)*deleted after it's copied. + ^( |\t)*Same as -put, except that the source is deleted after it's copied. @@ -458,23 +482,19 @@ RegexpComparator - ^-get( )*\[-p\]( )*\[-ignoreCrc\]( )*\[-crc\]( )*<src> \.\.\. <localdst>:( |\t)*Copy files that match the file pattern <src>( )* + ^-get( )*\[-p\]( )*\[-ignoreCrc\]( )*\[-crc\]( )*<src> \.\.\. <localdst> :\s* RegexpComparator - ^( |\t)*to the local name.( )*<src> is kept.( )*When copying multiple,( )* + ^( |\t)*Copy files that match the file pattern <src> to the local name.( )*<src> is kept.( )* RegexpComparator - ^( |\t)*files, the destination must be a directory.( )*Passing( )* + ^( |\t)*When copying multiple files, the destination must be a directory. Passing -p( )* RegexpComparator - ^( |\t)*-p preserves access and modification times,( )* - - - RegexpComparator - ^( |\t)*ownership and the mode.( )* + ^( |\t)*preserves access and modification times, ownership and the mode.( )* @@ -489,19 +509,19 @@ RegexpComparator - ^-getmerge \[-nl\] <src> <localdst>:( |\t)*Get all the files in the directories that( )* + ^-getmerge \[-nl\] <src> <localdst> :\s* RegexpComparator - ^( |\t)*match the source file pattern and merge and sort them to only( )* + ^( |\t)*Get all the files in the directories that match the source file pattern and( )* RegexpComparator - ^( |\t)*one file on local fs. <src> is kept.( )* + ^( |\t)*merge and sort them to only one file on local fs. <src> is kept.( )* RegexpComparator - ^( |\t)*-nl Add a newline character at the end of each file.( )* + ^( |\t)*-nl\s+Add a newline character at the end of each file.( )* @@ -517,11 +537,15 @@ RegexpComparator - ^-cat \[-ignoreCrc\] <src> \.\.\.:( |\t)*Fetch all files that match the file pattern <src>( )* + ^-cat \[-ignoreCrc\] <src> \.\.\. :\s* RegexpComparator - ^( |\t)*and display their content on stdout. + ^\s*Fetch all files that match the file pattern <src> and display their content on\s* + + + RegexpComparator + ^\s*stdout. @@ -537,7 +561,27 @@ RegexpComparator - ^-checksum <src> \.\.\.:( |\t)*Dump checksum information for files.* + ^-checksum <src> \.\.\. :\s* + + + RegexpComparator + ^\s*Dump checksum information for files that match the file pattern <src> to stdout\.\s* + + + RegexpComparator + ^\s*Note that this requires a round-trip to a datanode storing each block of the\s* + + + RegexpComparator + ^\s*file, and thus is not efficient to run on a large number of files\. The checksum\s* + + + RegexpComparator + ^\s*of a file depends on its content, block size and the checksum algorithm and\s* + + + RegexpComparator + ^\s*parameters used for creating the file\.\s* @@ -552,7 +596,11 @@ RegexpComparator - ^-copyToLocal \[-p\] \[-ignoreCrc\] \[-crc\] <src> \.\.\. <localdst>:\s+Identical to the -get command. + ^-copyToLocal \[-p\] \[-ignoreCrc\] \[-crc\] <src> \.\.\. <localdst> :\s* + + + RegexpComparator + ^\s*Identical to the -get command.\s* @@ -567,7 +615,11 @@ RegexpComparator - ^-moveToLocal <src> <localdst>:\s+Not implemented yet + ^-moveToLocal <src> <localdst> :\s* + + + RegexpComparator + ^\s*Not implemented yet @@ -582,7 +634,11 @@ RegexpComparator - ^-mkdir \[-p\] <path> \.\.\.:( |\t)*Create a directory in specified location.( )* + ^-mkdir \[-p\] <path> \.\.\. :\s* + + + RegexpComparator + ^\s*Create a directory in specified location.( )* TokenComparator @@ -601,27 +657,31 @@ RegexpComparator - ^-setrep \[-R\] \[-w\] <rep> <path> \.\.\.:( |\t)*Set the replication level of a file. If <path> is a directory( )* + ^-setrep \[-R\] \[-w\] <rep> <path> \.\.\. :\s* RegexpComparator - ^( |\t)*then the command recursively changes the replication factor of( )* + ^\s*Set the replication level of a file. If <path> is a directory then the command( )* RegexpComparator - ^( |\t)*all files under the directory tree rooted at <path>\.( )* + ^\s*recursively changes the replication factor of all files under the directory tree( )* + + + RegexpComparator + ^\s*rooted at <path>\.( )* RegexpComparator - ^( |\t)*The -w flag requests that the command wait for the replication( )* + ^\s*-w\s+It requests that the command waits for the replication to complete\. This( )* RegexpComparator - ^( |\t)*to complete. This can potentially take a very long time\.( )* + ^( |\t)*can potentially take a very long time\.( )* RegexpComparator - ^( |\t)*The -R flag is accepted for backwards compatibility\. It has no effect\.( )* + ^( |\t)*-R\s+It is accepted for backwards compatibility\. It has no effect\.( )* @@ -636,15 +696,15 @@ RegexpComparator - ^-touchz <path> \.\.\.:( |\t)*Creates a file of zero length( )* + ^-touchz <path> \.\.\. :( )* RegexpComparator - ^( |\t)*at <path> with current time as the timestamp of that <path>.( )* + ^( |\t)*Creates a file of zero length at <path> with current time as the timestamp of( )* RegexpComparator - ^( |\t)*An error is returned if the file exists with non-zero length( )* + ^( |\t)* that <path>\. An error is returned if the file exists with non-zero length( )* @@ -659,11 +719,15 @@ RegexpComparator - ^-test -\[defsz\] <path>:\sAnswer various questions about <path>, with result via exit status. + ^-test -\[defsz\] <path> :\s* RegexpComparator - ^( |\t)*else, return 1.( )* + ^\s*Answer various questions about <path>, with result via exit status. + + + RegexpComparator + ^\s*-[defsz]\s+return 0 if .* @@ -678,15 +742,23 @@ RegexpComparator - ^-stat \[format\] <path> \.\.\.:( |\t)*Print statistics about the file/directory at <path>( )* + ^-stat \[format\] <path> \.\.\. :\s* RegexpComparator - ^( |\t)*in the specified format. Format accepts filesize in blocks \(%b\), group name of owner\(%g\),( )* + ^( |\t)*Print statistics about the file/directory at <path> in the specified format.( )* RegexpComparator - ^( |\t)*filename \(%n\), block size \(%o\), replication \(%r\), user name of owner\(%u\), modification date \(%y, %Y\)( )* + ^( |\t)*Format accepts filesize in blocks \(%b\), group name of owner\(%g\), filename \(%n\),( )* + + + RegexpComparator + ^( |\t)*block size \(%o\), replication \(%r\), user name of owner\(%u\), modification date( )* + + + RegexpComparator + ^( |\t)*\(%y, %Y\)( )* @@ -701,11 +773,15 @@ RegexpComparator - ^-tail \[-f\] <file>:( |\t)+Show the last 1KB of the file.( )* + ^-tail \[-f\] <file> :\s* RegexpComparator - ^( |\t)*The -f option shows appended data as the file grows.( )* + ^\s*Show the last 1KB of the file.( )* + + + RegexpComparator + ^( |\t)*-f\s+Shows appended data as the file grows.( )* @@ -720,47 +796,55 @@ RegexpComparator - ^-chmod \[-R\] <MODE\[,MODE\]... \| OCTALMODE> PATH...:( |\t)*Changes permissions of a file.( )* + ^-chmod \[-R\] <MODE\[,MODE\]... \| OCTALMODE> PATH... :\s* RegexpComparator - ^( |\t)*This works similar to shell's chmod with a few exceptions.( )* + ^( |\t)*Changes permissions of a file. This works similar to the shell's chmod command( )* RegexpComparator - ^( |\t)*-R( |\t)*modifies the files recursively. This is the only option( )* + ^( |\t)*with a few exceptions.( )* RegexpComparator - ^( |\t)*currently supported.( )* + ^( |\t)*-R\s*modifies the files recursively. This is the only option currently( )* RegexpComparator - ^( |\t)*MODE( |\t)*Mode is same as mode used for chmod shell command.( )* + ^( |\t)*supported.( )* RegexpComparator - ^( |\t)*Only letters recognized are 'rwxXt'. E.g. \+t,a\+r,g-w,\+rwx,o=r( )* + ^( |\t)*<MODE>\s*Mode is the same as mode used for the shell's command. The only( )* RegexpComparator - ^( |\t)*OCTALMODE Mode specifed in 3 or 4 digits. If 4 digits, the first may( )* + ^( |\t)*letters recognized are 'rwxXt', e\.g\. \+t,a\+r,g-w,\+rwx,o=r\.( )* RegexpComparator - ^( |\t)*be 1 or 0 to turn the sticky bit on or off, respectively.( )*Unlike( |\t)*shell command, it is not possible to specify only part of the mode( )* + ^( |\t)*<OCTALMODE>\s+Mode specifed in 3 or 4 digits. If 4 digits, the first may be 1 or( )* RegexpComparator - ^( |\t)*E.g. 754 is same as u=rwx,g=rx,o=r( )* + ^( |\t)*0 to turn the sticky bit on or off, respectively.( )*Unlike( |\t)*the( )* RegexpComparator - ^( |\t)*If none of 'augo' is specified, 'a' is assumed and unlike( )* + ^( |\t)*shell command, it is not possible to specify only part of the( )* RegexpComparator - ^( |\t)*shell command, no umask is applied.( )* + ^( |\t)*mode, e\.g\. 754 is same as u=rwx,g=rx,o=r\.( )* + + + RegexpComparator + ^( |\t)*If none of 'augo' is specified, 'a' is assumed and unlike the shell command, no( )* + + + RegexpComparator + ^( |\t)*umask is applied.( )* @@ -775,51 +859,47 @@ RegexpComparator - ^-chown \[-R\] \[OWNER\]\[:\[GROUP\]\] PATH...:( |\t)*Changes owner and group of a file.( )* + ^-chown \[-R\] \[OWNER\]\[:\[GROUP\]\] PATH... :\s* RegexpComparator - ^( |\t)*This is similar to shell's chown with a few exceptions.( )* + ^\s*Changes owner and group of a file\. This is similar to the shell's chown command( )* RegexpComparator - ^( |\t)*-R( |\t)*modifies the files recursively. This is the only option( )* + ^( |\t)*with a few exceptions.( )* RegexpComparator - ^( |\t)*currently supported.( )* + ^( |\t)*-R( |\t)*modifies the files recursively. This is the only option currently( )* RegexpComparator - ^( |\t)*If only owner or group is specified then only owner or( )* + ^( |\t)*supported.( )* RegexpComparator - ^( |\t)*group is modified.( )* + ^( |\t)*If only the owner or group is specified, then only the owner or group is( )* RegexpComparator - ^( |\t)*The owner and group names may only consist of digits, alphabet,( )* + ^( |\t)*modified. The owner and group names may only consist of digits, alphabet, and( )* RegexpComparator - ^( |\t)*and any of .+?. The names are case sensitive.( )* + ^( |\t)*any of .+?. The names are case sensitive.( )* RegexpComparator - ^( |\t)*WARNING: Avoid using '.' to separate user name and group though( )* + ^( |\t)*WARNING: Avoid using '.' to separate user name and group though Linux allows it.( )* RegexpComparator - ^( |\t)*Linux allows it. If user names have dots in them and you are( )* + ^( |\t)*If user names have dots in them and you are using local file system, you might( )* RegexpComparator - ^( |\t)*using local file system, you might see surprising results since( )* - - - RegexpComparator - ^( |\t)*shell command 'chown' is used for local files.( )* + ^( |\t)*see surprising results since the shell command 'chown' is used for local files.( )* @@ -834,7 +914,11 @@ RegexpComparator - ^-chgrp \[-R\] GROUP PATH...:( |\t)*This is equivalent to -chown ... :GROUP ...( )* + ^-chgrp \[-R\] GROUP PATH... :( )* + + + RegexpComparator + ^( |\t)*This is equivalent to -chown ... :GROUP ...( )* @@ -849,11 +933,11 @@ RegexpComparator - ^-help \[cmd ...\]:( |\t)*Displays help for given command or all commands if none( )* + ^-help \[cmd ...\] :( )* RegexpComparator - ^( |\t)*is specified.( )* + ^( |\t)*Displays help for given command or all commands if none is specified.( )* diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java index 3325570c7d0..dbe22845263 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java @@ -40,7 +40,8 @@ import org.apache.hadoop.hdfs.protocol.CacheDirectiveStats; import org.apache.hadoop.hdfs.protocol.CachePoolEntry; import org.apache.hadoop.hdfs.protocol.CachePoolInfo; import org.apache.hadoop.hdfs.protocol.CachePoolStats; -import org.apache.hadoop.hdfs.tools.TableListing.Justification; +import org.apache.hadoop.tools.TableListing; +import org.apache.hadoop.tools.TableListing.Justification; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.Tool;