@Test public void testExecute() { List<Cluster> clusterList = getClusters(); when(periscopeNodeConfig.getId()).thenReturn("nodeId"); when(clusterService.findAllForNode(ClusterState.RUNNING, true, "nodeId")).thenReturn(clusterList); underTest.execute(getContext()); verify(executorServiceWithRegistry).submitIfAbsent(testExecutor, CLUSTER_ID); verify(monitored).setLastEvaluated(anyLong()); verify(rejectedThreadService).remove(CLUSTER_ID); }
@Override public void execute(JobExecutionContext context) { MDCBuilder.buildMdcContext(); evalContext(context); List<M> monitoredData = getMonitored(); LOGGER.debug("Job started: {}, monitored: {}", context.getJobDetail().getKey(), monitoredData.size()); for (M monitored : monitoredData) { try { EvaluatorExecutor evaluatorExecutor = getEvaluatorExecutorBean(monitored); EvaluatorContext evaluatorContext = getContext(monitored); evaluatorExecutor.setContext(evaluatorContext); executorServiceWithRegistry.submitIfAbsent(evaluatorExecutor, evaluatorContext.getItemId()); LOGGER.debug("Successfully submitted {} for cluster {}.", evaluatorExecutor.getName(), evaluatorContext.getData()); rejectedThreadService.remove(evaluatorContext.getData()); monitored.setLastEvaluated(System.currentTimeMillis()); save(monitored); } catch (RejectedExecutionException ignore) { LOGGER.info("Error in processing monitor: {}", monitored, ignore); } } }
AbstractMonitor implements Monitor<M> { @Override public void execute(JobExecutionContext context) { MDCBuilder.buildMdcContext(); evalContext(context); List<M> monitoredData = getMonitored(); LOGGER.debug("Job started: {}, monitored: {}", context.getJobDetail().getKey(), monitoredData.size()); for (M monitored : monitoredData) { try { EvaluatorExecutor evaluatorExecutor = getEvaluatorExecutorBean(monitored); EvaluatorContext evaluatorContext = getContext(monitored); evaluatorExecutor.setContext(evaluatorContext); executorServiceWithRegistry.submitIfAbsent(evaluatorExecutor, evaluatorContext.getItemId()); LOGGER.debug("Successfully submitted {} for cluster {}.", evaluatorExecutor.getName(), evaluatorContext.getData()); rejectedThreadService.remove(evaluatorContext.getData()); monitored.setLastEvaluated(System.currentTimeMillis()); save(monitored); } catch (RejectedExecutionException ignore) { LOGGER.info("Error in processing monitor: {}", monitored, ignore); } } } }
AbstractMonitor implements Monitor<M> { @Override public void execute(JobExecutionContext context) { MDCBuilder.buildMdcContext(); evalContext(context); List<M> monitoredData = getMonitored(); LOGGER.debug("Job started: {}, monitored: {}", context.getJobDetail().getKey(), monitoredData.size()); for (M monitored : monitoredData) { try { EvaluatorExecutor evaluatorExecutor = getEvaluatorExecutorBean(monitored); EvaluatorContext evaluatorContext = getContext(monitored); evaluatorExecutor.setContext(evaluatorContext); executorServiceWithRegistry.submitIfAbsent(evaluatorExecutor, evaluatorContext.getItemId()); LOGGER.debug("Successfully submitted {} for cluster {}.", evaluatorExecutor.getName(), evaluatorContext.getData()); rejectedThreadService.remove(evaluatorContext.getData()); monitored.setLastEvaluated(System.currentTimeMillis()); save(monitored); } catch (RejectedExecutionException ignore) { LOGGER.info("Error in processing monitor: {}", monitored, ignore); } } }  }
AbstractMonitor implements Monitor<M> { @Override public void execute(JobExecutionContext context) { MDCBuilder.buildMdcContext(); evalContext(context); List<M> monitoredData = getMonitored(); LOGGER.debug("Job started: {}, monitored: {}", context.getJobDetail().getKey(), monitoredData.size()); for (M monitored : monitoredData) { try { EvaluatorExecutor evaluatorExecutor = getEvaluatorExecutorBean(monitored); EvaluatorContext evaluatorContext = getContext(monitored); evaluatorExecutor.setContext(evaluatorContext); executorServiceWithRegistry.submitIfAbsent(evaluatorExecutor, evaluatorContext.getItemId()); LOGGER.debug("Successfully submitted {} for cluster {}.", evaluatorExecutor.getName(), evaluatorContext.getData()); rejectedThreadService.remove(evaluatorContext.getData()); monitored.setLastEvaluated(System.currentTimeMillis()); save(monitored); } catch (RejectedExecutionException ignore) { LOGGER.info("Error in processing monitor: {}", monitored, ignore); } } }  @Override void execute(JobExecutionContext context); }
AbstractMonitor implements Monitor<M> { @Override public void execute(JobExecutionContext context) { MDCBuilder.buildMdcContext(); evalContext(context); List<M> monitoredData = getMonitored(); LOGGER.debug("Job started: {}, monitored: {}", context.getJobDetail().getKey(), monitoredData.size()); for (M monitored : monitoredData) { try { EvaluatorExecutor evaluatorExecutor = getEvaluatorExecutorBean(monitored); EvaluatorContext evaluatorContext = getContext(monitored); evaluatorExecutor.setContext(evaluatorContext); executorServiceWithRegistry.submitIfAbsent(evaluatorExecutor, evaluatorContext.getItemId()); LOGGER.debug("Successfully submitted {} for cluster {}.", evaluatorExecutor.getName(), evaluatorContext.getData()); rejectedThreadService.remove(evaluatorContext.getData()); monitored.setLastEvaluated(System.currentTimeMillis()); save(monitored); } catch (RejectedExecutionException ignore) { LOGGER.info("Error in processing monitor: {}", monitored, ignore); } } }  @Override void execute(JobExecutionContext context);  }