HADOOP-10361. Correct alignment in CLI output for ACLs. Contributed by Chris Nauroth.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1571573 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris Nauroth 2014-02-25 05:54:51 +00:00
parent 440c3cd105
commit d5639c85fb
4 changed files with 12 additions and 12 deletions

View File

@ -333,6 +333,8 @@ Trunk (Unreleased)
HADOOP-10354. TestWebHDFS fails after merge of HDFS-4685 to trunk. (cnauroth) HADOOP-10354. TestWebHDFS fails after merge of HDFS-4685 to trunk. (cnauroth)
HADOOP-10361. Correct alignment in CLI output for ACLs. (cnauroth)
OPTIMIZATIONS OPTIMIZATIONS
HADOOP-7761. Improve the performance of raw comparisons. (todd) HADOOP-7761. Improve the performance of raw comparisons. (todd)

View File

@ -171,7 +171,7 @@ class AclCommands extends FsCommand {
FsAction entryPerm = entry.getPermission(); FsAction entryPerm = entry.getPermission();
FsAction effectivePerm = entryPerm.and(maskPerm); FsAction effectivePerm = entryPerm.and(maskPerm);
if (entryPerm != effectivePerm) { if (entryPerm != effectivePerm) {
out.println(String.format("%-31s #effective:%s", entry, out.println(String.format("%s\t#effective:%s", entry,
effectivePerm.SYMBOL)); effectivePerm.SYMBOL));
} else { } else {
out.println(entry); out.println(entry);

View File

@ -67,8 +67,7 @@ class Ls extends FsCommand {
protected static final SimpleDateFormat dateFormat = protected static final SimpleDateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd HH:mm"); new SimpleDateFormat("yyyy-MM-dd HH:mm");
protected int maxPerm = 9, maxRepl = 3, maxLen = 10, maxOwner = 0, protected int maxRepl = 3, maxLen = 10, maxOwner = 0, maxGroup = 0;
maxGroup = 0;
protected String lineFormat; protected String lineFormat;
protected boolean dirRecurse; protected boolean dirRecurse;
@ -117,7 +116,7 @@ class Ls extends FsCommand {
FileStatus stat = item.stat; FileStatus stat = item.stat;
String line = String.format(lineFormat, String line = String.format(lineFormat,
(stat.isDirectory() ? "d" : "-"), (stat.isDirectory() ? "d" : "-"),
stat.getPermission() + (hasAcl(item) ? "+" : ""), stat.getPermission() + (hasAcl(item) ? "+" : " "),
(stat.isFile() ? stat.getReplication() : "-"), (stat.isFile() ? stat.getReplication() : "-"),
stat.getOwner(), stat.getOwner(),
stat.getGroup(), stat.getGroup(),
@ -135,7 +134,6 @@ class Ls extends FsCommand {
private void adjustColumnWidths(PathData items[]) { private void adjustColumnWidths(PathData items[]) {
for (PathData item : items) { for (PathData item : items) {
FileStatus stat = item.stat; FileStatus stat = item.stat;
maxPerm = maxLength(maxPerm, stat.getPermission());
maxRepl = maxLength(maxRepl, stat.getReplication()); maxRepl = maxLength(maxRepl, stat.getReplication());
maxLen = maxLength(maxLen, stat.getLen()); maxLen = maxLength(maxLen, stat.getLen());
maxOwner = maxLength(maxOwner, stat.getOwner()); maxOwner = maxLength(maxOwner, stat.getOwner());
@ -143,7 +141,7 @@ class Ls extends FsCommand {
} }
StringBuilder fmt = new StringBuilder(); StringBuilder fmt = new StringBuilder();
fmt.append("%s%-" + maxPerm + "s "); // permission string fmt.append("%s%s"); // permission string
fmt.append("%" + maxRepl + "s "); fmt.append("%" + maxRepl + "s ");
// Do not use '%-0s' as a formatting conversion, since it will throw a // Do not use '%-0s' as a formatting conversion, since it will throw a
// a MissingFormatWidthException if it is used in String.format(). // a MissingFormatWidthException if it is used in String.format().

View File

@ -846,15 +846,15 @@
</comparator> </comparator>
<comparator> <comparator>
<type>RegexpComparator</type> <type>RegexpComparator</type>
<expected-output>^user:charlie:rwx\s+#effective:r-x$</expected-output> <expected-output>^user:charlie:rwx\t#effective:r-x$</expected-output>
</comparator> </comparator>
<comparator> <comparator>
<type>RegexpComparator</type> <type>RegexpComparator</type>
<expected-output>^group::-wx\s+#effective:--x$</expected-output> <expected-output>^group::-wx\t#effective:--x$</expected-output>
</comparator> </comparator>
<comparator> <comparator>
<type>RegexpComparator</type> <type>RegexpComparator</type>
<expected-output>^group:sales:rwx\s+#effective:r-x$</expected-output> <expected-output>^group:sales:rwx\t#effective:r-x$</expected-output>
</comparator> </comparator>
<comparator> <comparator>
<type>SubstringComparator</type> <type>SubstringComparator</type>
@ -870,15 +870,15 @@
</comparator> </comparator>
<comparator> <comparator>
<type>RegexpComparator</type> <type>RegexpComparator</type>
<expected-output>^default:user:charlie:rwx\s+#effective:rw-$</expected-output> <expected-output>^default:user:charlie:rwx\t#effective:rw-$</expected-output>
</comparator> </comparator>
<comparator> <comparator>
<type>RegexpComparator</type> <type>RegexpComparator</type>
<expected-output>^default:group::r-x\s+#effective:r--$</expected-output> <expected-output>^default:group::r-x\t#effective:r--$</expected-output>
</comparator> </comparator>
<comparator> <comparator>
<type>RegexpComparator</type> <type>RegexpComparator</type>
<expected-output>^default:group:sales:rwx\s+#effective:rw-$</expected-output> <expected-output>^default:group:sales:rwx\t#effective:rw-$</expected-output>
</comparator> </comparator>
<comparator> <comparator>
<type>SubstringComparator</type> <type>SubstringComparator</type>