Skip to content

Commit 4f8cbd3

Browse files
committed
HADOOP-9998. Provide methods to clear only part of the DNSToSwitchMapping. (Junping Du via Colin Patrick McCabe)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1526568 13f79535-47bb-0310-9956-ffa450edef68
1 parent f2cf669 commit 4f8cbd3

File tree

11 files changed

+59
-1
lines changed

11 files changed

+59
-1
lines changed

hadoop-common-project/hadoop-common/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ Release 2.3.0 - UNRELEASED
4949
HADOOP-9915. o.a.h.fs.Stat support on Mac OS X (Binglin Chang via Colin
5050
Patrick McCabe)
5151

52+
HADOOP-9998. Provide methods to clear only part of the DNSToSwitchMapping.
53+
(Junping Du via Colin Patrick McCabe)
54+
5255
OPTIMIZATIONS
5356

5457
HADOOP-9748. Reduce blocking on UGI.ensureInitialized (daryn)

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/CachedDNSToSwitchMapping.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,11 @@ public boolean isSingleSwitch() {
154154
public void reloadCachedMappings() {
155155
cache.clear();
156156
}
157+
158+
@Override
159+
public void reloadCachedMappings(List<String> names) {
160+
for (String name : names) {
161+
cache.remove(name);
162+
}
163+
}
157164
}

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/DNSToSwitchMapping.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,12 @@ public interface DNSToSwitchMapping {
5959
* will get a chance to see the new data.
6060
*/
6161
public void reloadCachedMappings();
62+
63+
/**
64+
* Reload cached mappings on specific nodes.
65+
*
66+
* If there is a cache on these nodes, this method will clear it, so that
67+
* future accesses will see updated data.
68+
*/
69+
public void reloadCachedMappings(List<String> names);
6270
}

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/ScriptBasedMapping.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,11 @@ public void reloadCachedMappings() {
269269
// Nothing to do here, since RawScriptBasedMapping has no cache, and
270270
// does not inherit from CachedDNSToSwitchMapping
271271
}
272+
273+
@Override
274+
public void reloadCachedMappings(List<String> names) {
275+
// Nothing to do here, since RawScriptBasedMapping has no cache, and
276+
// does not inherit from CachedDNSToSwitchMapping
277+
}
272278
}
273279
}

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/TableMapping.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,12 @@ public void reloadCachedMappings() {
162162
}
163163
}
164164
}
165+
166+
@Override
167+
public void reloadCachedMappings(List<String> names) {
168+
// TableMapping has to reload all mappings at once, so no chance to
169+
// reload mappings on specific nodes
170+
reloadCachedMappings();
171+
}
165172
}
166173
}

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/StaticMapping.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,10 @@ public void reloadCachedMappings() {
152152
// reloadCachedMappings does nothing for StaticMapping; there is
153153
// nowhere to reload from since all data is in memory.
154154
}
155+
156+
@Override
157+
public void reloadCachedMappings(List<String> names) {
158+
// reloadCachedMappings does nothing for StaticMapping; there is
159+
// nowhere to reload from since all data is in memory.
160+
}
155161
}

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestSwitchMapping.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,9 @@ public List<String> resolve(List<String> names) {
120120
@Override
121121
public void reloadCachedMappings() {
122122
}
123+
124+
@Override
125+
public void reloadCachedMappings(List<String> names) {
126+
}
123127
}
124128
}

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,12 @@ nodes with its data cleared (or user can just remove the StorageID
886886
// If the network location is invalid, clear the cached mappings
887887
// so that we have a chance to re-add this DataNode with the
888888
// correct network location later.
889-
dnsToSwitchMapping.reloadCachedMappings();
889+
List<String> invalidNodeNames = new ArrayList<String>(3);
890+
// clear cache for nodes in IP or Hostname
891+
invalidNodeNames.add(nodeReg.getIpAddr());
892+
invalidNodeNames.add(nodeReg.getHostName());
893+
invalidNodeNames.add(nodeReg.getPeerHostName());
894+
dnsToSwitchMapping.reloadCachedMappings(invalidNodeNames);
890895
throw e;
891896
}
892897
}

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryParsing.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ public List<String> resolve(List<String> names) {
9999
@Override
100100
public void reloadCachedMappings() {
101101
}
102+
103+
@Override
104+
public void reloadCachedMappings(List<String> names) {
105+
}
102106
}
103107

104108
@Test(timeout = 50000)

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClientContainerRequest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ public List<String> resolve(List<String> names) {
215215

216216
@Override
217217
public void reloadCachedMappings() {}
218+
219+
@Override
220+
public void reloadCachedMappings(List<String> names) {
221+
}
218222
}
219223

220224
private void verifyResourceRequest(

0 commit comments

Comments
 (0)