From 26b88c3279aa48c3bc2cdf455944eeda4490e82a Mon Sep 17 00:00:00 2001 From: Harsh J Date: Thu, 26 Jan 2012 10:05:40 +0000 Subject: [PATCH] merge HADOOP-4515 HADOOP-6490 HADOOP-7574 HADOOP-7736 HADOOP-7919 to 0.23 from trunk and update CHANGES.txt file accordingly. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1236124 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 13 +++++++++++++ .../java/org/apache/hadoop/conf/Configuration.java | 6 ++++++ .../src/main/java/org/apache/hadoop/fs/Path.java | 14 ++++++++------ .../main/java/org/apache/hadoop/fs/shell/Stat.java | 14 +++++++++++--- .../src/main/resources/core-default.xml | 14 -------------- .../org/apache/hadoop/conf/TestConfiguration.java | 6 ++++++ .../hadoop-common/src/test/resources/testConf.xml | 4 ++-- 7 files changed, 46 insertions(+), 25 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 9a308e9febd..3ab24c70009 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -66,6 +66,19 @@ Release 0.23.1 - Unreleased HADOOP-7987. Support setting the run-as user in unsecure mode. (jitendra) + HADOOP-4515. Configuration#getBoolean must not be case sensitive. (Sho Shimauchi via harsh) + + HADOOP-6490. Use StringUtils over String#replace in Path#normalizePath. + (Uma Maheswara Rao G via harsh) + + HADOOP-7574. Improve FSShell -stat, add user/group elements. + (XieXianshan via harsh) + + HADOOP-7736. Remove duplicate Path#normalizePath call. (harsh) + + HADOOP-7919. Remove the unused hadoop.logfile.* properties from the + core-default.xml file. (harsh) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java index 4514b807f14..58f9aa7c8af 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java @@ -826,6 +826,12 @@ public class Configuration implements Iterable>, */ public boolean getBoolean(String name, boolean defaultValue) { String valueString = getTrimmed(name); + if (null == valueString || "".equals(valueString)) { + return defaultValue; + } + + valueString = valueString.toLowerCase(); + if ("true".equals(valueString)) return true; else if ("false".equals(valueString)) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java index 25c0904ed80..81c79dbded7 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java @@ -18,10 +18,12 @@ package org.apache.hadoop.fs; -import java.net.*; -import java.io.*; -import org.apache.avro.reflect.Stringable; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import org.apache.avro.reflect.Stringable; +import org.apache.commons.lang.StringUtils; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; @@ -76,7 +78,7 @@ public class Path implements Comparable { } URI resolved = parentUri.resolve(child.uri); initialize(resolved.getScheme(), resolved.getAuthority(), - normalizePath(resolved.getPath()), resolved.getFragment()); + resolved.getPath(), resolved.getFragment()); } private void checkPathArg( String path ) { @@ -158,8 +160,8 @@ public class Path implements Comparable { private String normalizePath(String path) { // remove double slashes & backslashes - path = path.replace("//", "/"); - path = path.replace("\\", "/"); + path = StringUtils.replace(path, "//", "/"); + path = StringUtils.replace(path, "\\", "/"); // trim trailing slash from non-root path (ignoring windows drive) int minLength = hasWindowsDrive(path, true) ? 4 : 1; 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 e8a731a3351..d6034390bba 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 @@ -32,9 +32,11 @@ import org.apache.hadoop.fs.FileStatus; * Print statistics about path in specified format. * Format sequences: * %b: Size of file in blocks + * %g: Group name of owner * %n: Filename * %o: Block size * %r: replication + * %u: User name of owner * %y: UTC date as "yyyy-MM-dd HH:mm:ss" * %Y: Milliseconds since January 1, 1970 UTC */ @@ -50,8 +52,8 @@ class Stat extends FsCommand { 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), filename (%n),\n" + - "block size (%o), replication (%r), modification date (%y, %Y)\n"; + "in the specified format. Format accepts filesize in blocks (%b), group name of owner(%g),\n" + + "filename (%n), block size (%o), replication (%r), user name of owner(%u), modification date (%y, %Y)\n"; protected static final SimpleDateFormat timeFmt; static { @@ -92,6 +94,9 @@ class Stat extends FsCommand { ? "directory" : (stat.isFile() ? "regular file" : "symlink")); break; + case 'g': + buf.append(stat.getGroup()); + break; case 'n': buf.append(item.path.getName()); break; @@ -101,6 +106,9 @@ class Stat extends FsCommand { case 'r': buf.append(stat.getReplication()); break; + case 'u': + buf.append(stat.getOwner()); + break; case 'y': buf.append(timeFmt.format(new Date(stat.getModificationTime()))); break; @@ -118,4 +126,4 @@ class Stat extends FsCommand { } out.println(buf.toString()); } -} \ No newline at end of file +} diff --git a/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml b/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml index 1f50e682eb5..b86ad48b832 100644 --- a/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml +++ b/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml @@ -134,20 +134,6 @@ - - - - hadoop.logfile.size - 10000000 - The max size of each log file - - - - hadoop.logfile.count - 10 - The max number of log files - - io.file.buffer.size diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java index 021510c0bd1..13e0713444c 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java @@ -451,6 +451,9 @@ public class TestConfiguration extends TestCase { appendProperty("test.bool3", " true "); appendProperty("test.bool4", " false "); appendProperty("test.bool5", "foo"); + appendProperty("test.bool6", "TRUE"); + appendProperty("test.bool7", "FALSE"); + appendProperty("test.bool8", ""); endConfig(); Path fileResource = new Path(CONFIG); conf.addResource(fileResource); @@ -459,6 +462,9 @@ public class TestConfiguration extends TestCase { assertEquals(true, conf.getBoolean("test.bool3", false)); assertEquals(false, conf.getBoolean("test.bool4", true)); assertEquals(true, conf.getBoolean("test.bool5", true)); + assertEquals(true, conf.getBoolean("test.bool6", false)); + assertEquals(false, conf.getBoolean("test.bool7", true)); + assertEquals(false, conf.getBoolean("test.bool8", false)); } public void testFloatValues() throws IOException { 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 c471a9410ee..b1ce87e888b 100644 --- a/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml +++ b/hadoop-common-project/hadoop-common/src/test/resources/testConf.xml @@ -610,11 +610,11 @@ RegexpComparator - ^( |\t)*in the specified format. Format accepts filesize in blocks \(%b\), filename \(%n\),( )* + ^( |\t)*in the specified format. Format accepts filesize in blocks \(%b\), group name of owner\(%g\),( )* RegexpComparator - ^( |\t)*block size \(%o\), replication \(%r\), modification date \(%y, %Y\)( )* + ^( |\t)*filename \(%n\), block size \(%o\), replication \(%r\), user name of owner\(%u\), modification date \(%y, %Y\)( )*