Package com.browserup.bup.proxy.dns
Class NativeCacheManipulatingResolver
- java.lang.Object
-
- com.browserup.bup.proxy.dns.AbstractHostNameRemapper
-
- com.browserup.bup.proxy.dns.NativeResolver
-
- com.browserup.bup.proxy.dns.NativeCacheManipulatingResolver
-
- All Implemented Interfaces:
AdvancedHostResolver,HostResolver
public class NativeCacheManipulatingResolver extends NativeResolver
AnAdvancedHostResolverthat provides native JVM lookup usingNativeResolverbut 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 asNativeResolveron that platform.
-
-
Constructor Summary
Constructors Constructor Description NativeCacheManipulatingResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearDNSCache()Clears both the positive (successful DNS lookups) and negative (failed DNS lookups) cache.voidsetNegativeDNSCacheTimeout(int timeout, java.util.concurrent.TimeUnit timeUnit)Sets the negative (failed DNS lookup) timeout when making DNS lookups.voidsetPositiveDNSCacheTimeout(int timeout, java.util.concurrent.TimeUnit timeUnit)Sets the positive (successful DNS lookup) timeout when making DNS lookups.-
Methods inherited from class com.browserup.bup.proxy.dns.NativeResolver
resolveRemapped
-
Methods inherited from class com.browserup.bup.proxy.dns.AbstractHostNameRemapper
applyRemapping, clearHostRemappings, getHostRemappings, getOriginalHostnames, remapHost, remapHosts, removeHostRemapping, resolve
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.browserup.bup.proxy.dns.AdvancedHostResolver
clearHostRemappings, getHostRemappings, getOriginalHostnames, remapHost, remapHosts, removeHostRemapping
-
Methods inherited from interface com.browserup.bup.proxy.dns.HostResolver
resolve
-
-
-
-
Method Detail
-
clearDNSCache
public void clearDNSCache()
Description copied from interface:AdvancedHostResolverClears both the positive (successful DNS lookups) and negative (failed DNS lookups) cache.- Specified by:
clearDNSCachein interfaceAdvancedHostResolver- Overrides:
clearDNSCachein classNativeResolver
-
setPositiveDNSCacheTimeout
public void setPositiveDNSCacheTimeout(int timeout, java.util.concurrent.TimeUnit timeUnit)Description copied from interface:AdvancedHostResolverSets the positive (successful DNS lookup) timeout when making DNS lookups. Note: The timeUnit parameter does not guarantee the specified precision; implementations may need to reduce precision, depending on the underlying DNS implementation. For example, the Oracle JVM's DNS cache only supports timeouts in whole seconds, so specifying a timeout of 1200ms will result in a timeout of 1 second.- Specified by:
setPositiveDNSCacheTimeoutin interfaceAdvancedHostResolver- Overrides:
setPositiveDNSCacheTimeoutin classNativeResolver- Parameters:
timeout- maximum lookup timetimeUnit- units of the timeout value
-
setNegativeDNSCacheTimeout
public void setNegativeDNSCacheTimeout(int timeout, java.util.concurrent.TimeUnit timeUnit)Description copied from interface:AdvancedHostResolverSets the negative (failed DNS lookup) timeout when making DNS lookups. Note: The timeUnit parameter does not guarantee the specified precision; implementations may need to reduce precision, depending on the underlying DNS implementation. For example, the Oracle JVM's DNS cache only supports timeouts in whole seconds, so specifying a timeout of 1200ms will result in a timeout of 1 second.- Specified by:
setNegativeDNSCacheTimeoutin interfaceAdvancedHostResolver- Overrides:
setNegativeDNSCacheTimeoutin classNativeResolver- Parameters:
timeout- maximum lookup timetimeUnit- units of the timeout value
-
-