/** * Get the number of non-dispatched flows from database. {@inheritDoc} */ @Override public long getQueuedFlowSize() { long size = 0L; try { size = this.executorLoader.fetchQueuedFlows().size(); } catch (final ExecutorManagerException e) { this.logger.error("Failed to get queued flow size.", e); } return size; }
/** * Get execution ids of all non-dispatched flows from database. */ public List<Integer> getQueuedFlowIds() { final List<Integer> allIds = new ArrayList<>(); try { getExecutionIdsHelper(allIds, this.executorLoader.fetchQueuedFlows()); } catch (final ExecutorManagerException e) { this.logger.error("Failed to get queued flow ids.", e); } return allIds; }
private void loadQueuedFlows() throws ExecutorManagerException { final List<Pair<ExecutionReference, ExecutableFlow>> retrievedExecutions = this.executorLoader.fetchQueuedFlows(); if (retrievedExecutions != null) { for (final Pair<ExecutionReference, ExecutableFlow> pair : retrievedExecutions) { this.queuedFlows.enqueue(pair.getSecond(), pair.getFirst()); } } }
@Test public void testQueuedFlows() throws Exception { final ExecutorManager manager = createMultiExecutorManagerInstance(); final ExecutableFlow flow1 = TestUtils.createTestExecutableFlow("exectest1", "exec1"); flow1.setExecutionId(1); final ExecutableFlow flow2 = TestUtils.createTestExecutableFlow("exectest1", "exec2"); flow2.setExecutionId(2); final User testUser = TestUtils.getTestUser(); manager.submitExecutableFlow(flow1, testUser.getUserId()); manager.submitExecutableFlow(flow2, testUser.getUserId()); final List<Integer> testFlows = Arrays.asList(flow1.getExecutionId(), flow2.getExecutionId()); final List<Pair<ExecutionReference, ExecutableFlow>> queuedFlowsDB = this.loader.fetchQueuedFlows(); Assert.assertEquals(queuedFlowsDB.size(), testFlows.size()); // Verify things are correctly setup in db for (final Pair<ExecutionReference, ExecutableFlow> pair : queuedFlowsDB) { Assert.assertTrue(testFlows.contains(pair.getSecond().getExecutionId())); } // Verify running flows using old definition of "running" flows i.e. a // non-dispatched flow is also considered running final List<Integer> managerActiveFlows = manager.getRunningFlows() .stream().map(ExecutableFlow::getExecutionId).collect(Collectors.toList()); Assert.assertTrue(managerActiveFlows.containsAll(testFlows) && testFlows.containsAll(managerActiveFlows)); // Verify getQueuedFlowIds method Assert.assertEquals("[1, 2]", manager.getQueuedFlowIds()); }
when(this.loader.fetchActiveFlows()).thenReturn(this.activeFlows); this.queuedFlows = ImmutableList.of(new Pair<>(this.ref1, this.flow1)); when(this.loader.fetchQueuedFlows()).thenReturn(this.queuedFlows);
private void loadQueuedFlows() throws ExecutorManagerException { final List<Pair<ExecutionReference, ExecutableFlow>> retrievedExecutions = this.executorLoader.fetchQueuedFlows(); if (retrievedExecutions != null) { for (final Pair<ExecutionReference, ExecutableFlow> pair : retrievedExecutions) { this.queuedFlows.enqueue(pair.getSecond(), pair.getFirst()); } } }