@Test public void testScheduledRefresh() throws Exception { setupMocksForApp(1, 1, CRITICAL_APP, FLEX_APP); capacityMonitoringService.enterActiveMode(); testScheduler.triggerActions(); verify(agentManagementService, times(1)) .updateCapacity(CRITICAL_INSTANCE_GROUP_ID, Optional.of(1), Optional.empty()); verify(agentManagementService, times(0)) .updateCapacity(FLEX_INSTANCE_GROUP_ID, Optional.of(1), Optional.empty()); AgentInstanceGroup criticalInstanceGroup = getCriticalInstanceGroup(2, 2); CapacityAllocations allocations = new CapacityAllocations(singletonMap(criticalInstanceGroup, 2), emptyMap()); when(capacityGuaranteeStrategy.compute(any())).thenReturn(allocations); when(agentManagementService.updateCapacity(any(), any(), any())).thenReturn(Completable.complete()); testScheduler.advanceTimeBy(DefaultCapacityMonitoringService.PERIODIC_UPDATE_INTERVAL_MS, TimeUnit.MILLISECONDS); verify(agentManagementService, times(1)) .updateCapacity(CRITICAL_INSTANCE_GROUP_ID, Optional.of(2), Optional.empty()); }
@Activator public Observable<Void> enterActiveMode() { logger.info("Entering active mode"); schedulePeriodicUpdate(); return Observable.empty(); }
DefaultCapacityMonitoringService implements CapacityMonitoringService { @Activator public Observable<Void> enterActiveMode() { logger.info("Entering active mode"); schedulePeriodicUpdate(); return Observable.empty(); } }
DefaultCapacityMonitoringService implements CapacityMonitoringService { @Activator public Observable<Void> enterActiveMode() { logger.info("Entering active mode"); schedulePeriodicUpdate(); return Observable.empty(); } DefaultCapacityMonitoringService(CapacityManagementConfiguration configuration,
                                            CapacityGuaranteeStrategy strategy,
                                            ApplicationSlaStore storage,
                                            AgentManagementService agentManagementService,
                                            Registry registry,
                                            Scheduler scheduler); @Inject  DefaultCapacityMonitoringService(CapacityManagementConfiguration configuration,
                                            CapacityGuaranteeStrategy strategy,
                                            ApplicationSlaStore storage,
                                            AgentManagementService agentManagementService,
                                            Registry registry); }
DefaultCapacityMonitoringService implements CapacityMonitoringService { @Activator public Observable<Void> enterActiveMode() { logger.info("Entering active mode"); schedulePeriodicUpdate(); return Observable.empty(); } DefaultCapacityMonitoringService(CapacityManagementConfiguration configuration,
                                            CapacityGuaranteeStrategy strategy,
                                            ApplicationSlaStore storage,
                                            AgentManagementService agentManagementService,
                                            Registry registry,
                                            Scheduler scheduler); @Inject  DefaultCapacityMonitoringService(CapacityManagementConfiguration configuration,
                                            CapacityGuaranteeStrategy strategy,
                                            ApplicationSlaStore storage,
                                            AgentManagementService agentManagementService,
                                            Registry registry); @PreDestroy void shutdown(); @Activator Observable<Void> enterActiveMode(); @Override Observable<Void> refresh(); }
DefaultCapacityMonitoringService implements CapacityMonitoringService { @Activator public Observable<Void> enterActiveMode() { logger.info("Entering active mode"); schedulePeriodicUpdate(); return Observable.empty(); } DefaultCapacityMonitoringService(CapacityManagementConfiguration configuration,
                                            CapacityGuaranteeStrategy strategy,
                                            ApplicationSlaStore storage,
                                            AgentManagementService agentManagementService,
                                            Registry registry,
                                            Scheduler scheduler); @Inject  DefaultCapacityMonitoringService(CapacityManagementConfiguration configuration,
                                            CapacityGuaranteeStrategy strategy,
                                            ApplicationSlaStore storage,
                                            AgentManagementService agentManagementService,
                                            Registry registry); @PreDestroy void shutdown(); @Activator Observable<Void> enterActiveMode(); @Override Observable<Void> refresh();  }