@Test public void testVerifyAndUpdateJvmStatesOnNullJvmList() { when(mockJvmPersistenceService.getJvms()).thenReturn(null); jvmStateService.verifyAndUpdateJvmStates(); verify(mockJvmStateResolverWorker, never()).pingAndUpdateJvmState(any(Jvm.class), any(JvmStateService.class)); }
@Override @Scheduled(fixedDelayString = "${ping.jvm.period.millis}") public void verifyAndUpdateJvmStates() { final List<Jvm> jvms = jvmPersistenceService.getJvms(); if (CollectionUtils.isEmpty(jvms)) { LOGGER.warn("No JVMs found to ping."); return; } for (final Jvm jvm : jvms) { if (stateNotInMemory(jvm) || isValidState(jvm) && isFutureNilOrDone(jvm) && isStale(jvm)) { LOGGER.debug("Pinging JVM {} ...", jvm.getJvmName()); PING_FUTURE_MAP.put(jvm.getId(), jvmStateResolverWorker.pingAndUpdateJvmState(jvm, this)); LOGGER.debug("Pinged JVM {}", jvm.getJvmName()); } } }
JvmStateServiceImpl implements JvmStateService { @Override @Scheduled(fixedDelayString = "${ping.jvm.period.millis}") public void verifyAndUpdateJvmStates() { final List<Jvm> jvms = jvmPersistenceService.getJvms(); if (CollectionUtils.isEmpty(jvms)) { LOGGER.warn("No JVMs found to ping."); return; } for (final Jvm jvm : jvms) { if (stateNotInMemory(jvm) || isValidState(jvm) && isFutureNilOrDone(jvm) && isStale(jvm)) { LOGGER.debug("Pinging JVM {} ...", jvm.getJvmName()); PING_FUTURE_MAP.put(jvm.getId(), jvmStateResolverWorker.pingAndUpdateJvmState(jvm, this)); LOGGER.debug("Pinged JVM {}", jvm.getJvmName()); } } } }
JvmStateServiceImpl implements JvmStateService { @Override @Scheduled(fixedDelayString = "${ping.jvm.period.millis}") public void verifyAndUpdateJvmStates() { final List<Jvm> jvms = jvmPersistenceService.getJvms(); if (CollectionUtils.isEmpty(jvms)) { LOGGER.warn("No JVMs found to ping."); return; } for (final Jvm jvm : jvms) { if (stateNotInMemory(jvm) || isValidState(jvm) && isFutureNilOrDone(jvm) && isStale(jvm)) { LOGGER.debug("Pinging JVM {} ...", jvm.getJvmName()); PING_FUTURE_MAP.put(jvm.getId(), jvmStateResolverWorker.pingAndUpdateJvmState(jvm, this)); LOGGER.debug("Pinged JVM {}", jvm.getJvmName()); } } } @Autowired  JvmStateServiceImpl(final JvmPersistenceService jvmPersistenceService,
                               @Qualifier("jvmInMemoryStateManagerService")
                               final InMemoryStateManagerService<Identifier<Jvm>, CurrentState<Jvm, JvmState>> inMemoryStateManagerService,
                               final JvmStateResolverWorker jvmStateResolverWorker,
                               final MessagingService messagingService,
                               final GroupStateNotificationService groupStateNotificationService,
                               @Value("${jvm.state.update.interval:60000}")
                               final long jvmStateUpdateInterval,
                               final JvmCommandFactory jvmCommandFactory,
                               final SshConfiguration sshConfig,
                               @Value("${jvm.state.key.lock.timeout.millis:600000}")
                               final long lockTimeout,
                               @Value("${jvm.state.key.lock.stripe.count:120}")
                               final int keyLockStripeCount); }
