QueuedExecutions { public void enqueue(final ExecutableFlow exflow, final ExecutionReference ref) throws ExecutorManagerException { if (hasExecution(exflow.getExecutionId())) { final String errMsg = "Flow already in queue " + exflow.getExecutionId(); throw new ExecutorManagerException(errMsg); } final Pair<ExecutionReference, ExecutableFlow> pair = new Pair<>(ref, exflow); try { this.queuedFlowMap.put(exflow.getExecutionId(), pair); this.queuedFlowList.put(pair); } catch (final InterruptedException e) { final String errMsg = "Failed to insert flow " + exflow.getExecutionId(); logger.error(errMsg, e); throw new ExecutorManagerException(errMsg); } } QueuedExecutions(final long capacity); Pair<ExecutionReference, ExecutableFlow> fetchHead(); void dequeue(final int executionId); void enqueue(final ExecutableFlow exflow, final ExecutionReference ref); void enqueueAll(
      final Collection<Pair<ExecutionReference, ExecutableFlow>> collection); Collection<Pair<ExecutionReference, ExecutableFlow>> getAllEntries(); boolean hasExecution(final int executionId); ExecutableFlow getFlow(final int executionId); ExecutionReference getReference(final int executionId); long size(); boolean isFull(); boolean isEmpty(); void clear();  }
@Test(expected = ExecutorManagerException.class) public void testEnqueueDuplicateExecution() throws IOException, ExecutorManagerException { final Pair<ExecutionReference, ExecutableFlow> pair1 = createExecutablePair("exec1", 1); final QueuedExecutions queue = new QueuedExecutions(5); queue.enqueue(pair1.getSecond(), pair1.getFirst()); queue.enqueue(pair1.getSecond(), pair1.getFirst()); }
@Test(expected = ExecutorManagerException.class) public void testEnqueueOverflow() throws IOException, ExecutorManagerException { final Pair<ExecutionReference, ExecutableFlow> pair1 = createExecutablePair("exec1", 1); final QueuedExecutions queue = new QueuedExecutions(1); queue.enqueue(pair1.getSecond(), pair1.getFirst()); queue.enqueue(pair1.getSecond(), pair1.getFirst()); }