HDFS-8405. Fix a typo in NamenodeFsck. Contributed by Takanobu Asanuma

This commit is contained in:
Tsz-Wo Nicholas Sze 2015-05-19 02:57:54 +08:00
parent 411c09b613
commit 59d1b4a323
4 changed files with 13 additions and 14 deletions

View File

@ -82,6 +82,8 @@ Release 2.7.1 - UNRELEASED
HDFS-6300. Prevent multiple balancers from running simultaneously
(Rakesh R via vinayakumarb)
HDFS-8405. Fix a typo in NamenodeFsck. (Takanobu Asanuma via szetszwo)
Release 2.7.0 - 2015-04-20
INCOMPATIBLE CHANGES

View File

@ -66,7 +66,7 @@ public Object run() throws Exception {
namesystem.getNumberOfDatanodes(DatanodeReportType.LIVE);
new NamenodeFsck(conf, nn,
bm.getDatanodeManager().getNetworkTopology(), pmap, out,
totalDatanodes, bm.minReplication, remoteAddress).fsck();
totalDatanodes, remoteAddress).fsck();
return null;
}

View File

@ -118,7 +118,6 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
private final NameNode namenode;
private final NetworkTopology networktopology;
private final int totalDatanodes;
private final short minReplication;
private final InetAddress remoteAddress;
private String lostFound = null;
@ -175,19 +174,17 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
* @param pmap key=value[] map passed to the http servlet as url parameters
* @param out output stream to write the fsck output
* @param totalDatanodes number of live datanodes
* @param minReplication minimum replication
* @param remoteAddress source address of the fsck request
*/
NamenodeFsck(Configuration conf, NameNode namenode,
NetworkTopology networktopology,
Map<String,String[]> pmap, PrintWriter out,
int totalDatanodes, short minReplication, InetAddress remoteAddress) {
int totalDatanodes, InetAddress remoteAddress) {
this.conf = conf;
this.namenode = namenode;
this.networktopology = networktopology;
this.out = out;
this.totalDatanodes = totalDatanodes;
this.minReplication = minReplication;
this.remoteAddress = remoteAddress;
this.bpPolicy = BlockPlacementPolicy.getInstance(conf, null,
networktopology,
@ -290,7 +287,6 @@ public void fsck() {
final long startTime = Time.monotonicNow();
try {
if(blockIds != null) {
String[] blocks = blockIds.split(" ");
StringBuilder sb = new StringBuilder();
sb.append("FSCK started by " +
@ -509,7 +505,7 @@ void check(String parent, HdfsFileStatus file, Result res) throws IOException {
res.totalReplicas += liveReplicas;
short targetFileReplication = file.getReplication();
res.numExpectedReplicas += targetFileReplication;
if(liveReplicas<minReplication){
if(liveReplicas < res.minReplication){
res.numUnderMinReplicatedBlocks++;
}
if (liveReplicas > targetFileReplication) {
@ -529,7 +525,7 @@ void check(String parent, HdfsFileStatus file, Result res) throws IOException {
out.print("\n" + path + ": CORRUPT blockpool " + block.getBlockPoolId() +
" block " + block.getBlockName()+"\n");
}
if (liveReplicas >= minReplication)
if (liveReplicas >= res.minReplication)
res.numMinReplicatedBlocks++;
if (liveReplicas < targetFileReplication && liveReplicas > 0) {
res.missingReplicas += (targetFileReplication - liveReplicas);
@ -543,7 +539,8 @@ void check(String parent, HdfsFileStatus file, Result res) throws IOException {
targetFileReplication + " but found " +
liveReplicas + " replica(s).");
}
// verify block placement policy
// count mis replicated blocks
BlockPlacementStatus blockPlacementStatus = bpPolicy
.verifyBlockPlacement(path, lBlk, targetFileReplication);
if (!blockPlacementStatus.isPlacementPolicySatisfied()) {
@ -938,7 +935,7 @@ public String toString() {
((float) (numUnderMinReplicatedBlocks * 100) / (float) totalBlocks))
.append(" %)");
}
res.append("\n ").append("DFSConfigKeys.DFS_NAMENODE_REPLICATION_MIN_KEY:\t")
res.append("\n ").append(DFSConfigKeys.DFS_NAMENODE_REPLICATION_MIN_KEY + ":\t")
.append(minReplication);
}
if(corruptFiles>0) {

View File

@ -773,7 +773,7 @@ public void testUnderMinReplicatedBlock() throws Exception {
System.out.println(outStr);
assertTrue(outStr.contains(NamenodeFsck.HEALTHY_STATUS));
assertTrue(outStr.contains("UNDER MIN REPL'D BLOCKS:\t1 (100.0 %)"));
assertTrue(outStr.contains("DFSConfigKeys.DFS_NAMENODE_REPLICATION_MIN_KEY:\t2"));
assertTrue(outStr.contains("dfs.namenode.replication.min:\t2"));
} finally {
if (cluster != null) {cluster.shutdown();}
}
@ -969,7 +969,7 @@ public void testFsckMissingReplicas() throws IOException {
PrintWriter out = new PrintWriter(result, true);
InetAddress remoteAddress = InetAddress.getLocalHost();
NamenodeFsck fsck = new NamenodeFsck(conf, namenode, nettop, pmap, out,
NUM_REPLICAS, (short)1, remoteAddress);
NUM_REPLICAS, remoteAddress);
// Run the fsck and check the Result
final HdfsFileStatus file =
@ -1046,7 +1046,7 @@ public void testFsckMisPlacedReplicas() throws IOException {
PrintWriter out = new PrintWriter(result, true);
InetAddress remoteAddress = InetAddress.getLocalHost();
NamenodeFsck fsck = new NamenodeFsck(conf, namenode, nettop, pmap, out,
NUM_DN, REPL_FACTOR, remoteAddress);
NUM_DN, remoteAddress);
// Run the fsck and check the Result
final HdfsFileStatus file =
@ -1093,7 +1093,7 @@ public void testFsckFileNotFound() throws Exception {
when(blockManager.getDatanodeManager()).thenReturn(dnManager);
NamenodeFsck fsck = new NamenodeFsck(conf, namenode, nettop, pmap, out,
NUM_REPLICAS, (short)1, remoteAddress);
NUM_REPLICAS, remoteAddress);
String pathString = "/tmp/testFile";