From 1d357365b7f01ec783a8b2a10d270ad33267018e Mon Sep 17 00:00:00 2001 From: Arpit Agarwal Date: Mon, 4 Nov 2013 21:47:51 +0000 Subject: [PATCH] HDFS-5455. NN should update storageMap on first heartbeat. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-2832@1538787 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-hdfs/CHANGES_HDFS-2832.txt | 2 ++ .../blockmanagement/DatanodeDescriptor.java | 22 +++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-2832.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-2832.txt index b80fff3fc5..ffeb3155e0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-2832.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES_HDFS-2832.txt @@ -68,3 +68,5 @@ IMPROVEMENTS: HDFS-5448. Fix break caused by previous checkin for HDFS-5448. (Arpit Agarwal) + HDFS-5455. NN should update storageMap on first heartbeat. (Arpit Agarwal) + diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeDescriptor.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeDescriptor.java index 3153dd0b17..ad499912c2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeDescriptor.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeDescriptor.java @@ -350,18 +350,16 @@ public void updateHeartbeat(StorageReport[] reports, long cacheCapacity, this.volumeFailures = volFailures; for (StorageReport report : reports) { DatanodeStorageInfo storage = storageMap.get(report.getStorageID()); - if (storage != null) { - storage.receivedHeartbeat(report); - totalCapacity += report.getCapacity(); - totalRemaining += report.getRemaining(); - totalBlockPoolUsed += report.getBlockPoolUsed(); - totalDfsUsed += report.getDfsUsed(); - } else { - // This warning is generally benign during cluster initialization - // when the heartbeat is received before the initial block reports - // from each storage. - LOG.warn("Unrecognized storage ID " + report.getStorageID()); + if (storage == null) { + // This is seen during cluster initialization when the heartbeat + // is received before the initial block reports from each storage. + storage = updateStorage(new DatanodeStorage(report.getStorageID())); } + storage.receivedHeartbeat(report); + totalCapacity += report.getCapacity(); + totalRemaining += report.getRemaining(); + totalBlockPoolUsed += report.getBlockPoolUsed(); + totalDfsUsed += report.getDfsUsed(); } rollBlocksScheduled(getLastUpdate()); @@ -651,6 +649,8 @@ public DatanodeStorageInfo updateStorage(DatanodeStorage s) { synchronized (storageMap) { DatanodeStorageInfo storage = storageMap.get(s.getStorageID()); if (storage == null) { + LOG.info("Adding new storage ID " + s.getStorageID() + + " for DN " + getXferAddr()); storage = new DatanodeStorageInfo(this, s); storageMap.put(s.getStorageID(), storage); } else {