@Test public void shouldKeepActiveTaskStickynessWhenMoreClientThanActiveTasks() { final int p5 = 5; createClientWithPreviousActiveTasks(p1, 1, task00); createClientWithPreviousActiveTasks(p2, 1, task02); createClientWithPreviousActiveTasks(p3, 1, task01); createClient(p4, 1); createClient(p5, 1); final StickyTaskAssignor taskAssignor = createTaskAssignor(task00, task01, task02); taskAssignor.assign(0); assertThat(clients.get(p1).activeTasks(), equalTo(Collections.singleton(task00))); assertThat(clients.get(p2).activeTasks(), equalTo(Collections.singleton(task02))); assertThat(clients.get(p3).activeTasks(), equalTo(Collections.singleton(task01))); clients.clear(); createClient(p1, 1); createClientWithPreviousActiveTasks(p2, 1, task00); createClient(p3, 1); createClientWithPreviousActiveTasks(p4, 1, task02); createClientWithPreviousActiveTasks(p5, 1, task01); final StickyTaskAssignor secondAssignor = createTaskAssignor(task00, task01, task02); secondAssignor.assign(0); assertThat(clients.get(p2).activeTasks(), equalTo(Collections.singleton(task00))); assertThat(clients.get(p4).activeTasks(), equalTo(Collections.singleton(task02))); assertThat(clients.get(p5).activeTasks(), equalTo(Collections.singleton(task01))); }
@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);  }