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
This commit is contained in:
Harsh J 2012-01-26 10:05:40 +00:00
parent c9a5c42efd
commit 26b88c3279
7 changed files with 46 additions and 25 deletions

View File

@ -66,6 +66,19 @@ Release 0.23.1 - Unreleased
HADOOP-7987. Support setting the run-as user in unsecure mode. (jitendra) 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 OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -826,6 +826,12 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
*/ */
public boolean getBoolean(String name, boolean defaultValue) { public boolean getBoolean(String name, boolean defaultValue) {
String valueString = getTrimmed(name); String valueString = getTrimmed(name);
if (null == valueString || "".equals(valueString)) {
return defaultValue;
}
valueString = valueString.toLowerCase();
if ("true".equals(valueString)) if ("true".equals(valueString))
return true; return true;
else if ("false".equals(valueString)) else if ("false".equals(valueString))

View File

@ -18,10 +18,12 @@
package org.apache.hadoop.fs; package org.apache.hadoop.fs;
import java.net.*; import java.io.IOException;
import java.io.*; import java.net.URI;
import org.apache.avro.reflect.Stringable; 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.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
@ -76,7 +78,7 @@ public class Path implements Comparable {
} }
URI resolved = parentUri.resolve(child.uri); URI resolved = parentUri.resolve(child.uri);
initialize(resolved.getScheme(), resolved.getAuthority(), initialize(resolved.getScheme(), resolved.getAuthority(),
normalizePath(resolved.getPath()), resolved.getFragment()); resolved.getPath(), resolved.getFragment());
} }
private void checkPathArg( String path ) { private void checkPathArg( String path ) {
@ -158,8 +160,8 @@ public class Path implements Comparable {
private String normalizePath(String path) { private String normalizePath(String path) {
// remove double slashes & backslashes // remove double slashes & backslashes
path = path.replace("//", "/"); path = StringUtils.replace(path, "//", "/");
path = path.replace("\\", "/"); path = StringUtils.replace(path, "\\", "/");
// trim trailing slash from non-root path (ignoring windows drive) // trim trailing slash from non-root path (ignoring windows drive)
int minLength = hasWindowsDrive(path, true) ? 4 : 1; int minLength = hasWindowsDrive(path, true) ? 4 : 1;

View File

@ -32,9 +32,11 @@ import org.apache.hadoop.fs.FileStatus;
* Print statistics about path in specified format. * Print statistics about path in specified format.
* Format sequences: * Format sequences:
* %b: Size of file in blocks * %b: Size of file in blocks
* %g: Group name of owner
* %n: Filename * %n: Filename
* %o: Block size * %o: Block size
* %r: replication * %r: replication
* %u: User name of owner
* %y: UTC date as &quot;yyyy-MM-dd HH:mm:ss&quot; * %y: UTC date as &quot;yyyy-MM-dd HH:mm:ss&quot;
* %Y: Milliseconds since January 1, 1970 UTC * %Y: Milliseconds since January 1, 1970 UTC
*/ */
@ -50,8 +52,8 @@ class Stat extends FsCommand {
public static final String USAGE = "[format] <path> ..."; public static final String USAGE = "[format] <path> ...";
public static final String DESCRIPTION = public static final String DESCRIPTION =
"Print statistics about the file/directory at <path>\n" + "Print statistics about the file/directory at <path>\n" +
"in the specified format. Format accepts filesize in blocks (%b), filename (%n),\n" + "in the specified format. Format accepts filesize in blocks (%b), group name of owner(%g),\n" +
"block size (%o), replication (%r), modification date (%y, %Y)\n"; "filename (%n), block size (%o), replication (%r), user name of owner(%u), modification date (%y, %Y)\n";
protected static final SimpleDateFormat timeFmt; protected static final SimpleDateFormat timeFmt;
static { static {
@ -92,6 +94,9 @@ class Stat extends FsCommand {
? "directory" ? "directory"
: (stat.isFile() ? "regular file" : "symlink")); : (stat.isFile() ? "regular file" : "symlink"));
break; break;
case 'g':
buf.append(stat.getGroup());
break;
case 'n': case 'n':
buf.append(item.path.getName()); buf.append(item.path.getName());
break; break;
@ -101,6 +106,9 @@ class Stat extends FsCommand {
case 'r': case 'r':
buf.append(stat.getReplication()); buf.append(stat.getReplication());
break; break;
case 'u':
buf.append(stat.getOwner());
break;
case 'y': case 'y':
buf.append(timeFmt.format(new Date(stat.getModificationTime()))); buf.append(timeFmt.format(new Date(stat.getModificationTime())));
break; break;

View File

@ -134,20 +134,6 @@
</description> </description>
</property> </property>
<!--- logging properties -->
<property>
<name>hadoop.logfile.size</name>
<value>10000000</value>
<description>The max size of each log file</description>
</property>
<property>
<name>hadoop.logfile.count</name>
<value>10</value>
<description>The max number of log files</description>
</property>
<!-- i/o properties --> <!-- i/o properties -->
<property> <property>
<name>io.file.buffer.size</name> <name>io.file.buffer.size</name>

View File

@ -451,6 +451,9 @@ public class TestConfiguration extends TestCase {
appendProperty("test.bool3", " true "); appendProperty("test.bool3", " true ");
appendProperty("test.bool4", " false "); appendProperty("test.bool4", " false ");
appendProperty("test.bool5", "foo"); appendProperty("test.bool5", "foo");
appendProperty("test.bool6", "TRUE");
appendProperty("test.bool7", "FALSE");
appendProperty("test.bool8", "");
endConfig(); endConfig();
Path fileResource = new Path(CONFIG); Path fileResource = new Path(CONFIG);
conf.addResource(fileResource); conf.addResource(fileResource);
@ -459,6 +462,9 @@ public class TestConfiguration extends TestCase {
assertEquals(true, conf.getBoolean("test.bool3", false)); assertEquals(true, conf.getBoolean("test.bool3", false));
assertEquals(false, conf.getBoolean("test.bool4", true)); assertEquals(false, conf.getBoolean("test.bool4", true));
assertEquals(true, conf.getBoolean("test.bool5", 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 { public void testFloatValues() throws IOException {

View File

@ -610,11 +610,11 @@
</comparator> </comparator>
<comparator> <comparator>
<type>RegexpComparator</type> <type>RegexpComparator</type>
<expected-output>^( |\t)*in the specified format. Format accepts filesize in blocks \(%b\), filename \(%n\),( )*</expected-output> <expected-output>^( |\t)*in the specified format. Format accepts filesize in blocks \(%b\), group name of owner\(%g\),( )*</expected-output>
</comparator> </comparator>
<comparator> <comparator>
<type>RegexpComparator</type> <type>RegexpComparator</type>
<expected-output>^( |\t)*block size \(%o\), replication \(%r\), modification date \(%y, %Y\)( )*</expected-output> <expected-output>^( |\t)*filename \(%n\), block size \(%o\), replication \(%r\), user name of owner\(%u\), modification date \(%y, %Y\)( )*</expected-output>
</comparator> </comparator>
</comparators> </comparators>
</test> </test>