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
This commit is contained in:
Colin McCabe 2013-09-26 15:24:40 +00:00
parent 6e132b1a2b
commit fa2a3c94f2
11 changed files with 59 additions and 1 deletions

View File

@ -49,6 +49,9 @@ Release 2.3.0 - UNRELEASED
HADOOP-9915. o.a.h.fs.Stat support on Mac OS X (Binglin Chang via Colin HADOOP-9915. o.a.h.fs.Stat support on Mac OS X (Binglin Chang via Colin
Patrick McCabe) Patrick McCabe)
HADOOP-9998. Provide methods to clear only part of the DNSToSwitchMapping.
(Junping Du via Colin Patrick McCabe)
OPTIMIZATIONS OPTIMIZATIONS
HADOOP-9748. Reduce blocking on UGI.ensureInitialized (daryn) HADOOP-9748. Reduce blocking on UGI.ensureInitialized (daryn)

View File

@ -154,4 +154,11 @@ public class CachedDNSToSwitchMapping extends AbstractDNSToSwitchMapping {
public void reloadCachedMappings() { public void reloadCachedMappings() {
cache.clear(); cache.clear();
} }
@Override
public void reloadCachedMappings(List<String> names) {
for (String name : names) {
cache.remove(name);
}
}
} }

View File

@ -59,4 +59,12 @@ public interface DNSToSwitchMapping {
* will get a chance to see the new data. * will get a chance to see the new data.
*/ */
public void reloadCachedMappings(); public void reloadCachedMappings();
/**
* Reload cached mappings on specific nodes.
*
* If there is a cache on these nodes, this method will clear it, so that
* future accesses will see updated data.
*/
public void reloadCachedMappings(List<String> names);
} }

View File

@ -269,5 +269,11 @@ public final class ScriptBasedMapping extends CachedDNSToSwitchMapping {
// Nothing to do here, since RawScriptBasedMapping has no cache, and // Nothing to do here, since RawScriptBasedMapping has no cache, and
// does not inherit from CachedDNSToSwitchMapping // does not inherit from CachedDNSToSwitchMapping
} }
@Override
public void reloadCachedMappings(List<String> names) {
// Nothing to do here, since RawScriptBasedMapping has no cache, and
// does not inherit from CachedDNSToSwitchMapping
}
} }
} }

View File

@ -162,5 +162,12 @@ public class TableMapping extends CachedDNSToSwitchMapping {
} }
} }
} }
@Override
public void reloadCachedMappings(List<String> names) {
// TableMapping has to reload all mappings at once, so no chance to
// reload mappings on specific nodes
reloadCachedMappings();
}
} }
} }

View File

@ -152,4 +152,10 @@ public class StaticMapping extends AbstractDNSToSwitchMapping {
// reloadCachedMappings does nothing for StaticMapping; there is // reloadCachedMappings does nothing for StaticMapping; there is
// nowhere to reload from since all data is in memory. // nowhere to reload from since all data is in memory.
} }
@Override
public void reloadCachedMappings(List<String> names) {
// reloadCachedMappings does nothing for StaticMapping; there is
// nowhere to reload from since all data is in memory.
}
} }

View File

@ -120,5 +120,9 @@ public class TestSwitchMapping extends Assert {
@Override @Override
public void reloadCachedMappings() { public void reloadCachedMappings() {
} }
@Override
public void reloadCachedMappings(List<String> names) {
}
} }
} }

View File

@ -886,7 +886,12 @@ public class DatanodeManager {
// If the network location is invalid, clear the cached mappings // If the network location is invalid, clear the cached mappings
// so that we have a chance to re-add this DataNode with the // so that we have a chance to re-add this DataNode with the
// correct network location later. // correct network location later.
dnsToSwitchMapping.reloadCachedMappings(); List<String> invalidNodeNames = new ArrayList<String>(3);
// clear cache for nodes in IP or Hostname
invalidNodeNames.add(nodeReg.getIpAddr());
invalidNodeNames.add(nodeReg.getHostName());
invalidNodeNames.add(nodeReg.getPeerHostName());
dnsToSwitchMapping.reloadCachedMappings(invalidNodeNames);
throw e; throw e;
} }
} }

View File

@ -99,6 +99,10 @@ public class TestJobHistoryParsing {
@Override @Override
public void reloadCachedMappings() { public void reloadCachedMappings() {
} }
@Override
public void reloadCachedMappings(List<String> names) {
}
} }
@Test(timeout = 50000) @Test(timeout = 50000)

View File

@ -215,6 +215,10 @@ public class TestAMRMClientContainerRequest {
@Override @Override
public void reloadCachedMappings() {} public void reloadCachedMappings() {}
@Override
public void reloadCachedMappings(List<String> names) {
}
} }
private void verifyResourceRequest( private void verifyResourceRequest(

View File

@ -67,6 +67,10 @@ public class TestRackResolver {
public void reloadCachedMappings() { public void reloadCachedMappings() {
// nothing to do here, since RawScriptBasedMapping has no cache. // nothing to do here, since RawScriptBasedMapping has no cache.
} }
@Override
public void reloadCachedMappings(List<String> names) {
}
} }
@Test @Test