org.apache.kylin.job.exception.IllegalStateTranferException Java Examples

The following examples show how to use org.apache.kylin.job.exception.IllegalStateTranferException. 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 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 #2
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 #3
Source File: ExecutableManagerTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalStateTranferException.class)
public void testInvalidStateTransfer() {
    SucceedTestExecutable job = new SucceedTestExecutable();
    service.addJob(job);
    service.updateJobOutput(job.getId(), ExecutableState.ERROR, null, null);
    service.updateJobOutput(job.getId(), ExecutableState.STOPPED, null, null);
}
 
Example #4
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 #5
Source File: ExecutableManagerTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalStateTranferException.class)
public void testInvalidStateTransfer() {
    SucceedTestExecutable job = new SucceedTestExecutable();
    service.addJob(job);
    service.updateJobOutput(job.getId(), ExecutableState.ERROR, null, null);
    service.updateJobOutput(job.getId(), ExecutableState.STOPPED, null, null);
}
 
Example #6
Source File: ExecutableManagerTest.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalStateTranferException.class)
public void testInvalidStateTransfer(){
    SucceedTestExecutable job = new SucceedTestExecutable();
    service.addJob(job);
    service.updateJobOutput(job.getId(), ExecutableState.RUNNING, null, null);
    service.updateJobOutput(job.getId(), ExecutableState.STOPPED, null, null);
}