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

guangning pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit c8eb7198c56fdb47011f57b8a2d216cc729663a9
Author: lipenghui <[email protected]>
AuthorDate: Mon Feb 10 08:31:21 2020 +0800

    Expose bookkeeper expose explicit lac in broker.conf (#5822)
    
    ### Motivation
    
    Expose bookkeeper expose explicit lac configuration in broker.conf
    It's related to #3828 #4976, some Pulsar SQL users need to enable the 
explicitLacInterval, so that they can get the last message in Pulsar SQL.
---
 conf/broker.conf                                                 | 4 ++++
 conf/standalone.conf                                             | 4 ++++
 .../main/java/org/apache/pulsar/broker/ServiceConfiguration.java | 3 +++
 .../org/apache/pulsar/broker/BookKeeperClientFactoryImpl.java    | 1 +
 .../src/test/java/org/apache/pulsar/PulsarBrokerStarterTest.java | 2 ++
 .../apache/pulsar/broker/BookKeeperClientFactoryImplTest.java    | 9 +++++++++
 6 files changed, 23 insertions(+)

diff --git a/conf/broker.conf b/conf/broker.conf
index 05735c1..95eb411 100644
--- a/conf/broker.conf
+++ b/conf/broker.conf
@@ -517,6 +517,10 @@ bookkeeperTLSTrustCertsFilePath=
 # Enable/disable disk weight based placement. Default is false
 bookkeeperDiskWeightBasedPlacementEnabled=false
 
+# Set the interval to check the need for sending an explicit LAC
+# A value of '0' disables sending any explicit LACs. Default is 0.
+bookkeeperExplicitLacIntervalInMills=0;
+
 ### --- Managed Ledger --- ###
 
 # Number of bookies to use when creating a ledger
diff --git a/conf/standalone.conf b/conf/standalone.conf
index 6d1023b..138525e 100644
--- a/conf/standalone.conf
+++ b/conf/standalone.conf
@@ -334,6 +334,10 @@ bookkeeperTLSTrustCertsFilePath=
 # Enable/disable disk weight based placement. Default is false
 bookkeeperDiskWeightBasedPlacementEnabled=false
 
+# Set the interval to check the need for sending an explicit LAC
+# A value of '0' disables sending any explicit LACs. Default is 0.
+bookkeeperExplicitLacIntervalInMills=0;
+
 ### --- Managed Ledger --- ###
 
 # Number of bookies to use when creating a ledger
diff --git 
a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
 
b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
index 79d4da5..dceaf77 100644
--- 
a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
+++ 
b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
@@ -860,6 +860,9 @@ public class ServiceConfiguration implements 
PulsarConfiguration {
     @FieldContext(category = CATEGORY_STORAGE_BK, doc = "Enable/disable disk 
weight based placement. Default is false")
     private boolean bookkeeperDiskWeightBasedPlacementEnabled = false;
 
+    @FieldContext(category = CATEGORY_STORAGE_BK, doc = "Set the interval to 
check the need for sending an explicit LAC")
+    private int bookkeeperExplicitLacIntervalInMills = 0;
+
     /**** --- Managed Ledger --- ****/
     @FieldContext(
         minValue = 1,
diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/BookKeeperClientFactoryImpl.java
 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/BookKeeperClientFactoryImpl.java
index f48c915..0d1d7a8 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/BookKeeperClientFactoryImpl.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/BookKeeperClientFactoryImpl.java
@@ -115,6 +115,7 @@ public class BookKeeperClientFactoryImpl implements 
BookKeeperClientFactory {
         }
 
         
bkConf.setReorderReadSequenceEnabled(conf.isBookkeeperClientReorderReadSequenceEnabled());
+        
bkConf.setExplictLacInterval(conf.getBookkeeperExplicitLacIntervalInMills());
 
         return bkConf;
     }
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/PulsarBrokerStarterTest.java 
b/pulsar-broker/src/test/java/org/apache/pulsar/PulsarBrokerStarterTest.java
index ba4b212..9571140 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/PulsarBrokerStarterTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/PulsarBrokerStarterTest.java
@@ -78,6 +78,7 @@ public class PulsarBrokerStarterTest {
         printWriter.println("bookkeeperClientTimeoutInSeconds=12345");
         
printWriter.println("bookkeeperClientSpeculativeReadTimeoutInMillis=3000");
         printWriter.println("enableRunBookieTogether=true");
+        printWriter.println("bookkeeperExplicitLacIntervalInMills=5");
 
         printWriter.close();
         testConfigFile.deleteOnExit();
@@ -127,6 +128,7 @@ public class PulsarBrokerStarterTest {
         assertEquals(serviceConfig.getBookkeeperClientIsolationGroups(), 
"group1,group2");
         
assertEquals(serviceConfig.getBookkeeperClientSpeculativeReadTimeoutInMillis(), 
3000);
         assertEquals(serviceConfig.getBookkeeperClientTimeoutInSeconds(), 
12345);
+        assertEquals(serviceConfig.getBookkeeperExplicitLacIntervalInMills(), 
5);
     }
 
     @Test
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/BookKeeperClientFactoryImplTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/BookKeeperClientFactoryImplTest.java
index f06e791..36ce41f 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/BookKeeperClientFactoryImplTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/BookKeeperClientFactoryImplTest.java
@@ -159,4 +159,13 @@ public class BookKeeperClientFactoryImplTest {
         
assertTrue(factory.createBkClientConfiguration(conf).getDiskWeightBasedPlacementEnabled());
     }
 
+    @Test
+    public void testSetExplicitLacInterval() {
+        BookKeeperClientFactoryImpl factory = new 
BookKeeperClientFactoryImpl();
+        ServiceConfiguration conf = new ServiceConfiguration();
+        
assertEquals(factory.createBkClientConfiguration(conf).getExplictLacInterval(), 
0);
+        conf.setBookkeeperExplicitLacIntervalInMills(5);
+        
assertEquals(factory.createBkClientConfiguration(conf).getExplictLacInterval(), 
5);
+    }
+
 }

Reply via email to