Minor refactoring of how we set interval for maintainers
@@ -11,8 +11,6 @@ import java.time.Duration;
public class ConfigServerMaintenance extends AbstractComponent {
- private static final Duration intervalInCd = Duration.ofMinutes(5);
-
private final TenantsMaintainer tenantsMaintainer;
private final ZooKeeperDataMaintainer zooKeeperDataMaintainer;
@@ -20,12 +18,9 @@ public class ConfigServerMaintenance extends AbstractComponent {
public ConfigServerMaintenance(ConfigserverConfig configserverConfig,
ApplicationRepository applicationRepository,
Curator curator) {
- boolean isCd = configserverConfig.system().equals(SystemName.cd.name());
- Duration defaultInterval = isCd ? intervalInCd : Duration.ofMinutes(configserverConfig.maintainerIntervalMinutes());
- Duration tenantsMaintainerInterval = isCd ? intervalInCd : Duration.ofMinutes(configserverConfig.tenantsMaintainerIntervalMinutes());
-
- tenantsMaintainer = new TenantsMaintainer(applicationRepository, curator, tenantsMaintainerInterval);
- zooKeeperDataMaintainer = new ZooKeeperDataMaintainer(applicationRepository, curator, defaultInterval);
+ DefaultTimes defaults = new DefaultTimes(configserverConfig);
+ tenantsMaintainer = new TenantsMaintainer(applicationRepository, curator, defaults.tenantsMaintainerInterval);
+ zooKeeperDataMaintainer = new ZooKeeperDataMaintainer(applicationRepository, curator, defaults.zookeeperDataMaintainerInterval);
}
@Override
@@ -34,4 +29,24 @@ public class ConfigServerMaintenance extends AbstractComponent {
zooKeeperDataMaintainer.deconstruct();
}
+ /*
+ * Default values from config. If one of the values needs to be changed, add the value to
+ * configserver-config.xml in the config server application directory and restart the config server
+ */
+ private static class DefaultTimes {
+
+ private final Duration defaultInterval;
+ private final Duration tenantsMaintainerInterval;
+ private final Duration zookeeperDataMaintainerInterval;
+
+ DefaultTimes(ConfigserverConfig configserverConfig) {
+ boolean isCd = configserverConfig.system().equals(SystemName.cd.name());
+
+ this.defaultInterval = Duration.ofMinutes(configserverConfig.maintainerIntervalMinutes());
+ // TODO: Want job control or feature flag to control when to run this, for now use a very long interval unless in CD
+ this.tenantsMaintainerInterval = isCd ? defaultInterval : Duration.ofMinutes(configserverConfig.tenantsMaintainerIntervalMinutes());
+ this.zookeeperDataMaintainerInterval = defaultInterval;
+ }
+ }
+
}
