[09/50] [abbrv] hadoop git commit: HDFS-10320. Rack failures may result in NN terminate. (Xiao Chen via mingma)
HDFS-10320. Rack failures may result in NN terminate. (Xiao Chen via mingma) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/1268cf5f Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1268cf5f Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1268cf5f Branch: refs/heads/YARN-3368 Commit: 1268cf5fbe4458fa75ad0662512d352f9e8d3470 Parents: 9e37fe3 Author: Ming MaAuthored: Wed May 4 17:02:26 2016 -0700 Committer: Ming Ma Committed: Wed May 4 17:02:26 2016 -0700 -- .../org/apache/hadoop/net/NetworkTopology.java | 109 +-- .../AvailableSpaceBlockPlacementPolicy.java | 11 +- .../BlockPlacementPolicyDefault.java| 84 +++--- .../web/resources/NamenodeWebHdfsMethods.java | 13 +-- .../apache/hadoop/net/TestNetworkTopology.java | 75 - 5 files changed, 196 insertions(+), 96 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/1268cf5f/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java -- 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 e1d2968..1e23ff6 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 @@ -29,13 +29,13 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.google.common.annotations.VisibleForTesting; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.util.ReflectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; @@ -54,8 +54,8 @@ import com.google.common.collect.Lists; public class NetworkTopology { public final static String DEFAULT_RACK = "/default-rack"; public final static int DEFAULT_HOST_LEVEL = 2; - public static final Log LOG = -LogFactory.getLog(NetworkTopology.class); + public static final Logger LOG = + LoggerFactory.getLogger(NetworkTopology.class); public static class InvalidTopologyException extends RuntimeException { private static final long serialVersionUID = 1L; @@ -442,9 +442,7 @@ public class NetworkTopology { } } } - if(LOG.isDebugEnabled()) { -LOG.debug("NetworkTopology became:\n" + this.toString()); - } + LOG.debug("NetworkTopology became:\n{}", this.toString()); } finally { netlock.writeLock().unlock(); } @@ -517,9 +515,7 @@ public class NetworkTopology { numOfRacks--; } } - if(LOG.isDebugEnabled()) { -LOG.debug("NetworkTopology became:\n" + this.toString()); - } + LOG.debug("NetworkTopology became:\n{}", this.toString()); } finally { netlock.writeLock().unlock(); } @@ -717,26 +713,45 @@ public class NetworkTopology { r.setSeed(seed); } - /** randomly choose one node from scope - * if scope starts with ~, choose one from the all nodes except for the - * ones in scope; otherwise, choose one from scope + /** + * Randomly choose a node. + * * @param scope range of nodes from which a node will be chosen * @return the chosen node + * + * @see #chooseRandom(String, Collection) */ - public Node chooseRandom(String scope) { + public Node chooseRandom(final String scope) { +return chooseRandom(scope, null); + } + + /** + * Randomly choose one node from scope. + * + * If scope starts with ~, choose one from the all nodes except for the + * ones in scope; otherwise, choose one from scope. + * If excludedNodes is given, choose a node that's not in excludedNodes. + * + * @param scope range of nodes from which a node will be chosen + * @param excludedNodes nodes to be excluded from + * @return the chosen node + */ + public Node chooseRandom(final String scope, + final Collection excludedNodes) { netlock.readLock().lock(); try { if (scope.startsWith("~")) { -return chooseRandom(NodeBase.ROOT, scope.substring(1)); +return chooseRandom(NodeBase.ROOT, scope.substring(1), excludedNodes); } else { -return
[24/50] [abbrv] hadoop git commit: HDFS-10320. Rack failures may result in NN terminate. (Xiao Chen via mingma)
HDFS-10320. Rack failures may result in NN terminate. (Xiao Chen via mingma) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/1268cf5f Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1268cf5f Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1268cf5f Branch: refs/heads/HDFS-1312 Commit: 1268cf5fbe4458fa75ad0662512d352f9e8d3470 Parents: 9e37fe3 Author: Ming MaAuthored: Wed May 4 17:02:26 2016 -0700 Committer: Ming Ma Committed: Wed May 4 17:02:26 2016 -0700 -- .../org/apache/hadoop/net/NetworkTopology.java | 109 +-- .../AvailableSpaceBlockPlacementPolicy.java | 11 +- .../BlockPlacementPolicyDefault.java| 84 +++--- .../web/resources/NamenodeWebHdfsMethods.java | 13 +-- .../apache/hadoop/net/TestNetworkTopology.java | 75 - 5 files changed, 196 insertions(+), 96 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/1268cf5f/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java -- 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 e1d2968..1e23ff6 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 @@ -29,13 +29,13 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.google.common.annotations.VisibleForTesting; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.util.ReflectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; @@ -54,8 +54,8 @@ import com.google.common.collect.Lists; public class NetworkTopology { public final static String DEFAULT_RACK = "/default-rack"; public final static int DEFAULT_HOST_LEVEL = 2; - public static final Log LOG = -LogFactory.getLog(NetworkTopology.class); + public static final Logger LOG = + LoggerFactory.getLogger(NetworkTopology.class); public static class InvalidTopologyException extends RuntimeException { private static final long serialVersionUID = 1L; @@ -442,9 +442,7 @@ public class NetworkTopology { } } } - if(LOG.isDebugEnabled()) { -LOG.debug("NetworkTopology became:\n" + this.toString()); - } + LOG.debug("NetworkTopology became:\n{}", this.toString()); } finally { netlock.writeLock().unlock(); } @@ -517,9 +515,7 @@ public class NetworkTopology { numOfRacks--; } } - if(LOG.isDebugEnabled()) { -LOG.debug("NetworkTopology became:\n" + this.toString()); - } + LOG.debug("NetworkTopology became:\n{}", this.toString()); } finally { netlock.writeLock().unlock(); } @@ -717,26 +713,45 @@ public class NetworkTopology { r.setSeed(seed); } - /** randomly choose one node from scope - * if scope starts with ~, choose one from the all nodes except for the - * ones in scope; otherwise, choose one from scope + /** + * Randomly choose a node. + * * @param scope range of nodes from which a node will be chosen * @return the chosen node + * + * @see #chooseRandom(String, Collection) */ - public Node chooseRandom(String scope) { + public Node chooseRandom(final String scope) { +return chooseRandom(scope, null); + } + + /** + * Randomly choose one node from scope. + * + * If scope starts with ~, choose one from the all nodes except for the + * ones in scope; otherwise, choose one from scope. + * If excludedNodes is given, choose a node that's not in excludedNodes. + * + * @param scope range of nodes from which a node will be chosen + * @param excludedNodes nodes to be excluded from + * @return the chosen node + */ + public Node chooseRandom(final String scope, + final Collection excludedNodes) { netlock.readLock().lock(); try { if (scope.startsWith("~")) { -return chooseRandom(NodeBase.ROOT, scope.substring(1)); +return chooseRandom(NodeBase.ROOT, scope.substring(1), excludedNodes); } else { -return
[06/18] hadoop git commit: HDFS-10320. Rack failures may result in NN terminate. (Xiao Chen via mingma)
HDFS-10320. Rack failures may result in NN terminate. (Xiao Chen via mingma) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/1268cf5f Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1268cf5f Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1268cf5f Branch: refs/heads/HADOOP-12930 Commit: 1268cf5fbe4458fa75ad0662512d352f9e8d3470 Parents: 9e37fe3 Author: Ming MaAuthored: Wed May 4 17:02:26 2016 -0700 Committer: Ming Ma Committed: Wed May 4 17:02:26 2016 -0700 -- .../org/apache/hadoop/net/NetworkTopology.java | 109 +-- .../AvailableSpaceBlockPlacementPolicy.java | 11 +- .../BlockPlacementPolicyDefault.java| 84 +++--- .../web/resources/NamenodeWebHdfsMethods.java | 13 +-- .../apache/hadoop/net/TestNetworkTopology.java | 75 - 5 files changed, 196 insertions(+), 96 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/1268cf5f/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java -- 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 e1d2968..1e23ff6 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 @@ -29,13 +29,13 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.google.common.annotations.VisibleForTesting; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.util.ReflectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; @@ -54,8 +54,8 @@ import com.google.common.collect.Lists; public class NetworkTopology { public final static String DEFAULT_RACK = "/default-rack"; public final static int DEFAULT_HOST_LEVEL = 2; - public static final Log LOG = -LogFactory.getLog(NetworkTopology.class); + public static final Logger LOG = + LoggerFactory.getLogger(NetworkTopology.class); public static class InvalidTopologyException extends RuntimeException { private static final long serialVersionUID = 1L; @@ -442,9 +442,7 @@ public class NetworkTopology { } } } - if(LOG.isDebugEnabled()) { -LOG.debug("NetworkTopology became:\n" + this.toString()); - } + LOG.debug("NetworkTopology became:\n{}", this.toString()); } finally { netlock.writeLock().unlock(); } @@ -517,9 +515,7 @@ public class NetworkTopology { numOfRacks--; } } - if(LOG.isDebugEnabled()) { -LOG.debug("NetworkTopology became:\n" + this.toString()); - } + LOG.debug("NetworkTopology became:\n{}", this.toString()); } finally { netlock.writeLock().unlock(); } @@ -717,26 +713,45 @@ public class NetworkTopology { r.setSeed(seed); } - /** randomly choose one node from scope - * if scope starts with ~, choose one from the all nodes except for the - * ones in scope; otherwise, choose one from scope + /** + * Randomly choose a node. + * * @param scope range of nodes from which a node will be chosen * @return the chosen node + * + * @see #chooseRandom(String, Collection) */ - public Node chooseRandom(String scope) { + public Node chooseRandom(final String scope) { +return chooseRandom(scope, null); + } + + /** + * Randomly choose one node from scope. + * + * If scope starts with ~, choose one from the all nodes except for the + * ones in scope; otherwise, choose one from scope. + * If excludedNodes is given, choose a node that's not in excludedNodes. + * + * @param scope range of nodes from which a node will be chosen + * @param excludedNodes nodes to be excluded from + * @return the chosen node + */ + public Node chooseRandom(final String scope, + final Collection excludedNodes) { netlock.readLock().lock(); try { if (scope.startsWith("~")) { -return chooseRandom(NodeBase.ROOT, scope.substring(1)); +return chooseRandom(NodeBase.ROOT, scope.substring(1), excludedNodes); } else { -
hadoop git commit: HDFS-10320. Rack failures may result in NN terminate. (Xiao Chen via mingma)
Repository: hadoop Updated Branches: refs/heads/branch-2.8 22ac37615 -> d6e95ae47 HDFS-10320. Rack failures may result in NN terminate. (Xiao Chen via mingma) (cherry picked from commit 1268cf5fbe4458fa75ad0662512d352f9e8d3470) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/d6e95ae4 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/d6e95ae4 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/d6e95ae4 Branch: refs/heads/branch-2.8 Commit: d6e95ae47b6281219ca2b634507ece3b4ac6a12e Parents: 22ac376 Author: Ming MaAuthored: Wed May 4 17:02:26 2016 -0700 Committer: Ming Ma Committed: Wed May 4 17:07:36 2016 -0700 -- .../org/apache/hadoop/net/NetworkTopology.java | 109 +-- .../AvailableSpaceBlockPlacementPolicy.java | 11 +- .../BlockPlacementPolicyDefault.java| 84 +++--- .../web/resources/NamenodeWebHdfsMethods.java | 13 +-- .../apache/hadoop/net/TestNetworkTopology.java | 75 - 5 files changed, 196 insertions(+), 96 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/d6e95ae4/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java -- 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 b637da1..d680094 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 @@ -29,13 +29,13 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.google.common.annotations.VisibleForTesting; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.util.ReflectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; @@ -54,8 +54,8 @@ import com.google.common.collect.Lists; public class NetworkTopology { public final static String DEFAULT_RACK = "/default-rack"; public final static int DEFAULT_HOST_LEVEL = 2; - public static final Log LOG = -LogFactory.getLog(NetworkTopology.class); + public static final Logger LOG = + LoggerFactory.getLogger(NetworkTopology.class); public static class InvalidTopologyException extends RuntimeException { private static final long serialVersionUID = 1L; @@ -432,9 +432,7 @@ public class NetworkTopology { } } } - if(LOG.isDebugEnabled()) { -LOG.debug("NetworkTopology became:\n" + this.toString()); - } + LOG.debug("NetworkTopology became:\n{}", this.toString()); } finally { netlock.writeLock().unlock(); } @@ -507,9 +505,7 @@ public class NetworkTopology { numOfRacks--; } } - if(LOG.isDebugEnabled()) { -LOG.debug("NetworkTopology became:\n" + this.toString()); - } + LOG.debug("NetworkTopology became:\n{}", this.toString()); } finally { netlock.writeLock().unlock(); } @@ -702,26 +698,45 @@ public class NetworkTopology { r.setSeed(seed); } - /** randomly choose one node from scope - * if scope starts with ~, choose one from the all nodes except for the - * ones in scope; otherwise, choose one from scope + /** + * Randomly choose a node. + * * @param scope range of nodes from which a node will be chosen * @return the chosen node + * + * @see #chooseRandom(String, Collection) */ - public Node chooseRandom(String scope) { + public Node chooseRandom(final String scope) { +return chooseRandom(scope, null); + } + + /** + * Randomly choose one node from scope. + * + * If scope starts with ~, choose one from the all nodes except for the + * ones in scope; otherwise, choose one from scope. + * If excludedNodes is given, choose a node that's not in excludedNodes. + * + * @param scope range of nodes from which a node will be chosen + * @param excludedNodes nodes to be excluded from + * @return the chosen node + */ + public Node chooseRandom(final String scope, + final Collection excludedNodes) { netlock.readLock().lock(); try { if (scope.startsWith("~")) { -return
hadoop git commit: HDFS-10320. Rack failures may result in NN terminate. (Xiao Chen via mingma)
Repository: hadoop Updated Branches: refs/heads/branch-2 8262ef831 -> 5b5383317 HDFS-10320. Rack failures may result in NN terminate. (Xiao Chen via mingma) (cherry picked from commit 1268cf5fbe4458fa75ad0662512d352f9e8d3470) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/5b538331 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/5b538331 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/5b538331 Branch: refs/heads/branch-2 Commit: 5b53833171f9427234d2c608e48b1eb323efb435 Parents: 8262ef8 Author: Ming MaAuthored: Wed May 4 17:02:26 2016 -0700 Committer: Ming Ma Committed: Wed May 4 17:04:44 2016 -0700 -- .../org/apache/hadoop/net/NetworkTopology.java | 109 +-- .../AvailableSpaceBlockPlacementPolicy.java | 11 +- .../BlockPlacementPolicyDefault.java| 84 +++--- .../web/resources/NamenodeWebHdfsMethods.java | 13 +-- .../apache/hadoop/net/TestNetworkTopology.java | 75 - 5 files changed, 196 insertions(+), 96 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/5b538331/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java -- 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 e1d2968..1e23ff6 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 @@ -29,13 +29,13 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.google.common.annotations.VisibleForTesting; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.util.ReflectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; @@ -54,8 +54,8 @@ import com.google.common.collect.Lists; public class NetworkTopology { public final static String DEFAULT_RACK = "/default-rack"; public final static int DEFAULT_HOST_LEVEL = 2; - public static final Log LOG = -LogFactory.getLog(NetworkTopology.class); + public static final Logger LOG = + LoggerFactory.getLogger(NetworkTopology.class); public static class InvalidTopologyException extends RuntimeException { private static final long serialVersionUID = 1L; @@ -442,9 +442,7 @@ public class NetworkTopology { } } } - if(LOG.isDebugEnabled()) { -LOG.debug("NetworkTopology became:\n" + this.toString()); - } + LOG.debug("NetworkTopology became:\n{}", this.toString()); } finally { netlock.writeLock().unlock(); } @@ -517,9 +515,7 @@ public class NetworkTopology { numOfRacks--; } } - if(LOG.isDebugEnabled()) { -LOG.debug("NetworkTopology became:\n" + this.toString()); - } + LOG.debug("NetworkTopology became:\n{}", this.toString()); } finally { netlock.writeLock().unlock(); } @@ -717,26 +713,45 @@ public class NetworkTopology { r.setSeed(seed); } - /** randomly choose one node from scope - * if scope starts with ~, choose one from the all nodes except for the - * ones in scope; otherwise, choose one from scope + /** + * Randomly choose a node. + * * @param scope range of nodes from which a node will be chosen * @return the chosen node + * + * @see #chooseRandom(String, Collection) */ - public Node chooseRandom(String scope) { + public Node chooseRandom(final String scope) { +return chooseRandom(scope, null); + } + + /** + * Randomly choose one node from scope. + * + * If scope starts with ~, choose one from the all nodes except for the + * ones in scope; otherwise, choose one from scope. + * If excludedNodes is given, choose a node that's not in excludedNodes. + * + * @param scope range of nodes from which a node will be chosen + * @param excludedNodes nodes to be excluded from + * @return the chosen node + */ + public Node chooseRandom(final String scope, + final Collection excludedNodes) { netlock.readLock().lock(); try { if (scope.startsWith("~")) { -return
hadoop git commit: HDFS-10320. Rack failures may result in NN terminate. (Xiao Chen via mingma)
Repository: hadoop Updated Branches: refs/heads/trunk 9e37fe3b7 -> 1268cf5fb HDFS-10320. Rack failures may result in NN terminate. (Xiao Chen via mingma) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/1268cf5f Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1268cf5f Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1268cf5f Branch: refs/heads/trunk Commit: 1268cf5fbe4458fa75ad0662512d352f9e8d3470 Parents: 9e37fe3 Author: Ming MaAuthored: Wed May 4 17:02:26 2016 -0700 Committer: Ming Ma Committed: Wed May 4 17:02:26 2016 -0700 -- .../org/apache/hadoop/net/NetworkTopology.java | 109 +-- .../AvailableSpaceBlockPlacementPolicy.java | 11 +- .../BlockPlacementPolicyDefault.java| 84 +++--- .../web/resources/NamenodeWebHdfsMethods.java | 13 +-- .../apache/hadoop/net/TestNetworkTopology.java | 75 - 5 files changed, 196 insertions(+), 96 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/1268cf5f/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java -- 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 e1d2968..1e23ff6 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 @@ -29,13 +29,13 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import com.google.common.annotations.VisibleForTesting; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.util.ReflectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; @@ -54,8 +54,8 @@ import com.google.common.collect.Lists; public class NetworkTopology { public final static String DEFAULT_RACK = "/default-rack"; public final static int DEFAULT_HOST_LEVEL = 2; - public static final Log LOG = -LogFactory.getLog(NetworkTopology.class); + public static final Logger LOG = + LoggerFactory.getLogger(NetworkTopology.class); public static class InvalidTopologyException extends RuntimeException { private static final long serialVersionUID = 1L; @@ -442,9 +442,7 @@ public class NetworkTopology { } } } - if(LOG.isDebugEnabled()) { -LOG.debug("NetworkTopology became:\n" + this.toString()); - } + LOG.debug("NetworkTopology became:\n{}", this.toString()); } finally { netlock.writeLock().unlock(); } @@ -517,9 +515,7 @@ public class NetworkTopology { numOfRacks--; } } - if(LOG.isDebugEnabled()) { -LOG.debug("NetworkTopology became:\n" + this.toString()); - } + LOG.debug("NetworkTopology became:\n{}", this.toString()); } finally { netlock.writeLock().unlock(); } @@ -717,26 +713,45 @@ public class NetworkTopology { r.setSeed(seed); } - /** randomly choose one node from scope - * if scope starts with ~, choose one from the all nodes except for the - * ones in scope; otherwise, choose one from scope + /** + * Randomly choose a node. + * * @param scope range of nodes from which a node will be chosen * @return the chosen node + * + * @see #chooseRandom(String, Collection) */ - public Node chooseRandom(String scope) { + public Node chooseRandom(final String scope) { +return chooseRandom(scope, null); + } + + /** + * Randomly choose one node from scope. + * + * If scope starts with ~, choose one from the all nodes except for the + * ones in scope; otherwise, choose one from scope. + * If excludedNodes is given, choose a node that's not in excludedNodes. + * + * @param scope range of nodes from which a node will be chosen + * @param excludedNodes nodes to be excluded from + * @return the chosen node + */ + public Node chooseRandom(final String scope, + final Collection excludedNodes) { netlock.readLock().lock(); try { if (scope.startsWith("~")) { -return chooseRandom(NodeBase.ROOT, scope.substring(1)); +return