Java Code Examples for org.apache.kylin.job.execution.ExecutableState#RUNNING

The following examples show how to use org.apache.kylin.job.execution.ExecutableState#RUNNING . 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: JobService.java    From Kylin with Apache License 2.0 6 votes vote down vote up
private ExecutableState parseToExecutableState(JobStatusEnum status) {
    switch (status) {
        case DISCARDED:
            return ExecutableState.DISCARDED;
        case ERROR:
            return ExecutableState.ERROR;
        case FINISHED:
            return ExecutableState.SUCCEED;
        case NEW:
            return ExecutableState.READY;
        case PENDING:
            return ExecutableState.READY;
        case RUNNING:
            return ExecutableState.RUNNING;
        default:
            throw new RuntimeException("illegal status:" + status);
    }
}
 
Example 2
Source File: DistributedScheduler.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
private void resumeAllRunningJobs() {
    for (final String id : executableManager.getAllJobIds()) {
        final Output output = executableManager.getOutput(id);
        AbstractExecutable executable = executableManager.getJob(id);
        if (output.getState() == ExecutableState.RUNNING && executable instanceof DefaultChainedExecutable) {
            try {
                if (!jobLock.isLocked(getLockPath(executable.getId()))) {
                    executableManager.resumeRunningJobForce(executable.getId());
                    fetcherPool.schedule(fetcher, 0, TimeUnit.SECONDS);
                }
            } catch (Exception e) {
                logger.error("resume the job " + id + " fail in server: " + serverName, e);
            }
        }
    }
}
 
Example 3
Source File: CubeMetadataUpgrade.java    From Kylin with Apache License 2.0 6 votes vote down vote up
private ExecutableState parseState(JobStepStatusEnum state) {
    switch (state) {
        case NEW:
        case PENDING:
        case WAITING:
            return ExecutableState.READY;
        case RUNNING:
            return ExecutableState.RUNNING;
        case FINISHED:
            return ExecutableState.SUCCEED;
        case ERROR:
            return ExecutableState.ERROR;
        case DISCARDED:
            return ExecutableState.DISCARDED;
        default:
            return ExecutableState.DISCARDED;
    }

}
 
Example 4
Source File: CubeMetadataUpgrade.java    From Kylin with Apache License 2.0 6 votes vote down vote up
private ExecutableState parseState(JobStatusEnum state) {
    switch (state) {
        case NEW:
        case PENDING:
            return ExecutableState.READY;
        case RUNNING:
            return ExecutableState.RUNNING;
        case FINISHED:
            return ExecutableState.SUCCEED;
        case ERROR:
            return ExecutableState.ERROR;
        case DISCARDED:
            return ExecutableState.DISCARDED;
        default:
            return ExecutableState.DISCARDED;
    }
}
 
Example 5
Source File: JobService.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
private ExecutableState parseToExecutableState(JobStatusEnum status) {
    Message msg = MsgPicker.getMsg();

    switch (status) {
    case DISCARDED:
        return ExecutableState.DISCARDED;
    case ERROR:
        return ExecutableState.ERROR;
    case FINISHED:
        return ExecutableState.SUCCEED;
    case NEW:
        return ExecutableState.READY;
    case PENDING:
        return ExecutableState.READY;
    case RUNNING:
        return ExecutableState.RUNNING;
    case STOPPED:
        return ExecutableState.STOPPED;
    default:
        throw new BadRequestException(String.format(Locale.ROOT, msg.getILLEGAL_EXECUTABLE_STATE(), status));
    }
}
 
Example 6
Source File: TableService.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public void calculateCardinalityIfNotPresent(String[] tables, String submitter, String prj) throws Exception {
    // calculate cardinality for Hive source
    ProjectInstance projectInstance = getProjectManager().getProject(prj);
    if (projectInstance == null || projectInstance.getSourceType() != ISourceAware.ID_HIVE) {
        return;
    }
    TableMetadataManager metaMgr = getTableManager();
    ExecutableManager exeMgt = ExecutableManager.getInstance(getConfig());
    for (String table : tables) {
        TableExtDesc tableExtDesc = metaMgr.getTableExt(table, prj);
        String jobID = tableExtDesc.getJodID();
        if (null == jobID || ExecutableState.RUNNING != exeMgt.getOutput(jobID).getState()) {
            calculateCardinality(table, submitter, prj);
        }
    }
}
 
Example 7
Source File: TableService.java    From kylin with Apache License 2.0 6 votes vote down vote up
public void calculateCardinalityIfNotPresent(String[] tables, String submitter, String prj) throws Exception {
    // calculate cardinality for Hive source
    ProjectInstance projectInstance = getProjectManager().getProject(prj);
    if (projectInstance == null || projectInstance.getSourceType() != ISourceAware.ID_HIVE){
        return;
    }
    TableMetadataManager metaMgr = getTableManager();
    ExecutableManager exeMgt = ExecutableManager.getInstance(getConfig());
    for (String table : tables) {
        TableExtDesc tableExtDesc = metaMgr.getTableExt(table, prj);
        String jobID = tableExtDesc.getJodID();
        if (null == jobID || ExecutableState.RUNNING != exeMgt.getOutput(jobID).getState()) {
            calculateCardinality(table, submitter, prj);
        }
    }
}
 
