Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
Expand Down Expand Up @@ -898,21 +897,4 @@ public void testNewShareGroupEpochRecord() {
10
));
}

/**
* Creates a map of partitions to racks for testing.
*
* @param numPartitions The number of partitions for the topic.
*
* For testing purposes, the following criteria are used:
* - Number of replicas for each partition: 2
* - Number of racks available to the cluster: 4
*/
public static Map<Integer, Set<String>> mkMapOfPartitionRacks(int numPartitions) {
Map<Integer, Set<String>> partitionRacks = new HashMap<>(numPartitions);
for (int i = 0; i < numPartitions; i++) {
partitionRacks.put(i, new HashSet<>(Arrays.asList("rack" + i % 4, "rack" + (i + 1) % 4)));
}
return partitionRacks;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private List<PartitionInfo> partitionInfos(String topic, int numberOfPartitions,
for (int i = 0; i < numberOfPartitions; i++) {
Node[] replicas = new Node[3];
for (int j = 0; j < 3; j++) {
// Assign nodes based on partition number to mimic mkMapOfPartitionRacks logic.
// Assign nodes based on partition number.
int nodeIndex = (i + j) % NUMBER_OF_RACKS;
replicas[j] = nodes.get(nodeIndex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.annotations.Warmup;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -186,18 +185,6 @@ private Optional<String> rackId(int memberIndex) {
return isRackAware ? Optional.of("rack" + memberIndex % NUMBER_OF_RACKS) : Optional.empty();
}

private static Map<Integer, Set<String>> mkMapOfPartitionRacks(int numPartitions) {
Map<Integer, Set<String>> partitionRacks = new HashMap<>(numPartitions);
for (int i = 0; i < numPartitions; i++) {
partitionRacks.put(i, new HashSet<>(Arrays.asList(
"rack" + i % NUMBER_OF_RACKS,
"rack" + (i + 1) % NUMBER_OF_RACKS,
"rack" + (i + 2) % NUMBER_OF_RACKS
)));
}
return partitionRacks;
}

private void simulateIncrementalRebalance() {
GroupAssignment initialAssignment = partitionAssignor.assign(groupSpec, subscribedTopicDescriber);
Map<String, MemberAssignment> members = initialAssignment.members();
Expand Down