private void ajaxFetchExecutableFlow(final HttpServletRequest req, final HttpServletResponse resp, final HashMap<String, Object> ret, final User user, final ExecutableFlow exFlow) throws ServletException { logger.info("Fetching " + exFlow.getExecutionId()); final Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.READ); if (project == null) { return; } ret.put("submitTime", exFlow.getSubmitTime()); ret.put("submitUser", exFlow.getSubmitUser()); ret.put("execid", exFlow.getExecutionId()); ret.put("projectId", exFlow.getProjectId()); ret.put("project", project.getName()); final Map<String, Object> flowObj = getExecutableNodeInfo(exFlow); ret.putAll(flowObj); }
flowInfo.put("startTime", flow.getStartTime()); flowInfo.put("endTime", flow.getEndTime()); flowInfo.put("submitUser", flow.getSubmitUser());
exFlow.setExecutionOptions(executionOptions); ret.put("submitTime", exFlow.getSubmitTime()); ret.put("submitUser", exFlow.getSubmitUser()); ret.put("execid", exFlow.getExecutionId()); ret.put("projectId", exFlow.getProjectId());
public static Props addCommonFlowProperties(final Props parentProps, final ExecutableFlowBase flow) { final Props props = new Props(parentProps); props.put(CommonJobProperties.FLOW_ID, flow.getFlowId()); props.put(CommonJobProperties.EXEC_ID, flow.getExecutionId()); props.put(CommonJobProperties.PROJECT_ID, flow.getProjectId()); props.put(CommonJobProperties.PROJECT_NAME, flow.getProjectName()); props.put(CommonJobProperties.PROJECT_VERSION, flow.getVersion()); props.put(CommonJobProperties.FLOW_UUID, UUID.randomUUID().toString()); props.put(CommonJobProperties.PROJECT_LAST_CHANGED_BY, flow.getLastModifiedByUser()); props.put(CommonJobProperties.PROJECT_LAST_CHANGED_DATE, flow.getLastModifiedTimestamp()); props.put(CommonJobProperties.SUBMIT_USER, flow.getExecutableFlow().getSubmitUser()); final DateTime loadTime = new DateTime(); props.put(CommonJobProperties.FLOW_START_TIMESTAMP, loadTime.toString()); props.put(CommonJobProperties.FLOW_START_YEAR, loadTime.toString("yyyy")); props.put(CommonJobProperties.FLOW_START_MONTH, loadTime.toString("MM")); props.put(CommonJobProperties.FLOW_START_DAY, loadTime.toString("dd")); props.put(CommonJobProperties.FLOW_START_HOUR, loadTime.toString("HH")); props.put(CommonJobProperties.FLOW_START_MINUTE, loadTime.toString("mm")); props.put(CommonJobProperties.FLOW_START_SECOND, loadTime.toString("ss")); props.put(CommonJobProperties.FLOW_START_MILLISSECOND, loadTime.toString("SSS")); props.put(CommonJobProperties.FLOW_START_TIMEZONE, loadTime.toString("ZZZZ")); return props; }
private void assertTwoFlowSame(final ExecutableFlow flow1, final ExecutableFlow flow2, final boolean compareFlowData) { assertThat(flow1.getExecutionId()).isEqualTo(flow2.getExecutionId()); assertThat(flow1.getStatus()).isEqualTo(flow2.getStatus()); assertThat(flow1.getEndTime()).isEqualTo(flow2.getEndTime()); assertThat(flow1.getStartTime()).isEqualTo(flow2.getStartTime()); assertThat(flow1.getSubmitTime()).isEqualTo(flow2.getSubmitTime()); assertThat(flow1.getFlowId()).isEqualTo(flow2.getFlowId()); assertThat(flow1.getProjectId()).isEqualTo(flow2.getProjectId()); assertThat(flow1.getVersion()).isEqualTo(flow2.getVersion()); assertThat(flow1.getSubmitUser()).isEqualTo(flow2.getSubmitUser()); if (compareFlowData) { assertThat(flow1.getExecutionOptions().getFailureAction()) .isEqualTo(flow2.getExecutionOptions().getFailureAction()); assertThat(new HashSet<>(flow1.getEndNodes())).isEqualTo(new HashSet<>(flow2.getEndNodes())); } }
public synchronized void uploadExecutableFlow(final ExecutableFlow flow) throws ExecutorManagerException { final String INSERT_EXECUTABLE_FLOW = "INSERT INTO execution_flows " + "(project_id, flow_id, version, status, submit_time, submit_user, update_time) " + "values (?,?,?,?,?,?,?)"; final long submitTime = System.currentTimeMillis(); flow.setStatus(Status.PREPARING); flow.setSubmitTime(submitTime); /** * Why we need a transaction to get last insert ID? * Because "SELECT LAST_INSERT_ID()" needs to have the same connection * as inserting the new entry. * See https://dev.mysql.com/doc/refman/5.7/en/information-functions.html#function_last-insert-id */ final SQLTransaction<Long> insertAndGetLastID = transOperator -> { transOperator.update(INSERT_EXECUTABLE_FLOW, flow.getProjectId(), flow.getFlowId(), flow.getVersion(), Status.PREPARING.getNumVal(), submitTime, flow.getSubmitUser(), submitTime); transOperator.getConnection().commit(); return transOperator.getLastInsertId(); }; try { final long id = this.dbOperator.transaction(insertAndGetLastID); logger.info("Flow given " + flow.getFlowId() + " given id " + id); flow.setExecutionId((int) id); updateExecutableFlow(flow); } catch (final SQLException e) { throw new ExecutorManagerException("Error creating execution.", e); } }
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; }
Assert.assertEquals(exA.getVersion(), exB.getVersion()); Assert.assertEquals(exA.getSubmitTime(), exB.getSubmitTime()); Assert.assertEquals(exA.getSubmitUser(), exB.getSubmitUser()); Assert.assertEquals(exA.getExecutionPath(), exB.getExecutionPath());
private void ajaxFetchExecutableFlow( HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret, User user, ExecutableFlow exFlow) throws ServletException { System.out.println("Fetching " + exFlow.getExecutionId()); Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.READ); if (project == null) { return; } ret.put("submitTime", exFlow.getSubmitTime()); ret.put("submitUser", exFlow.getSubmitUser()); ret.put("execid", exFlow.getExecutionId()); ret.put("projectId", exFlow.getProjectId()); ret.put("project", project.getName()); Map<String,Object> flowObj = getExecutableNodeInfo(exFlow); ret.putAll(flowObj); }
flowInfo.put("startTime", flow.getStartTime()); flowInfo.put("endTime", flow.getEndTime()); flowInfo.put("submitUser", flow.getSubmitUser());
public static Props addCommonFlowProperties(final Props parentProps, final ExecutableFlowBase flow) { final Props props = new Props(parentProps); props.put(CommonJobProperties.FLOW_ID, flow.getFlowId()); props.put(CommonJobProperties.EXEC_ID, flow.getExecutionId()); props.put(CommonJobProperties.PROJECT_ID, flow.getProjectId()); props.put(CommonJobProperties.PROJECT_NAME, flow.getProjectName()); props.put(CommonJobProperties.PROJECT_VERSION, flow.getVersion()); props.put(CommonJobProperties.FLOW_UUID, UUID.randomUUID().toString()); props.put(CommonJobProperties.PROJECT_LAST_CHANGED_BY, flow.getLastModifiedByUser()); props.put(CommonJobProperties.PROJECT_LAST_CHANGED_DATE, flow.getLastModifiedTimestamp()); props.put(CommonJobProperties.SUBMIT_USER, flow.getExecutableFlow().getSubmitUser()); final DateTime loadTime = new DateTime(); props.put(CommonJobProperties.FLOW_START_TIMESTAMP, loadTime.toString()); props.put(CommonJobProperties.FLOW_START_YEAR, loadTime.toString("yyyy")); props.put(CommonJobProperties.FLOW_START_MONTH, loadTime.toString("MM")); props.put(CommonJobProperties.FLOW_START_DAY, loadTime.toString("dd")); props.put(CommonJobProperties.FLOW_START_HOUR, loadTime.toString("HH")); props.put(CommonJobProperties.FLOW_START_MINUTE, loadTime.toString("mm")); props.put(CommonJobProperties.FLOW_START_SECOND, loadTime.toString("ss")); props.put(CommonJobProperties.FLOW_START_MILLISSECOND, loadTime.toString("SSS")); props.put(CommonJobProperties.FLOW_START_TIMEZONE, loadTime.toString("ZZZZ")); return props; }
public synchronized void uploadExecutableFlow(final ExecutableFlow flow) throws ExecutorManagerException { final String INSERT_EXECUTABLE_FLOW = "INSERT INTO execution_flows " + "(project_id, flow_id, version, status, submit_time, submit_user, update_time) " + "values (?,?,?,?,?,?,?)"; final long submitTime = System.currentTimeMillis(); flow.setStatus(Status.PREPARING); /** * Why we need a transaction to get last insert ID? * Because "SELECT LAST_INSERT_ID()" needs to have the same connection * as inserting the new entry. * See https://dev.mysql.com/doc/refman/5.7/en/information-functions.html#function_last-insert-id */ final SQLTransaction<Long> insertAndGetLastID = transOperator -> { transOperator.update(INSERT_EXECUTABLE_FLOW, flow.getProjectId(), flow.getFlowId(), flow.getVersion(), Status.PREPARING.getNumVal(), submitTime, flow.getSubmitUser(), submitTime); transOperator.getConnection().commit(); return transOperator.getLastInsertId(); }; try { final long id = this.dbOperator.transaction(insertAndGetLastID); logger.info("Flow given " + flow.getFlowId() + " given id " + id); flow.setExecutionId((int) id); updateExecutableFlow(flow); } catch (final SQLException e) { throw new ExecutorManagerException("Error creating execution.", e); } }
Status.PREPARING.getNumVal(), submitTime, flow.getSubmitUser(), submitTime); connection.commit();