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

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


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 44131f98110 [fix][broker] Fix typo in the config key (#21690)
44131f98110 is described below

commit 44131f98110466044fc30aba7072f470b6f92212
Author: Cong Zhao <[email protected]>
AuthorDate: Fri Dec 8 04:23:30 2023 +0800

    [fix][broker] Fix typo in the config key (#21690)
---
 conf/broker.conf                                             |  2 +-
 conf/standalone.conf                                         |  2 +-
 .../java/org/apache/pulsar/broker/ServiceConfiguration.java  |  2 +-
 .../java/org/apache/pulsar/compaction/TwoPhaseCompactor.java | 12 ++++++------
 .../java/org/apache/pulsar/compaction/CompactionTest.java    |  5 ++---
 5 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/conf/broker.conf b/conf/broker.conf
index 46af8530623..1c4e2a26afb 100644
--- a/conf/broker.conf
+++ b/conf/broker.conf
@@ -538,7 +538,7 @@ brokerServiceCompactionThresholdInBytes=0
 brokerServiceCompactionPhaseOneLoopTimeInSeconds=30
 
 # Whether retain null-key message during topic compaction
-topicCompactionRemainNullKey=true
+topicCompactionRetainNullKey=true
 
 # Whether to enable the delayed delivery for messages.
 # If disabled, messages will be immediately delivered and there will
diff --git a/conf/standalone.conf b/conf/standalone.conf
index 1f1910435dd..c055264ef3f 100644
--- a/conf/standalone.conf
+++ b/conf/standalone.conf
@@ -1268,4 +1268,4 @@ delayedDeliveryMaxIndexesPerBucketSnapshotSegment=5000
 delayedDeliveryMaxNumBuckets=-1
 
 # Whether retain null-key message during topic compaction
-topicCompactionRemainNullKey=true
+topicCompactionRetainNullKey=true
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 2b0d185ca55..077228191ad 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
@@ -2748,7 +2748,7 @@ public class ServiceConfiguration implements 
PulsarConfiguration {
             category = CATEGORY_SERVER,
             doc = "Whether retain null-key message during topic compaction."
     )
-    private boolean topicCompactionRemainNullKey = true;
+    private boolean topicCompactionRetainNullKey = true;
 
     @FieldContext(
         category = CATEGORY_SERVER,
diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/compaction/TwoPhaseCompactor.java
 
b/pulsar-broker/src/main/java/org/apache/pulsar/compaction/TwoPhaseCompactor.java
index f0aa95d40a8..e35a1a0c380 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/compaction/TwoPhaseCompactor.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/compaction/TwoPhaseCompactor.java
@@ -61,7 +61,7 @@ public class TwoPhaseCompactor extends Compactor {
     private static final int MAX_OUTSTANDING = 500;
     protected static final String COMPACTED_TOPIC_LEDGER_PROPERTY = 
"CompactedTopicLedger";
     private final Duration phaseOneLoopReadTimeout;
-    private final boolean topicCompactionRemainNullKey;
+    private final boolean topicCompactionRetainNullKey;
 
     public TwoPhaseCompactor(ServiceConfiguration conf,
                              PulsarClient pulsar,
@@ -69,7 +69,7 @@ public class TwoPhaseCompactor extends Compactor {
                              ScheduledExecutorService scheduler) {
         super(conf, pulsar, bk, scheduler);
         phaseOneLoopReadTimeout = 
Duration.ofSeconds(conf.getBrokerServiceCompactionPhaseOneLoopTimeInSeconds());
-        topicCompactionRemainNullKey = conf.isTopicCompactionRemainNullKey();
+        topicCompactionRetainNullKey = conf.isTopicCompactionRetainNullKey();
     }
 
     @Override
@@ -137,7 +137,7 @@ public class TwoPhaseCompactor extends Compactor {
                                 .extractIdsAndKeysAndSize(m, true)) {
                             if (e != null) {
                                 if (e.getMiddle() == null) {
-                                    if (!topicCompactionRemainNullKey) {
+                                    if (!topicCompactionRetainNullKey) {
                                         // record delete null-key message event
                                         deleteCnt++;
                                         
mxBean.addCompactionRemovedEvent(reader.getTopic());
@@ -174,7 +174,7 @@ public class TwoPhaseCompactor extends Compactor {
                             latestForKey.remove(keyAndSize.getLeft());
                         }
                     } else {
-                        if (!topicCompactionRemainNullKey) {
+                        if (!topicCompactionRetainNullKey) {
                             deletedMessage = true;
                         }
                     }
@@ -266,7 +266,7 @@ public class TwoPhaseCompactor extends Compactor {
                 if (RawBatchConverter.isReadableBatch(m)) {
                     try {
                         messageToAdd = RawBatchConverter.rebatchMessage(
-                                m, (key, subid) -> 
subid.equals(latestForKey.get(key)), topicCompactionRemainNullKey);
+                                m, (key, subid) -> 
subid.equals(latestForKey.get(key)), topicCompactionRetainNullKey);
                     } catch (IOException ioe) {
                         log.info("Error decoding batch for message {}. Whole 
batch will be included in output",
                                 id, ioe);
@@ -276,7 +276,7 @@ public class TwoPhaseCompactor extends Compactor {
                     Pair<String, Integer> keyAndSize = extractKeyAndSize(m);
                     MessageId msg;
                     if (keyAndSize == null) {
-                        messageToAdd = topicCompactionRemainNullKey ? 
Optional.of(m) : Optional.empty();
+                        messageToAdd = topicCompactionRetainNullKey ? 
Optional.of(m) : Optional.empty();
                     } else if ((msg = latestForKey.get(keyAndSize.getLeft())) 
!= null
                             && msg.equals(id)) { // consider message only if 
present into latestForKey map
                         if (keyAndSize.getRight() <= 0) {
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/compaction/CompactionTest.java 
b/pulsar-broker/src/test/java/org/apache/pulsar/compaction/CompactionTest.java
index be8c368a1ee..add1b3e9252 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/compaction/CompactionTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/compaction/CompactionTest.java
@@ -27,7 +27,6 @@ import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertSame;
 import static org.testng.Assert.assertTrue;
-
 import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import io.netty.buffer.ByteBuf;
@@ -651,9 +650,9 @@ public class CompactionTest extends 
MockedPulsarServiceBaseTest {
 
     @Test(dataProvider = "retainNullKey")
     public void testKeyLessMessagesPassThrough(boolean retainNullKey) throws 
Exception {
-        conf.setTopicCompactionRemainNullKey(retainNullKey);
+        conf.setTopicCompactionRetainNullKey(retainNullKey);
         restartBroker();
-        FieldUtils.writeDeclaredField(compactor, 
"topicCompactionRemainNullKey", retainNullKey, true);
+        FieldUtils.writeDeclaredField(compactor, 
"topicCompactionRetainNullKey", retainNullKey, true);
 
         String topic = "persistent://my-property/use/my-ns/my-topic1";
 

Reply via email to