From 0be0f1ce1da984ff3a8fd4b079297ead2dc6722d Mon Sep 17 00:00:00 2001 From: Xiaoyu Yao Date: Wed, 14 Mar 2018 10:38:00 -0700 Subject: [PATCH] HDFS-13275. Adding log for BlockPoolManager#refreshNamenodes failures. Contributed by Ajay Kumar. --- .../server/datanode/BlockPoolManager.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java index 141550ef3b..b03c51120a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java @@ -146,13 +146,25 @@ void joinAll() { void refreshNamenodes(Configuration conf) throws IOException { - LOG.info("Refresh request received for nameservices: " + conf.get - (DFSConfigKeys.DFS_NAMESERVICES)); + LOG.info("Refresh request received for nameservices: " + + conf.get(DFSConfigKeys.DFS_NAMESERVICES)); - Map> newAddressMap = DFSUtil - .getNNServiceRpcAddressesForCluster(conf); - Map> newLifelineAddressMap = DFSUtil - .getNNLifelineRpcAddressesForCluster(conf); + Map> newAddressMap = null; + Map> newLifelineAddressMap = null; + + try { + newAddressMap = + DFSUtil.getNNServiceRpcAddressesForCluster(conf); + newLifelineAddressMap = + DFSUtil.getNNLifelineRpcAddressesForCluster(conf); + } catch (IOException ioe) { + LOG.warn("Unable to get NameNode addresses."); + } + + if (newAddressMap == null || newAddressMap.isEmpty()) { + throw new IOException("No services to connect, missing NameNode " + + "address."); + } synchronized (refreshNamenodesLock) { doRefreshNamenodes(newAddressMap, newLifelineAddressMap);