private ExecutableManager(KylinConfig config) { logger.info("Using metadata url: " + config); this.config = config; this.executableDao = ExecutableDao.getInstance(config); }
public void resetJobOutput(String jobId, ExecutableState state, String output) { try { final ExecutableOutputPO jobOutput = executableDao.getJobOutput(jobId); jobOutput.setStatus(state.toString()); if (output != null) { jobOutput.setContent(output); } executableDao.updateJobOutput(jobOutput); } catch (PersistentException e) { throw new RuntimeException(e); } }
public List<AbstractExecutable> getAllExecutables() { try { List<AbstractExecutable> ret = Lists.newArrayList(); for (ExecutablePO po : executableDao.getJobs()) { try { AbstractExecutable ae = parseTo(po); ret.add(ae); } catch (IllegalArgumentException e) { logger.error("error parsing one executabePO: ", e); } } return ret; } catch (PersistentException e) { logger.error("error get All Jobs", e); throw new RuntimeException(e); } }
public void updateCheckpointJob(String jobId, List<AbstractExecutable> subTasksForCheck) { try { final ExecutablePO job = executableDao.getJob(jobId); Preconditions.checkArgument(job != null, "there is no related job for job id:" + jobId); List<ExecutablePO> tasksForCheck = Lists.newArrayListWithExpectedSize(subTasksForCheck.size()); for (AbstractExecutable taskForCheck : subTasksForCheck) { tasksForCheck.add(parse(taskForCheck)); } job.setTasksForCheck(tasksForCheck); executableDao.updateJob(job); } catch (PersistentException e) { logger.error("fail to update checkpoint job:" + jobId, e); throw new RuntimeException(e); } }
public void syncDigestsOfJob(String uuid) throws PersistentException { ExecutablePO job = getJob(uuid); ExecutablePO jobDigest = getJobDigest(uuid); if (job == null && jobDigest != null) { executableDigestMap.remove(uuid); } else if (job != null && jobDigest == null) { executableDigestMap.put(uuid, job); } ExecutableOutputPO jobOutput = getJobOutput(uuid); ExecutableOutputPO jobOutputDigest = getJobOutputDigest(uuid); if (jobOutput == null && jobOutputDigest != null) { executableOutputDigestMap.remove(uuid); } else if (jobOutput != null && jobOutputDigest == null) { executableOutputDigestMap.put(uuid, jobOutput); } } }
ExecutableDao executableDao = ExecutableDao.getInstance(config); List<ExecutablePO> allExecutable = executableDao.getJobs(); for (ExecutablePO executable : allExecutable) { long lastModified = executable.getLastModified(); String jobStatus = executableDao.getJobOutput(executable.getUuid()).getStatus();
public ExecutablePO updateJob(ExecutablePO job) throws PersistentException { try { if (getJob(job.getUuid()) == null) { throw new IllegalArgumentException("job id:" + job.getUuid() + " does not exist"); } writeJobResource(pathOfJob(job), job); executableDigestMap.put(job.getId(), job); return job; } catch (IOException e) { logger.error("error update job:" + job.getUuid(), e); throw new PersistentException(e); } }
public ExecutableOutputPO getJobOutput(String jobId) { try { return executableDao.getJobOutput(jobId); } catch (PersistentException e) { logger.error("Can't get output of Job " + jobId); throw new RuntimeException(e); } }
public void forceKillJob(String jobId) { try { final ExecutableOutputPO jobOutput = executableDao.getJobOutput(jobId); List<ExecutablePO> tasks = executableDao.getJob(jobId).getTasks(); for (ExecutablePO task : tasks) { if (executableDao.getJobOutput(task.getId()).getStatus().equals("SUCCEED")) { continue; } else if (executableDao.getJobOutput(task.getId()).getStatus().equals("RUNNING")) { updateJobOutput(task.getId(), ExecutableState.READY, Maps.<String, String> newHashMap(), ""); } break; } if (!jobOutput.getStatus().equals(ExecutableState.ERROR.toString())) { jobOutput.setStatus(ExecutableState.ERROR.toString()); executableDao.updateJobOutput(jobOutput); } } catch (PersistentException e) { throw new RuntimeException(e); } }
public void updateAllRunningJobsToError() { try { final List<ExecutableOutputPO> jobOutputs = executableDao.getJobOutputs(); for (ExecutableOutputPO executableOutputPO : jobOutputs) { if (executableOutputPO.getStatus().equalsIgnoreCase(ExecutableState.RUNNING.toString())) { executableOutputPO.setStatus(ExecutableState.ERROR.toString()); executableDao.updateJobOutput(executableOutputPO); } } } catch (PersistentException e) { logger.error("error reset job status from RUNNING to ERROR", e); throw new RuntimeException(e); } }
public AbstractExecutable getJob(String uuid) { try { return parseTo(executableDao.getJob(uuid)); } catch (PersistentException e) { logger.error("fail to get job:" + uuid, e); throw new RuntimeException(e); } }
public void addJob(AbstractExecutable executable) { try { executable.initConfig(config); if (executableDao.getJob(executable.getId()) != null) { throw new IllegalArgumentException("job id:" + executable.getId() + " already exists"); } addJobOutput(executable); executableDao.addJob(parse(executable)); } catch (PersistentException e) { logger.error("fail to submit job:" + executable.getId(), e); throw new RuntimeException(e); } }
public Map<String, Output> getAllOutputs() { try { final List<ExecutableOutputPO> jobOutputs = executableDao.getJobOutputs(); HashMap<String, Output> result = Maps.newHashMap(); for (ExecutableOutputPO jobOutput : jobOutputs) { result.put(jobOutput.getId(), parseOutput(jobOutput)); } return result; } catch (PersistentException e) { logger.error("fail to get all job output:", e); throw new RuntimeException(e); } }
private void addJobOutput(AbstractExecutable executable) throws PersistentException { ExecutableOutputPO executableOutputPO = new ExecutableOutputPO(); executableOutputPO.setUuid(executable.getId()); executableDao.addJobOutput(executableOutputPO); if (executable instanceof DefaultChainedExecutable) { for (AbstractExecutable subTask : ((DefaultChainedExecutable) executable).getTasks()) { addJobOutput(subTask); } } }
public List<String> getAllJobIds() { try { return executableDao.getJobIds(); } catch (PersistentException e) { logger.error("error get All Job Ids", e); throw new RuntimeException(e); } }
public void deleteJob(String jobId) { try { executableDao.deleteJob(jobId); } catch (PersistentException e) { logger.error("fail to delete job:" + jobId, e); throw new RuntimeException(e); } }
static ExecutableDao newInstance(KylinConfig config) throws IOException { return new ExecutableDao(config); }
public void addJob(AbstractExecutable executable) { try { executableDao.addJob(parse(executable)); addJobOutput(executable); } catch (PersistentException e) { logger.error("fail to submit job:" + executable.getId(), e); throw new RuntimeException(e); } }
ExecutableDao executableDao = ExecutableDao.getInstance(KylinConfig.getInstanceFromEnv()); List<ExecutablePO> allExecutable = executableDao.getJobs(); for (ExecutablePO executable : allExecutable) { long lastModified = executable.getLastModified(); ExecutableOutputPO output = executableDao.getJobOutput(executable.getUuid()); if (System.currentTimeMillis() - lastModified > TIME_THREADSHOLD_FOR_JOB && (ExecutableState.SUCCEED.toString().equals(output.getStatus()) || ExecutableState.DISCARDED.toString().equals(output.getStatus()))) { toDeleteResource.add(ResourceStore.EXECUTE_RESOURCE_ROOT + "/" + executable.getUuid());
public ExecutablePO addJob(ExecutablePO job) throws PersistentException { try { if (getJob(job.getUuid()) != null) { throw new IllegalArgumentException("job id:" + job.getUuid() + " already exists"); } writeJobResource(pathOfJob(job), job); executableDigestMap.put(job.getId(), job); return job; } catch (IOException e) { logger.error("error save job:" + job.getUuid(), e); throw new PersistentException(e); } }