Technoboy- commented on code in PR #19737:
URL: https://github.com/apache/pulsar/pull/19737#discussion_r1160417473


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -430,6 +443,41 @@ public AtomicLong getPendingWriteOps() {
         return pendingWriteOps;
     }
 
+    /**
+     * Unload a subscriber.
+     * @throws SubscriptionNotFoundException If subscription not founded.
+     * @throws UnsupportedSubscriptionException If the subscription is typed 
compaction.
+     */
+    public CompletableFuture<Void> unloadSubscription(@Nonnull String subName) 
{
+        final PersistentSubscription sub = subscriptions.get(subName);
+        if (sub == null) {
+            return CompletableFuture.failedFuture(
+                    new 
SubscriptionNotFoundException(String.format("Subscription %s not found", 
subName)));
+        }
+        if (Compactor.COMPACTION_SUBSCRIPTION.equals(sub.getName())){
+            return CompletableFuture.failedFuture(
+                    new 
UnsupportedSubscriptionException(String.format("Unsupported subscription: %s", 
subName)));
+        }
+        // Fence old subscription -> Rewind cursor -> Replace with a new 
subscription.
+        CompletableFuture<Void> result = 
unloadSubscriptionFutures.computeIfAbsent(subName,
+                k -> sub.disconnect().thenAccept(ignore -> {

Review Comment:
   Why do we need to store `unloadSubscription` ?



-- 
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]

Reply via email to