Skip to content

Commit

Permalink
Use a different connectTimeout for HealthManager (#460)
Browse files Browse the repository at this point in the history
* Use a different connectTimeout for health manager
* Fix test
  • Loading branch information
hamadodene authored Feb 21, 2024
1 parent e945c8c commit 834e95c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class RuntimeServerConfiguration {
private int accessLogAdvancedBodySize = 1_000; // bytes
private String userRealmClassname;
private int healthProbePeriod = 0;
private int healthConnectTimeout = 5_000;
private int dynamicCertificatesManagerPeriod = 0;
private int keyPairsSize = DEFAULT_KEYPAIRS_SIZE;
private Set<String> domainsCheckerIPAddresses;
Expand Down Expand Up @@ -209,6 +210,12 @@ public void configure(ConfigurationStore properties) throws ConfigurationNotVali
LOG.warning("BACKEND-HEALTH-MANAGER DISABLED");
}

healthConnectTimeout = properties.getInt("healthmanager.connecttimeout", healthConnectTimeout);
LOG.log(Level.INFO, "healthmanager.connecttimeout={0}", healthConnectTimeout);
if (healthConnectTimeout < 0) {
throw new ConfigurationNotValidException("Invalid value '" + this.healthConnectTimeout + "' for healthmanager.connecttimeout. ConnectTimeout cannot be negative");
}

dynamicCertificatesManagerPeriod = properties.getInt("dynamiccertificatesmanager.period", 0);
LOG.log(Level.INFO, "dynamiccertificatesmanager.period={0}", dynamicCertificatesManagerPeriod);
keyPairsSize = properties.getInt("dynamiccertificatesmanager.keypairssize", DEFAULT_KEYPAIRS_SIZE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public BackendHealthManager(RuntimeServerConfiguration conf, EndpointMapper mapp

// will be overridden before start
this.period = DEFAULT_PERIOD;
this.connectTimeout = conf.getConnectTimeout();
this.connectTimeout = conf.getHealthConnectTimeout();

}

Expand Down Expand Up @@ -122,8 +122,8 @@ public synchronized void reloadConfiguration(RuntimeServerConfiguration newConfi
LOG.info("Applying health probe period " + period + " s");
}

if (this.connectTimeout != newConfiguration.getConnectTimeout()) {
this.connectTimeout = newConfiguration.getConnectTimeout();
if (this.connectTimeout != newConfiguration.getHealthConnectTimeout()) {
this.connectTimeout = newConfiguration.getHealthConnectTimeout();
LOG.info("Applying new connect timeout " + this.connectTimeout + " ms");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public void testChangeBackendHealthManagerConfiguration() throws Exception {

{
Properties configuration = new Properties();
configuration.put("connectionsmanager.connecttimeout", "9479");
configuration.put("healthmanager.connecttimeout", "9479");
server.configureAtBoot(new PropertiesConfigurationStore(configuration));
}
server.start();
Expand All @@ -386,7 +386,7 @@ public void testChangeBackendHealthManagerConfiguration() throws Exception {
// change configuration
{
Properties configuration = new Properties();
configuration.put("connectionsmanager.connecttimeout", "9233");
configuration.put("healthmanager.connecttimeout", "9233");
reloadConfiguration(configuration, server);

assertEquals(9233, server.getBackendHealthManager().getConnectTimeout());
Expand Down

0 comments on commit 834e95c

Please sign in to comment.