You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/09/06 11:07:04 UTC

[GitHub] [pulsar] AnonHxy commented on a diff in pull request #17371: [feat][broker]PIP-180 ShadowTopic - Part IV - Add Shadow Replicator

AnonHxy commented on code in PR #17371:
URL: https://github.com/apache/pulsar/pull/17371#discussion_r963536451


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -1036,6 +1036,14 @@ public CompletableFuture<Void> deleteTopic(String topic, boolean forceDelete) {
                         new IllegalStateException("Delete forbidden topic is replicated on clusters " + clusters));
             }
 
+            // shadow topic should be deleted first.
+            if (t.isShadowReplicated()) {
+                final List<String> shadowTopics = t.getShadowReplicators().keys();
+                log.error("Delete forbidden. Topic {} is replicated to shadow topics: {}", topic, shadowTopics);
+                return FutureUtil.failedFuture(new IllegalStateException(
+                                "Delete forbidden. Topic {} is replicated to shadow topics: " + shadowTopics));

Review Comment:
   `{}` will not take effect.
   
   ```suggestion
                                   "Delete forbidden. Topic " + topic + “ is replicated to shadow topics: " + shadowTopics));
   ```



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java:
##########
@@ -233,6 +233,7 @@ CompletableFuture<Subscription> createSubscription(String subscriptionName, Init
     boolean getSchemaValidationEnforced();
 
     boolean isReplicated();
+    boolean isShadowReplicated();

Review Comment:
   Better and a blank line above line236
   ```suggestion
   
       boolean isShadowReplicated();
   ```



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -1423,6 +1439,38 @@ public CompletableFuture<Void> checkReplication() {
             }
         });
 
+        futures.add(checkShadowReplication());
+
+        return FutureUtil.waitForAll(futures);
+    }
+
+    private CompletableFuture<Void> checkShadowReplication() {
+        if (CollectionUtils.isEmpty(shadowTopics)) {
+            return CompletableFuture.completedFuture(null);
+        }
+        List<String> configuredShadowTopics = shadowTopics;

Review Comment:
   I wonder is it necessary add new variable `configuredShadowTopics` here.  Becase both `configuredShadowTopics` and `shadowTopics` refers the same object.



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org