@Test public void testImmediateMigrations() { dataGenerator.addJobAttribute("jobToMigrate", RelocationAttributes.RELOCATION_REQUIRED_BY_IMMEDIATELY, "" + (clock.wallTime() + 1)); Task task0 = jobOperations.getTasks("jobToMigrate").get(0); dataGenerator.place("active1", task0); Map<String, DeschedulingResult> immediateEvictions = newDescheduler(Collections.emptyMap()).findAllImmediateEvictions(); assertThat(immediateEvictions).hasSize(1).containsKey(task0.getId()); }
Map<String, DeschedulingResult> findAllImmediateEvictions() { long now = clock.wallTime(); Map<String, DeschedulingResult> result = new HashMap<>(); tasksById.values().forEach(task -> { Job<?> job = jobsById.get(task.getJobId()); Node instance = evacuatedAgentsAllocationTracker.getAgent(task); if (job != null && instance != null) { RelocationPredicates.checkIfMustBeRelocatedImmediately(job, task, instance).ifPresent(reason -> { evictionQuotaTracker.consumeQuotaNoError(job.getId()); result.put(task.getId(), newDeschedulingResultForRequestedRelocation(now, task, instance, reason.getRight())); }); } }); return result; }
TaskMigrationDescheduler { Map<String, DeschedulingResult> findAllImmediateEvictions() { long now = clock.wallTime(); Map<String, DeschedulingResult> result = new HashMap<>(); tasksById.values().forEach(task -> { Job<?> job = jobsById.get(task.getJobId()); Node instance = evacuatedAgentsAllocationTracker.getAgent(task); if (job != null && instance != null) { RelocationPredicates.checkIfMustBeRelocatedImmediately(job, task, instance).ifPresent(reason -> { evictionQuotaTracker.consumeQuotaNoError(job.getId()); result.put(task.getId(), newDeschedulingResultForRequestedRelocation(now, task, instance, reason.getRight())); }); } }); return result; } }
TaskMigrationDescheduler { Map<String, DeschedulingResult> findAllImmediateEvictions() { long now = clock.wallTime(); Map<String, DeschedulingResult> result = new HashMap<>(); tasksById.values().forEach(task -> { Job<?> job = jobsById.get(task.getJobId()); Node instance = evacuatedAgentsAllocationTracker.getAgent(task); if (job != null && instance != null) { RelocationPredicates.checkIfMustBeRelocatedImmediately(job, task, instance).ifPresent(reason -> { evictionQuotaTracker.consumeQuotaNoError(job.getId()); result.put(task.getId(), newDeschedulingResultForRequestedRelocation(now, task, instance, reason.getRight())); }); } }); return result; } TaskMigrationDescheduler(Map<String, TaskRelocationPlan> plannedAheadTaskRelocationPlans,
                             EvacuatedAgentsAllocationTracker evacuatedAgentsAllocationTracker,
                             EvictionQuotaTracker evictionQuotaTracker,
                             Map<String, Job<?>> jobsById,
                             Map<String, Task> tasksById,
                             TitusRuntime titusRuntime); }
TaskMigrationDescheduler { Map<String, DeschedulingResult> findAllImmediateEvictions() { long now = clock.wallTime(); Map<String, DeschedulingResult> result = new HashMap<>(); tasksById.values().forEach(task -> { Job<?> job = jobsById.get(task.getJobId()); Node instance = evacuatedAgentsAllocationTracker.getAgent(task); if (job != null && instance != null) { RelocationPredicates.checkIfMustBeRelocatedImmediately(job, task, instance).ifPresent(reason -> { evictionQuotaTracker.consumeQuotaNoError(job.getId()); result.put(task.getId(), newDeschedulingResultForRequestedRelocation(now, task, instance, reason.getRight())); }); } }); return result; } TaskMigrationDescheduler(Map<String, TaskRelocationPlan> plannedAheadTaskRelocationPlans,
                             EvacuatedAgentsAllocationTracker evacuatedAgentsAllocationTracker,
                             EvictionQuotaTracker evictionQuotaTracker,
                             Map<String, Job<?>> jobsById,
                             Map<String, Task> tasksById,
                             TitusRuntime titusRuntime);  }
TaskMigrationDescheduler { Map<String, DeschedulingResult> findAllImmediateEvictions() { long now = clock.wallTime(); Map<String, DeschedulingResult> result = new HashMap<>(); tasksById.values().forEach(task -> { Job<?> job = jobsById.get(task.getJobId()); Node instance = evacuatedAgentsAllocationTracker.getAgent(task); if (job != null && instance != null) { RelocationPredicates.checkIfMustBeRelocatedImmediately(job, task, instance).ifPresent(reason -> { evictionQuotaTracker.consumeQuotaNoError(job.getId()); result.put(task.getId(), newDeschedulingResultForRequestedRelocation(now, task, instance, reason.getRight())); }); } }); return result; } TaskMigrationDescheduler(Map<String, TaskRelocationPlan> plannedAheadTaskRelocationPlans,
                             EvacuatedAgentsAllocationTracker evacuatedAgentsAllocationTracker,
                             EvictionQuotaTracker evictionQuotaTracker,
                             Map<String, Job<?>> jobsById,
                             Map<String, Task> tasksById,
                             TitusRuntime titusRuntime);   }