From d06a782c1e4243e36b486f66e66cdcc91ec6e275 Mon Sep 17 00:00:00 2001 From: Arpit Agarwal Date: Wed, 13 Nov 2013 02:59:46 +0000 Subject: [PATCH] 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 --- .../hadoop-hdfs/CHANGES_HDFS-2832.txt | 3 +++ .../hdfs/server/datanode/BPServiceActor.java | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-2832.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-2832.txt index 1e33fa0e0a8..485f782c7fd 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-2832.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-2832.txt @@ -101,3 +101,6 @@ IMPROVEMENTS: HDFS-5508. Fix compilation error after merge. (Contributed by szetszwo) + HDFS-5501. Fix pendingReceivedRequests tracking in BPServiceActor. (Arpit + Agarwal) + diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java index a10768c3d27..81cf5f79fcf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java @@ -280,13 +280,14 @@ class BPServiceActor implements Runnable { pendingIncrementalBRperStorage.entrySet()) { final String storageUuid = entry.getKey(); final PerStoragePendingIncrementalBR perStorageMap = entry.getValue(); - ReceivedDeletedBlockInfo[] receivedAndDeletedBlockArray = null; if (perStorageMap.getBlockInfoCount() > 0) { // Send newly-received and deleted blockids to namenode - receivedAndDeletedBlockArray = perStorageMap.dequeueBlockInfos(); - pendingReceivedRequests -= receivedAndDeletedBlockArray.length; - blockArrays.put(storageUuid, receivedAndDeletedBlockArray); + ReceivedDeletedBlockInfo[] rdbi = perStorageMap.dequeueBlockInfos(); + pendingReceivedRequests = + (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. PerStoragePendingIncrementalBR perStorageMap = pendingIncrementalBRperStorage.get(storageUuid); - perStorageMap.putMissingBlockInfos(rdbi); - pendingReceivedRequests += perStorageMap.getBlockInfoCount(); + pendingReceivedRequests += perStorageMap.putMissingBlockInfos(rdbi); } } } @@ -859,13 +859,17 @@ class BPServiceActor implements Runnable { * Add blocks from blockArray to pendingIncrementalBR, unless the * block already exists in pendingIncrementalBR. * @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) { if (!pendingIncrementalBR.containsKey(rdbi.getBlock().getBlockId())) { pendingIncrementalBR.put(rdbi.getBlock().getBlockId(), rdbi); + ++blocksPut; } } + return blocksPut; } /**