poorbarcode commented on code in PR #16165:
URL: https://github.com/apache/pulsar/pull/16165#discussion_r930773553


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java:
##########
@@ -104,6 +122,27 @@ public ConnectionPool(ClientConfigurationData conf, 
EventLoopGroup eventLoopGrou
 
         this.shouldCloseDnsResolver = !addressResolver.isPresent();
         this.addressResolver = addressResolver.orElseGet(() -> 
createAddressResolver(conf, eventLoopGroup));
+        // Auto release useless connections. see: 
https://github.com/apache/pulsar/issues/15516.
+        this.connectionMaxIdleSeconds = conf.getConnectionMaxIdleSeconds();
+        this.autoReleaseIdleConnectionsEnabled = connectionMaxIdleSeconds > 0;
+        if (autoReleaseIdleConnectionsEnabled) {
+            // Start async task for release useless connections.
+            this.idleDetectionIntervalSeconds = connectionMaxIdleSeconds;
+            if (this.idleDetectionIntervalSeconds < 30){
+                log.warn("Connection idle detect interval seconds default same 
as max idle seconds, but max idle"
+                                + " seconds less than " + 
IDLE_DETECTION_INTERVAL_SECONDS_MIN + ", to avoid checking"
+                                + " connection status too much, use default 
value : "
+                                + IDLE_DETECTION_INTERVAL_SECONDS_MIN);
+                this.idleDetectionIntervalSeconds = 
IDLE_DETECTION_INTERVAL_SECONDS_MIN;
+            }
+            asyncReleaseUselessConnectionsTask = 
eventLoopGroup.scheduleAtFixedRate(() -> {

Review Comment:
   Already fixed. Thanks



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to