소스 검색

HADOOP-3300. Fix locking of explicit locks in NetworkTopology. Contributed by
Tom White.


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@651045 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 17 년 전
부모
커밋
845599bb94
2개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 0
      CHANGES.txt
  2. 2 2
      src/java/org/apache/hadoop/net/NetworkTopology.java

+ 3 - 0
CHANGES.txt

@@ -71,6 +71,9 @@ Trunk (unreleased changes)
     HADOOP-3127. Deleting files in trash should really remove them.
     HADOOP-3127. Deleting files in trash should really remove them.
     (Brice Arnould via omalley)
     (Brice Arnould via omalley)
 
 
+    HADOOP-3300. Fix locking of explicit locks in NetworkTopology.
+    (tomwhite via omalley)
+
 Release 0.17.0 - Unreleased
 Release 0.17.0 - Unreleased
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 2 - 2
src/java/org/apache/hadoop/net/NetworkTopology.java

@@ -317,8 +317,8 @@ public class NetworkTopology {
       throw new IllegalArgumentException(
       throw new IllegalArgumentException(
         "Not allow to add an inner node: "+NodeBase.getPath(node));
         "Not allow to add an inner node: "+NodeBase.getPath(node));
     }
     }
-    netlock.writeLock().lock();
     LOG.info("Adding a new node: "+NodeBase.getPath(node));
     LOG.info("Adding a new node: "+NodeBase.getPath(node));
+    netlock.writeLock().lock();
     try {
     try {
       Node rack = getNode(node.getNetworkLocation());
       Node rack = getNode(node.getNetworkLocation());
       if (rack != null && !(rack instanceof InnerNode)) {
       if (rack != null && !(rack instanceof InnerNode)) {
@@ -344,12 +344,12 @@ public class NetworkTopology {
    */ 
    */ 
   public void remove(Node node) {
   public void remove(Node node) {
     if (node==null) return;
     if (node==null) return;
-    netlock.writeLock().lock();
     if( node instanceof InnerNode ) {
     if( node instanceof InnerNode ) {
       throw new IllegalArgumentException(
       throw new IllegalArgumentException(
         "Not allow to remove an inner node: "+NodeBase.getPath(node));
         "Not allow to remove an inner node: "+NodeBase.getPath(node));
     }
     }
     LOG.info("Removing a node: "+NodeBase.getPath(node));
     LOG.info("Removing a node: "+NodeBase.getPath(node));
+    netlock.writeLock().lock();
     try {
     try {
       if (clusterMap.remove(node)) {
       if (clusterMap.remove(node)) {
         InnerNode rack = (InnerNode)getNode(node.getNetworkLocation());
         InnerNode rack = (InnerNode)getNode(node.getNetworkLocation());