@Test public void testSubmitIfAbsent() { when(evaluatorExecutorRegistry.putIfAbsent(any(), eq(CLUSTER_ID))).thenReturn(true); executorServiceWithRegistry.submitIfAbsent(getEvaluatorExecutor(), CLUSTER_ID); verify(executorService).submit((Runnable) any()); verify(evaluatorExecutorRegistry, never()).remove(any(), anyLong()); }
public void submitIfAbsent(EvaluatorExecutor evaluatorExecutor, long clusterId) { if (evaluatorExecutorRegistry.putIfAbsent(evaluatorExecutor, clusterId)) { try { executorService.submit(evaluatorExecutor); } catch (RejectedExecutionException e) { evaluatorExecutorRegistry.remove(evaluatorExecutor, clusterId); throw e; } } else { LOGGER.info("Evaluator {} is not accepted for cluster {}", evaluatorExecutor.getName(), clusterId); } }
ExecutorServiceWithRegistry { public void submitIfAbsent(EvaluatorExecutor evaluatorExecutor, long clusterId) { if (evaluatorExecutorRegistry.putIfAbsent(evaluatorExecutor, clusterId)) { try { executorService.submit(evaluatorExecutor); } catch (RejectedExecutionException e) { evaluatorExecutorRegistry.remove(evaluatorExecutor, clusterId); throw e; } } else { LOGGER.info("Evaluator {} is not accepted for cluster {}", evaluatorExecutor.getName(), clusterId); } } }
ExecutorServiceWithRegistry { public void submitIfAbsent(EvaluatorExecutor evaluatorExecutor, long clusterId) { if (evaluatorExecutorRegistry.putIfAbsent(evaluatorExecutor, clusterId)) { try { executorService.submit(evaluatorExecutor); } catch (RejectedExecutionException e) { evaluatorExecutorRegistry.remove(evaluatorExecutor, clusterId); throw e; } } else { LOGGER.info("Evaluator {} is not accepted for cluster {}", evaluatorExecutor.getName(), clusterId); } }  }
ExecutorServiceWithRegistry { public void submitIfAbsent(EvaluatorExecutor evaluatorExecutor, long clusterId) { if (evaluatorExecutorRegistry.putIfAbsent(evaluatorExecutor, clusterId)) { try { executorService.submit(evaluatorExecutor); } catch (RejectedExecutionException e) { evaluatorExecutorRegistry.remove(evaluatorExecutor, clusterId); throw e; } } else { LOGGER.info("Evaluator {} is not accepted for cluster {}", evaluatorExecutor.getName(), clusterId); } }  void submitIfAbsent(EvaluatorExecutor evaluatorExecutor, long clusterId); void finished(EvaluatorExecutor evaluator, long clusterId); int activeCount(); }
ExecutorServiceWithRegistry { public void submitIfAbsent(EvaluatorExecutor evaluatorExecutor, long clusterId) { if (evaluatorExecutorRegistry.putIfAbsent(evaluatorExecutor, clusterId)) { try { executorService.submit(evaluatorExecutor); } catch (RejectedExecutionException e) { evaluatorExecutorRegistry.remove(evaluatorExecutor, clusterId); throw e; } } else { LOGGER.info("Evaluator {} is not accepted for cluster {}", evaluatorExecutor.getName(), clusterId); } }  void submitIfAbsent(EvaluatorExecutor evaluatorExecutor, long clusterId); void finished(EvaluatorExecutor evaluator, long clusterId); int activeCount();  }