Skip to content

Commit

Permalink
Expose bookkeeper expose explicit lac in broker.conf (apache#5822)
Browse files Browse the repository at this point in the history
### Motivation

Expose bookkeeper expose explicit lac configuration in broker.conf
It's related to apache#3828 apache#4976, some Pulsar SQL users need to enable the explicitLacInterval, so that they can get the last message in Pulsar SQL.
  • Loading branch information
codelipenghui authored and tuteng committed Feb 23, 2020
1 parent 92b0c75 commit c8eb719
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions conf/broker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions conf/standalone.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ ClientConfiguration createBkClientConfiguration(ServiceConfiguration conf) {
}

bkConf.setReorderReadSequenceEnabled(conf.isBookkeeperClientReorderReadSequenceEnabled());
bkConf.setExplictLacInterval(conf.getBookkeeperExplicitLacIntervalInMills());

return bkConf;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private File createValidBrokerConfigFile() throws FileNotFoundException {
printWriter.println("bookkeeperClientTimeoutInSeconds=12345");
printWriter.println("bookkeeperClientSpeculativeReadTimeoutInMillis=3000");
printWriter.println("enableRunBookieTogether=true");
printWriter.println("bookkeeperExplicitLacIntervalInMills=5");

printWriter.close();
testConfigFile.deleteOnExit();
Expand Down Expand Up @@ -127,6 +128,7 @@ public void testLoadConfig() throws SecurityException, NoSuchMethodException, IO
assertEquals(serviceConfig.getBookkeeperClientIsolationGroups(), "group1,group2");
assertEquals(serviceConfig.getBookkeeperClientSpeculativeReadTimeoutInMillis(), 3000);
assertEquals(serviceConfig.getBookkeeperClientTimeoutInSeconds(), 12345);
assertEquals(serviceConfig.getBookkeeperExplicitLacIntervalInMills(), 5);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,13 @@ public void testSetDiskWeightBasedPlacementEnabled() {
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);
}

}

0 comments on commit c8eb719

Please sign in to comment.