JvmStateServiceImpl implements JvmStateService { @Override @Scheduled(fixedDelayString = "${ping.jvm.period.millis}") public void verifyAndUpdateJvmStates() { final List<Jvm> jvms = jvmPersistenceService.getJvms(); if (CollectionUtils.isEmpty(jvms)) { LOGGER.warn("No JVMs found to ping."); return; } for (final Jvm jvm : jvms) { if (stateNotInMemory(jvm) || isValidState(jvm) && isFutureNilOrDone(jvm) && isStale(jvm)) { LOGGER.debug("Pinging JVM {} ...", jvm.getJvmName()); PING_FUTURE_MAP.put(jvm.getId(), jvmStateResolverWorker.pingAndUpdateJvmState(jvm, this)); LOGGER.debug("Pinged JVM {}", jvm.getJvmName()); } } } @Autowired  JvmStateServiceImpl(final JvmPersistenceService jvmPersistenceService,
                               @Qualifier("jvmInMemoryStateManagerService")
                               final InMemoryStateManagerService<Identifier<Jvm>, CurrentState<Jvm, JvmState>> inMemoryStateManagerService,
                               final JvmStateResolverWorker jvmStateResolverWorker,
                               final MessagingService messagingService,
                               final GroupStateNotificationService groupStateNotificationService,
                               @Value("${jvm.state.update.interval:60000}")
                               final long jvmStateUpdateInterval,
                               final JvmCommandFactory jvmCommandFactory,
                               final SshConfiguration sshConfig,
                               @Value("${jvm.state.key.lock.timeout.millis:600000}")
                               final long lockTimeout,
                               @Value("${jvm.state.key.lock.stripe.count:120}")
                               final int keyLockStripeCount); @Override @Scheduled(fixedDelayString = "${ping.jvm.period.millis}") void verifyAndUpdateJvmStates(); @Override void updateNotInMemOrStaleState(final Jvm jvm, final JvmState state, final String errMsg); @Override RemoteCommandReturnInfo getServiceStatus(final Jvm jvm); @Override void updateState(Jvm jvm, final JvmState state); @Override void updateState(final Jvm jvm, final JvmState state, final String errMsg); }
JvmStateServiceImpl implements JvmStateService { @Override @Scheduled(fixedDelayString = "${ping.jvm.period.millis}") public void verifyAndUpdateJvmStates() { final List<Jvm> jvms = jvmPersistenceService.getJvms(); if (CollectionUtils.isEmpty(jvms)) { LOGGER.warn("No JVMs found to ping."); return; } for (final Jvm jvm : jvms) { if (stateNotInMemory(jvm) || isValidState(jvm) && isFutureNilOrDone(jvm) && isStale(jvm)) { LOGGER.debug("Pinging JVM {} ...", jvm.getJvmName()); PING_FUTURE_MAP.put(jvm.getId(), jvmStateResolverWorker.pingAndUpdateJvmState(jvm, this)); LOGGER.debug("Pinged JVM {}", jvm.getJvmName()); } } } @Autowired  JvmStateServiceImpl(final JvmPersistenceService jvmPersistenceService,
                               @Qualifier("jvmInMemoryStateManagerService")
                               final InMemoryStateManagerService<Identifier<Jvm>, CurrentState<Jvm, JvmState>> inMemoryStateManagerService,
                               final JvmStateResolverWorker jvmStateResolverWorker,
                               final MessagingService messagingService,
                               final GroupStateNotificationService groupStateNotificationService,
                               @Value("${jvm.state.update.interval:60000}")
                               final long jvmStateUpdateInterval,
                               final JvmCommandFactory jvmCommandFactory,
                               final SshConfiguration sshConfig,
                               @Value("${jvm.state.key.lock.timeout.millis:600000}")
                               final long lockTimeout,
                               @Value("${jvm.state.key.lock.stripe.count:120}")
                               final int keyLockStripeCount); @Override @Scheduled(fixedDelayString = "${ping.jvm.period.millis}") void verifyAndUpdateJvmStates(); @Override void updateNotInMemOrStaleState(final Jvm jvm, final JvmState state, final String errMsg); @Override RemoteCommandReturnInfo getServiceStatus(final Jvm jvm); @Override void updateState(Jvm jvm, final JvmState state); @Override void updateState(final Jvm jvm, final JvmState state, final String errMsg);  }