Repository: aurora Updated Branches: refs/heads/master cbe99f547 -> ad0bc5f9d
Add initial interval before searching for preemption slots Between failovers, tasks that normally would not require preemption could be in a PENDING state for an extended period of time and become eligible for preemption. Thus, when the scheduler starts, offers could not have been processed yet and the tasks can preempt other tasks needlessly. Added an initial delay to preemption slot searching on scheduler startup so PENDING tasks have a chance to be scheduled before preempting. Reviewed at https://reviews.apache.org/r/66573/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/ad0bc5f9 Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/ad0bc5f9 Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/ad0bc5f9 Branch: refs/heads/master Commit: ad0bc5f9df4bcb6c5713db6d2defdffed006210c Parents: cbe99f5 Author: Jordan Ly <[email protected]> Authored: Thu Apr 12 13:28:48 2018 -0700 Committer: Jordan Ly <[email protected]> Committed: Thu Apr 12 13:28:48 2018 -0700 ---------------------------------------------------------------------- .../aurora/scheduler/preemptor/PreemptorModule.java | 15 ++++++++++++++- .../aurora/scheduler/config/CommandLineTest.java | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/ad0bc5f9/src/main/java/org/apache/aurora/scheduler/preemptor/PreemptorModule.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/preemptor/PreemptorModule.java b/src/main/java/org/apache/aurora/scheduler/preemptor/PreemptorModule.java index 7618efc..2843e9f 100644 --- a/src/main/java/org/apache/aurora/scheduler/preemptor/PreemptorModule.java +++ b/src/main/java/org/apache/aurora/scheduler/preemptor/PreemptorModule.java @@ -39,6 +39,7 @@ import org.apache.aurora.scheduler.base.TaskGroupKey; import org.apache.aurora.scheduler.config.CliOptions; import org.apache.aurora.scheduler.config.splitters.CommaSplitter; import org.apache.aurora.scheduler.config.types.TimeAmount; +import org.apache.aurora.scheduler.config.validators.PositiveAmount; import org.apache.aurora.scheduler.config.validators.PositiveNumber; import org.apache.aurora.scheduler.events.PubsubEventModule; import org.apache.aurora.scheduler.preemptor.BiCache.BiCacheSettings; @@ -64,15 +65,24 @@ public class PreemptorModule extends AbstractModule { public boolean enablePreemptor = true; @Parameter(names = "-preemption_delay", + validateValueWith = PositiveAmount.class, description = "Time interval after which a pending task becomes eligible to preempt other tasks") public TimeAmount preemptionDelay = new TimeAmount(3, Time.MINUTES); @Parameter(names = "-preemption_slot_hold_time", + validateValueWith = PositiveAmount.class, description = "Time to hold a preemption slot found before it is discarded.") public TimeAmount preemptionSlotHoldTime = new TimeAmount(5, Time.MINUTES); + @Parameter(names = "-preemption_slot_search_initial_delay", + validateValueWith = PositiveAmount.class, + description = + "Initial amount of time to delay preemption slot searching after scheduler start up.") + public TimeAmount preemptionSlotSearchInitialDelay = new TimeAmount(3, Time.MINUTES); + @Parameter(names = "-preemption_slot_search_interval", + validateValueWith = PositiveAmount.class, description = "Time interval between pending task preemption slot searches.") public TimeAmount preemptionSlotSearchInterval = new TimeAmount(1, Time.MINUTES); @@ -129,10 +139,13 @@ public class PreemptorModule extends AbstractModule { install(module); } + // We need to convert the initial delay time unit to be the same as the search interval + long preemptionSlotSearchInitialDelay = options.preemptionSlotSearchInitialDelay + .as(options.preemptionSlotSearchInterval.getUnit()); bind(PreemptorService.class).in(Singleton.class); bind(AbstractScheduledService.Scheduler.class).toInstance( AbstractScheduledService.Scheduler.newFixedRateSchedule( - 0L, + preemptionSlotSearchInitialDelay, options.preemptionSlotSearchInterval.getValue(), options.preemptionSlotSearchInterval.getUnit().getTimeUnit())); http://git-wip-us.apache.org/repos/asf/aurora/blob/ad0bc5f9/src/test/java/org/apache/aurora/scheduler/config/CommandLineTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/aurora/scheduler/config/CommandLineTest.java b/src/test/java/org/apache/aurora/scheduler/config/CommandLineTest.java index 0a16d3c..e66ec11 100644 --- a/src/test/java/org/apache/aurora/scheduler/config/CommandLineTest.java +++ b/src/test/java/org/apache/aurora/scheduler/config/CommandLineTest.java @@ -220,6 +220,7 @@ public class CommandLineTest { expected.preemptor.enablePreemptor = false; expected.preemptor.preemptionDelay = TEST_TIME; expected.preemptor.preemptionSlotHoldTime = TEST_TIME; + expected.preemptor.preemptionSlotSearchInitialDelay = TEST_TIME; expected.preemptor.preemptionSlotSearchInterval = TEST_TIME; expected.preemptor.reservationMaxBatchSize = 42; expected.preemptor.slotFinderModules = ImmutableList.of(NoopModule.class); @@ -352,6 +353,7 @@ public class CommandLineTest { "-enable_preemptor=false", "-preemption_delay=42days", "-preemption_slot_hold_time=42days", + "-preemption_slot_search_initial_delay=42days", "-preemption_slot_search_interval=42days", "-preemption_reservation_max_batch_size=42", "-preemption_slot_finder_modules="
