HADOOP-16385. Namenode crashes with 'RedundancyMonitor thread received Runtime exception'. Contributed by Ayush Saxena.

This commit is contained in:
Inigo Goiri 2019-07-02 13:22:30 -07:00
parent 564758ae8d
commit aa9f0850e8

View File

@ -569,10 +569,11 @@ protected Node chooseRandom(final String scope, String excludedScope,
private Node chooseRandom(final InnerNode parentNode, private Node chooseRandom(final InnerNode parentNode,
final Node excludedScopeNode, final Collection<Node> excludedNodes, final Node excludedScopeNode, final Collection<Node> excludedNodes,
final int totalInScopeNodes, final int availableNodes) { final int totalInScopeNodes, final int availableNodes) {
Preconditions.checkArgument( if (totalInScopeNodes < availableNodes) {
totalInScopeNodes >= availableNodes && availableNodes > 0, String LOG.warn("Total Nodes in scope : {} are less than Available Nodes : {}",
.format("%d should >= %d, and both should be positive.", totalInScopeNodes, availableNodes);
totalInScopeNodes, availableNodes)); return null;
}
if (excludedNodes == null || excludedNodes.isEmpty()) { if (excludedNodes == null || excludedNodes.isEmpty()) {
// if there are no excludedNodes, randomly choose a node // if there are no excludedNodes, randomly choose a node
final int index = r.nextInt(totalInScopeNodes); final int index = r.nextInt(totalInScopeNodes);