HDFS-12988. RBF: Mount table entries not properly updated in the local cache. Contributed by Inigo Goiri.
This commit is contained in:
parent
0c75d0634b
commit
83b513ac6d
|
@ -267,7 +267,9 @@ public class MountTableResolver
|
|||
// Node exists, check for updates
|
||||
MountTable existingEntry = this.tree.get(srcPath);
|
||||
if (existingEntry != null && !existingEntry.equals(entry)) {
|
||||
// Entry has changed
|
||||
LOG.info("Entry has changed from \"{}\" to \"{}\"",
|
||||
existingEntry, entry);
|
||||
this.tree.put(srcPath, entry);
|
||||
invalidateLocationCache(srcPath);
|
||||
LOG.info("Updated mount point {} in resolver");
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ import static org.junit.Assert.fail;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -409,4 +411,34 @@ public class TestMountTableResolver {
|
|||
assertEquals(numRootTrees, mountTable.getMountPoints("/").size());
|
||||
assertEquals(100000, mountTable.getMounts("/").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate() throws IOException {
|
||||
|
||||
// Add entry to update later
|
||||
Map<String, String> map = getMountTableEntry("1", "/");
|
||||
mountTable.addEntry(MountTable.newInstance("/testupdate", map));
|
||||
|
||||
MountTable entry = mountTable.getMountPoint("/testupdate");
|
||||
List<RemoteLocation> dests = entry.getDestinations();
|
||||
assertEquals(1, dests.size());
|
||||
RemoteLocation dest = dests.get(0);
|
||||
assertEquals("1", dest.getNameserviceId());
|
||||
|
||||
// Update entry
|
||||
Collection<MountTable> entries = Collections.singletonList(
|
||||
MountTable.newInstance("/testupdate", getMountTableEntry("2", "/")));
|
||||
mountTable.refreshEntries(entries);
|
||||
|
||||
MountTable entry1 = mountTable.getMountPoint("/testupdate");
|
||||
List<RemoteLocation> dests1 = entry1.getDestinations();
|
||||
assertEquals(1, dests1.size());
|
||||
RemoteLocation dest1 = dests1.get(0);
|
||||
assertEquals("2", dest1.getNameserviceId());
|
||||
|
||||
// Remove the entry to test updates and check
|
||||
mountTable.removeEntry("/testupdate");
|
||||
MountTable entry2 = mountTable.getMountPoint("/testupdate");
|
||||
assertNull(entry2);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue