This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 18ef01a  Make client keepAliveInterval configurable in client side 
(#1547)
18ef01a is described below

commit 18ef01a1b035730a5a8b5ad479869131012e72b6
Author: Jia Zhai <zhaiji...@gmail.com>
AuthorDate: Thu Apr 12 14:25:04 2018 -0700

    Make client keepAliveInterval configurable in client side (#1547)
    
    * make client keepAliveInterval configurable
    
    * add client builder for config
    
    * change to use TimeUnit
---
 .../src/main/java/org/apache/pulsar/client/api/ClientBuilder.java | 8 ++++++++
 .../java/org/apache/pulsar/client/impl/ClientBuilderImpl.java     | 6 ++++++
 .../src/main/java/org/apache/pulsar/client/impl/ClientCnx.java    | 2 +-
 .../apache/pulsar/client/impl/conf/ClientConfigurationData.java   | 1 +
 4 files changed, 16 insertions(+), 1 deletion(-)

diff --git 
a/pulsar-client/src/main/java/org/apache/pulsar/client/api/ClientBuilder.java 
b/pulsar-client/src/main/java/org/apache/pulsar/client/api/ClientBuilder.java
index b832e59..418953d 100644
--- 
a/pulsar-client/src/main/java/org/apache/pulsar/client/api/ClientBuilder.java
+++ 
b/pulsar-client/src/main/java/org/apache/pulsar/client/api/ClientBuilder.java
@@ -262,4 +262,12 @@ public interface ClientBuilder extends Serializable, 
Cloneable {
      * @param maxNumberOfRejectedRequestPerConnection
      */
     ClientBuilder maxNumberOfRejectedRequestPerConnection(int 
maxNumberOfRejectedRequestPerConnection);
+
+    /**
+     * Set keep alive interval in seconds for each client-broker-connection. 
<i>(default: 30)</i>.
+     *
+     * @param keepAliveIntervalSeconds
+     * @param unit time unit for {@code statsInterval}
+     */
+    ClientBuilder keepAliveInterval(int keepAliveIntervalSeconds, TimeUnit 
unit);
 }
diff --git 
a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientBuilderImpl.java
 
b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientBuilderImpl.java
index 3effc7f..deb0625 100644
--- 
a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientBuilderImpl.java
+++ 
b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientBuilderImpl.java
@@ -155,6 +155,12 @@ public class ClientBuilderImpl implements ClientBuilder {
         return this;
     }
 
+    @Override
+    public ClientBuilder keepAliveInterval(int keepAliveIntervalSeconds, 
TimeUnit unit) {
+        
conf.setKeepAliveIntervalSeconds((int)unit.toSeconds(keepAliveIntervalSeconds));
+        return this;
+    }
+
     public ClientConfigurationData getClientConfigurationData() {
         return conf;
     }
diff --git 
a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java 
b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java
index d89d8fb..39aac44 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java
@@ -107,7 +107,7 @@ public class ClientCnx extends PulsarHandler {
     }
 
     public ClientCnx(ClientConfigurationData conf, EventLoopGroup 
eventLoopGroup) {
-        super(30, TimeUnit.SECONDS);
+        super(conf.getKeepAliveIntervalSeconds(), TimeUnit.SECONDS);
         this.pendingLookupRequestSemaphore = new 
Semaphore(conf.getConcurrentLookupRequest(), true);
         this.authentication = conf.getAuthentication();
         this.eventLoopGroup = eventLoopGroup;
diff --git 
a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ClientConfigurationData.java
 
b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ClientConfigurationData.java
index 4fe7569..859bb1b 100644
--- 
a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ClientConfigurationData.java
+++ 
b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ClientConfigurationData.java
@@ -53,6 +53,7 @@ public class ClientConfigurationData implements Serializable, 
Cloneable {
     private boolean tlsHostnameVerificationEnable = false;
     private int concurrentLookupRequest = 50000;
     private int maxNumberOfRejectedRequestPerConnection = 50;
+    private int keepAliveIntervalSeconds = 30;
 
     public ClientConfigurationData clone() {
         try {

-- 
To stop receiving notification emails like this one, please contact
mme...@apache.org.

Reply via email to