List<ExecutableFlow> fetchRecentlyFinishedFlows(final Duration maxAge) throws ExecutorManagerException { try { return this.dbOperator.query(FetchRecentlyFinishedFlows.FETCH_RECENTLY_FINISHED_FLOW, new FetchRecentlyFinishedFlows(), System.currentTimeMillis() - maxAge.toMillis(), Status.SUCCEEDED.getNumVal(), Status.KILLED.getNumVal(), Status.FAILED.getNumVal()); } catch (final SQLException e) { throw new ExecutorManagerException("Error fetching recently finished flows", e); } }
public Map<String, Object> toObject() { final HashMap<String, Object> attempts = new HashMap<>(); attempts.put(ATTEMPT_PARAM, this.attempt); attempts.put(STARTTIME_PARAM, this.startTime); attempts.put(ENDTIME_PARAM, this.endTime); attempts.put(STATUS_PARAM, this.status.toString()); return attempts; } }
public void applyUpdateObject(final TypedMapWrapper<String, Object> updateData) { this.status = Status.fromInteger(updateData.getInt(STATUS_PARAM, this.status.getNumVal())); this.startTime = updateData.getLong(STARTTIME_PARAM); this.updateTime = updateData.getLong(UPDATETIME_PARAM); this.endTime = updateData.getLong(ENDTIME_PARAM); if (updateData.containsKey(ATTEMPT_PARAM)) { this.attempt.set(updateData.getInt(ATTEMPT_PARAM)); if (this.attempt.get() > 0) { updatePastAttempts(updateData.<Object>getList(PASTATTEMPTS_PARAM, Collections.<Object>emptyList())); } } }
@Override public void doAction() throws Exception { final ExecutableFlow exFlow = executorManagerAdapter.getExecutableFlow(this.execId); logger.info("ready to kill execution " + this.execId); if (!Status.isStatusFinished(exFlow.getStatus())) { logger.info("Killing execution " + this.execId); executorManagerAdapter.cancelFlow(exFlow, Constants.AZKABAN_SLA_CHECKER_USERNAME); } }
public static ExecutionChecker createFromJson(final HashMap<String, Object> jsonObj) throws Exception { if (!jsonObj.get("type").equals(type)) { throw new Exception("Cannot create checker of " + type + " from " + jsonObj.get("type")); } final int execId = Integer.valueOf((String) jsonObj.get("execId")); String jobName = null; if (jsonObj.containsKey("jobName")) { jobName = (String) jsonObj.get("jobName"); } final String checkerId = (String) jsonObj.get("checkerId"); final Status wantedStatus = Status.valueOf((String) jsonObj.get("wantedStatus")); return new ExecutionChecker(checkerId, execId, jobName, wantedStatus); }
ArrayList<ExecutableNode> jobsToRun = new ArrayList<ExecutableNode>(); if (isFlowFinished() && !Status.isStatusFinished(getStatus())) { jobsToRun.add(this); nodeloop: for (ExecutableNode node: executableNodes.values()) { if(Status.isStatusFinished(node.getStatus())) { continue; if ((node instanceof ExecutableFlowBase) && Status.isStatusRunning(node.getStatus())) { else if (Status.isStatusRunning(node.getStatus())) { continue; for (String dependency: node.getInNodes()) { if (!Status.isStatusFinished(getExecutableNode(dependency).getStatus())) { continue nodeloop;
@Override public List<ExecutableJobInfo> handle(final ResultSet rs) throws SQLException { if (!rs.next()) { return Collections.<ExecutableJobInfo>emptyList(); } final List<ExecutableJobInfo> execNodes = new ArrayList<>(); do { final int execId = rs.getInt(1); final int projectId = rs.getInt(2); final int version = rs.getInt(3); final String flowId = rs.getString(4); final String jobId = rs.getString(5); final long startTime = rs.getLong(6); final long endTime = rs.getLong(7); final Status status = Status.fromInteger(rs.getInt(8)); final int attempt = rs.getInt(9); final ExecutableJobInfo info = new ExecutableJobInfo(execId, projectId, version, flowId, jobId, startTime, endTime, status, attempt); execNodes.add(info); } while (rs.next()); return execNodes; } }
public void applyUpdateObject(final TypedMapWrapper<String, Object> updateData) { this.status = Status.fromInteger(updateData.getInt(STATUS_PARAM, this.status.getNumVal())); this.startTime = updateData.getLong(STARTTIME_PARAM); this.updateTime = updateData.getLong(UPDATETIME_PARAM); this.endTime = updateData.getLong(ENDTIME_PARAM); if (updateData.containsKey(ATTEMPT_PARAM)) { this.attempt.set(updateData.getInt(ATTEMPT_PARAM)); if (this.attempt.get() > 0) { updatePastAttempts(updateData.<Object>getList(PASTATTEMPTS_PARAM, Collections.<Object>emptyList())); } } }
public Status blockOnFinishedStatus() { if (status == null) { return null; } while (!Status.isStatusFinished(status)) { synchronized(this) { try { this.wait(WAIT_TIME); } catch (InterruptedException e) { } } } return status; }
public static ExecutionAttempt fromObject(final Object obj) { final Map<String, Object> map = (Map<String, Object>) obj; final TypedMapWrapper<String, Object> wrapper = new TypedMapWrapper<>(map); final int attempt = wrapper.getInt(ATTEMPT_PARAM); final long startTime = wrapper.getLong(STARTTIME_PARAM); final long endTime = wrapper.getLong(ENDTIME_PARAM); final Status status = Status.valueOf(wrapper.getString(STATUS_PARAM)); return new ExecutionAttempt(attempt, startTime, endTime, status); }
private boolean runReadyJob(ExecutableNode node) throws IOException { if (Status.isStatusFinished(node.getStatus()) || Status.isStatusRunning(node.getStatus())) { return false;
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); }
private static Pair<ExecutionReference, ExecutableFlow> getExecutableFlowHelper( final ResultSet rs) throws SQLException { final int id = rs.getInt("exec_id"); final int encodingType = rs.getInt("enc_type"); final byte[] data = rs.getBytes("flow_data"); if (data == null) { logger.warn("Execution id " + id + " has flow_data = null. To clean up, update status to " + "FAILED manually, eg. " + "SET status = " + Status.FAILED.getNumVal() + " WHERE id = " + id); } else { final EncodingType encType = EncodingType.fromInteger(encodingType); final ExecutableFlow exFlow; try { exFlow = ExecutableFlow.createExecutableFlowFromObject( GZIPUtils.transformBytesToObject(data, encType)); } catch (final IOException e) { throw new SQLException("Error retrieving flow data " + id, e); } return getPairWithExecutorInfo(rs, exFlow); } return null; }
@Override public Object toJson() { final Map<String, Object> jsonObj = new HashMap<>(); jsonObj.put("type", type); jsonObj.put("execId", String.valueOf(this.execId)); if (this.jobName != null) { jsonObj.put("jobName", this.jobName); } jsonObj.put("wantedStatus", this.wantedStatus.toString()); jsonObj.put("checkerId", this.checkerId); return jsonObj; }
public void applyUpdateObject(TypedMapWrapper<String, Object> updateData) { this.status = Status.fromInteger(updateData.getInt(STATUS_PARAM, this.status.getNumVal())); this.startTime = updateData.getLong(STARTTIME_PARAM); this.updateTime = updateData.getLong(UPDATETIME_PARAM); this.endTime = updateData.getLong(ENDTIME_PARAM); if (updateData.containsKey(ATTEMPT_PARAM)) { attempt = updateData.getInt(ATTEMPT_PARAM); if (attempt > 0) { updatePastAttempts( updateData.<Object>getList(PASTATTEMPTS_PARAM, Collections.<Object>emptyList())); } } }
public void changeStatus(Status status) { synchronized(this) { this.status = status; if (Status.isStatusFinished(status)) { unblock(); } } }
this.conditionOnJobStatus = ConditionOnJobStatus.fromString(wrappedMap.getString (CONDITION_ON_JOB_STATUS_PARAM)); this.status = Status.valueOf(wrappedMap.getString(STATUS_PARAM)); this.startTime = wrappedMap.getLong(STARTTIME_PARAM); this.endTime = wrappedMap.getLong(ENDTIME_PARAM);
if (Status.isStatusRunning(node.getStatus()) || node.getStatus() == Status.SUCCEEDED) { return null; Status depStatus = dependencyNode.getStatus(); if (!Status.isStatusFinished(depStatus)) { return null;