RocMarshal commented on code in PR #865: URL: https://github.com/apache/flink-kubernetes-operator/pull/865#discussion_r1717923090
########## flink-autoscaler-plugin-jdbc/src/main/java/org/apache/flink/autoscaler/jdbc/event/JdbcAutoScalerEventHandler.java: ########## @@ -38,13 +47,34 @@ * @param <Context> The job autoscaler context. */ @Experimental +@Slf4j public class JdbcAutoScalerEventHandler<KEY, Context extends JobAutoScalerContext<KEY>> implements AutoScalerEventHandler<KEY, Context> { private final JdbcEventInteractor jdbcEventInteractor; + private final Duration eventHandlerTtl; + @Nullable private final ScheduledExecutorService scheduledEventHandlerCleaner; - public JdbcAutoScalerEventHandler(JdbcEventInteractor jdbcEventInteractor) { + public JdbcAutoScalerEventHandler( + JdbcEventInteractor jdbcEventInteractor, Duration eventHandlerTtl) { this.jdbcEventInteractor = jdbcEventInteractor; + this.eventHandlerTtl = Preconditions.checkNotNull(eventHandlerTtl); + + if (eventHandlerTtl.toMillis() <= 0) { + this.scheduledEventHandlerCleaner = null; + return; + } + this.scheduledEventHandlerCleaner = + Executors.newSingleThreadScheduledExecutor( + new ThreadFactoryBuilder() + .setNameFormat("jdbc-autoscaler-events-cleaner") + .setDaemon(false) Review Comment: - IIUC, There is no explicit exit operation in the entire service, so the default value of false can be used here. It is not necessary to set it to true to automatically exit after waiting for other threads to finish. - Explicit call for readability -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org