hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lium...@apache.org
Subject hadoop git commit: HDFS-11803. Add -v option for du command to show header line. Contributed by Xiaobing Zhou
Date Fri, 19 May 2017 21:21:11 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk e82da2b4f -> 1db186f66


HDFS-11803. Add -v option for du command to show header line. Contributed by Xiaobing Zhou


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/1db186f6
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1db186f6
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1db186f6

Branch: refs/heads/trunk
Commit: 1db186f662af971d956d74aed03150b0692a2315
Parents: e82da2b
Author: Mingliang Liu <liuml07@apache.org>
Authored: Fri May 19 14:17:14 2017 -0700
Committer: Mingliang Liu <liuml07@apache.org>
Committed: Fri May 19 14:21:01 2017 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/hadoop/fs/shell/FsUsage.java | 14 +++++++++++---
 .../src/site/markdown/FileSystemShell.md              |  1 +
 .../hadoop-common/src/test/resources/testConf.xml     |  2 +-
 3 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/1db186f6/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/FsUsage.java
----------------------------------------------------------------------
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 6b1d7e0..6596527 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
@@ -160,7 +160,7 @@ class FsUsage extends FsCommand {
   /** show disk usage */
   public static class Du extends FsUsage {
     public static final String NAME = "du";
-    public static final String USAGE = "[-s] [-h] [-x] <path> ...";
+    public static final String USAGE = "[-s] [-h] [-v] [-x] <path> ...";
     public static final String DESCRIPTION =
         "Show the amount of space, in bytes, used by the files that match " +
             "the specified file pattern. The following flags are optional:\n" +
@@ -168,6 +168,7 @@ class FsUsage extends FsCommand {
             " 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" +
+            "-v: option displays a header line.\n" +
             "-x: Excludes snapshots from being counted.\n\n" +
             "Note that, even without the -s option, this only shows size " +
             "summaries one level deep into a directory.\n\n" +
@@ -175,14 +176,16 @@ class FsUsage extends FsCommand {
             "\tsize\tdisk space consumed\tname(full path)\n";
 
     protected boolean summary = false;
+    private boolean showHeaderLine = false;
     private boolean excludeSnapshots = false;
     
     @Override
     protected void processOptions(LinkedList<String> args) throws IOException {
-      CommandFormat cf = new CommandFormat(0, Integer.MAX_VALUE, "h", "s", "x");
+      CommandFormat cf = new CommandFormat(0, Integer.MAX_VALUE, "h", "s", "v", "x");
       cf.parse(args);
       setHumanReadable(cf.getOpt("h"));
       summary = cf.getOpt("s");
+      showHeaderLine = cf.getOpt("v");
       excludeSnapshots = cf.getOpt("x");
       if (args.isEmpty()) args.add(Path.CUR_DIR);
     }
@@ -190,7 +193,12 @@ class FsUsage extends FsCommand {
     @Override
     protected void processArguments(LinkedList<PathData> args)
         throws IOException {
-      setUsagesTable(new TableBuilder(3));
+      if (showHeaderLine) {
+        setUsagesTable(new TableBuilder("SIZE",
+            "DISK_SPACE_CONSUMED_WITH_ALL_REPLICAS", "FULL_PATH_NAME"));
+      } else {
+        setUsagesTable(new TableBuilder(3));
+      }
       super.processArguments(args);
       if (!getUsagesTable().isEmpty()) {
         getUsagesTable().printToStream(out);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/1db186f6/hadoop-common-project/hadoop-common/src/site/markdown/FileSystemShell.md
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/site/markdown/FileSystemShell.md b/hadoop-common-project/hadoop-common/src/site/markdown/FileSystemShell.md
index 0412f1f..c5e0524 100644
--- a/hadoop-common-project/hadoop-common/src/site/markdown/FileSystemShell.md
+++ b/hadoop-common-project/hadoop-common/src/site/markdown/FileSystemShell.md
@@ -232,6 +232,7 @@ Options:
 
 * The -s option will result in an aggregate summary of file lengths being displayed, rather
than the individual files. Without the -s option, calculation is done by going 1-level deep
from the given path.
 * The -h option will format file sizes in a "human-readable" fashion (e.g 64.0m instead of
67108864)
+* The -v option will display the names of columns as a header line.
 * The -x option will exclude snapshots from the result calculation. Without the -x option
(default), the result is always calculated from all INodes, including all snapshots under
the given path.
 
 The du returns three columns with the following format:

http://git-wip-us.apache.org/repos/asf/hadoop/blob/1db186f6/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml
----------------------------------------------------------------------
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 6347aa0..6644cd8 100644
--- a/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml
+++ b/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml
@@ -200,7 +200,7 @@
       <comparators>
         <comparator>
           <type>RegexpComparator</type>
-          <expected-output>^-du \[-s\] \[-h\] \[-x\] &lt;path&gt; \.\.\. :\s*</expected-output>
+          <expected-output>^-du \[-s\] \[-h\] \[-v\] \[-x\] &lt;path&gt; \.\.\.
:\s*</expected-output>
         </comparator>
         <comparator>
           <type>RegexpComparator</type>


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message