You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ay...@apache.org on 2020/09/20 03:28:05 UTC

[hadoop] branch trunk updated: HDFS-15579. RBF: The constructor of PathLocation may got some misunderstanding. Contributed by Janus Chow.

This is an automated email from the ASF dual-hosted git repository.

ayushsaxena pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 8eba922  HDFS-15579. RBF: The constructor of PathLocation may got some misunderstanding. Contributed by Janus Chow.
8eba922 is described below

commit 8eba922bb3860e9a819953964fc6ba3bd221b47d
Author: Ayush Saxena <ay...@apache.org>
AuthorDate: Sun Sep 20 08:54:25 2020 +0530

    HDFS-15579. RBF: The constructor of PathLocation may got some misunderstanding. Contributed by Janus Chow.
---
 .../resolver/MultipleDestinationMountTableResolver.java  |  5 +++--
 .../hdfs/server/federation/resolver/PathLocation.java    | 16 ++++++++++++++++
 .../resolver/TestMultipleDestinationResolver.java        |  9 +++++++++
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/MultipleDestinationMountTableResolver.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/MultipleDestinationMountTableResolver.java
index b09a883..752f5c9 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/MultipleDestinationMountTableResolver.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/MultipleDestinationMountTableResolver.java
@@ -99,8 +99,9 @@ public class MultipleDestinationMountTableResolver extends MountTableResolver {
 
         // Change the order of the name spaces according to the policy
         if (firstNamespace != null) {
-          // This is the entity in the tree, we need to create our own copy
-          mountTableResult = new PathLocation(mountTableResult, firstNamespace);
+          // Create our own prioritized copy based on the entity in the tree.
+          mountTableResult = PathLocation.prioritizeDestination(
+              mountTableResult, firstNamespace);
           LOG.debug("Ordered locations following {} are {}",
               order, mountTableResult);
         } else {
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/PathLocation.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/PathLocation.java
index cb04ff8..44856cb 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/PathLocation.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/PathLocation.java
@@ -87,6 +87,7 @@ public class PathLocation {
    * @param other Other path location to copy from.
    * @param firstNsId Identifier of the namespace to place first.
    */
+  @Deprecated
   public PathLocation(PathLocation other, String firstNsId) {
     this.sourcePath = other.sourcePath;
     this.destOrder = other.destOrder;
@@ -94,6 +95,21 @@ public class PathLocation {
   }
 
   /**
+   * Return a path location with the prioritized destinations based on
+   * the current path location.
+   *
+   * @param base The base path location we'd like to prioritize on.
+   * @param firstNsId Identifier of the namespace to place first.
+   */
+  public static PathLocation prioritizeDestination(
+      PathLocation base, String firstNsId) {
+    List<RemoteLocation> prioritizedDestinations = orderedNamespaces(
+        base.destinations, firstNsId);
+    return new PathLocation(base.sourcePath, prioritizedDestinations,
+        base.destOrder);
+  }
+
+  /**
    * Prioritize a location/destination by its name space/nameserviceId.
    * This destination might be used by other threads, so the source is not
    * modifiable.
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/resolver/TestMultipleDestinationResolver.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/resolver/TestMultipleDestinationResolver.java
index 3915c56..c4b211c 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/resolver/TestMultipleDestinationResolver.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/resolver/TestMultipleDestinationResolver.java
@@ -360,6 +360,15 @@ public class TestMultipleDestinationResolver {
     assertEquals(3, destinations.size());
   }
 
+  @Test
+  public void testPrioritizeDestination() throws IOException {
+    PathLocation dest0 = resolver.getDestinationForPath("/hashall/file0.txt");
+    assertDest("subcluster0", dest0);
+    PathLocation prioritizedDest = PathLocation.prioritizeDestination(dest0,
+        "subcluster1");
+    assertDest("subcluster1", prioritizedDest);
+  }
+
   /**
    * Test that a path has files distributed across destinations evenly.
    * @param path Path to check.


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org