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

inigoiri 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 f8d0949f7d6 HDFS-16953. RBF: Mount table store APIs should update 
cache only if state store record is successfully updated (#5482)
f8d0949f7d6 is described below

commit f8d0949f7d60f952fe658dd295bf040fc7cc2b15
Author: Viraj Jasani <vjas...@apache.org>
AuthorDate: Sat Mar 18 14:43:25 2023 -0700

    HDFS-16953. RBF: Mount table store APIs should update cache only if state 
store record is successfully updated (#5482)
---
 .../server/federation/store/impl/MountTableStoreImpl.java    | 12 +++++++++---
 .../hdfs/server/federation/router/TestRouterAdminCLI.java    | 12 +++++++++++-
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git 
a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/impl/MountTableStoreImpl.java
 
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/impl/MountTableStoreImpl.java
index 680752b8efe..a9b0174e6a8 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/impl/MountTableStoreImpl.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/impl/MountTableStoreImpl.java
@@ -117,7 +117,9 @@ public class MountTableStoreImpl extends MountTableStore {
       AddMountTableEntryResponse response =
           AddMountTableEntryResponse.newInstance();
       response.setStatus(status);
-      updateCacheAllRouters();
+      if (status) {
+        updateCacheAllRouters();
+      }
       return response;
     } else {
       AddMountTableEntryResponse response =
@@ -139,7 +141,9 @@ public class MountTableStoreImpl extends MountTableStore {
       UpdateMountTableEntryResponse response =
           UpdateMountTableEntryResponse.newInstance();
       response.setStatus(status);
-      updateCacheAllRouters();
+      if (status) {
+        updateCacheAllRouters();
+      }
       return response;
     } else {
       UpdateMountTableEntryResponse response =
@@ -170,7 +174,9 @@ public class MountTableStoreImpl extends MountTableStore {
     RemoveMountTableEntryResponse response =
         RemoveMountTableEntryResponse.newInstance();
     response.setStatus(status);
-    updateCacheAllRouters();
+    if (status) {
+      updateCacheAllRouters();
+    }
     return response;
   }
 
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdminCLI.java
 
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdminCLI.java
index 761fad2fb7a..75c79dd2c2e 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdminCLI.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterAdminCLI.java
@@ -167,8 +167,9 @@ public class TestRouterAdminCLI {
     assertEquals(0, ToolRunner.run(admin, argv));
     assertEquals(-1, ToolRunner.run(admin, argv));
 
-
     stateStore.loadCache(MountTableStoreImpl.class, true);
+    verifyMountTableContents(src, dest);
+
     GetMountTableEntriesRequest getRequest = GetMountTableEntriesRequest
         .newInstance(src);
     GetMountTableEntriesResponse getResponse = client.getMountTableManager()
@@ -207,6 +208,15 @@ public class TestRouterAdminCLI {
     assertTrue(mountTable.isFaultTolerant());
   }
 
+  private void verifyMountTableContents(String src, String dest) throws 
Exception {
+    String[] argv = new String[] {"-ls", "/"};
+    System.setOut(new PrintStream(out));
+    assertEquals(0, ToolRunner.run(admin, argv));
+    String response = out.toString();
+    assertTrue("The response should have " + src + ": " + response, 
response.contains(src));
+    assertTrue("The response should have " + dest + ": " + response, 
response.contains(dest));
+  }
+
   @Test
   public void testAddMountTableNotNormalized() throws Exception {
     String nsId = "ns0";


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

Reply via email to