Browse Source

HDFS-12620. Backporting HDFS-10467 to branch-2. Contributed by Inigo Goiri.

(cherry picked from commit 0f1c0376186de6446d595be7bb445ed6b71ae499)
Inigo Goiri 7 years ago
parent
commit
f4a2f0ee9f

+ 4 - 1
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/MockResolver.java

@@ -264,7 +264,10 @@ public class MockResolver
   @Override
   public PathLocation getDestinationForPath(String path) throws IOException {
     List<RemoteLocation> remoteLocations = new LinkedList<>();
-    for (String key : this.locations.keySet()) {
+    // We go from the leaves to the root
+    List<String> keys = new ArrayList<>(this.locations.keySet());
+    Collections.sort(keys, Collections.reverseOrder());
+    for (String key : keys) {
       if (path.startsWith(key)) {
         for (RemoteLocation location : this.locations.get(key)) {
           String finalPath = location.getDest() + path.substring(key.length());