org.apache.jmeter.protocol.http.control

## Class DNSCacheManager

- java.lang.Object
- - org.apache.jmeter.testelement.AbstractTestElement
  - - org.apache.jmeter.config.ConfigTestElement
    - - org.apache.jmeter.protocol.http.control.DNSCacheManager

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.apache.http.conn.DnsResolver, ConfigElement, Searchable, TestElement, TestIterationListener

      public class DNSCacheManager
      extends ConfigTestElement
      implements TestIterationListener, java.io.Serializable, org.apache.http.conn.DnsResolver

  This config element provides ability to have flexible control over DNS caching function. Depending on option from @see `DNSCachePanel`, either system or custom resolver can be used. Custom resolver uses dnsjava library, and gives ability to bypass both OS and JVM cache. It allows to use paradigm "1 virtual user - 1 DNS cache" in performance tests.
  Since:
    2.12
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `DEFAULT_CLEAR_CACHE_EACH_ITER`

    - ### Fields inherited from class org.apache.jmeter.config.ConfigTestElement

      `PASSWORD, USERNAME`

    - ### Fields inherited from interface org.apache.jmeter.testelement.TestElement

      `COMMENTS, ENABLED, GUI_CLASS, NAME, TEST_CLASS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DNSCacheManager()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addHost(java.lang.String dnsHost, java.lang.String addresses)` Add static host
    `void` | `addServer(java.lang.String dnsServer)` Add DNS Server
    `void` | `clear()` Clear the TestElement of all data.
    `java.lang.Object` | `clone()`
    `CollectionProperty` | `getHosts()`
    `CollectionProperty` | `getServers()`
    `boolean` | `isClearEachIteration()` Clean DNS cache each iteration
    `boolean` | `isCustomResolver()`
    `java.net.InetAddress[]` | `resolve(java.lang.String host)` Resolves address using system or custom DNS resolver
    `void` | `setClearEachIteration(boolean clear)` Clean DNS cache each iteration
    `void` | `setCustomResolver(boolean isCustomResolver)`
    `void` | `testIterationStart(LoopIterationEvent event)` Each time through a Thread Group's test script, an iteration event is fired for each thread.

    - ### Methods inherited from class org.apache.jmeter.config.ConfigTestElement

      `addConfigElement, addTestElement, expectsModification`

    - ### Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

      `addPropertiesValues, addProperty, addProperty, canRemove, clearTemporary, clearTestElementChildren, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.jmeter.testelement.TestElement

      `removed`

- - ### Field Detail

    - #### DEFAULT_CLEAR_CACHE_EACH_ITER

          public static final boolean DEFAULT_CLEAR_CACHE_EACH_ITER

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### DNSCacheManager

          public DNSCacheManager()

  - ### Method Detail

    - #### clone

          public java.lang.Object clone()

      Specified by:
        `clone` in interface `ConfigElement`
      Specified by:
        `clone` in interface `TestElement`
      Overrides:
        `clone` in class `AbstractTestElement`

    - #### resolve

          public java.net.InetAddress[] resolve(java.lang.String host)
                                         throws java.net.UnknownHostException

      Resolves address using system or custom DNS resolver
      Specified by:
        `resolve` in interface `org.apache.http.conn.DnsResolver`
      Throws:
        `java.net.UnknownHostException`

    - #### testIterationStart

          public void testIterationStart(LoopIterationEvent event)

      Each time through a Thread Group's test script, an iteration event is fired for each thread. This will be after the test elements have been cloned, so in general the instance will not be the same as the ones the start/end methods call. Clean DNS cache if appropriate check-box was selected
      Specified by:
        `testIterationStart` in interface `TestIterationListener`
      Parameters:
        `event` - the iteration event

    - #### clear

          public void clear()

      Clear the TestElement of all data.
      Specified by:
        `clear` in interface `TestElement`
      Overrides:
        `clear` in class `AbstractTestElement`

    - #### addServer

          public void addServer(java.lang.String dnsServer)

      Add DNS Server
      Parameters:
        `dnsServer` - DNS Server

    - #### getServers

          public CollectionProperty getServers()

      Returns:
        DNS Servers

    - #### addHost

          public void addHost(java.lang.String dnsHost,
                              java.lang.String addresses)

      Add static host
      Parameters:
        `dnsHost` - DNS host
        `addresses` - Comma separated list of addresses

    - #### getHosts

          public CollectionProperty getHosts()

    - #### isClearEachIteration

          public boolean isClearEachIteration()

      Clean DNS cache each iteration
      Returns:
        boolean

    - #### setClearEachIteration

          public void setClearEachIteration(boolean clear)

      Clean DNS cache each iteration
      Parameters:
        `clear` - flag whether DNS cache should be cleared on each iteration

    - #### isCustomResolver

          public boolean isCustomResolver()

    - #### setCustomResolver

          public void setCustomResolver(boolean isCustomResolver)

Copyright © 1998-2018 Apache Software Foundation. All Rights Reserved.