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

This commit is contained in:
Inigo Goiri 2017-10-19 18:08:45 -07:00
parent 7b4b018780
commit 0f1c037618
1 changed files with 4 additions and 1 deletions

View File

@ -264,7 +264,10 @@ public class MockResolver
@Override @Override
public PathLocation getDestinationForPath(String path) throws IOException { public PathLocation getDestinationForPath(String path) throws IOException {
List<RemoteLocation> remoteLocations = new LinkedList<>(); 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)) { if (path.startsWith(key)) {
for (RemoteLocation location : this.locations.get(key)) { for (RemoteLocation location : this.locations.get(key)) {
String finalPath = location.getDest() + path.substring(key.length()); String finalPath = location.getDest() + path.substring(key.length());