소스 검색

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

(cherry picked from commit 0f1c0376186de6446d595be7bb445ed6b71ae499)
Inigo Goiri 7 년 전
부모
커밋
f4a2f0ee9f
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/MockResolver.java

+ 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());