HDFS-5501. Fix pendingReceivedRequests tracking in BPServiceActor.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-2832@1541371 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Arpit Agarwal 2013-11-13 02:59:46 +00:00
parent 46cbce9af1
commit d06a782c1e
2 changed files with 14 additions and 7 deletions

View File

@ -101,3 +101,6 @@ IMPROVEMENTS:
HDFS-5508. Fix compilation error after merge. (Contributed by szetszwo) HDFS-5508. Fix compilation error after merge. (Contributed by szetszwo)
HDFS-5501. Fix pendingReceivedRequests tracking in BPServiceActor. (Arpit
Agarwal)

View File

@ -280,13 +280,14 @@ class BPServiceActor implements Runnable {
pendingIncrementalBRperStorage.entrySet()) { pendingIncrementalBRperStorage.entrySet()) {
final String storageUuid = entry.getKey(); final String storageUuid = entry.getKey();
final PerStoragePendingIncrementalBR perStorageMap = entry.getValue(); final PerStoragePendingIncrementalBR perStorageMap = entry.getValue();
ReceivedDeletedBlockInfo[] receivedAndDeletedBlockArray = null;
if (perStorageMap.getBlockInfoCount() > 0) { if (perStorageMap.getBlockInfoCount() > 0) {
// Send newly-received and deleted blockids to namenode // Send newly-received and deleted blockids to namenode
receivedAndDeletedBlockArray = perStorageMap.dequeueBlockInfos(); ReceivedDeletedBlockInfo[] rdbi = perStorageMap.dequeueBlockInfos();
pendingReceivedRequests -= receivedAndDeletedBlockArray.length; pendingReceivedRequests =
blockArrays.put(storageUuid, receivedAndDeletedBlockArray); (pendingReceivedRequests > rdbi.length ?
(pendingReceivedRequests - rdbi.length) : 0);
blockArrays.put(storageUuid, rdbi);
} }
} }
} }
@ -312,8 +313,7 @@ class BPServiceActor implements Runnable {
// didn't put something newer in the meantime. // didn't put something newer in the meantime.
PerStoragePendingIncrementalBR perStorageMap = PerStoragePendingIncrementalBR perStorageMap =
pendingIncrementalBRperStorage.get(storageUuid); pendingIncrementalBRperStorage.get(storageUuid);
perStorageMap.putMissingBlockInfos(rdbi); pendingReceivedRequests += perStorageMap.putMissingBlockInfos(rdbi);
pendingReceivedRequests += perStorageMap.getBlockInfoCount();
} }
} }
} }
@ -859,13 +859,17 @@ class BPServiceActor implements Runnable {
* Add blocks from blockArray to pendingIncrementalBR, unless the * Add blocks from blockArray to pendingIncrementalBR, unless the
* block already exists in pendingIncrementalBR. * block already exists in pendingIncrementalBR.
* @param blockArray list of blocks to add. * @param blockArray list of blocks to add.
* @return the number of missing blocks that we added.
*/ */
void putMissingBlockInfos(ReceivedDeletedBlockInfo[] blockArray) { int putMissingBlockInfos(ReceivedDeletedBlockInfo[] blockArray) {
int blocksPut = 0;
for (ReceivedDeletedBlockInfo rdbi : blockArray) { for (ReceivedDeletedBlockInfo rdbi : blockArray) {
if (!pendingIncrementalBR.containsKey(rdbi.getBlock().getBlockId())) { if (!pendingIncrementalBR.containsKey(rdbi.getBlock().getBlockId())) {
pendingIncrementalBR.put(rdbi.getBlock().getBlockId(), rdbi); pendingIncrementalBR.put(rdbi.getBlock().getBlockId(), rdbi);
++blocksPut;
} }
} }
return blocksPut;
} }
/** /**