use of com.linkedin.kafka.cruisecontrol.analyzer.goals.PreferredLeaderElectionGoal in project cruise-control by linkedin.
the class PreferredLeaderElectionGoalTest method testOptimize.
@Test
public void testOptimize() throws KafkaCruiseControlException {
ClusterModel clusterModel = createClusterModel();
PreferredLeaderElectionGoal goal = new PreferredLeaderElectionGoal();
goal.optimize(clusterModel, Collections.emptySet(), Collections.emptySet());
for (String t : Arrays.asList(TOPIC0, TOPIC1, TOPIC2)) {
for (int p = 0; p < 3; p++) {
List<Replica> replicas = clusterModel.partition(new TopicPartition(t, p)).replicas();
for (int i = 0; i < 3; i++) {
// only the first replica should be leader.
assertEquals(i == 0, replicas.get(i).isLeader());
}
}
}
}
Aggregations