Search in sources :

Example 21 with AssignmentConfigs

use of org.apache.kafka.streams.processor.internals.assignment.AssignorConfiguration.AssignmentConfigs in project kafka by apache.

the class HighAvailabilityTaskAssignorTest method shouldDistributeStatelessTasksEvenlyOverClientsWithUnevenlyDistributedStreamThreadsAndNoStatefulTasks.

@Test
public void shouldDistributeStatelessTasksEvenlyOverClientsWithUnevenlyDistributedStreamThreadsAndNoStatefulTasks() {
    final Set<TaskId> allTasks = mkSet(TASK_0_0, TASK_0_1, TASK_0_2, TASK_0_3, TASK_1_0, TASK_1_1, TASK_1_2);
    final Set<TaskId> statefulTasks = EMPTY_TASKS;
    final Set<TaskId> statelessTasks = new HashSet<>(allTasks);
    final Map<TaskId, Long> taskLags = new HashMap<>();
    final ClientState client1 = new ClientState(emptySet(), emptySet(), taskLags, 1);
    final ClientState client2 = new ClientState(emptySet(), emptySet(), taskLags, 2);
    final ClientState client3 = new ClientState(emptySet(), emptySet(), taskLags, 3);
    final Map<UUID, ClientState> clientStates = getClientStatesMap(client1, client2, client3);
    final boolean probingRebalanceNeeded = new HighAvailabilityTaskAssignor().assign(clientStates, allTasks, statefulTasks, new AssignmentConfigs(0L, 1, 0, 60_000L));
    assertValidAssignment(0, EMPTY_TASKS, statelessTasks, clientStates, new StringBuilder());
    assertBalancedActiveAssignment(clientStates, new StringBuilder());
    assertThat(probingRebalanceNeeded, is(false));
}
Also used : TaskId(org.apache.kafka.streams.processor.TaskId) HashMap(java.util.HashMap) AssignmentConfigs(org.apache.kafka.streams.processor.internals.assignment.AssignorConfiguration.AssignmentConfigs) UUID(java.util.UUID) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

AssignmentConfigs (org.apache.kafka.streams.processor.internals.assignment.AssignorConfiguration.AssignmentConfigs)21 Test (org.junit.Test)20 UUID (java.util.UUID)17 TaskId (org.apache.kafka.streams.processor.TaskId)17 HashMap (java.util.HashMap)13 HashSet (java.util.HashSet)13 Collections.emptySet (java.util.Collections.emptySet)9 Collections.singleton (java.util.Collections.singleton)9 Collections.singletonMap (java.util.Collections.singletonMap)9 Map (java.util.Map)9 Set (java.util.Set)9 Collectors (java.util.stream.Collectors)9 Utils.mkEntry (org.apache.kafka.common.utils.Utils.mkEntry)9 Utils.mkMap (org.apache.kafka.common.utils.Utils.mkMap)9 Utils.mkSet (org.apache.kafka.common.utils.Utils.mkSet)9 EMPTY_TASKS (org.apache.kafka.streams.processor.internals.assignment.AssignmentTestUtils.EMPTY_TASKS)9 TASK_0_0 (org.apache.kafka.streams.processor.internals.assignment.AssignmentTestUtils.TASK_0_0)9 TASK_0_1 (org.apache.kafka.streams.processor.internals.assignment.AssignmentTestUtils.TASK_0_1)9 TASK_0_2 (org.apache.kafka.streams.processor.internals.assignment.AssignmentTestUtils.TASK_0_2)9 TASK_0_3 (org.apache.kafka.streams.processor.internals.assignment.AssignmentTestUtils.TASK_0_3)9