HDFS-14935. Refactor DFSNetworkTopology#isNodeInScope. Contributed by Lisheng Sun.

This commit is contained in:
Ayush Saxena 2019-10-29 12:30:24 +05:30
parent 30ed24a421
commit fa4904cdca

View File

@ -259,10 +259,11 @@ Node chooseRandomWithStorageType(final String scope,
}
private boolean isNodeInScope(Node node, String scope) {
if (!scope.endsWith("/")) {
scope += "/";
if (!scope.endsWith(NodeBase.PATH_SEPARATOR_STR)) {
scope += NodeBase.PATH_SEPARATOR_STR;
}
String nodeLocation = node.getNetworkLocation() + "/";
String nodeLocation =
node.getNetworkLocation() + NodeBase.PATH_SEPARATOR_STR;
return nodeLocation.startsWith(scope);
}