maytasm commented on a change in pull request #9724:
URL: https://github.com/apache/druid/pull/9724#discussion_r412716261



##########
File path: 
integration-tests/src/main/java/org/apache/druid/testing/utils/KafkaAdminClient.java
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.druid.testing.utils;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.kafka.clients.admin.AdminClient;
+import org.apache.kafka.clients.admin.AdminClientConfig;
+import org.apache.kafka.clients.admin.CreatePartitionsResult;
+import org.apache.kafka.clients.admin.CreateTopicsResult;
+import org.apache.kafka.clients.admin.DeleteTopicsResult;
+import org.apache.kafka.clients.admin.DescribeTopicsResult;
+import org.apache.kafka.clients.admin.NewPartitions;
+import org.apache.kafka.clients.admin.NewTopic;
+import org.apache.kafka.clients.admin.TopicDescription;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+public class KafkaAdminClient implements StreamAdminClient
+{
+  AdminClient adminClient;
+
+  public KafkaAdminClient(String kafkaInternalHost)
+  {
+    Properties config = new Properties();
+    config.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaInternalHost);
+    adminClient = AdminClient.create(config);
+  }
+
+  @Override
+  public void createStream(String streamName, int partitionCount, Map<String, 
String> tags) throws Exception
+  {
+    final short replicationFactor = 1;
+    final NewTopic newTopic = new NewTopic(streamName, partitionCount, 
replicationFactor);
+    final CreateTopicsResult createTopicsResult = 
adminClient.createTopics(Collections.singleton(newTopic));
+    // Wait for create topic to compelte
+    createTopicsResult.values().get(streamName).get();
+  }
+
+  @Override
+  public void deleteStream(String streamName) throws Exception
+  {
+    DeleteTopicsResult deleteTopicsResult = 
adminClient.deleteTopics(ImmutableList.of(streamName));
+    deleteTopicsResult.values().get(streamName).get();
+  }
+
+  /**
+   * This method can only increase the partition count of {@param streamName} 
to have a final partition
+   * count of {@param newPartitionCount}
+   * If {@param blocksUntilStarted} is set to true, then this method will 
blocks until the partitioning
+   * started (but not nessesary finished), otherwise, the method will returns 
right after issue the reshard command
+   */
+  @Override
+  public void updateShardCount(String streamName, int newPartitionCount, 
boolean blocksUntilStarted) throws Exception
+  {
+    Map<String, NewPartitions> counts = new HashMap<>();
+    counts.put(streamName, NewPartitions.increaseTo(newPartitionCount));
+    CreatePartitionsResult createPartitionsResult = 
adminClient.createPartitions(counts);
+    if (blocksUntilStarted) {
+      createPartitionsResult.values().get(streamName).get();
+
+    }
+  }
+
+  @Override
+  public boolean isStreamActive(String streamName)
+  {
+    return true;

Review comment:
       It doesn't means anything but since it implement the interface it needs 
the method. Added comment.




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

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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to