From b3f28dbb3d1ab6b2f686efdd7bdb064426177f21 Mon Sep 17 00:00:00 2001 From: Todd Lipcon Date: Mon, 5 Dec 2011 06:36:00 +0000 Subject: [PATCH] HDFS-2626. BPOfferService.verifyAndSetNamespaceInfo needs to be synchronized. Contributed by Todd Lipcon. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1210340 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt | 2 ++ .../apache/hadoop/hdfs/server/datanode/BPOfferService.java | 2 +- .../apache/hadoop/hdfs/server/datanode/BPServiceActor.java | 4 +--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt index 6c932936712..d5f4d0d7f79 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt @@ -39,3 +39,5 @@ HDFS-2622. Fix TestDFSUpgrade in HA branch. (todd) HDFS-2612. Handle refreshNameNodes in federated HA clusters (todd) HDFS-2623. Add test case for hot standby capability (todd) + +HDFS-2626. BPOfferService.verifyAndSetNamespaceInfo needs to be synchronized (todd) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java index 62b825be56f..eb611bffcb0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java @@ -262,7 +262,7 @@ DataNode getDataNode() { * verifies that this namespace matches (eg to prevent a misconfiguration * where a StandbyNode from a different cluster is specified) */ - void verifyAndSetNamespaceInfo(NamespaceInfo nsInfo) throws IOException { + synchronized void verifyAndSetNamespaceInfo(NamespaceInfo nsInfo) throws IOException { if (this.bpNSInfo == null) { this.bpNSInfo = nsInfo; 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 e83ec99c1ac..bf49cc0a6b9 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 @@ -336,8 +336,6 @@ DatanodeCommand blockReport() throws IOException { HeartbeatResponse sendHeartBeat() throws IOException { LOG.info("heartbeat: " + this); - // TODO: saw an NPE here - maybe if the two BPOS register at - // same time, this one won't block on the other one? return bpNamenode.sendHeartbeat(bpRegistration, dn.getFSDataset().getCapacity(), dn.getFSDataset().getDfsUsed(), @@ -632,4 +630,4 @@ void reRegister() throws IOException { } } -} \ No newline at end of file +}