}
});
// AsyncModule itself is not a subclass of PrivateModule because TaskEventModule internally uses
// a MultiBinder, which cannot span multiple injectors.
install(new PrivateModule() {
@Override
protected void configure() {
bind(new TypeLiteral<Amount<Long, Time>>() { })
.toInstance(TRANSIENT_TASK_STATE_TIMEOUT.get());
bind(ScheduledExecutorService.class).toInstance(executor);
bind(TaskTimeout.class).in(Singleton.class);
requireBinding(StatsProvider.class);
expose(TaskTimeout.class);
}
});
PubsubEventModule.bindSubscriber(binder(), TaskTimeout.class);
install(new PrivateModule() {
@Override
protected void configure() {
bind(TaskGroupsSettings.class).toInstance(new TaskGroupsSettings(
new TruncatedBinaryBackoff(INITIAL_SCHEDULE_DELAY.get(), MAX_SCHEDULE_DELAY.get()),
RateLimiter.create(MAX_SCHEDULE_ATTEMPTS_PER_SEC.get())));
bind(RescheduleCalculatorImpl.RescheduleCalculatorSettings.class)
.toInstance(new RescheduleCalculatorImpl.RescheduleCalculatorSettings(
new TruncatedBinaryBackoff(INITIAL_FLAPPING_DELAY.get(), MAX_FLAPPING_DELAY.get()),
FLAPPING_THRESHOLD.get(),
MAX_RESCHEDULING_DELAY.get()));
bind(RescheduleCalculator.class).to(RescheduleCalculatorImpl.class).in(Singleton.class);
expose(RescheduleCalculator.class);
if (ENABLE_PREEMPTOR.get()) {
bind(PREEMPTOR_KEY).to(PreemptorImpl.class);
bind(PreemptorImpl.class).in(Singleton.class);
LOG.info("Preemptor Enabled.");
} else {
bind(PREEMPTOR_KEY).toInstance(NULL_PREEMPTOR);
LOG.warning("Preemptor Disabled.");
}
expose(PREEMPTOR_KEY);
bind(new TypeLiteral<Amount<Long, Time>>() { }).annotatedWith(PreemptionDelay.class)
.toInstance(PREEMPTION_DELAY.get());
bind(TaskGroups.class).in(Singleton.class);
expose(TaskGroups.class);
}
});
bindTaskScheduler(binder(), PREEMPTOR_KEY, RESERVATION_DURATION.get());
PubsubEventModule.bindSubscriber(binder(), TaskGroups.class);
install(new PrivateModule() {
@Override
protected void configure() {
bind(OfferReturnDelay.class).to(RandomJitterReturnDelay.class);
bind(ScheduledExecutorService.class).toInstance(executor);
bind(OfferQueue.class).to(OfferQueueImpl.class);
bind(OfferQueueImpl.class).in(Singleton.class);
expose(OfferQueue.class);
}
});
PubsubEventModule.bindSubscriber(binder(), OfferQueue.class);
install(new PrivateModule() {
@Override
protected void configure() {
// TODO(ksweeney): Create a configuration validator module so this can be injected.
// TODO(William Farner): Revert this once large task counts is cheap ala hierarchichal store
bind(HistoryPrunnerSettings.class).toInstance(new HistoryPrunnerSettings(
HISTORY_PRUNE_THRESHOLD.get(),
HISTORY_MIN_RETENTION_THRESHOLD.get(),
HISTORY_MAX_PER_JOB_THRESHOLD.get()
));
bind(ScheduledExecutorService.class).toInstance(executor);
bind(HistoryPruner.class).in(Singleton.class);
expose(HistoryPruner.class);
}
});
PubsubEventModule.bindSubscriber(binder(), HistoryPruner.class);
install(new PrivateModule() {
@Override
protected void configure() {
bind(ScheduledExecutorService.class).toInstance(executor);
bind(TaskThrottler.class).in(Singleton.class);
expose(TaskThrottler.class);
}
});
PubsubEventModule.bindSubscriber(binder(), TaskThrottler.class);
install(new PrivateModule() {
@Override
protected void configure() {
bind(GcExecutorSettings.class).toInstance(new RandomGcExecutorSettings(
EXECUTOR_GC_INTERVAL.get(),
Optional.fromNullable(GC_EXECUTOR_PATH.get())));