HDFS-13703. Avoid allocation of CorruptedBlocks hashmap when no corrupted blocks are hit. Contributed by Todd Lipcon.
This commit is contained in:
parent
d40121845e
commit
6ba9974108
@ -1423,7 +1423,7 @@ protected void reportCheckSumFailure(CorruptedBlocks corruptedBlocks,
|
||||
|
||||
Map<ExtendedBlock, Set<DatanodeInfo>> corruptedBlockMap =
|
||||
corruptedBlocks.getCorruptionMap();
|
||||
if (corruptedBlockMap.isEmpty()) {
|
||||
if (corruptedBlockMap == null) {
|
||||
return;
|
||||
}
|
||||
List<LocatedBlock> reportList = new ArrayList<>(corruptedBlockMap.size());
|
||||
|
@ -751,14 +751,14 @@ public static InterruptedIOException toInterruptedIOException(String message,
|
||||
public static class CorruptedBlocks {
|
||||
private Map<ExtendedBlock, Set<DatanodeInfo>> corruptionMap;
|
||||
|
||||
public CorruptedBlocks() {
|
||||
this.corruptionMap = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate a block replica on the specified datanode is corrupted
|
||||
*/
|
||||
public void addCorruptedBlock(ExtendedBlock blk, DatanodeInfo node) {
|
||||
if (corruptionMap == null) {
|
||||
corruptionMap = new HashMap<>();
|
||||
}
|
||||
|
||||
Set<DatanodeInfo> dnSet = corruptionMap.get(blk);
|
||||
if (dnSet == null) {
|
||||
dnSet = new HashSet<>();
|
||||
@ -770,7 +770,8 @@ public void addCorruptedBlock(ExtendedBlock blk, DatanodeInfo node) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the map that contains all the corruption entries.
|
||||
* @return the map that contains all the corruption entries, or null if
|
||||
* there were no corrupted entries
|
||||
*/
|
||||
public Map<ExtendedBlock, Set<DatanodeInfo>> getCorruptionMap() {
|
||||
return corruptionMap;
|
||||
|
@ -1278,7 +1278,7 @@ public void reportCorruptedBlocks(
|
||||
DFSUtilClient.CorruptedBlocks corruptedBlocks) throws IOException {
|
||||
Map<ExtendedBlock, Set<DatanodeInfo>> corruptionMap =
|
||||
corruptedBlocks.getCorruptionMap();
|
||||
if (!corruptionMap.isEmpty()) {
|
||||
if (corruptionMap != null) {
|
||||
for (Map.Entry<ExtendedBlock, Set<DatanodeInfo>> entry :
|
||||
corruptionMap.entrySet()) {
|
||||
for (DatanodeInfo dnInfo : entry.getValue()) {
|
||||
|
Loading…
Reference in New Issue
Block a user