diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/MountTableResolver.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/MountTableResolver.java index 4457cba099..24082d46d7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/MountTableResolver.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/MountTableResolver.java @@ -267,7 +267,9 @@ public void refreshEntries(final Collection entries) { // 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"); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/resolver/TestMountTableResolver.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/resolver/TestMountTableResolver.java index c92e92c2fc..7a596c1f46 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/resolver/TestMountTableResolver.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/federation/resolver/TestMountTableResolver.java @@ -24,6 +24,8 @@ 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 void testMountTableScalability() throws IOException { assertEquals(numRootTrees, mountTable.getMountPoints("/").size()); assertEquals(100000, mountTable.getMounts("/").size()); } + + @Test + public void testUpdate() throws IOException { + + // Add entry to update later + Map map = getMountTableEntry("1", "/"); + mountTable.addEntry(MountTable.newInstance("/testupdate", map)); + + MountTable entry = mountTable.getMountPoint("/testupdate"); + List dests = entry.getDestinations(); + assertEquals(1, dests.size()); + RemoteLocation dest = dests.get(0); + assertEquals("1", dest.getNameserviceId()); + + // Update entry + Collection entries = Collections.singletonList( + MountTable.newInstance("/testupdate", getMountTableEntry("2", "/"))); + mountTable.refreshEntries(entries); + + MountTable entry1 = mountTable.getMountPoint("/testupdate"); + List 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); + } } \ No newline at end of file