dnsMonitoring turned on by default for SingleServerConfig

pull/903/head
Nikita 8 years ago
parent ee3617be5d
commit 4a37a5e4a4

@ -64,7 +64,7 @@ public class SingleServerConfig extends BaseConfig<SingleServerConfig> {
* <em>NB: applications must ensure the JVM DNS cache TTL is low enough to support this.</em> * <em>NB: applications must ensure the JVM DNS cache TTL is low enough to support this.</em>
* e.g., http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-jvm-ttl.html * e.g., http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-jvm-ttl.html
*/ */
private boolean dnsMonitoring = false; private boolean dnsMonitoring = true;
/** /**
* Interval in milliseconds to check DNS * Interval in milliseconds to check DNS
@ -144,8 +144,10 @@ public class SingleServerConfig extends BaseConfig<SingleServerConfig> {
/** /**
* Monitoring of the endpoint address for DNS changes. * Monitoring of the endpoint address for DNS changes.
* * <p>
* Default is false * Applications must ensure the JVM DNS cache TTL is low enough to support this
* <p>
* Default is <code>true</code>
* *
* @param dnsMonitoring flag * @param dnsMonitoring flag
* @return config * @return config
@ -161,7 +163,7 @@ public class SingleServerConfig extends BaseConfig<SingleServerConfig> {
/** /**
* Interval in milliseconds to check the endpoint DNS if {@link #isDnsMonitoring()} is true. * Interval in milliseconds to check the endpoint DNS if {@link #isDnsMonitoring()} is true.
* *
* Default is 5000 * Default is <code>5000</code>
* *
* @param dnsMonitoringInterval time * @param dnsMonitoringInterval time
* @return config * @return config

@ -93,7 +93,11 @@ public class SingleConnectionManager extends MasterSlaveConnectionManager {
} }
private void monitorDnsChange(final SingleServerConfig cfg) { private void monitorDnsChange(final SingleServerConfig cfg) {
monitorFuture = GlobalEventExecutor.INSTANCE.scheduleWithFixedDelay(new Runnable() { monitorFuture = GlobalEventExecutor.INSTANCE.schedule(new Runnable() {
@Override
public void run() {
// As InetAddress.getByName call is blocking. Method should be run in dedicated thread
getExecutor().execute(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
@ -106,14 +110,16 @@ public class SingleConnectionManager extends MasterSlaveConnectionManager {
log.info("Master has been changed"); log.info("Master has been changed");
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} finally {
monitorDnsChange(cfg);
} }
}
});
} }
}, cfg.getDnsMonitoringInterval(), cfg.getDnsMonitoringInterval(), TimeUnit.MILLISECONDS); }, cfg.getDnsMonitoringInterval(), TimeUnit.MILLISECONDS);
} }
@Override @Override

Loading…
Cancel
Save