@Test public void testScheduleWhenRunFails() throws InterruptedException { Server server = mock(Server.class); when(server.getRunPeriodSeconds()).thenReturn(2); when(queryExecutorRepository.getExecutor(same(server))).thenThrow(new IllegalStateException("Command failed")); serverScheduler.schedule(server); verify(queryExecutorRepository, timeout(6000L).atLeast(2)).getExecutor(same(server)); }
public void schedule(Server server) { ServerCommand serverCommand = new ServerCommand(server, queryExecutorRepository, resultProcessor); long runPeriod = serverCommand.getRunPeriodSeconds(configuration.getRunPeriod()); ScheduledFuture<?> scheduledFuture = scheduledExecutor.scheduleAtFixedRate(serverCommand, runPeriod, runPeriod, TimeUnit.SECONDS); synchronized (this.scheduledServerCommands) { this.scheduledServerCommands.add(new ScheduledServerCommand(serverCommand, scheduledFuture)); } log.debug("Scheduled job for server {}", serverCommand.getName()); }
ServerScheduler { public void schedule(Server server) { ServerCommand serverCommand = new ServerCommand(server, queryExecutorRepository, resultProcessor); long runPeriod = serverCommand.getRunPeriodSeconds(configuration.getRunPeriod()); ScheduledFuture<?> scheduledFuture = scheduledExecutor.scheduleAtFixedRate(serverCommand, runPeriod, runPeriod, TimeUnit.SECONDS); synchronized (this.scheduledServerCommands) { this.scheduledServerCommands.add(new ScheduledServerCommand(serverCommand, scheduledFuture)); } log.debug("Scheduled job for server {}", serverCommand.getName()); } }
ServerScheduler { public void schedule(Server server) { ServerCommand serverCommand = new ServerCommand(server, queryExecutorRepository, resultProcessor); long runPeriod = serverCommand.getRunPeriodSeconds(configuration.getRunPeriod()); ScheduledFuture<?> scheduledFuture = scheduledExecutor.scheduleAtFixedRate(serverCommand, runPeriod, runPeriod, TimeUnit.SECONDS); synchronized (this.scheduledServerCommands) { this.scheduledServerCommands.add(new ScheduledServerCommand(serverCommand, scheduledFuture)); } log.debug("Scheduled job for server {}", serverCommand.getName()); } @Inject  ServerScheduler(
			@Nonnull JmxTransConfiguration configuration,
			@Nonnull ScheduledExecutorService scheduledExecutor,
			@Nonnull @Named("queryExecutorRepository") ExecutorRepository queryExecutorRepository,
			@Nonnull ResultProcessor resultProcessor); }
ServerScheduler { public void schedule(Server server) { ServerCommand serverCommand = new ServerCommand(server, queryExecutorRepository, resultProcessor); long runPeriod = serverCommand.getRunPeriodSeconds(configuration.getRunPeriod()); ScheduledFuture<?> scheduledFuture = scheduledExecutor.scheduleAtFixedRate(serverCommand, runPeriod, runPeriod, TimeUnit.SECONDS); synchronized (this.scheduledServerCommands) { this.scheduledServerCommands.add(new ScheduledServerCommand(serverCommand, scheduledFuture)); } log.debug("Scheduled job for server {}", serverCommand.getName()); } @Inject  ServerScheduler(
			@Nonnull JmxTransConfiguration configuration,
			@Nonnull ScheduledExecutorService scheduledExecutor,
			@Nonnull @Named("queryExecutorRepository") ExecutorRepository queryExecutorRepository,
			@Nonnull ResultProcessor resultProcessor); void start(); void schedule(Server server); void unscheduleAll(); void stop(); }
ServerScheduler { public void schedule(Server server) { ServerCommand serverCommand = new ServerCommand(server, queryExecutorRepository, resultProcessor); long runPeriod = serverCommand.getRunPeriodSeconds(configuration.getRunPeriod()); ScheduledFuture<?> scheduledFuture = scheduledExecutor.scheduleAtFixedRate(serverCommand, runPeriod, runPeriod, TimeUnit.SECONDS); synchronized (this.scheduledServerCommands) { this.scheduledServerCommands.add(new ScheduledServerCommand(serverCommand, scheduledFuture)); } log.debug("Scheduled job for server {}", serverCommand.getName()); } @Inject  ServerScheduler(
			@Nonnull JmxTransConfiguration configuration,
			@Nonnull ScheduledExecutorService scheduledExecutor,
			@Nonnull @Named("queryExecutorRepository") ExecutorRepository queryExecutorRepository,
			@Nonnull ResultProcessor resultProcessor); void start(); void schedule(Server server); void unscheduleAll(); void stop();  }