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>
* 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
@ -144,8 +144,10 @@ public class SingleServerConfig extends BaseConfig<SingleServerConfig> {
/**
* Monitoring of the endpoint address for DNS changes.
*
* Default is false
* <p>
* Applications must ensure the JVM DNS cache TTL is low enough to support this
* <p>
* Default is <code>true</code>
*
* @param dnsMonitoring flag
* @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.
*
* Default is 5000
* Default is <code>5000</code>
*
* @param dnsMonitoringInterval time
* @return config

@ -93,7 +93,11 @@ public class SingleConnectionManager extends MasterSlaveConnectionManager {
}
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
public void run() {
try {
@ -106,14 +110,16 @@ public class SingleConnectionManager extends MasterSlaveConnectionManager {
log.info("Master has been changed");
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
monitorDnsChange(cfg);
}
}
});
}
}, cfg.getDnsMonitoringInterval(), cfg.getDnsMonitoringInterval(), TimeUnit.MILLISECONDS);
}, cfg.getDnsMonitoringInterval(), TimeUnit.MILLISECONDS);
}
@Override

Loading…
Cancel
Save