You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2018/07/04 02:37:30 UTC

[3/7] james-project git commit: JAMES-2443 Add more configuration elements in DNSService

JAMES-2443 Add more configuration elements in DNSService


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/42e473ec
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/42e473ec
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/42e473ec

Branch: refs/heads/master
Commit: 42e473ecfb9fdd4ed18f8d20131bd27e7d86c35a
Parents: c09ed3b
Author: Antoine Duprat <ad...@linagora.com>
Authored: Wed Jun 27 15:38:25 2018 +0200
Committer: benwa <bt...@linagora.com>
Committed: Wed Jul 4 09:33:15 2018 +0700

----------------------------------------------------------------------
 .../apache/james/dnsservice/dnsjava/DNSJavaService.java  | 11 +++++++++++
 src/site/xdoc/server/config-dnsservice.xml               |  4 ++++
 2 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/42e473ec/server/dns-service/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
----------------------------------------------------------------------
diff --git a/server/dns-service/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java b/server/dns-service/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
index fe8e6d7..efef1f3 100644
--- a/server/dns-service/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
+++ b/server/dns-service/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java
@@ -65,6 +65,8 @@ import com.google.common.collect.ImmutableList;
 public class DNSJavaService implements DNSService, DNSServiceMBean, Configurable {
     private static final Logger LOGGER = LoggerFactory.getLogger(DNSJavaService.class);
 
+    private static final int CACHE_TTL_DISABLE = -1;
+
     /**
      * A resolver instance used to retrieve DNS records. This is a reference to
      * a third party library object.
@@ -82,6 +84,8 @@ public class DNSJavaService implements DNSService, DNSServiceMBean, Configurable
      */
     private int maxCacheSize = 50000;
 
+    private int negativeCacheTTL;
+
     /**
      * Whether the DNS response is required to be authoritative
      */
@@ -123,6 +127,10 @@ public class DNSJavaService implements DNSService, DNSServiceMBean, Configurable
 
     @Override
     public void configure(HierarchicalConfiguration configuration) throws ConfigurationException {
+        boolean verbose = configuration.getBoolean("verbose", false);
+        if (verbose) {
+            System.setProperty("dnsjava.options", "verbose,verbosemsg,verbosecache");
+        }
 
         boolean autodiscover = configuration.getBoolean("autodiscover", true);
 
@@ -177,6 +185,8 @@ public class DNSJavaService implements DNSService, DNSServiceMBean, Configurable
         dnsCredibility = authoritative ? Credibility.AUTH_ANSWER : Credibility.NONAUTH_ANSWER;
 
         maxCacheSize = configuration.getInt("maxcachesize", maxCacheSize);
+
+        negativeCacheTTL = configuration.getInt("negativeCacheTTL", CACHE_TTL_DISABLE);
     }
 
     @PostConstruct
@@ -210,6 +220,7 @@ public class DNSJavaService implements DNSService, DNSServiceMBean, Configurable
 
         cache = new Cache(DClass.IN);
         cache.setMaxEntries(maxCacheSize);
+        cache.setMaxNCache(negativeCacheTTL);
 
         if (setAsDNSJavaDefault) {
             Lookup.setDefaultResolver(resolver);

http://git-wip-us.apache.org/repos/asf/james-project/blob/42e473ec/src/site/xdoc/server/config-dnsservice.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-dnsservice.xml b/src/site/xdoc/server/config-dnsservice.xml
index cd8c3f4..3ddd2a6 100755
--- a/src/site/xdoc/server/config-dnsservice.xml
+++ b/src/site/xdoc/server/config-dnsservice.xml
@@ -61,8 +61,12 @@
            This should always be <strong>false</strong> unless you understand the implications.</dd>
         <dt><strong>maxcachesize</strong></dt>
         <dd>Maximum number of entries to maintain in the DNS cache (typically 50000)</dd>
+        <dt><strong>negativeCacheTTL</strong></dt>
+        <dd>Sets the maximum length of time that negative records will be stored in the DNS negative cache in seconds (a negative record means the name has not been found in the DNS). Values for this cache can be positive meaning the time in seconds before retrying to resolve the name, zero meaning no cache or a negative value meaning infinite caching.</dd>
         <dt><strong>singleIPperMX</strong></dt>
         <dd>true or false (default) - Specifies if Apache James Server must try a single server for each multihomed mx host</dd>
+        <dt><strong>verbose</strong></dt>
+        <dd>Turn on general debugging statements</dd>
       </dl>
       
     </subsection>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org