Class NativeCacheManipulatingResolver

  • All Implemented Interfaces:
    AdvancedHostResolver, HostResolver

    public class NativeCacheManipulatingResolver
    extends NativeResolver
    An 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 Detail

      • NativeCacheManipulatingResolver

        public NativeCacheManipulatingResolver()
    • Method Detail

      • setPositiveDNSCacheTimeout

        public void setPositiveDNSCacheTimeout​(int timeout,
                                               java.util.concurrent.TimeUnit timeUnit)
        Description copied from interface: AdvancedHostResolver
        Sets 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:
        setPositiveDNSCacheTimeout in interface AdvancedHostResolver
        Overrides:
        setPositiveDNSCacheTimeout in class NativeResolver
        Parameters:
        timeout - maximum lookup time
        timeUnit - units of the timeout value
      • setNegativeDNSCacheTimeout

        public void setNegativeDNSCacheTimeout​(int timeout,
                                               java.util.concurrent.TimeUnit timeUnit)
        Description copied from interface: AdvancedHostResolver
        Sets 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:
        setNegativeDNSCacheTimeout in interface AdvancedHostResolver
        Overrides:
        setNegativeDNSCacheTimeout in class NativeResolver
        Parameters:
        timeout - maximum lookup time
        timeUnit - units of the timeout value