public class NativeCacheManipulatingResolver extends NativeResolver
AdvancedHostResolver
that provides native JVM lookup using NativeResolver
but also implements DNS cache manipulation functionality.
Important note: The Oracle JVM does not provide any public facility to manipulate the JVM's DNS cache. This class uses reflection to forcibly
manipulate the cache, which includes access to private class members that are not part of the published Java specification. As such, this
implementation is brittle and may break in a future Java release, or may not work on non-Oracle JVMs. If this implementation cannot
perform any of its operations due to a failure to find or set the relevant field using reflection, it will log a warning but will not
throw an exception. You are using this class at your own risk! JVM cache manipulation does not work on Windows -- this class will behave exactly
the same as NativeResolver
on that platform.Constructor and Description |
---|
NativeCacheManipulatingResolver() |
Modifier and Type | Method and Description |
---|---|
void |
clearDNSCache()
Clears both the positive (successful DNS lookups) and negative (failed DNS lookups) cache.
|
void |
setNegativeDNSCacheTimeout(int timeout,
TimeUnit timeUnit)
Sets the negative (failed DNS lookup) timeout when making DNS lookups.
|
void |
setPositiveDNSCacheTimeout(int timeout,
TimeUnit timeUnit)
Sets the positive (successful DNS lookup) timeout when making DNS lookups.
|
resolveRemapped
applyRemapping, clearHostRemappings, getHostRemappings, getOriginalHostnames, remapHost, remapHosts, removeHostRemapping, resolve
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clearHostRemappings, getHostRemappings, getOriginalHostnames, remapHost, remapHosts, removeHostRemapping
resolve
public void clearDNSCache()
AdvancedHostResolver
clearDNSCache
in interface AdvancedHostResolver
clearDNSCache
in class NativeResolver
public void setPositiveDNSCacheTimeout(int timeout, TimeUnit timeUnit)
AdvancedHostResolver
setPositiveDNSCacheTimeout
in interface AdvancedHostResolver
setPositiveDNSCacheTimeout
in class NativeResolver
timeout
- maximum lookup timetimeUnit
- units of the timeout valuepublic void setNegativeDNSCacheTimeout(int timeout, TimeUnit timeUnit)
AdvancedHostResolver
setNegativeDNSCacheTimeout
in interface AdvancedHostResolver
setNegativeDNSCacheTimeout
in class NativeResolver
timeout
- maximum lookup timetimeUnit
- units of the timeout valueCopyright © 2017. All rights reserved.