HDFS-4030. BlockManager excessBlocksCount and postponedMisreplicatedBlocksCount should be AtomicLongs. Contributed by Eli Collins

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1430549 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2013-01-08 21:37:46 +00:00
parent ecf8c442f4
commit 99a64115ce
2 changed files with 14 additions and 11 deletions

View File

@ -161,6 +161,9 @@ Release 2.0.3-alpha - Unreleased
HADOOP-9173. Add security token protobuf definition to common and HADOOP-9173. Add security token protobuf definition to common and
use it in hdfs. (suresh) use it in hdfs. (suresh)
HDFS-4030. BlockManager excessBlocksCount and
postponedMisreplicatedBlocksCount should be AtomicLongs. (eli)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -33,7 +33,7 @@ import java.util.Map;
import java.util.Queue; import java.util.Queue;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.TreeSet; import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -108,8 +108,8 @@ public class BlockManager {
private volatile long corruptReplicaBlocksCount = 0L; private volatile long corruptReplicaBlocksCount = 0L;
private volatile long underReplicatedBlocksCount = 0L; private volatile long underReplicatedBlocksCount = 0L;
private volatile long scheduledReplicationBlocksCount = 0L; private volatile long scheduledReplicationBlocksCount = 0L;
private volatile long excessBlocksCount = 0L; private AtomicLong excessBlocksCount = new AtomicLong(0L);
private volatile long postponedMisreplicatedBlocksCount = 0L; private AtomicLong postponedMisreplicatedBlocksCount = new AtomicLong(0L);
/** Used by metrics */ /** Used by metrics */
public long getPendingReplicationBlocksCount() { public long getPendingReplicationBlocksCount() {
@ -133,11 +133,11 @@ public class BlockManager {
} }
/** Used by metrics */ /** Used by metrics */
public long getExcessBlocksCount() { public long getExcessBlocksCount() {
return excessBlocksCount; return excessBlocksCount.get();
} }
/** Used by metrics */ /** Used by metrics */
public long getPostponedMisreplicatedBlocksCount() { public long getPostponedMisreplicatedBlocksCount() {
return postponedMisreplicatedBlocksCount; return postponedMisreplicatedBlocksCount.get();
} }
/** Used by metrics */ /** Used by metrics */
public int getPendingDataNodeMessageCount() { public int getPendingDataNodeMessageCount() {
@ -1067,7 +1067,7 @@ public class BlockManager {
private void postponeBlock(Block blk) { private void postponeBlock(Block blk) {
if (postponedMisreplicatedBlocks.add(blk)) { if (postponedMisreplicatedBlocks.add(blk)) {
postponedMisreplicatedBlocksCount++; postponedMisreplicatedBlocksCount.incrementAndGet();
} }
} }
@ -1599,7 +1599,7 @@ public class BlockManager {
"in block map."); "in block map.");
} }
it.remove(); it.remove();
postponedMisreplicatedBlocksCount--; postponedMisreplicatedBlocksCount.decrementAndGet();
continue; continue;
} }
MisReplicationResult res = processMisReplicatedBlock(bi); MisReplicationResult res = processMisReplicatedBlock(bi);
@ -1609,7 +1609,7 @@ public class BlockManager {
} }
if (res != MisReplicationResult.POSTPONE) { if (res != MisReplicationResult.POSTPONE) {
it.remove(); it.remove();
postponedMisreplicatedBlocksCount--; postponedMisreplicatedBlocksCount.decrementAndGet();
} }
} }
} }
@ -2474,7 +2474,7 @@ assert storedBlock.findDatanode(dn) < 0 : "Block " + block
excessReplicateMap.put(dn.getStorageID(), excessBlocks); excessReplicateMap.put(dn.getStorageID(), excessBlocks);
} }
if (excessBlocks.add(block)) { if (excessBlocks.add(block)) {
excessBlocksCount++; excessBlocksCount.incrementAndGet();
if(blockLog.isDebugEnabled()) { if(blockLog.isDebugEnabled()) {
blockLog.debug("BLOCK* addToExcessReplicate:" blockLog.debug("BLOCK* addToExcessReplicate:"
+ " (" + dn + ", " + block + " (" + dn + ", " + block
@ -2522,7 +2522,7 @@ assert storedBlock.findDatanode(dn) < 0 : "Block " + block
.getStorageID()); .getStorageID());
if (excessBlocks != null) { if (excessBlocks != null) {
if (excessBlocks.remove(block)) { if (excessBlocks.remove(block)) {
excessBlocksCount--; excessBlocksCount.decrementAndGet();
if(blockLog.isDebugEnabled()) { if(blockLog.isDebugEnabled()) {
blockLog.debug("BLOCK* removeStoredBlock: " blockLog.debug("BLOCK* removeStoredBlock: "
+ block + " is removed from excessBlocks"); + block + " is removed from excessBlocks");
@ -2867,7 +2867,7 @@ assert storedBlock.findDatanode(dn) < 0 : "Block " + block
// Remove the block from pendingReplications // Remove the block from pendingReplications
pendingReplications.remove(block); pendingReplications.remove(block);
if (postponedMisreplicatedBlocks.remove(block)) { if (postponedMisreplicatedBlocks.remove(block)) {
postponedMisreplicatedBlocksCount--; postponedMisreplicatedBlocksCount.decrementAndGet();
} }
} }