HDFS-16638. Add isDebugEnabled check for debug blockLogs in BlockManager. (#4480). Contributed by dzcxzl.

Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
This commit is contained in:
cxzl25 2022-07-04 05:06:29 +08:00 committed by GitHub
parent a333674785
commit ea46f49b04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 59 additions and 34 deletions

View File

@ -1893,8 +1893,10 @@ public class BlockManager implements BlockStatsMXBean {
DatanodeStorageInfo storageInfo, DatanodeStorageInfo storageInfo,
DatanodeDescriptor node) throws IOException { DatanodeDescriptor node) throws IOException {
if (b.getStored().isDeleted()) { if (b.getStored().isDeleted()) {
blockLog.debug("BLOCK markBlockAsCorrupt: {} cannot be marked as" + if(blockLog.isDebugEnabled()) {
" corrupt as it does not belong to any file", b); blockLog.debug("BLOCK markBlockAsCorrupt: {} cannot be marked as" +
" corrupt as it does not belong to any file", b);
}
addToInvalidates(b.getCorrupted(), node); addToInvalidates(b.getCorrupted(), node);
return; return;
} }
@ -1975,10 +1977,12 @@ public class BlockManager implements BlockStatsMXBean {
// Check how many copies we have of the block // Check how many copies we have of the block
if (nr.replicasOnStaleNodes() > 0 && !deleteCorruptReplicaImmediately) { if (nr.replicasOnStaleNodes() > 0 && !deleteCorruptReplicaImmediately) {
blockLog.debug("BLOCK* invalidateBlocks: postponing " + if(blockLog.isDebugEnabled()) {
"invalidation of {} on {} because {} replica(s) are located on " + blockLog.debug("BLOCK* invalidateBlocks: postponing " +
"nodes with potentially out-of-date block reports", b, dn, "invalidation of {} on {} because {} replica(s) are located on " +
nr.replicasOnStaleNodes()); "nodes with potentially out-of-date block reports", b, dn,
nr.replicasOnStaleNodes());
}
postponeBlock(b.getCorrupted()); postponeBlock(b.getCorrupted());
return false; return false;
} else { } else {
@ -2220,8 +2224,10 @@ public class BlockManager implements BlockStatsMXBean {
int pendingNum = pendingReconstruction.getNumReplicas(block); int pendingNum = pendingReconstruction.getNumReplicas(block);
if (hasEnoughEffectiveReplicas(block, numReplicas, pendingNum)) { if (hasEnoughEffectiveReplicas(block, numReplicas, pendingNum)) {
neededReconstruction.remove(block, priority); neededReconstruction.remove(block, priority);
blockLog.debug("BLOCK* Removing {} from neededReconstruction as" + if(blockLog.isDebugEnabled()) {
" it has enough replicas", block); blockLog.debug("BLOCK* Removing {} from neededReconstruction as" +
" it has enough replicas", block);
}
NameNode.getNameNodeMetrics().incNumTimesReReplicationNotScheduled(); NameNode.getNameNodeMetrics().incNumTimesReReplicationNotScheduled();
return null; return null;
} }
@ -2317,8 +2323,10 @@ public class BlockManager implements BlockStatsMXBean {
if (hasEnoughEffectiveReplicas(block, numReplicas, pendingNum)) { if (hasEnoughEffectiveReplicas(block, numReplicas, pendingNum)) {
neededReconstruction.remove(block, priority); neededReconstruction.remove(block, priority);
rw.resetTargets(); rw.resetTargets();
blockLog.debug("BLOCK* Removing {} from neededReconstruction as" + if(blockLog.isDebugEnabled()) {
" it has enough replicas", block); blockLog.debug("BLOCK* Removing {} from neededReconstruction as" +
" it has enough replicas", block);
}
return false; return false;
} }
@ -2349,8 +2357,10 @@ public class BlockManager implements BlockStatsMXBean {
// The reason we use 'pending' is so we can retry // The reason we use 'pending' is so we can retry
// reconstructions that fail after an appropriate amount of time. // reconstructions that fail after an appropriate amount of time.
pendingReconstruction.increment(block, targets); pendingReconstruction.increment(block, targets);
blockLog.debug("BLOCK* block {} is moved from neededReconstruction to " if(blockLog.isDebugEnabled()) {
+ "pendingReconstruction", block); blockLog.debug("BLOCK* block {} is moved from neededReconstruction to "
+ "pendingReconstruction", block);
}
int numEffectiveReplicas = numReplicas.liveReplicas() + pendingNum; int numEffectiveReplicas = numReplicas.liveReplicas() + pendingNum;
// remove from neededReconstruction // remove from neededReconstruction
@ -2896,9 +2906,11 @@ public class BlockManager implements BlockStatsMXBean {
if(blockLog.isDebugEnabled()) { if(blockLog.isDebugEnabled()) {
for (Block b : invalidatedBlocks) { for (Block b : invalidatedBlocks) {
blockLog.debug("BLOCK* processReport 0x{} with lease ID 0x{}: {} on node {} size {} " + if(blockLog.isDebugEnabled()) {
"does not belong to any file.", strBlockReportId, fullBrLeaseId, b, blockLog.debug("BLOCK* processReport 0x{} with lease ID 0x{}: {} on node {} size {} " +
node, b.getNumBytes()); "does not belong to any file.", strBlockReportId, fullBrLeaseId, b,
node, b.getNumBytes());
}
} }
} }
@ -3056,9 +3068,11 @@ public class BlockManager implements BlockStatsMXBean {
} }
} }
if (isCorrupt) { if (isCorrupt) {
blockLog.debug("BLOCK* markBlockReplicasAsCorrupt: mark block replica" + if(blockLog.isDebugEnabled()) {
" {} on {} as corrupt because the dn is not in the new committed " + blockLog.debug("BLOCK* markBlockReplicasAsCorrupt: mark block replica" +
"storage list.", b, storage.getDatanodeDescriptor()); " {} on {} as corrupt because the dn is not in the new committed " +
"storage list.", b, storage.getDatanodeDescriptor());
}
markBlockAsCorrupt(b, storage, storage.getDatanodeDescriptor()); markBlockAsCorrupt(b, storage, storage.getDatanodeDescriptor());
} }
} }
@ -3575,8 +3589,10 @@ public class BlockManager implements BlockStatsMXBean {
} }
if (storedBlock == null || storedBlock.isDeleted()) { if (storedBlock == null || storedBlock.isDeleted()) {
// If this block does not belong to anyfile, then we are done. // If this block does not belong to anyfile, then we are done.
blockLog.debug("BLOCK* addStoredBlock: {} on {} size {} but it does not" + if(blockLog.isDebugEnabled()) {
" belong to any file", block, node, block.getNumBytes()); blockLog.debug("BLOCK* addStoredBlock: {} on {} size {} but it does not" +
" belong to any file", block, node, block.getNumBytes());
}
// we could add this block to invalidate set of this datanode. // we could add this block to invalidate set of this datanode.
// it will happen in next block report otherwise. // it will happen in next block report otherwise.
@ -3605,9 +3621,11 @@ public class BlockManager implements BlockStatsMXBean {
corruptReplicas.removeFromCorruptReplicasMap(block, node, corruptReplicas.removeFromCorruptReplicasMap(block, node,
Reason.GENSTAMP_MISMATCH); Reason.GENSTAMP_MISMATCH);
curReplicaDelta = 0; curReplicaDelta = 0;
blockLog.debug("BLOCK* addStoredBlock: Redundant addStoredBlock request" if(blockLog.isDebugEnabled()) {
+ " received for {} on node {} size {}", storedBlock, node, blockLog.debug("BLOCK* addStoredBlock: Redundant addStoredBlock request"
storedBlock.getNumBytes()); + " received for {} on node {} size {}", storedBlock, node,
storedBlock.getNumBytes());
}
} }
// Now check for completion of blocks and safe block count // Now check for completion of blocks and safe block count
@ -3708,8 +3726,10 @@ public class BlockManager implements BlockStatsMXBean {
removedFromBlocksMap = false; removedFromBlocksMap = false;
} }
} catch (IOException e) { } catch (IOException e) {
blockLog.debug("invalidateCorruptReplicas error in deleting bad block" if(blockLog.isDebugEnabled()) {
+ " {} on {}", blk, node, e); blockLog.debug("invalidateCorruptReplicas error in deleting bad block"
+ " {} on {}", blk, node, e);
}
removedFromBlocksMap = false; removedFromBlocksMap = false;
} }
} }
@ -4158,8 +4178,10 @@ public class BlockManager implements BlockStatsMXBean {
// //
final Block blockToInvalidate = getBlockOnStorage(storedBlock, chosen); final Block blockToInvalidate = getBlockOnStorage(storedBlock, chosen);
addToInvalidates(blockToInvalidate, chosen.getDatanodeDescriptor()); addToInvalidates(blockToInvalidate, chosen.getDatanodeDescriptor());
blockLog.debug("BLOCK* chooseExcessRedundancies: " if(blockLog.isDebugEnabled()) {
+ "({}, {}) is added to invalidated blocks set", chosen, storedBlock); blockLog.debug("BLOCK* chooseExcessRedundancies: "
+ "({}, {}) is added to invalidated blocks set", chosen, storedBlock);
}
} }
private void removeStoredBlock(DatanodeStorageInfo storageInfo, Block block, private void removeStoredBlock(DatanodeStorageInfo storageInfo, Block block,
@ -4220,8 +4242,7 @@ public class BlockManager implements BlockStatsMXBean {
for (ReplicaUnderConstruction r : staleReplicas) { for (ReplicaUnderConstruction r : staleReplicas) {
removeStoredBlock(block, removeStoredBlock(block,
r.getExpectedStorageLocation().getDatanodeDescriptor()); r.getExpectedStorageLocation().getDatanodeDescriptor());
NameNode.blockStateChangeLog blockLog.debug("BLOCK* Removing stale replica {} of {}", r,
.debug("BLOCK* Removing stale replica {}" + " of {}", r,
Block.toString(r)); Block.toString(r));
} }
} }
@ -4350,8 +4371,10 @@ public class BlockManager implements BlockStatsMXBean {
maxNumBlocksToLog, numBlocksLogged); maxNumBlocksToLog, numBlocksLogged);
} }
for (Block b : toInvalidate) { for (Block b : toInvalidate) {
blockLog.debug("BLOCK* addBlock: block {} on node {} size {} does not " + if(blockLog.isDebugEnabled()) {
"belong to any file", b, node, b.getNumBytes()); blockLog.debug("BLOCK* addBlock: block {} on node {} size {} does not " +
"belong to any file", b, node, b.getNumBytes());
}
addToInvalidates(b, node); addToInvalidates(b, node);
} }
for (BlockToMarkCorrupt b : toCorrupt) { for (BlockToMarkCorrupt b : toCorrupt) {
@ -4432,9 +4455,11 @@ public class BlockManager implements BlockStatsMXBean {
blockLog.debug("BLOCK* block {}: {} is received from {}", blockLog.debug("BLOCK* block {}: {} is received from {}",
rdbi.getStatus(), rdbi.getBlock(), node); rdbi.getStatus(), rdbi.getBlock(), node);
} }
blockLog.debug("*BLOCK* NameNode.processIncrementalBlockReport: from " if(blockLog.isDebugEnabled()) {
+ "{} receiving: {}, received: {}, deleted: {}", node, receiving, blockLog.debug("*BLOCK* NameNode.processIncrementalBlockReport: from "
received, deleted); + "{} receiving: {}, received: {}, deleted: {}", node, receiving,
received, deleted);
}
} }
/** /**