codelipenghui commented on code in PR #20718:
URL: https://github.com/apache/pulsar/pull/20718#discussion_r1260420271
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java:
##########
@@ -1914,4 +1914,13 @@ public void shutdownNow() {
protected BrokerService newBrokerService(PulsarService pulsar) throws
Exception {
return new BrokerService(pulsar, ioEventLoopGroup);
}
+
+ private CompactionServiceFactory loadCompactionServiceFactory() {
+ String compactionServiceFactoryClassName =
config.getCompactionServiceFactoryClassName();
+ var compactionServiceFactory =
+ Reflections.createInstance(compactionServiceFactoryClassName,
CompactionServiceFactory.class,
+ Thread.currentThread().getContextClassLoader());
+ compactionServiceFactory.initialize(this).join();
Review Comment:
@coderzc Maybe you missed this one
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -481,8 +492,10 @@ public CompletableFuture<Void> unloadSubscription(@Nonnull
String subName) {
private PersistentSubscription createPersistentSubscription(String
subscriptionName, ManagedCursor cursor,
boolean replicated, Map<String, String> subscriptionProperties) {
- Objects.requireNonNull(compactedTopic);
- if (isCompactionSubscription(subscriptionName)) {
+ Objects.requireNonNull(topicCompactionService);
+ if (isCompactionSubscription(subscriptionName)
+ && topicCompactionService instanceof
PulsarTopicCompactionService pulsarTopicCompactionService) {
+ CompactedTopicImpl compactedTopic =
pulsarTopicCompactionService.getCompactedTopic();
Review Comment:
Could you point out how the broker creates the __compaction subscription if
the topic compaction service is not `PulsarTopicCompactionService`? Or it will
be handled by the user?
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -210,9 +212,9 @@ public class PersistentTopic extends AbstractTopic
implements Topic, AddEntryCal
protected final MessageDeduplication messageDeduplication;
- private static final long COMPACTION_NEVER_RUN = -0xfebecffeL;
+ private static final Long COMPACTION_NEVER_RUN = -0xfebecffeL;
private CompletableFuture<Long> currentCompaction =
CompletableFuture.completedFuture(COMPACTION_NEVER_RUN);
- private final CompactedTopic compactedTopic;
+ private TopicCompactionService topicCompactionService;
Review Comment:
But maybe the user-defined compaction service will open resources for each
topic. For example, if you try to write the compacted to a new topic with a
producer (each compaction task will write the compacted to a new topic and then
remove the old one). When the original topic is closed, we should also close
the producer for writing compacted data? And we can't close the
CompactionserviceFactory because the broker is still running, just some topics
move to other brokers.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]