You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "ZanderXu (Jira)" <ji...@apache.org> on 2022/05/16 03:35:00 UTC

[jira] [Created] (HADOOP-18236) Remove duplicate locks in NetworkTopology

ZanderXu created HADOOP-18236:
---------------------------------

             Summary: Remove duplicate locks in NetworkTopology
                 Key: HADOOP-18236
                 URL: https://issues.apache.org/jira/browse/HADOOP-18236
             Project: Hadoop Common
          Issue Type: Improvement
            Reporter: ZanderXu
            Assignee: ZanderXu


During reading the hadoop NetworkTopology.java, I suspect there is a duplicate lock.

chooseRandom(line 532), and code is:
{code:java}
final int availableNodes;
if (excludedScope == null) {
  availableNodes = countNumOfAvailableNodes(scope, excludedNodes);
} else {
  netlock.readLock().lock();
  try {
    availableNodes = countNumOfAvailableNodes(scope, excludedNodes) -
        countNumOfAvailableNodes(excludedScope, excludedNodes);
  } finally {
    netlock.readLock().unlock();
  }
} {code}
All the places where called `chooseRandom` have the global read lock, so the internal read lock is duplicated.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-dev-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-dev-help@hadoop.apache.org