From 9d382a41743831fbcfecd302ead02095f36b7f59 Mon Sep 17 00:00:00 2001 From: Arpit Agarwal Date: Sat, 11 Jan 2014 00:05:55 +0000 Subject: [PATCH] HDFS-5747. Fix NPEs in BlockManager. (Arpit Agarwal) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1557289 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../blockmanagement/BlockInfoUnderConstruction.java | 8 +++++--- .../org/apache/hadoop/hdfs/server/namenode/NameNode.java | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index d1fd8ba7c9..af95486f1e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -744,6 +744,8 @@ Release 2.4.0 - UNRELEASED HDFS-5756. hadoopRzOptionsSetByteBufferPool does not accept NULL argument, contrary to docs. (cmccabe via wang) + HDFS-5747. Fix NPEs in BlockManager. (Arpit Agarwal) + BREAKDOWN OF HDFS-2832 SUBTASKS AND RELATED JIRAS HDFS-4985. Add storage type to the protocol and expose it in block report diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfoUnderConstruction.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfoUnderConstruction.java index 54e560ddeb..1161077f49 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfoUnderConstruction.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockInfoUnderConstruction.java @@ -324,12 +324,14 @@ void addReplicaIfNotPresent(DatanodeStorageInfo storage, Iterator it = replicas.iterator(); while (it.hasNext()) { ReplicaUnderConstruction r = it.next(); - if(r.getExpectedStorageLocation() == storage) { + DatanodeStorageInfo expectedLocation = r.getExpectedStorageLocation(); + if(expectedLocation == storage) { // Record the gen stamp from the report r.setGenerationStamp(block.getGenerationStamp()); return; - } else if (r.getExpectedStorageLocation().getDatanodeDescriptor() == - storage.getDatanodeDescriptor()) { + } else if (expectedLocation != null && + expectedLocation.getDatanodeDescriptor() == + storage.getDatanodeDescriptor()) { // The Datanode reported that the block is on a different storage // than the one chosen by BlockPlacementPolicy. This can occur as diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java index 12e26f1fdb..eb3755bdc4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java @@ -547,8 +547,8 @@ private void startCommonServices(Configuration conf) throws IOException { } private void stopCommonServices() { - if(namesystem != null) namesystem.close(); if(rpcServer != null) rpcServer.stop(); + if(namesystem != null) namesystem.close(); if (pauseMonitor != null) pauseMonitor.stop(); if (plugins != null) { for (ServicePlugin p : plugins) {