From aa9f0850e85203b2ce4f4a8dc8968e9186cdc67a Mon Sep 17 00:00:00 2001 From: Inigo Goiri Date: Tue, 2 Jul 2019 13:22:30 -0700 Subject: [PATCH] HADOOP-16385. Namenode crashes with 'RedundancyMonitor thread received Runtime exception'. Contributed by Ayush Saxena. --- .../main/java/org/apache/hadoop/net/NetworkTopology.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java index 053c95972c..6fc4acc941 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java @@ -569,10 +569,11 @@ protected Node chooseRandom(final String scope, String excludedScope, private Node chooseRandom(final InnerNode parentNode, final Node excludedScopeNode, final Collection excludedNodes, final int totalInScopeNodes, final int availableNodes) { - Preconditions.checkArgument( - totalInScopeNodes >= availableNodes && availableNodes > 0, String - .format("%d should >= %d, and both should be positive.", - totalInScopeNodes, availableNodes)); + if (totalInScopeNodes < availableNodes) { + LOG.warn("Total Nodes in scope : {} are less than Available Nodes : {}", + totalInScopeNodes, availableNodes); + return null; + } if (excludedNodes == null || excludedNodes.isEmpty()) { // if there are no excludedNodes, randomly choose a node final int index = r.nextInt(totalInScopeNodes);