in wrapper/src/main/java/software/amazon/jdbc/hostlistprovider/monitoring/ClusterTopologyMonitorImpl.java [121:173]
public ClusterTopologyMonitorImpl(
final String clusterId,
final CacheMap<String, List<HostSpec>> topologyMap,
final HostSpec initialHostSpec,
final Properties properties,
final PluginService pluginService,
final HostListProviderService hostListProviderService,
final HostSpec clusterInstanceTemplate,
final long refreshRateNano,
final long highRefreshRateNano,
final long topologyCacheExpirationNano,
final String topologyQuery,
final String writerTopologyQuery,
final String nodeIdQuery) {
this.clusterId = clusterId;
this.topologyMap = topologyMap;
this.initialHostSpec = initialHostSpec;
this.pluginService = pluginService;
this.hostListProviderService = hostListProviderService;
this.clusterInstanceTemplate = clusterInstanceTemplate;
this.properties = properties;
this.refreshRateNano = refreshRateNano;
this.highRefreshRateNano = highRefreshRateNano;
this.topologyCacheExpirationNano = topologyCacheExpirationNano;
this.topologyQuery = topologyQuery;
this.writerTopologyQuery = writerTopologyQuery;
this.nodeIdQuery = nodeIdQuery;
this.monitoringProperties = PropertyUtils.copyProperties(properties);
this.properties.stringPropertyNames().stream()
.filter(p -> p.startsWith(MONITORING_PROPERTY_PREFIX))
.forEach(
p -> {
this.monitoringProperties.put(
p.substring(MONITORING_PROPERTY_PREFIX.length()),
this.properties.getProperty(p));
this.monitoringProperties.remove(p);
});
// Set default values if they are not provided.
if (PropertyDefinition.SOCKET_TIMEOUT.getString(this.monitoringProperties) == null) {
PropertyDefinition.SOCKET_TIMEOUT.set(
this.monitoringProperties, String.valueOf(defaultSocketTimeoutMs));
}
if (PropertyDefinition.CONNECT_TIMEOUT.getString(this.monitoringProperties) == null) {
PropertyDefinition.CONNECT_TIMEOUT.set(
this.monitoringProperties, String.valueOf(defaultConnectionTimeoutMs));
}
this.monitorExecutor.submit(this);
this.monitorExecutor.shutdown(); // No more tasks are accepted by the pool.
}