HDFS-16953. RBF: Mount table store APIs should update cache only if state store record is successfully updated (#5482)

This commit is contained in:
Viraj Jasani 2023-03-18 14:43:25 -07:00 committed by GitHub
parent b6a9d7b442
commit f8d0949f7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View File

@ -117,7 +117,9 @@ public class MountTableStoreImpl extends MountTableStore {
AddMountTableEntryResponse response = AddMountTableEntryResponse response =
AddMountTableEntryResponse.newInstance(); AddMountTableEntryResponse.newInstance();
response.setStatus(status); response.setStatus(status);
updateCacheAllRouters(); if (status) {
updateCacheAllRouters();
}
return response; return response;
} else { } else {
AddMountTableEntryResponse response = AddMountTableEntryResponse response =
@ -139,7 +141,9 @@ public class MountTableStoreImpl extends MountTableStore {
UpdateMountTableEntryResponse response = UpdateMountTableEntryResponse response =
UpdateMountTableEntryResponse.newInstance(); UpdateMountTableEntryResponse.newInstance();
response.setStatus(status); response.setStatus(status);
updateCacheAllRouters(); if (status) {
updateCacheAllRouters();
}
return response; return response;
} else { } else {
UpdateMountTableEntryResponse response = UpdateMountTableEntryResponse response =
@ -170,7 +174,9 @@ public class MountTableStoreImpl extends MountTableStore {
RemoveMountTableEntryResponse response = RemoveMountTableEntryResponse response =
RemoveMountTableEntryResponse.newInstance(); RemoveMountTableEntryResponse.newInstance();
response.setStatus(status); response.setStatus(status);
updateCacheAllRouters(); if (status) {
updateCacheAllRouters();
}
return response; return response;
} }

View File

@ -167,8 +167,9 @@ public class TestRouterAdminCLI {
assertEquals(0, ToolRunner.run(admin, argv)); assertEquals(0, ToolRunner.run(admin, argv));
assertEquals(-1, ToolRunner.run(admin, argv)); assertEquals(-1, ToolRunner.run(admin, argv));
stateStore.loadCache(MountTableStoreImpl.class, true); stateStore.loadCache(MountTableStoreImpl.class, true);
verifyMountTableContents(src, dest);
GetMountTableEntriesRequest getRequest = GetMountTableEntriesRequest GetMountTableEntriesRequest getRequest = GetMountTableEntriesRequest
.newInstance(src); .newInstance(src);
GetMountTableEntriesResponse getResponse = client.getMountTableManager() GetMountTableEntriesResponse getResponse = client.getMountTableManager()
@ -207,6 +208,15 @@ public class TestRouterAdminCLI {
assertTrue(mountTable.isFaultTolerant()); 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 @Test
public void testAddMountTableNotNormalized() throws Exception { public void testAddMountTableNotNormalized() throws Exception {
String nsId = "ns0"; String nsId = "ns0";