@Override public ExecutableFlow fetchExecutableFlow(final int id) throws ExecutorManagerException { return this.executionFlowDao.fetchExecutableFlow(id); }
@Override public List<ExecutableFlow> fetchFlowHistory(final int projectId, final String flowId, final long startTime) throws ExecutorManagerException { return this.executionFlowDao.fetchFlowHistory(projectId, flowId, startTime); }
@Override public List<Pair<ExecutionReference, ExecutableFlow>> fetchQueuedFlows() throws ExecutorManagerException { return this.executionFlowDao.fetchQueuedFlows(); }
@Test public void testAdvancedFilter() throws Exception { createTestProject(); final ExecutableFlow flow = createTestFlow(); this.executionFlowDao.uploadExecutableFlow(flow); final List<ExecutableFlow> flowList1 = this.executionFlowDao .fetchFlowHistory("exectest1", "", "", 0, -1, -1, 0, 16); assertThat(flowList1.size()).isEqualTo(1); final ExecutableFlow fetchFlow = this.executionFlowDao.fetchExecutableFlow(flow.getExecutionId()); assertTwoFlowSame(flowList1.get(0), fetchFlow); }
@Test public void testFetchRecentlyFinishedFlows() throws Exception { final ExecutableFlow flow1 = createTestFlow(); this.executionFlowDao.uploadExecutableFlow(flow1); flow1.setStatus(Status.SUCCEEDED); flow1.setEndTime(System.currentTimeMillis()); this.executionFlowDao.updateExecutableFlow(flow1); //Flow just finished. Fetch recently finished flows immediately. Should get it. final List<ExecutableFlow> flows = this.executionFlowDao.fetchRecentlyFinishedFlows( RECENTLY_FINISHED_LIFETIME); assertThat(flows.size()).isEqualTo(1); assertTwoFlowSame(flow1, flows.get(0)); }
@Test public void testUpdateExecutableFlow() throws Exception { final ExecutableFlow flow = createTestFlow(); this.executionFlowDao.uploadExecutableFlow(flow); final ExecutableFlow fetchFlow = this.executionFlowDao.fetchExecutableFlow(flow.getExecutionId()); fetchFlow.setEndTime(System.currentTimeMillis()); fetchFlow.setStatus(Status.SUCCEEDED); this.executionFlowDao.updateExecutableFlow(fetchFlow); final ExecutableFlow fetchFlow2 = this.executionFlowDao.fetchExecutableFlow(flow.getExecutionId()); assertTwoFlowSame(fetchFlow, fetchFlow2); }
private ExecutableFlow createExecution(final Status status) throws IOException, ExecutorManagerException { final ExecutableFlow flow = TestUtils.createTestExecutableFlow("exectest1", "exec1"); this.executionFlowDao.uploadExecutableFlow(flow); assertEquals(Status.PREPARING, flow.getStatus()); flow.setStatus(status); this.executionFlowDao.updateExecutableFlow(flow); return flow; }
void updateExecutableFlow(final ExecutableFlow flow) throws ExecutorManagerException { updateExecutableFlow(flow, EncodingType.GZIP); }
@Override public synchronized void uploadExecutableFlow(final ExecutableFlow flow) throws ExecutorManagerException { this.executionFlowDao.uploadExecutableFlow(flow); }
@Test public void testUploadAndFetchExecutionFlows() throws Exception { final ExecutableFlow flow = createTestFlow(); this.executionFlowDao.uploadExecutableFlow(flow); final ExecutableFlow fetchFlow = this.executionFlowDao.fetchExecutableFlow(flow.getExecutionId()); assertThat(flow).isNotSameAs(fetchFlow); assertTwoFlowSame(flow, fetchFlow); }
@Test public void testFetchQueuedFlows() throws Exception { final ExecutableFlow flow = createTestFlow(); flow.setStatus(Status.PREPARING); this.executionFlowDao.uploadExecutableFlow(flow); final ExecutableFlow flow2 = TestUtils.createTestExecutableFlow("exectest1", "exec2"); flow2.setStatus(Status.PREPARING); this.executionFlowDao.uploadExecutableFlow(flow2); final List<Pair<ExecutionReference, ExecutableFlow>> fetchedQueuedFlows = this.executionFlowDao .fetchQueuedFlows(); assertThat(fetchedQueuedFlows.size()).isEqualTo(2); final Pair<ExecutionReference, ExecutableFlow> fetchedFlow1 = fetchedQueuedFlows.get(0); final Pair<ExecutionReference, ExecutableFlow> fetchedFlow2 = fetchedQueuedFlows.get(1); assertTwoFlowSame(flow, fetchedFlow1.getSecond()); assertTwoFlowSame(flow2, fetchedFlow2.getSecond()); }
final ExecutableFlow flow1 = createTestFlow(); flow1.setStartTime(dateUtil.dateStrToLong("2018-09-01 10:00:00")); this.executionFlowDao.uploadExecutableFlow(flow1); this.executionFlowDao.uploadExecutableFlow(flow2); this.executionFlowDao.uploadExecutableFlow(flow3); this.executionFlowDao.uploadExecutableFlow(flow4); final List<ExecutableFlow> flowList = this.executionFlowDao.fetchFlowHistory (flow1.getProjectId(), flow1.getFlowId(), dateUtil.dateStrToLong("2018-09-01 09:00:00")); final List<ExecutableFlow> expected = new ArrayList<>();
@Test public void testSelectAndUpdateExecution() throws Exception { final ExecutableFlow flow = TestUtils.createTestExecutableFlow("exectest1", "exec1"); flow.setExecutionId(1); this.executionFlowDao.uploadExecutableFlow(flow); final Executor executor = this.executorDao.addExecutor("localhost", 12345); assertThat(this.executionFlowDao.selectAndUpdateExecution(executor.getId())).isEqualTo(flow .getExecutionId()); assertThat(this.executorDao.fetchExecutorByExecutionId(flow.getExecutionId())).isEqualTo (executor); }
/** * maxAge indicates how long finished flows are shown in Recently Finished flow page. */ @Override public List<ExecutableFlow> fetchRecentlyFinishedFlows(final Duration maxAge) throws ExecutorManagerException { return this.executionFlowDao.fetchRecentlyFinishedFlows(maxAge); }
@Override public int selectAndUpdateExecution(final int executorId) throws ExecutorManagerException { return this.executionFlowDao.selectAndUpdateExecution(executorId); } }
@Before public void setup() { this.executionFlowDao = new ExecutionFlowDao(dbOperator); this.numExecutionsDao = new NumExecutionsDao(dbOperator); }
@Test public void fetchFlowHistory() throws Exception { final ExecutableFlow flow = createTestFlow(); this.executionFlowDao.uploadExecutableFlow(flow); final List<ExecutableFlow> flowList1 = this.executionFlowDao.fetchFlowHistory(0, 2); assertThat(flowList1.size()).isEqualTo(1); final List<ExecutableFlow> flowList2 = this.executionFlowDao .fetchFlowHistory(flow.getProjectId(), flow.getId(), 0, 2); assertThat(flowList2.size()).isEqualTo(1); final ExecutableFlow fetchFlow = this.executionFlowDao.fetchExecutableFlow(flow.getExecutionId()); assertTwoFlowSame(flowList1.get(0), flowList2.get(0)); assertTwoFlowSame(flowList1.get(0), fetchFlow); }
@Test public void testFetchEmptyRecentlyFinishedFlows() throws Exception { final ExecutableFlow flow1 = createTestFlow(); this.executionFlowDao.uploadExecutableFlow(flow1); flow1.setStatus(Status.SUCCEEDED); flow1.setEndTime(DateTimeUtils.currentTimeMillis()); this.executionFlowDao.updateExecutableFlow(flow1); //Todo jamiesjc: use java8.java.time api instead of jodatime //Mock flow finished time to be 2 min ago. DateTimeUtils.setCurrentMillisOffset(-FLOW_FINISHED_TIME.toMillis()); flow1.setEndTime(DateTimeUtils.currentTimeMillis()); this.executionFlowDao.updateExecutableFlow(flow1); //Fetch recently finished flows within 1 min. Should be empty. final List<ExecutableFlow> flows = this.executionFlowDao .fetchRecentlyFinishedFlows(RECENTLY_FINISHED_LIFETIME); assertThat(flows.size()).isEqualTo(0); }
@Test public void testFetchActiveFlowsStatusChanged() throws Exception { final ExecutableFlow flow1 = TestUtils.createTestExecutableFlow("exectest1", "exec1"); this.executionFlowDao.uploadExecutableFlow(flow1); final Executor executor = this.executorDao.addExecutor("test", 1); this.assignExecutor.assignExecutor(executor.getId(), flow1.getExecutionId()); Map<Integer, Pair<ExecutionReference, ExecutableFlow>> activeFlows1 = this.fetchActiveFlowDao.fetchActiveFlows(); assertThat(activeFlows1.containsKey(flow1.getExecutionId())).isTrue(); // When flow status becomes SUCCEEDED/KILLED/FAILED, it should not be in active state flow1.setStatus(Status.SUCCEEDED); this.executionFlowDao.updateExecutableFlow(flow1); activeFlows1 = this.fetchActiveFlowDao.fetchActiveFlows(); assertThat(activeFlows1.containsKey(flow1.getExecutionId())).isFalse(); flow1.setStatus(Status.KILLED); this.executionFlowDao.updateExecutableFlow(flow1); activeFlows1 = this.fetchActiveFlowDao.fetchActiveFlows(); assertThat(activeFlows1.containsKey(flow1.getExecutionId())).isFalse(); flow1.setStatus(Status.FAILED); this.executionFlowDao.updateExecutableFlow(flow1); activeFlows1 = this.fetchActiveFlowDao.fetchActiveFlows(); assertThat(activeFlows1.containsKey(flow1.getExecutionId())).isFalse(); }
@Override public void updateExecutableFlow(final ExecutableFlow flow) throws ExecutorManagerException { this.executionFlowDao.updateExecutableFlow(flow); }