private static Pair<ExecutionReference, ExecutableFlow> getExecutableFlowMetadataHelper( final ResultSet rs) throws SQLException { final Flow flow = new Flow(rs.getString("flow_id")); final Project project = new Project(rs.getInt("project_id"), null); project.setVersion(rs.getInt("version")); final ExecutableFlow exFlow = new ExecutableFlow(project, flow); exFlow.setExecutionId(rs.getInt("exec_id")); exFlow.setStatus(Status.fromInteger(rs.getInt("status"))); exFlow.setSubmitTime(rs.getLong("submit_time")); exFlow.setStartTime(rs.getLong("start_time")); exFlow.setEndTime(rs.getLong("end_time")); exFlow.setSubmitUser(rs.getString("submit_user")); return getPairWithExecutorInfo(rs, exFlow); }
@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 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); }
flow.setEndTime(System.currentTimeMillis()); executorLoader.updateExecutableFlow(dsFlow);
exFlow.setEndTime(time);
flow.setEndTime(System.currentTimeMillis()); this.executorLoader.updateExecutableFlow(dsFlow);
@Test public void createErrorEmail() throws Exception { setJobStatus(Status.FAILED); this.executableFlow.setEndTime(END_TIME_MILLIS); this.executableFlow.setStatus(Status.FAILED); final List<ExecutableFlow> executableFlows = new ArrayList<>(); final ExecutableFlow executableFlow1 = new ExecutableFlow(this.project, this.flow); executableFlow1.setExecutionId(1); executableFlow1.setStartTime(START_TIME_MILLIS); executableFlow1.setEndTime(END_TIME_MILLIS); executableFlow1.setStatus(Status.FAILED); executableFlows.add(executableFlow1); final ExecutableFlow executableFlow2 = new ExecutableFlow(this.project, this.flow); executableFlow2.setExecutionId(2); executableFlow2.setStartTime(START_TIME_MILLIS); executableFlow2.setEndTime(END_TIME_MILLIS); executableFlow2.setStatus(Status.SUCCEEDED); executableFlows.add(executableFlow2); assertTrue(this.mailCreator.createErrorEmail( this.executableFlow, executableFlows, this.message, this.azkabanName, this.scheme, this .clientHostname, this.clientPortNumber)); assertEquals("Flow 'mail-creator-test' has failed on unit-tests", this.message.getSubject()); assertThat(TestUtils.readResource("errorEmail.html", this)) .isEqualToIgnoringWhitespace(this.message.getBody()); }
private List<ExecutableFlow> createExecutions() throws Exception { final Executor executor = this.executorDao.addExecutor("test", 1); final ExecutableFlow flow1 = createExecutionAndAssign(Status.PREPARING, executor); // flow2 is not assigned final ExecutableFlow flow2 = createExecution(Status.PREPARING); final ExecutableFlow flow3 = createExecutionAndAssign(Status.RUNNING, executor); flow3.setStartTime(System.currentTimeMillis() + 1); this.executionFlowDao.updateExecutableFlow(flow3); final ExecutableFlow flow4 = createExecutionAndAssign(Status.SUCCEEDED, executor); flow4.setStartTime(System.currentTimeMillis() - 2); flow4.setEndTime(System.currentTimeMillis() - 1); this.executionFlowDao.updateExecutableFlow(flow4); final Executor executor2 = this.executorDao.addExecutor("test2", 2); // flow5 is assigned to an executor that is then removed final ExecutableFlow flow5 = createExecutionAndAssign(Status.RUNNING, executor2); flow5.setStartTime(System.currentTimeMillis() + 1); this.executionFlowDao.updateExecutableFlow(flow5); this.executorDao.removeExecutor(executor2.getHost(), executor2.getPort()); return ImmutableList.of(flow1, flow2, flow3, flow4, flow5); }
@Test public void createSuccessEmail() throws Exception { setJobStatus(Status.SUCCEEDED); this.executableFlow.setEndTime(END_TIME_MILLIS); this.executableFlow.setStatus(Status.SUCCEEDED); assertTrue(this.mailCreator.createSuccessEmail( this.executableFlow, this.message, this.azkabanName, this.scheme, this.clientHostname, this.clientPortNumber)); assertEquals("Flow 'mail-creator-test' has succeeded on unit-tests", this.message.getSubject()); assertThat(TestUtils.readResource("successEmail.html", this)) .isEqualToIgnoringWhitespace(this.message.getBody()); }
@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); }
assertNotNull(jobdInnerFlowA, jobdInnerFlowB, jobdInnerFlowC, jobdInnerFlow); exFlow.setEndTime(1000); exFlow.setStartTime(500); exFlow.setStatus(Status.RUNNING);
private ExecutableFlow getExecutableFlowMetadata( ExecutableFlow fullExFlow) { final Flow flow = new Flow(fullExFlow.getId()); final Project project = new Project(fullExFlow.getProjectId(), null); project.setVersion(fullExFlow.getVersion()); flow.setVersion(fullExFlow.getVersion()); final ExecutableFlow metadata = new ExecutableFlow(project, flow); metadata.setExecutionId(fullExFlow.getExecutionId()); metadata.setStatus(fullExFlow.getStatus()); metadata.setSubmitTime(fullExFlow.getSubmitTime()); metadata.setStartTime(fullExFlow.getStartTime()); metadata.setEndTime(fullExFlow.getEndTime()); metadata.setSubmitUser(fullExFlow.getSubmitUser()); return metadata; }
flow.setEndTime(System.currentTimeMillis()); logger.info("Setting end time for flow " + execId + " to " + System.currentTimeMillis()); closeLogger();
flow.setEndTime(System.currentTimeMillis()); executorLoader.updateExecutableFlow(dsFlow);
flow.setEndTime(System.currentTimeMillis()); this.executorLoader.updateExecutableFlow(dsFlow);
exFlow.setEndTime(time);
private void failEverything(final ExecutableFlow exFlow) { final long time = System.currentTimeMillis(); for (final ExecutableNode node : exFlow.getExecutableNodes()) { switch (node.getStatus()) { case SUCCEEDED: case FAILED: case KILLED: case SKIPPED: case DISABLED: continue; // case UNKNOWN: case READY: node.setStatus(Status.KILLING); break; default: node.setStatus(Status.FAILED); break; } if (node.getStartTime() == -1) { node.setStartTime(time); } if (node.getEndTime() == -1) { node.setEndTime(time); } } if (exFlow.getEndTime() == -1) { exFlow.setEndTime(time); } exFlow.setStatus(Status.FAILED); }
flow.setEndTime(updateFlow.getEndTime()); flow.setUpdateTime(updateFlow.getUpdateTime());