@Test public void testPutIfAbsent() { assertTrue(underTest.putIfAbsent(getEvaluatorExecutor(EXECUTOR_ONE), CLUSTER_ONE)); }
boolean putIfAbsent(EvaluatorExecutor evaluator, long resourceId) { long now = clock.getCurrentTimeMillis(); Element elementToSubmit = new Element(evaluator, resourceId, now); Element elementAlreadyPresent = submittedEvaluators.putIfAbsent(elementToSubmit, elementToSubmit); if (elementAlreadyPresent == null) { return true; } else if (now - elementAlreadyPresent.getTimestampMillis() > timeout) { LOGGER.info("Timeout after {}: {} for cluster {} still present, resubmitting", now - elementAlreadyPresent.getTimestampMillis(), elementAlreadyPresent.getEvaluatorExecutor().getName(), elementAlreadyPresent.getResourceId()); return true; } LOGGER.debug("Submitting {} for cluster {} failed, it has been present in the system for {} ms", elementAlreadyPresent.getEvaluatorExecutor().getName(), elementAlreadyPresent.getResourceId(), now - elementAlreadyPresent.getTimestampMillis()); return false; }
EvaluatorExecutorRegistry { boolean putIfAbsent(EvaluatorExecutor evaluator, long resourceId) { long now = clock.getCurrentTimeMillis(); Element elementToSubmit = new Element(evaluator, resourceId, now); Element elementAlreadyPresent = submittedEvaluators.putIfAbsent(elementToSubmit, elementToSubmit); if (elementAlreadyPresent == null) { return true; } else if (now - elementAlreadyPresent.getTimestampMillis() > timeout) { LOGGER.info("Timeout after {}: {} for cluster {} still present, resubmitting", now - elementAlreadyPresent.getTimestampMillis(), elementAlreadyPresent.getEvaluatorExecutor().getName(), elementAlreadyPresent.getResourceId()); return true; } LOGGER.debug("Submitting {} for cluster {} failed, it has been present in the system for {} ms", elementAlreadyPresent.getEvaluatorExecutor().getName(), elementAlreadyPresent.getResourceId(), now - elementAlreadyPresent.getTimestampMillis()); return false; } }
EvaluatorExecutorRegistry { boolean putIfAbsent(EvaluatorExecutor evaluator, long resourceId) { long now = clock.getCurrentTimeMillis(); Element elementToSubmit = new Element(evaluator, resourceId, now); Element elementAlreadyPresent = submittedEvaluators.putIfAbsent(elementToSubmit, elementToSubmit); if (elementAlreadyPresent == null) { return true; } else if (now - elementAlreadyPresent.getTimestampMillis() > timeout) { LOGGER.info("Timeout after {}: {} for cluster {} still present, resubmitting", now - elementAlreadyPresent.getTimestampMillis(), elementAlreadyPresent.getEvaluatorExecutor().getName(), elementAlreadyPresent.getResourceId()); return true; } LOGGER.debug("Submitting {} for cluster {} failed, it has been present in the system for {} ms", elementAlreadyPresent.getEvaluatorExecutor().getName(), elementAlreadyPresent.getResourceId(), now - elementAlreadyPresent.getTimestampMillis()); return false; }  }
EvaluatorExecutorRegistry { boolean putIfAbsent(EvaluatorExecutor evaluator, long resourceId) { long now = clock.getCurrentTimeMillis(); Element elementToSubmit = new Element(evaluator, resourceId, now); Element elementAlreadyPresent = submittedEvaluators.putIfAbsent(elementToSubmit, elementToSubmit); if (elementAlreadyPresent == null) { return true; } else if (now - elementAlreadyPresent.getTimestampMillis() > timeout) { LOGGER.info("Timeout after {}: {} for cluster {} still present, resubmitting", now - elementAlreadyPresent.getTimestampMillis(), elementAlreadyPresent.getEvaluatorExecutor().getName(), elementAlreadyPresent.getResourceId()); return true; } LOGGER.debug("Submitting {} for cluster {} failed, it has been present in the system for {} ms", elementAlreadyPresent.getEvaluatorExecutor().getName(), elementAlreadyPresent.getResourceId(), now - elementAlreadyPresent.getTimestampMillis()); return false; }  void remove(EvaluatorExecutor evaluator, long clusterId); int activeCount(); }
EvaluatorExecutorRegistry { boolean putIfAbsent(EvaluatorExecutor evaluator, long resourceId) { long now = clock.getCurrentTimeMillis(); Element elementToSubmit = new Element(evaluator, resourceId, now); Element elementAlreadyPresent = submittedEvaluators.putIfAbsent(elementToSubmit, elementToSubmit); if (elementAlreadyPresent == null) { return true; } else if (now - elementAlreadyPresent.getTimestampMillis() > timeout) { LOGGER.info("Timeout after {}: {} for cluster {} still present, resubmitting", now - elementAlreadyPresent.getTimestampMillis(), elementAlreadyPresent.getEvaluatorExecutor().getName(), elementAlreadyPresent.getResourceId()); return true; } LOGGER.debug("Submitting {} for cluster {} failed, it has been present in the system for {} ms", elementAlreadyPresent.getEvaluatorExecutor().getName(), elementAlreadyPresent.getResourceId(), now - elementAlreadyPresent.getTimestampMillis()); return false; }  void remove(EvaluatorExecutor evaluator, long clusterId); int activeCount();  }