Skip to content

Commit

Permalink
HDFS-16953. RBF: Mount table store APIs should update cache only if s…
Browse files Browse the repository at this point in the history
…tate store record is successfully updated (#5482)
  • Loading branch information
virajjasani committed Mar 18, 2023
1 parent b6a9d7b commit f8d0949
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Expand Up @@ -117,7 +117,9 @@ public AddMountTableEntryResponse addMountTableEntry(
AddMountTableEntryResponse response =
AddMountTableEntryResponse.newInstance();
response.setStatus(status);
updateCacheAllRouters();
if (status) {
updateCacheAllRouters();
}
return response;
} else {
AddMountTableEntryResponse response =
Expand All @@ -139,7 +141,9 @@ public UpdateMountTableEntryResponse updateMountTableEntry(
UpdateMountTableEntryResponse response =
UpdateMountTableEntryResponse.newInstance();
response.setStatus(status);
updateCacheAllRouters();
if (status) {
updateCacheAllRouters();
}
return response;
} else {
UpdateMountTableEntryResponse response =
Expand Down Expand Up @@ -170,7 +174,9 @@ public RemoveMountTableEntryResponse removeMountTableEntry(
RemoveMountTableEntryResponse response =
RemoveMountTableEntryResponse.newInstance();
response.setStatus(status);
updateCacheAllRouters();
if (status) {
updateCacheAllRouters();
}
return response;
}

Expand Down
Expand Up @@ -167,8 +167,9 @@ public void testAddMountTable() throws Exception {
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()
Expand Down Expand Up @@ -207,6 +208,15 @@ public void testAddMountTable() throws Exception {
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";
Expand Down

0 comments on commit f8d0949

Please sign in to comment.