[
https://issues.apache.org/jira/browse/KAFKA-6771?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16439088#comment-16439088
]
ASF GitHub Bot commented on KAFKA-6771:
---
rajinisivaram closed pull request #4850: KAFKA-6771. Make specifying partitions
more flexible
URL: https://github.com/apache/kafka/pull/4850
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/tools/src/main/java/org/apache/kafka/trogdor/common/StringExpander.java
b/tools/src/main/java/org/apache/kafka/trogdor/common/StringExpander.java
new file mode 100644
index 000..82f5003fbb6
--- /dev/null
+++ b/tools/src/main/java/org/apache/kafka/trogdor/common/StringExpander.java
@@ -0,0 +1,56 @@
+/*
+ * 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.kafka.trogdor.common;
+
+import java.util.HashSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Utilities for expanding strings that have range expressions in them.
+ *
+ * For example, 'foo[1-3]' would be expaneded to foo1, foo2, foo3.
+ * Strings that have no range expressions will not be expanded.
+ */
+public class StringExpander {
+private final static Pattern NUMERIC_RANGE_PATTERN =
+Pattern.compile("(.*?)\\[([0-9]*)\\-([0-9]*)\\](.*?)");
+
+public static HashSet expand(String val) {
+HashSet set = new HashSet<>();
+Matcher matcher = NUMERIC_RANGE_PATTERN.matcher(val);
+if (!matcher.matches()) {
+set.add(val);
+return set;
+}
+String prequel = matcher.group(1);
+String rangeStart = matcher.group(2);
+String rangeEnd = matcher.group(3);
+String epilog = matcher.group(4);
+int rangeStartInt = Integer.parseInt(rangeStart);
+int rangeEndInt = Integer.parseInt(rangeEnd);
+if (rangeEndInt < rangeStartInt) {
+throw new RuntimeException("Invalid range: start " + rangeStartInt
+
+" is higher than end " + rangeEndInt);
+}
+for (int i = rangeStartInt; i <= rangeEndInt; i++) {
+set.add(String.format("%s%d%s", prequel, i, epilog));
+}
+return set;
+}
+}
diff --git
a/tools/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java
b/tools/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java
index 0677296ee3c..f2eb0343aa8 100644
---
a/tools/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java
+++
b/tools/src/main/java/org/apache/kafka/trogdor/coordinator/CoordinatorClient.java
@@ -132,7 +132,7 @@ public StopTaskResponse stopTask(StopTaskRequest request)
throws Exception {
public TasksResponse tasks(TasksRequest request) throws Exception {
UriBuilder uriBuilder = UriBuilder.fromPath(url("/coordinator/tasks"));
-uriBuilder.queryParam("taskId", request.taskIds().toArray(new
String[0]));
+uriBuilder.queryParam("taskId", (Object[])
request.taskIds().toArray(new String[0]));
uriBuilder.queryParam("firstStartMs", request.firstStartMs());
uriBuilder.queryParam("lastStartMs", request.lastStartMs());
uriBuilder.queryParam("firstEndMs", request.firstEndMs());
diff --git
a/tools/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchSpec.java
b/tools/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchSpec.java
index cef913bc01a..1b429ead3c8 100644
---
a/tools/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchSpec.java
+++
b/tools/src/main/java/org/apache/kafka/trogdor/workload/ConsumeBenchSpec.java
@@ -41,10 +41,7 @@
private final Map consumerConf;
private final Map adminClientConf;
private final Map commonClientConf;
-private final String topicRegex;
-private final int startPartition;
-private final int endPartition;
-
+private final TopicsSpec activeTopics;
@JsonCreator