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/trunk@1526567 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Colin McCabe 2013-09-26 15:24:30 +00:00
parent 476eca47b5
commit 8a66e493ba
11 changed files with 59 additions and 1 deletions

View File

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

View File

@ -154,4 +154,11 @@ public class CachedDNSToSwitchMapping extends AbstractDNSToSwitchMapping {
public void reloadCachedMappings() {
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.
*/
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
// 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
// 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
public void reloadCachedMappings() {
}
@Override
public void reloadCachedMappings(List<String> names) {
}
}
}

View File

@ -887,7 +887,12 @@ public class DatanodeManager {
// If the network location is invalid, clear the cached mappings
// so that we have a chance to re-add this DataNode with the
// 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;
}
}

View File

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

View File

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

View File

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