From 88dc6c1ed3eb6506298ef24453104689bd1c7554 Mon Sep 17 00:00:00 2001 From: Suresh Srinivas Date: Thu, 27 Mar 2014 04:27:50 +0000 Subject: [PATCH] HDFS-6162. Merge r1582181 from trunk. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1582182 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../main/java/org/apache/hadoop/hdfs/DFSInputStream.java | 2 +- .../apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 4 ++-- .../main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java | 4 ++-- .../hadoop/hdfs/tools/offlineImageViewer/LsrPBImage.java | 6 +++--- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 3095589b27f..6b37993ac2a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -33,6 +33,9 @@ Release 2.5.0 - UNRELEASED HDFS-3087. Decomissioning on NN restart can complete without blocks being replicated. (Rushabh S Shah via kihwal) + HDFS-6162. Format strings should use platform independent line separator. + (suresh) + Release 2.4.0 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java index 2d42139d7d8..7396dedc545 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java @@ -801,7 +801,7 @@ implements ByteBufferReadable, CanSetDropBehind, CanSetReadahead, // got a EOS from reader though we expect more data on it. throw new IOException("Unexpected EOS from the reader"); } - if (dfsClient.stats != null && result != -1) { + if (dfsClient.stats != null) { dfsClient.stats.incrementBytesRead(result); } return result; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 2c256e48385..9ea35e80459 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -4985,7 +4985,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats, if (blockSafe < blockThreshold) { msg += String.format( "The reported blocks %d needs additional %d" - + " blocks to reach the threshold %.4f of total blocks %d.\n", + + " blocks to reach the threshold %.4f of total blocks %d.%n", blockSafe, (blockThreshold - blockSafe) + 1, threshold, blockTotal); thresholdsMet = false; } else { @@ -4995,7 +4995,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats, if (numLive < datanodeThreshold) { msg += String.format( "The number of live datanodes %d needs an additional %d live " - + "datanodes to reach the minimum number %d.\n", + + "datanodes to reach the minimum number %d.%n", numLive, (datanodeThreshold - numLive), datanodeThreshold); thresholdsMet = false; } else { 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 7ee148cc236..b7ac968dede 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 @@ -583,7 +583,7 @@ public class CacheAdmin extends Configured implements Tool { tableListing.addRow(row.toArray(new String[0])); numEntries++; } - System.out.print(String.format("Found %d entr%s\n", + System.out.print(String.format("Found %d entr%s%n", numEntries, numEntries == 1 ? "y" : "ies")); if (numEntries > 0) { System.out.print(tableListing); @@ -968,7 +968,7 @@ public class CacheAdmin extends Configured implements Tool { System.err.println(prettifyException(e)); return 2; } - System.out.print(String.format("Found %d result%s.\n", numResults, + System.out.print(String.format("Found %d result%s.%n", numResults, (numResults == 1 ? "" : "s"))); if (numResults > 0) { System.out.print(listing); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/LsrPBImage.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/LsrPBImage.java index d80fcf1e94c..7ea8ba44fc1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/LsrPBImage.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/LsrPBImage.java @@ -159,7 +159,7 @@ final class LsrPBImage { INodeFile f = inode.getFile(); PermissionStatus p = FSImageFormatPBINode.Loader.loadPermission( f.getPermission(), stringTable); - out.print(String.format("-%s %2s %8s %10s %10s %10d %s%s\n", p + out.print(String.format("-%s %2s %8s %10s %10s %10d %s%s%n", p .getPermission().toString(), f.getReplication(), p.getUserName(), p .getGroupName(), f.getModificationTime(), getFileSize(f), parent, inode.getName().toStringUtf8())); @@ -169,7 +169,7 @@ final class LsrPBImage { INodeDirectory d = inode.getDirectory(); PermissionStatus p = FSImageFormatPBINode.Loader.loadPermission( d.getPermission(), stringTable); - out.print(String.format("d%s - %8s %10s %10s %10d %s%s\n", p + out.print(String.format("d%s - %8s %10s %10s %10d %s%s%n", p .getPermission().toString(), p.getUserName(), p.getGroupName(), d .getModificationTime(), 0, parent, inode.getName().toStringUtf8())); } @@ -178,7 +178,7 @@ final class LsrPBImage { INodeSymlink d = inode.getSymlink(); PermissionStatus p = FSImageFormatPBINode.Loader.loadPermission( d.getPermission(), stringTable); - out.print(String.format("-%s - %8s %10s %10s %10d %s%s -> %s\n", p + out.print(String.format("-%s - %8s %10s %10s %10d %s%s -> %s%n", p .getPermission().toString(), p.getUserName(), p.getGroupName(), d .getModificationTime(), 0, parent, inode.getName().toStringUtf8(), d.getTarget().toStringUtf8()));