Example 8
Source File: JobService.java    From kylin with Apache License 2.0 6 votes vote down vote up
private ExecutableState parseToExecutableState(JobStatusEnum status) {
    Message msg = MsgPicker.getMsg();

    switch (status) {
    case DISCARDED:
        return ExecutableState.DISCARDED;
    case ERROR:
        return ExecutableState.ERROR;
    case FINISHED:
        return ExecutableState.SUCCEED;
    case NEW:
        return ExecutableState.READY;
    case PENDING:
        return ExecutableState.READY;
    case RUNNING:
        return ExecutableState.RUNNING;
    case STOPPED:
        return ExecutableState.STOPPED;
    default:
        throw new BadRequestException(String.format(Locale.ROOT, msg.getILLEGAL_EXECUTABLE_STATE(), status));
    }
}
 
Example 9
Source File: DistributedScheduler.java    From kylin with Apache License 2.0 6 votes vote down vote up
private void resumeAllRunningJobs() {
    for (final String id : executableManager.getAllJobIds()) {
        final Output output = executableManager.getOutput(id);
        AbstractExecutable executable = executableManager.getJob(id);
        if (output.getState() == ExecutableState.RUNNING && executable instanceof DefaultChainedExecutable) {
            try {
                if (!jobLock.isLocked(getLockPath(executable.getId()))) {
                    executableManager.resumeRunningJobForce(executable.getId());
                    fetcherPool.schedule(fetcher, 0, TimeUnit.SECONDS);
                }
            } catch (Exception e) {
                logger.error("resume the job " + id + " fail in server: " + serverName, e);
            }
        }
    }
}
 
Example 10
Source File: JobInfoConverterTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testParseToJobStatusReturnsJobStatusRunning() {
    ExecutableState executableState = ExecutableState.RUNNING;
    JobStatusEnum jobStatusEnum = JobInfoConverter.parseToJobStatus(executableState);

    assertEquals(2, jobStatusEnum.getCode());
    assertEquals(JobStatusEnum.RUNNING, jobStatusEnum);
}
 
Example 11
Source File: BaseSchedulerTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
protected void runningJobToError(String jobId) {
    while (true) {
        try {
            AbstractExecutable job = execMgr.getJob(jobId);
            ExecutableState status = job.getStatus();
            if (status == ExecutableState.RUNNING) {
                scheduler.getFetcherRunner().setFetchFailed(true);
                break;
            }
            Thread.sleep(1000);
        } catch (Exception ex) {
            logger.error("", ex);
        }
    }
}
 
Example 12
Source File: DistributedScheduler.java    From kylin with Apache License 2.0 5 votes vote down vote up
private void releaseJobLock(AbstractExecutable executable) {
    if (executable instanceof DefaultChainedExecutable) {
        ExecutableState state = executable.getStatus();

        if (state != ExecutableState.READY && state != ExecutableState.RUNNING) {
            if (jobWithLocks.contains(executable.getId())) {
                logger.info(
                        executable.toString() + " will release the lock for the job: " + executable.getId());
                jobLock.unlock(getLockPath(executable.getId()));
                jobWithLocks.remove(executable.getId());
            }
        }
    }
}
 
Example 13
Source File: JobInfoConverterTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testParseToJobStepStatusReturnsJobStepStatusRunning() {
    ExecutableState executableState = ExecutableState.RUNNING;
    JobStepStatusEnum jobStepStatusEnum = JobInfoConverter.parseToJobStepStatus(executableState);

    assertEquals(2, jobStepStatusEnum.getCode());
    assertFalse(jobStepStatusEnum.isComplete());
    assertFalse(jobStepStatusEnum.isRunable());
    assertEquals(JobStepStatusEnum.RUNNING, jobStepStatusEnum);
}
 
Example 14
Source File: JobInfoConverterTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testParseToJobStepStatusReturnsJobStepStatusRunning() {
    ExecutableState executableState = ExecutableState.RUNNING;
    JobStepStatusEnum jobStepStatusEnum = JobInfoConverter.parseToJobStepStatus(executableState);

    assertEquals(2, jobStepStatusEnum.getCode());
    assertFalse(jobStepStatusEnum.isComplete());
    assertFalse(jobStepStatusEnum.isRunable());
    assertEquals(JobStepStatusEnum.RUNNING, jobStepStatusEnum);
}
 
Example 15
Source File: BaseSchedulerTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
protected void runningJobToError(String jobId) {
    while (true) {
        try {
            AbstractExecutable job = execMgr.getJob(jobId);
            ExecutableState status = job.getStatus();
            if (status == ExecutableState.RUNNING) {
                scheduler.getFetcherRunner().setFetchFailed(true);
                break;
            }
            Thread.sleep(1000);
        } catch (Exception ex) {
            logger.error("", ex);
        }
    }
}
 
Example 16
Source File: DistributedScheduler.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private void releaseJobLock(AbstractExecutable executable) {
    if (executable instanceof DefaultChainedExecutable) {
        ExecutableState state = executable.getStatus();

        if (state != ExecutableState.READY && state != ExecutableState.RUNNING) {
            if (jobWithLocks.contains(executable.getId())) {
                logger.info(
                        executable.toString() + " will release the lock for the job: " + executable.getId());
                jobLock.unlock(getLockPath(executable.getId()));
                jobWithLocks.remove(executable.getId());
            }
        }
    }
}
 
Example 17
Source File: JobInfoConverterTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testParseToJobStatusReturnsJobStatusRunning() {
    ExecutableState executableState = ExecutableState.RUNNING;
    JobStatusEnum jobStatusEnum = JobInfoConverter.parseToJobStatus(executableState);

    assertEquals(2, jobStatusEnum.getCode());
    assertEquals(JobStatusEnum.RUNNING, jobStatusEnum);
}