List of usage examples for com.google.common.util.concurrent AbstractScheduledService scheduler
protected abstract Scheduler scheduler();
From source file:org.apache.aurora.scheduler.async.preemptor.PreemptorModule.java
@Override protected void configure() { install(new PrivateModule() { @Override//from w w w . ja v a2 s . co m protected void configure() { if (enablePreemptor) { LOG.info("Preemptor Enabled."); bind(PreemptorMetrics.class).in(Singleton.class); bind(PreemptionVictimFilter.class).to(PreemptionVictimFilter.PreemptionVictimFilterImpl.class); bind(PreemptionVictimFilter.PreemptionVictimFilterImpl.class).in(Singleton.class); bind(Preemptor.class).to(Preemptor.PreemptorImpl.class); bind(Preemptor.PreemptorImpl.class).in(Singleton.class); bind(new TypeLiteral<Amount<Long, Time>>() { }).annotatedWith(PendingTaskProcessor.PreemptionDelay.class).toInstance(preemptionDelay); bind(BiCacheSettings.class).toInstance( new BiCacheSettings(PREEMPTION_SLOT_HOLD_TIME.get(), "preemption_slot_cache_size")); bind(new TypeLiteral<BiCache<PreemptionProposal, TaskGroupKey>>() { }).in(Singleton.class); bind(PendingTaskProcessor.class).in(Singleton.class); bind(ClusterState.class).to(ClusterStateImpl.class); bind(ClusterStateImpl.class).in(Singleton.class); expose(ClusterStateImpl.class); bind(PreemptorService.class).in(Singleton.class); bind(AbstractScheduledService.Scheduler.class) .toInstance(AbstractScheduledService.Scheduler.newFixedRateSchedule(0L, slotSearchInterval.getValue(), slotSearchInterval.getUnit().getTimeUnit())); expose(PreemptorService.class); expose(PendingTaskProcessor.class); } else { bind(Preemptor.class).toInstance(NULL_PREEMPTOR); LOG.warning("Preemptor Disabled."); } expose(Preemptor.class); } }); // We can't do this in the private module due to the known conflict between multibindings // and private modules due to multiple injectors. We accept the added complexity here to keep // the other bindings private. PubsubEventModule.bindSubscriber(binder(), ClusterStateImpl.class); if (enablePreemptor) { SchedulerServicesModule.addSchedulerActiveServiceBinding(binder()).to(PreemptorService.class); } }
From source file:fr.inria.eventcloud.load_balancing.services.LoadBalancingService.java
/** * {@inheritDoc}/* w ww .ja v a2 s .c o m*/ */ @Override protected Scheduler scheduler() { return AbstractScheduledService.Scheduler.newFixedDelaySchedule( EventCloudProperties.LOAD_BALANCING_PERIOD.getValue(), EventCloudProperties.LOAD_BALANCING_PERIOD.getValue(), TimeUnit.MILLISECONDS); }
From source file:org.apache.aurora.scheduler.preemptor.PreemptorModule.java
@Override protected void configure() { install(new PrivateModule() { @Override//from www . ja v a2 s . c o m protected void configure() { if (enablePreemptor) { LOG.info("Preemptor Enabled."); bind(PreemptorMetrics.class).in(Singleton.class); bind(Preemptor.class).to(Preemptor.PreemptorImpl.class); bind(Preemptor.PreemptorImpl.class).in(Singleton.class); bind(new TypeLiteral<Amount<Long, Time>>() { }).annotatedWith(PendingTaskProcessor.PreemptionDelay.class).toInstance(preemptionDelay); bind(BiCacheSettings.class) .toInstance(new BiCacheSettings(PREEMPTION_SLOT_HOLD_TIME.get(), "preemption_slot")); bind(new TypeLiteral<BiCache<PreemptionProposal, TaskGroupKey>>() { }).in(Singleton.class); bind(new TypeLiteral<Integer>() { }).annotatedWith(PendingTaskProcessor.ReservationBatchSize.class) .toInstance(reservationBatchSize); bind(ClusterState.class).to(ClusterStateImpl.class); bind(ClusterStateImpl.class).in(Singleton.class); expose(ClusterStateImpl.class); for (Module module : slotFinderModules) { install(module); } bind(PreemptorService.class).in(Singleton.class); bind(AbstractScheduledService.Scheduler.class) .toInstance(AbstractScheduledService.Scheduler.newFixedRateSchedule(0L, slotSearchInterval.getValue(), slotSearchInterval.getUnit().getTimeUnit())); expose(PreemptorService.class); expose(Runnable.class).annotatedWith(PreemptionSlotFinder.class); } else { bind(Preemptor.class).toInstance(NULL_PREEMPTOR); LOG.warn("Preemptor Disabled."); } expose(Preemptor.class); } }); // We can't do this in the private module due to the known conflict between multibindings // and private modules due to multiple injectors. We accept the added complexity here to keep // the other bindings private. PubsubEventModule.bindSubscriber(binder(), ClusterStateImpl.class); if (enablePreemptor) { SchedulerServicesModule.addSchedulerActiveServiceBinding(binder()).to(PreemptorService.class); } }