Java Code Examples for org.apache.kylin.job.dao.ExecutableOutputPO#setStatus()

The following examples show how to use org.apache.kylin.job.dao.ExecutableOutputPO#setStatus() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExecutableManager.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 2
Source File: ExecutableManager.java    From kylin with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example 3
Source File: ExecutableManager.java    From Kylin with Apache License 2.0 6 votes vote down vote up
public void updateJobOutput(String jobId, ExecutableState newStatus, Map<String, String> info, String output) {
    try {
        final ExecutableOutputPO jobOutput = executableDao.getJobOutput(jobId);
        Preconditions.checkArgument(jobOutput != null, "there is no related output for job id:" + jobId);
        ExecutableState oldStatus = ExecutableState.valueOf(jobOutput.getStatus());
        if (newStatus != null && oldStatus != newStatus) {
            if (!ExecutableState.isValidStateTransfer(oldStatus, newStatus)) {
                throw new IllegalStateTranferException("there is no valid state transfer from:" + oldStatus + " to:" + newStatus);
            }
            jobOutput.setStatus(newStatus.toString());
        }
        if (info != null) {
            jobOutput.setInfo(info);
        }
        if (output != null) {
            jobOutput.setContent(output);
        }
        executableDao.updateJobOutput(jobOutput);
        logger.info("job id:" + jobId + " from " + oldStatus + " to " + newStatus);
    } catch (PersistentException e) {
        logger.error("error change job:" + jobId + " to " + newStatus.toString());
        throw new RuntimeException(e);
    }
}
 
Example 4
Source File: ExecutableManager.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 5
Source File: ExecutableManager.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public void resumeAllRunningJobs() {
    try {
        final List<ExecutableOutputPO> jobOutputs = executableDao.getJobOutputs();
        for (ExecutableOutputPO executableOutputPO : jobOutputs) {
            if (executableOutputPO.getStatus().equalsIgnoreCase(ExecutableState.RUNNING.toString())) {
                executableOutputPO.setStatus(ExecutableState.READY.toString());
                executableDao.updateJobOutput(executableOutputPO);
            }
        }
    } catch (PersistentException e) {
        logger.error("error reset job status from RUNNING to READY", e);
        throw new RuntimeException(e);
    }
}
 
Example 6
Source File: ExecutableManager.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public void updateJobOutput(String jobId, ExecutableState newStatus, Map<String, String> info, String output) {
    // when 
    if (Thread.currentThread().isInterrupted()) {
        throw new RuntimeException("Current thread is interruptted, aborting");
    }

    try {
        final ExecutableOutputPO jobOutput = executableDao.getJobOutput(jobId);
        Preconditions.checkArgument(jobOutput != null, "there is no related output for job id:" + jobId);
        ExecutableState oldStatus = ExecutableState.valueOf(jobOutput.getStatus());
        if (newStatus != null && oldStatus != newStatus) {
            if (!ExecutableState.isValidStateTransfer(oldStatus, newStatus)) {
                throw new IllegalStateTranferException("there is no valid state transfer from:" + oldStatus + " to:"
                        + newStatus + ", job id: " + jobId);
            }
            jobOutput.setStatus(newStatus.toString());
        }
        if (info != null) {
            jobOutput.setInfo(info);
        }
        if (output != null) {
            if (output.length() > config.getJobOutputMaxSize()) {
                output = output.substring(0, config.getJobOutputMaxSize());
            }
            jobOutput.setContent(output);
        }
        executableDao.updateJobOutput(jobOutput);
        logger.info("job id:" + jobId + " from " + oldStatus + " to " + newStatus);

        if (needDestroyProcess(oldStatus, newStatus)) {
            logger.debug("need kill {}, from {} to {}", jobId, oldStatus, newStatus);
            // kill spark-submit process
            destroyProcess(jobId);
        }
    } catch (PersistentException e) {
        logger.error("error change job:" + jobId + " to " + newStatus);
        throw new RuntimeException(e);
    }
}
 
Example 7
Source File: ExecutableManager.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 8
Source File: ExecutableManager.java    From kylin with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 9
Source File: ExecutableManager.java    From kylin with Apache License 2.0 5 votes vote down vote up
public void resumeAllRunningJobs() {
    try {
        final List<ExecutableOutputPO> jobOutputs = executableDao.getJobOutputs();
        for (ExecutableOutputPO executableOutputPO : jobOutputs) {
            if (executableOutputPO.getStatus().equalsIgnoreCase(ExecutableState.RUNNING.toString())) {
                executableOutputPO.setStatus(ExecutableState.READY.toString());
                executableDao.updateJobOutput(executableOutputPO);
            }
        }
    } catch (PersistentException e) {
        logger.error("error reset job status from RUNNING to READY", e);
        throw new RuntimeException(e);
    }
}
 
Example 10
Source File: ExecutableManager.java    From kylin with Apache License 2.0 5 votes vote down vote up
public void updateJobOutput(String jobId, ExecutableState newStatus, Map<String, String> info, String output) {
    // when 
    if (Thread.currentThread().isInterrupted()) {
        throw new RuntimeException("Current thread is interruptted, aborting");
    }

    try {
        final ExecutableOutputPO jobOutput = executableDao.getJobOutput(jobId);
        Preconditions.checkArgument(jobOutput != null, "there is no related output for job id:" + jobId);
        ExecutableState oldStatus = ExecutableState.valueOf(jobOutput.getStatus());
        if (newStatus != null && oldStatus != newStatus) {
            if (!ExecutableState.isValidStateTransfer(oldStatus, newStatus)) {
                throw new IllegalStateTranferException("there is no valid state transfer from:" + oldStatus + " to:"
                        + newStatus + ", job id: " + jobId);
            }
            jobOutput.setStatus(newStatus.toString());
        }
        if (info != null) {
            jobOutput.setInfo(info);
        }
        if (output != null) {
            if (output.length() > config.getJobOutputMaxSize()) {
                output = output.substring(0, config.getJobOutputMaxSize());
            }
            jobOutput.setContent(output);
        }
        executableDao.updateJobOutput(jobOutput);
        logger.info("job id:" + jobId + " from " + oldStatus + " to " + newStatus);
    } catch (PersistentException e) {
        logger.error("error change job:" + jobId + " to " + newStatus);
        throw new RuntimeException(e);
    }
}
 
Example 11
Source File: ExecutableManager.java    From kylin with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 12
Source File: ExecutableManager.java    From Kylin with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 13
Source File: ExecutableManager.java    From Kylin with Apache License 2.0 5 votes vote down vote up
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);
    }
}