Skip to content

Commit 394b674

Browse files
nikhil-ctdssrinath-ctds
authored andcommitted
Fix cherry-pick issue
1 parent ab9e2eb commit 394b674

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public class TopicTransactionBuffer extends TopicTransactionBufferState implemen
102102

103103
private final AbortedTxnProcessor snapshotAbortedTxnProcessor;
104104

105+
private final AbortedTxnProcessor.SnapshotType snapshotType;
105106
private final MaxReadPositionCallBack maxReadPositionCallBack;
106107

107108
private static AbortedTxnProcessor createSnapshotProcessor(PersistentTopic topic) {
@@ -110,13 +111,19 @@ private static AbortedTxnProcessor createSnapshotProcessor(PersistentTopic topic
110111
: new SingleSnapshotAbortedTxnProcessorImpl(topic);
111112
}
112113

114+
private static AbortedTxnProcessor.SnapshotType determineSnapshotType(PersistentTopic topic) {
115+
return topic.getBrokerService().getPulsar().getConfiguration().isTransactionBufferSegmentedSnapshotEnabled()
116+
? AbortedTxnProcessor.SnapshotType.Segment
117+
: AbortedTxnProcessor.SnapshotType.Single;
118+
}
113119

114120
public TopicTransactionBuffer(PersistentTopic topic) {
115-
this(topic, createSnapshotProcessor(topic));
121+
this(topic, createSnapshotProcessor(topic), determineSnapshotType(topic));
116122
}
117123

118124
@VisibleForTesting
119-
TopicTransactionBuffer(PersistentTopic topic, AbortedTxnProcessor snapshotAbortedTxnProcessor) {
125+
TopicTransactionBuffer(PersistentTopic topic, AbortedTxnProcessor snapshotAbortedTxnProcessor,
126+
AbortedTxnProcessor.SnapshotType snapshotType) {
120127
super(State.None);
121128
this.topic = topic;
122129
this.timer = topic.getBrokerService().getPulsar().getTransactionTimer();
@@ -126,6 +133,7 @@ public TopicTransactionBuffer(PersistentTopic topic) {
126133
.getConfiguration().getTransactionBufferSnapshotMinTimeInMillis();
127134
this.maxReadPosition = (PositionImpl) topic.getManagedLedger().getLastConfirmedEntry();
128135
this.snapshotAbortedTxnProcessor = snapshotAbortedTxnProcessor;
136+
this.snapshotType = snapshotType;
129137
this.maxReadPositionCallBack = topic.getMaxReadPositionCallBack();
130138
this.recover();
131139
}

0 commit comments

Comments
 (0)