|
@@ -212,8 +212,7 @@ public class DFSNetworkTopology extends NetworkTopology {
|
|
}
|
|
}
|
|
if (excludedNodes != null) {
|
|
if (excludedNodes != null) {
|
|
for (Node excludedNode : excludedNodes) {
|
|
for (Node excludedNode : excludedNodes) {
|
|
- if (excludeRoot != null
|
|
|
|
- && excludedNode.getNetworkLocation().startsWith(excludedScope)) {
|
|
|
|
|
|
+ if (excludeRoot != null && isNodeInScope(excludedNode, excludedScope)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if (excludedNode instanceof DatanodeDescriptor) {
|
|
if (excludedNode instanceof DatanodeDescriptor) {
|
|
@@ -259,6 +258,14 @@ public class DFSNetworkTopology extends NetworkTopology {
|
|
return chosen;
|
|
return chosen;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private boolean isNodeInScope(Node node, String scope) {
|
|
|
|
+ if (!scope.endsWith("/")) {
|
|
|
|
+ scope += "/";
|
|
|
|
+ }
|
|
|
|
+ String nodeLocation = node.getNetworkLocation() + "/";
|
|
|
|
+ return nodeLocation.startsWith(scope);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Choose a random node that has the required storage type, under the given
|
|
* Choose a random node that has the required storage type, under the given
|
|
* root, with an excluded subtree root (could also just be a leaf node).
|
|
* root, with an excluded subtree root (could also just be a leaf node).
|