THostPort hostPort = new THostPort(nodes.get(j).getHostName(), nodes.get(j).getPort());
List<TTaskLaunchSpec> specs = taskPlacer.assignTask(hostPort);
assertTrue(specs != null);
if (j < NUM_TASKS) {
assertEquals(1, specs.size());
TTaskLaunchSpec spec = specs.get(0);
assertTrue("Expect to receive a task spec for task " + j + " at " +
hostPort.getHost() + ":" + hostPort.getPort(), spec != null);
assertTrue("Expect list of unlaunched tasks to contain " + spec.getTaskId(),
taskIdsCopy.contains(spec.getTaskId()));
taskIdsCopy.remove(spec.getTaskId());
} else {
assertTrue(taskPlacer.allTasksPlaced());
assertEquals(0, specs.size());
}
}