HADOOP-10953. NetworkTopology#add calls NetworkTopology#toString without holding the netlock (Liang Xie via Colin P. McCabe)

(cherry picked from commit 6338ce3ae8)
This commit is contained in:
Colin Patrick Mccabe 2015-02-10 13:24:40 -08:00
parent ca11ffa5de
commit 5e7deba1f4
2 changed files with 8 additions and 5 deletions

View File

@ -508,6 +508,9 @@ Release 2.7.0 - UNRELEASED
HADOOP-11535 TableMapping related tests failed due to 'successful'
resolving of invalid test hostname. (Kai Zheng via stevel)
HADOOP-10953. NetworkTopology#add calls NetworkTopology#toString without
holding the netlock (Liang Xie via Colin P. McCabe)
Release 2.6.1 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -394,14 +394,14 @@ public class NetworkTopology {
*/
public void add(Node node) {
if (node==null) return;
String oldTopoStr = this.toString();
if( node instanceof InnerNode ) {
throw new IllegalArgumentException(
"Not allow to add an inner node: "+NodeBase.getPath(node));
}
int newDepth = NodeBase.locationToDepth(node.getNetworkLocation()) + 1;
netlock.writeLock().lock();
try {
String oldTopoStr = this.toString();
if( node instanceof InnerNode ) {
throw new IllegalArgumentException(
"Not allow to add an inner node: "+NodeBase.getPath(node));
}
if ((depthOfAllLeaves != -1) && (depthOfAllLeaves != newDepth)) {
LOG.error("Error: can't add leaf node " + NodeBase.getPath(node) +
" at depth " + newDepth + " to topology:\n" + oldTopoStr);