From a7830423c578d2909112f90aedf3d9aefeabc9c2 Mon Sep 17 00:00:00 2001 From: He Xiaoqiao Date: Mon, 24 Aug 2020 21:13:47 +0800 Subject: [PATCH] HDFS-15448. Remove duplicate BlockPoolManager starting when run DataNode. Contriubted by jianghua zhu. --- .../apache/hadoop/hdfs/server/datanode/DataNode.java | 6 +++++- .../hadoop/hdfs/server/datanode/TestDataNodeExit.java | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java index 7f740c39d8..36ec1f4ace 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java @@ -2710,7 +2710,11 @@ void closeBlock(ExtendedBlock block, String delHint, String storageUuid, * If this thread is specifically interrupted, it will stop waiting. */ public void runDatanodeDaemon() throws IOException { - blockPoolManager.startAll(); + + // Verify that blockPoolManager has been started. + if (!isDatanodeUp()) { + throw new IOException("Failed to instantiate DataNode."); + } // start dataXceiveServer dataXceiverServer.start(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeExit.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeExit.java index 918ad83bbd..8c2fe37a58 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeExit.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeExit.java @@ -82,6 +82,17 @@ private void stopBPServiceThreads(int numStopThreads, DataNode dn) dn.getBpOsCount()); } + @Test + public void testBPServiceState() { + List dataNodes = cluster.getDataNodes(); + for (DataNode dataNode : dataNodes) { + List bposList = dataNode.getAllBpOs(); + for (BPOfferService bpOfferService : bposList) { + assertTrue(bpOfferService.isAlive()); + } + } + } + /** * Test BPService Thread Exit */