@Test public void shouldAssignStandbyTasksToDifferentClientThanCorrespondingActiveTaskIsAssingedTo() throws Exception { createClientWithPreviousActiveTasks(p1, 1, task00); createClientWithPreviousActiveTasks(p2, 1, task01); createClientWithPreviousActiveTasks(p3, 1, task02); createClientWithPreviousActiveTasks(p4, 1, task03); final StickyTaskAssignor taskAssignor = createTaskAssignor(task00, task01, task02, task03); taskAssignor.assign(1); assertThat(clients.get(p1).standbyTasks(), not(hasItems(task00))); assertTrue(clients.get(p1).standbyTasks().size() <= 2); assertThat(clients.get(p2).standbyTasks(), not(hasItems(task01))); assertTrue(clients.get(p2).standbyTasks().size() <= 2); assertThat(clients.get(p3).standbyTasks(), not(hasItems(task02))); assertTrue(clients.get(p3).standbyTasks().size() <= 2); assertThat(clients.get(p4).standbyTasks(), not(hasItems(task03))); assertTrue(clients.get(p4).standbyTasks().size() <= 2); int nonEmptyStandbyTaskCount = 0; for (final Integer client : clients.keySet()) { nonEmptyStandbyTaskCount += clients.get(client).standbyTasks().isEmpty() ? 0 : 1; } assertTrue(nonEmptyStandbyTaskCount >= 3); assertThat(allStandbyTasks(), equalTo(Arrays.asList(task00, task01, task02, task03))); }
@Override public void assign(final int numStandbyReplicas) { assignActive(); assignStandby(numStandbyReplicas); }
StickyTaskAssignor implements TaskAssignor<ID, TaskId> { @Override public void assign(final int numStandbyReplicas) { assignActive(); assignStandby(numStandbyReplicas); } }
StickyTaskAssignor implements TaskAssignor<ID, TaskId> { @Override public void assign(final int numStandbyReplicas) { assignActive(); assignStandby(numStandbyReplicas); } StickyTaskAssignor(final Map<ID, ClientState> clients, final Set<TaskId> taskIds); }
StickyTaskAssignor implements TaskAssignor<ID, TaskId> { @Override public void assign(final int numStandbyReplicas) { assignActive(); assignStandby(numStandbyReplicas); } StickyTaskAssignor(final Map<ID, ClientState> clients, final Set<TaskId> taskIds); @Override void assign(final int numStandbyReplicas); }
StickyTaskAssignor implements TaskAssignor<ID, TaskId> { @Override public void assign(final int numStandbyReplicas) { assignActive(); assignStandby(numStandbyReplicas); } StickyTaskAssignor(final Map<ID, ClientState> clients, final Set<TaskId> taskIds); @Override void assign(final int numStandbyReplicas);  }