poorbarcode commented on code in PR #22203:
URL: https://github.com/apache/pulsar/pull/22203#discussion_r1558828533


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java:
##########
@@ -626,17 +626,7 @@ private void 
internalCreatePartitionedTopicToReplicatedClustersInBackground(int
                 .thenAccept(clusters -> {
                     for (String cluster : clusters) {
                         if 
(!cluster.equals(pulsar().getConfiguration().getClusterName())) {
-                            // this call happens in the background without 
async composition. completion is logged.

Review Comment:
   I think keeping this comment there is better.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java:
##########
@@ -654,6 +644,16 @@ private void 
internalCreatePartitionedTopicToReplicatedClustersInBackground(int
                 });
     }
 
+    protected CompletableFuture<Void> 
internalCreatePartitionedTopicForRemoteCluster(String cluster,
+                                                                               
      int numPartitions) {
+        return pulsar().getPulsarResources().getClusterResources()
+                .getClusterAsync(cluster)
+                .thenCompose(clusterDataOp -> ((TopicsImpl) 
pulsar().getBrokerService()
+                        .getClusterPulsarAdmin(cluster, 
clusterDataOp).topics())
+                        
.createPartitionedTopicAsync(topicName.getPartitionedTopicName(), 
numPartitions, true, null));

Review Comment:
   We should care about two scenarios:
   - the partitioned topic on the remote cluster already exists.
   - the partition count of the existing topic on the remote cluster is 
different from the current cluster.
   
   BTW, we can handle these scenarios in a separate PR.



##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/MultipleZkReplicatorTest.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotEquals;
+import java.lang.reflect.Method;
+import java.util.List;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.pulsar.broker.BrokerTestUtil;
+import org.apache.pulsar.client.api.Producer;
+import org.apache.pulsar.client.api.PulsarClient;
+import org.apache.pulsar.client.impl.PulsarClientImpl;
+import org.apache.pulsar.common.naming.TopicName;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Starts 2 brokers that are in 2 different clusters with different zookeeper
+ */
+@Test(groups = "broker")
+@Slf4j
+public class MultipleZkReplicatorTest extends MultipleZKReplicatorTestBase {
+
+    protected String methodName;
+
+    @BeforeMethod(alwaysRun = true)
+    public void beforeMethod(Method m) throws Exception {
+        methodName = m.getName();
+    }
+
+    @Override
+    @BeforeClass(alwaysRun = true, timeOut = 300000)
+    public void setup() throws Exception {
+        super.setup();
+    }
+
+    @Override
+    @AfterClass(alwaysRun = true, timeOut = 300000)
+    public void cleanup() throws Exception {
+        super.cleanup();
+    }
+
+    @Test
+    public void testReplicatorProducerCreatePartitionTopics() throws Exception 
{
+        log.info("--- testReplicatorProducerCreatePartitionTopics ---");
+        String namespace1 = "pulsar/ns";
+        admin1.namespaces().createNamespace(namespace1);
+        admin2.namespaces().createNamespace(namespace1);
+
+        TopicName dest1 = TopicName.get(
+                BrokerTestUtil.newUniqueName("persistent://" + namespace1 + 
"/testReplicatorProducerNotExceed1"));
+        // TODO: the non-partition topic can not be auto-created in the remote 
clusters when the namespace is empty.
+        admin1.topics().createPartitionedTopic(dest1.toString(), 3);
+        admin2.topics().createPartitionedTopic(dest1.toString(), 3);

Review Comment:
   Why do we need to create topics here?



##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/MultipleZkReplicatorTest.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotEquals;
+import java.lang.reflect.Method;
+import java.util.List;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.pulsar.broker.BrokerTestUtil;
+import org.apache.pulsar.client.api.Producer;
+import org.apache.pulsar.client.api.PulsarClient;
+import org.apache.pulsar.client.impl.PulsarClientImpl;
+import org.apache.pulsar.common.naming.TopicName;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Starts 2 brokers that are in 2 different clusters with different zookeeper
+ */
+@Test(groups = "broker")
+@Slf4j
+public class MultipleZkReplicatorTest extends MultipleZKReplicatorTestBase {

Review Comment:
   Maybe we can reuse `OneWayReplicatorTest` 



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