@Test public void testSelfMigration() { Task job1Task0 = jobOperations.getTasks("job1").get(0); dataGenerator.place("removable1", job1Task0); dataGenerator.setQuota("job1", 1); TaskRelocationPlan job1Task0Plan = TaskRelocationPlan.newBuilder() .withTaskId(job1Task0.getId()) .withRelocationTime(Long.MAX_VALUE / 2) .build(); Optional<Pair<Node, List<Task>>> results = newDescheduler(Collections.singletonMap(job1Task0.getId(), job1Task0Plan)).nextBestMatch(); assertThat(results).isEmpty(); }
Optional<Pair<Node, List<Task>>> nextBestMatch() { if (evictionQuotaTracker.getSystemEvictionQuota() <= 0) { return Optional.empty(); } return evacuatedAgentsAllocationTracker.getRemovableAgentsById().values().stream() .map(i -> Pair.of(i, computeFitness(i))) .filter(p -> p.getRight().getLeft() > 0) .max(Comparator.comparingDouble(p -> p.getRight().getLeft())) .map(p -> { Node agent = p.getLeft(); List<Task> tasks = p.getRight().getRight(); tasks.forEach(task -> { evacuatedAgentsAllocationTracker.descheduled(task); evictionQuotaTracker.consumeQuota(task.getJobId()); }); return Pair.of(agent, tasks); }); }
TaskMigrationDescheduler { Optional<Pair<Node, List<Task>>> nextBestMatch() { if (evictionQuotaTracker.getSystemEvictionQuota() <= 0) { return Optional.empty(); } return evacuatedAgentsAllocationTracker.getRemovableAgentsById().values().stream() .map(i -> Pair.of(i, computeFitness(i))) .filter(p -> p.getRight().getLeft() > 0) .max(Comparator.comparingDouble(p -> p.getRight().getLeft())) .map(p -> { Node agent = p.getLeft(); List<Task> tasks = p.getRight().getRight(); tasks.forEach(task -> { evacuatedAgentsAllocationTracker.descheduled(task); evictionQuotaTracker.consumeQuota(task.getJobId()); }); return Pair.of(agent, tasks); }); } }
TaskMigrationDescheduler { Optional<Pair<Node, List<Task>>> nextBestMatch() { if (evictionQuotaTracker.getSystemEvictionQuota() <= 0) { return Optional.empty(); } return evacuatedAgentsAllocationTracker.getRemovableAgentsById().values().stream() .map(i -> Pair.of(i, computeFitness(i))) .filter(p -> p.getRight().getLeft() > 0) .max(Comparator.comparingDouble(p -> p.getRight().getLeft())) .map(p -> { Node agent = p.getLeft(); List<Task> tasks = p.getRight().getRight(); tasks.forEach(task -> { evacuatedAgentsAllocationTracker.descheduled(task); evictionQuotaTracker.consumeQuota(task.getJobId()); }); return Pair.of(agent, tasks); }); } TaskMigrationDescheduler(Map<String, TaskRelocationPlan> plannedAheadTaskRelocationPlans,
                             EvacuatedAgentsAllocationTracker evacuatedAgentsAllocationTracker,
                             EvictionQuotaTracker evictionQuotaTracker,
                             Map<String, Job<?>> jobsById,
                             Map<String, Task> tasksById,
                             TitusRuntime titusRuntime); }
TaskMigrationDescheduler { Optional<Pair<Node, List<Task>>> nextBestMatch() { if (evictionQuotaTracker.getSystemEvictionQuota() <= 0) { return Optional.empty(); } return evacuatedAgentsAllocationTracker.getRemovableAgentsById().values().stream() .map(i -> Pair.of(i, computeFitness(i))) .filter(p -> p.getRight().getLeft() > 0) .max(Comparator.comparingDouble(p -> p.getRight().getLeft())) .map(p -> { Node agent = p.getLeft(); List<Task> tasks = p.getRight().getRight(); tasks.forEach(task -> { evacuatedAgentsAllocationTracker.descheduled(task); evictionQuotaTracker.consumeQuota(task.getJobId()); }); return Pair.of(agent, tasks); }); } TaskMigrationDescheduler(Map<String, TaskRelocationPlan> plannedAheadTaskRelocationPlans,
                             EvacuatedAgentsAllocationTracker evacuatedAgentsAllocationTracker,
                             EvictionQuotaTracker evictionQuotaTracker,
                             Map<String, Job<?>> jobsById,
                             Map<String, Task> tasksById,
                             TitusRuntime titusRuntime);  }
TaskMigrationDescheduler { Optional<Pair<Node, List<Task>>> nextBestMatch() { if (evictionQuotaTracker.getSystemEvictionQuota() <= 0) { return Optional.empty(); } return evacuatedAgentsAllocationTracker.getRemovableAgentsById().values().stream() .map(i -> Pair.of(i, computeFitness(i))) .filter(p -> p.getRight().getLeft() > 0) .max(Comparator.comparingDouble(p -> p.getRight().getLeft())) .map(p -> { Node agent = p.getLeft(); List<Task> tasks = p.getRight().getRight(); tasks.forEach(task -> { evacuatedAgentsAllocationTracker.descheduled(task); evictionQuotaTracker.consumeQuota(task.getJobId()); }); return Pair.of(agent, tasks); }); } TaskMigrationDescheduler(Map<String, TaskRelocationPlan> plannedAheadTaskRelocationPlans,
                             EvacuatedAgentsAllocationTracker evacuatedAgentsAllocationTracker,
                             EvictionQuotaTracker evictionQuotaTracker,
                             Map<String, Job<?>> jobsById,
                             Map<String, Task> tasksById,
                             TitusRuntime titusRuntime);   }