HDFS-16953. RBF: Mount table store APIs should update cache only if state store record is successfully updated (#5482)
This commit is contained in:
parent
b6a9d7b442
commit
f8d0949f7d
@ -117,7 +117,9 @@ public AddMountTableEntryResponse addMountTableEntry(
|
||||
AddMountTableEntryResponse response =
|
||||
AddMountTableEntryResponse.newInstance();
|
||||
response.setStatus(status);
|
||||
if (status) {
|
||||
updateCacheAllRouters();
|
||||
}
|
||||
return response;
|
||||
} else {
|
||||
AddMountTableEntryResponse response =
|
||||
@ -139,7 +141,9 @@ public UpdateMountTableEntryResponse updateMountTableEntry(
|
||||
UpdateMountTableEntryResponse response =
|
||||
UpdateMountTableEntryResponse.newInstance();
|
||||
response.setStatus(status);
|
||||
if (status) {
|
||||
updateCacheAllRouters();
|
||||
}
|
||||
return response;
|
||||
} else {
|
||||
UpdateMountTableEntryResponse response =
|
||||
@ -170,7 +174,9 @@ public RemoveMountTableEntryResponse removeMountTableEntry(
|
||||
RemoveMountTableEntryResponse response =
|
||||
RemoveMountTableEntryResponse.newInstance();
|
||||
response.setStatus(status);
|
||||
if (status) {
|
||||
updateCacheAllRouters();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user