org.apache.kylin.job.constant.JobStatusEnum Java Examples

The following examples show how to use org.apache.kylin.job.constant.JobStatusEnum. 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 JobStatusEnum parseToJobStatus(ExecutableState state) {
    switch (state) {
        case READY:
            return JobStatusEnum.PENDING;
        case RUNNING:
            return JobStatusEnum.RUNNING;
        case ERROR:
            return JobStatusEnum.ERROR;
        case DISCARDED:
            return JobStatusEnum.DISCARDED;
        case SUCCEED:
            return JobStatusEnum.FINISHED;
        case STOPPED:
        default:
            throw new RuntimeException("invalid state:" + state);
    }
}
 
Example #2
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 #3
Source File: JobInfoConverter.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public static JobStatusEnum parseToJobStatus(ExecutableState state) {
    switch (state) {
    case READY:
        return JobStatusEnum.PENDING;
    case RUNNING:
        return JobStatusEnum.RUNNING;
    case ERROR:
        return JobStatusEnum.ERROR;
    case DISCARDED:
        return JobStatusEnum.DISCARDED;
    case SUCCEED:
        return JobStatusEnum.FINISHED;
    case STOPPED:
        return JobStatusEnum.STOPPED;
    default:
        throw new RuntimeException("invalid state:" + state);
    }
}
 
Example #4
Source File: CubeDescCreator.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public static CubeDesc generateKylinCubeDesc(String tableName, int storageType,
        List<DimensionDesc> dimensionDescList, List<MeasureDesc> measureDescList, RowKeyDesc rowKeyDesc,
        AggregationGroup aggGroup, HBaseMappingDesc hBaseMapping, Map<String, String> overrideProperties) {
    CubeDesc desc = new CubeDesc();
    desc.setName(tableName.replace('.', '_'));
    desc.setModelName(tableName.replace('.', '_'));
    desc.setDescription("");
    desc.setLastModified(0L);
    desc.setDimensions(dimensionDescList);
    desc.setMeasures(measureDescList);
    desc.setRowkey(rowKeyDesc);
    desc.setHbaseMapping(hBaseMapping);
    desc.setNotifyList(Lists.<String> newArrayList());
    desc.setStatusNeedNotify(Lists.newArrayList(JobStatusEnum.ERROR.toString()));
    desc.setAutoMergeTimeRanges(new long[] { 86400000L, 604800000L, 2419200000L });
    desc.setEngineType(IEngineAware.ID_MR_V2);
    desc.setStorageType(storageType);
    desc.setAggregationGroups(Lists.newArrayList(aggGroup));
    desc.getOverrideKylinProps().putAll(overrideProperties);
    desc.updateRandomUuid();
    return desc;
}
 
Example #5
Source File: JobService.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
* currently only support substring match
*
* @return
*/
public List<JobInstance> searchJobs(final String cubeNameSubstring, final String projectName,
        final List<JobStatusEnum> statusList, final Integer limitValue, final Integer offsetValue,
        final JobTimeFilterEnum timeFilter, JobSearchMode jobSearchMode) {
    Integer limit = (null == limitValue) ? 30 : limitValue;
    Integer offset = (null == offsetValue) ? 0 : offsetValue;
    List<JobInstance> jobs = searchJobsByCubeName(cubeNameSubstring, projectName, statusList, timeFilter,
            jobSearchMode);

    Collections.sort(jobs);

    if (jobs.size() <= offset) {
        return Collections.emptyList();
    }

    if ((jobs.size() - offset) < limit) {
        return jobs.subList(offset, jobs.size());
    }

    return jobs.subList(offset, offset + limit);
}
 
Example #6
Source File: JobService.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public List<JobInstance> innerSearchJobs(final String cubeName, final String jobName, final String projectName,
        final List<JobStatusEnum> statusList, final JobTimeFilterEnum timeFilter, JobSearchMode jobSearchMode) {
    List<JobInstance> result = Lists.newArrayList();
    switch (jobSearchMode) {
    case ALL:
        result.addAll(innerSearchCubingJobs(cubeName, jobName, projectName, statusList, timeFilter));
        result.addAll(innerSearchCheckpointJobs(cubeName, jobName, projectName, statusList, timeFilter));
        break;
    case CHECKPOINT_ONLY:
        result.addAll(innerSearchCheckpointJobs(cubeName, jobName, projectName, statusList, timeFilter));
        break;
    case CUBING_ONLY:
    default:
        result.addAll(innerSearchCubingJobs(cubeName, jobName, projectName, statusList, timeFilter));
    }
    return result;
}
 
Example #7
Source File: JobService.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public List<JobInstance> innerSearchCheckpointJobs(final String cubeName, final String jobName,
        final String projectName, final List<JobStatusEnum> statusList, final JobTimeFilterEnum timeFilter) {
    // TODO: use cache of jobs for this method
    // prepare time range
    Calendar calendar = Calendar.getInstance(TimeZone.getDefault(), Locale.ROOT);
    calendar.setTime(new Date());
    long timeStartInMillis = getTimeStartInMillis(calendar, timeFilter);
    long timeEndInMillis = Long.MAX_VALUE;
    Set<ExecutableState> states = convertStatusEnumToStates(statusList);
    final Map<String, Output> allOutputs = getExecutableManager().getAllOutputs(timeStartInMillis, timeEndInMillis);

    return Lists
            .newArrayList(FluentIterable
                    .from(innerSearchCheckpointJobs(cubeName, jobName, states, timeStartInMillis, timeEndInMillis,
                            allOutputs, false, projectName))
                    .transform(new Function<CheckpointExecutable, JobInstance>() {
                        @Override
                        public JobInstance apply(CheckpointExecutable checkpointExecutable) {
                            return JobInfoConverter.parseToJobInstanceQuietly(checkpointExecutable, allOutputs);
                        }
                    }));
}
 
Example #8
Source File: JobService.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * it loads all cache for digest metadata of "execute" and "execute_output", and returns the search results within the scope of the given filters
 *
 * @return List of search results searched by the method
 *
 */
public List<JobSearchResult> searchJobsByCubeNameV2(final String cubeNameSubstring, final String projectName,
        final List<JobStatusEnum> statusList, final JobTimeFilterEnum timeFilter,
        final JobSearchMode jobSearchMode) {
    List<JobSearchResult> result = Lists.newArrayList();
    switch (jobSearchMode) {
    case ALL:
        result.addAll(innerSearchCubingJobsV2(cubeNameSubstring, null, projectName, statusList, timeFilter));
        result.addAll(innerSearchCheckpointJobsV2(cubeNameSubstring, null, projectName, statusList, timeFilter));
        break;
    case CHECKPOINT_ONLY:
        result.addAll(innerSearchCheckpointJobsV2(cubeNameSubstring, null, projectName, statusList, timeFilter));
        break;
    case CUBING_ONLY:
    default:
        result.addAll(innerSearchCubingJobsV2(cubeNameSubstring, null, projectName, statusList, timeFilter));
    }
    return result;
}
 
Example #9
Source File: CubeDescCreator.java    From kylin with Apache License 2.0 6 votes vote down vote up
public static CubeDesc generateKylinCubeDesc(String tableName, int storageType,
        List<DimensionDesc> dimensionDescList, List<MeasureDesc> measureDescList, RowKeyDesc rowKeyDesc,
        AggregationGroup aggGroup, HBaseMappingDesc hBaseMapping, Map<String, String> overrideProperties) {
    CubeDesc desc = new CubeDesc();
    desc.setName(tableName.replace('.', '_'));
    desc.setModelName(tableName.replace('.', '_'));
    desc.setDescription("");
    desc.setLastModified(0L);
    desc.setDimensions(dimensionDescList);
    desc.setMeasures(measureDescList);
    desc.setRowkey(rowKeyDesc);
    desc.setHbaseMapping(hBaseMapping);
    desc.setNotifyList(Lists.<String> newArrayList());
    desc.setStatusNeedNotify(Lists.newArrayList(JobStatusEnum.ERROR.toString()));
    desc.setAutoMergeTimeRanges(new long[] { 86400000L, 604800000L, 2419200000L, 7776000000L, 31104000000L });
    desc.setEngineType(IEngineAware.ID_MR_V2);
    desc.setStorageType(storageType);
    desc.setAggregationGroups(Lists.newArrayList(aggGroup));
    desc.getOverrideKylinProps().putAll(overrideProperties);
    desc.updateRandomUuid();
    return desc;
}
 
Example #10
Source File: JobInstanceExtractor.java    From kylin with Apache License 2.0 6 votes vote down vote up
private JobStatusEnum parseToJobStatus(ExecutableState state) {
    switch (state) {
    case READY:
        return JobStatusEnum.PENDING;
    case RUNNING:
        return JobStatusEnum.RUNNING;
    case ERROR:
        return JobStatusEnum.ERROR;
    case DISCARDED:
        return JobStatusEnum.DISCARDED;
    case SUCCEED:
        return JobStatusEnum.FINISHED;
    case STOPPED:
    default:
        throw new RuntimeException("invalid state:" + state);
    }
}
 
Example #11
Source File: JobInfoConverter.java    From kylin with Apache License 2.0 6 votes vote down vote up
public static JobStatusEnum parseToJobStatus(ExecutableState state) {
    switch (state) {
    case READY:
        return JobStatusEnum.PENDING;
    case RUNNING:
        return JobStatusEnum.RUNNING;
    case ERROR:
        return JobStatusEnum.ERROR;
    case DISCARDED:
        return JobStatusEnum.DISCARDED;
    case SUCCEED:
        return JobStatusEnum.FINISHED;
    case STOPPED:
        return JobStatusEnum.STOPPED;
    default:
        throw new RuntimeException("invalid state:" + state);
    }
}
 
Example #12
Source File: JobInfoConverterTest.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void testParseToJobInstance4CuboidJob() {
    TestJob task = new TestJob();
    String jobId = UUID.randomUUID().toString();
    String cubeName = "cube1";
    task.setId(jobId);
    task.setParam(CubingExecutableUtil.CUBE_NAME, cubeName);
    Map<String, Output> outPutMap = Maps.newHashMap();
    DefaultOutput executeOutput = new DefaultOutput();
    executeOutput.setState(ExecutableState.READY);
    Map<String, String> extraMap = Maps.newHashMap();
    executeOutput.setExtra(extraMap);
    outPutMap.put(jobId, executeOutput);

    JobInstance instance3 = JobInfoConverter.parseToJobInstanceQuietly(task, outPutMap);
    // no exception thrown is expected
    assertEquals(jobId, instance3.getId());
    assertEquals(CubeBuildTypeEnum.BUILD, instance3.getType());
    assertEquals(cubeName, instance3.getRelatedCube());
    assertEquals(JobStatusEnum.PENDING, instance3.getStatus());
}
 
Example #13
Source File: JobInfoConverterTest.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void testParseToJobInstance4CheckpointJob() {
    Test2Job task = new Test2Job();
    String jobId = UUID.randomUUID().toString();
    String cubeName = "cube1";
    task.setId(jobId);
    task.setParam(CubingExecutableUtil.CUBE_NAME, cubeName);
    Map<String, Output> outPutMap = Maps.newHashMap();
    DefaultOutput executeOutput = new DefaultOutput();
    executeOutput.setState(ExecutableState.READY);
    Map<String, String> extraMap = Maps.newHashMap();
    executeOutput.setExtra(extraMap);
    outPutMap.put(jobId, executeOutput);

    JobInstance instance3 = JobInfoConverter.parseToJobInstanceQuietly(task, outPutMap);
    // no exception thrown is expected
    assertEquals(jobId, instance3.getId());
    assertEquals(CubeBuildTypeEnum.CHECKPOINT, instance3.getType());
    assertEquals(cubeName, instance3.getRelatedCube());
    assertEquals(JobStatusEnum.PENDING, instance3.getStatus());
}
 
Example #14
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 #15
Source File: JobInstanceExtractor.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
private JobStatusEnum parseToJobStatus(ExecutableState state) {
    switch (state) {
    case READY:
        return JobStatusEnum.PENDING;
    case RUNNING:
        return JobStatusEnum.RUNNING;
    case ERROR:
        return JobStatusEnum.ERROR;
    case DISCARDED:
        return JobStatusEnum.DISCARDED;
    case SUCCEED:
        return JobStatusEnum.FINISHED;
    case STOPPED:
    default:
        throw new RuntimeException("invalid state:" + state);
    }
}
 
Example #16
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 #17
Source File: JobService.java    From Kylin with Apache License 2.0 6 votes vote down vote up
private List<JobInstance> listCubeJobInstance(final String cubeName, final String projectName, List<JobStatusEnum> statusList) {
    Set<ExecutableState> states;
    if (statusList == null || statusList.isEmpty()) {
        states = EnumSet.allOf(ExecutableState.class);
    } else {
        states = Sets.newHashSet();
        for (JobStatusEnum status : statusList) {
            states.add(parseToExecutableState(status));
        }
    }
    return Lists.newArrayList(FluentIterable.from(listAllCubingJobs(cubeName, projectName, states)).transform(new Function<CubingJob, JobInstance>() {
        @Override
        public JobInstance apply(CubingJob cubingJob) {
            return parseToJobInstance(cubingJob);
        }
    }));
}
 
Example #18
Source File: JobService.java    From Kylin with Apache License 2.0 6 votes vote down vote up
public List<JobInstance> listAllJobs(final String cubeName, final String projectName, final List<JobStatusEnum> statusList, final Integer limitValue, final Integer offsetValue) throws IOException, JobException {
    Integer limit = (null == limitValue) ? 30 : limitValue;
    Integer offset = (null == offsetValue) ? 0 : offsetValue;
    List<JobInstance> jobs = listAllJobs(cubeName, projectName, statusList);
    Collections.sort(jobs);

    if (jobs.size() <= offset) {
        return Collections.emptyList();
    }

    if ((jobs.size() - offset) < limit) {
        return jobs.subList(offset, jobs.size());
    }

    return jobs.subList(offset, offset + limit);
}
 
Example #19
Source File: JobController.java    From Kylin with Apache License 2.0 6 votes vote down vote up
/**
 * get all cube jobs
 * 
 * @return
 * @throws IOException
 */
@RequestMapping(value = "", method = { RequestMethod.GET })
@ResponseBody
public List<JobInstance> list(JobListRequest jobRequest) {

    List<JobInstance> jobInstanceList = Collections.emptyList();
    List<JobStatusEnum> statusList = new ArrayList<JobStatusEnum>();

    if (null != jobRequest.getStatus()) {
        for (int status : jobRequest.getStatus()) {
            statusList.add(JobStatusEnum.getByCode(status));
        }
    }

    try {
        jobInstanceList = jobService.listAllJobs(jobRequest.getCubeName(), jobRequest.getProjectName(), statusList, jobRequest.getLimit(), jobRequest.getOffset());
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(e);
    }
    return jobInstanceList;
}
 
Example #20
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 #21
Source File: JobService.java    From kylin with Apache License 2.0 6 votes vote down vote up
/**
 * it loads all cache for digest metadata of "execute" and "execute_output", and returns the search results within the scope of the given filters
 *
 * @return List of search results searched by the method
 *
 */
public List<JobSearchResult> searchJobsByCubeNameV2(final String cubeNameSubstring, final String projectName,
        final List<JobStatusEnum> statusList, final JobTimeFilterEnum timeFilter,
        final JobSearchMode jobSearchMode) {
    List<JobSearchResult> result = Lists.newArrayList();
    switch (jobSearchMode) {
    case ALL:
        result.addAll(innerSearchCubingJobsV2(cubeNameSubstring, null, projectName, statusList, timeFilter));
        result.addAll(innerSearchCheckpointJobsV2(cubeNameSubstring, null, projectName, statusList, timeFilter));
        break;
    case CHECKPOINT_ONLY:
        result.addAll(innerSearchCheckpointJobsV2(cubeNameSubstring, null, projectName, statusList, timeFilter));
        break;
    case CUBING_ONLY:
    default:
        result.addAll(innerSearchCubingJobsV2(cubeNameSubstring, null, projectName, statusList, timeFilter));
    }
    return result;
}
 
Example #22
Source File: JobService.java    From kylin with Apache License 2.0 6 votes vote down vote up
public List<JobInstance> innerSearchCheckpointJobs(final String cubeName, final String jobName,
        final String projectName, final List<JobStatusEnum> statusList, final JobTimeFilterEnum timeFilter) {
    // TODO: use cache of jobs for this method
    // prepare time range
    Calendar calendar = Calendar.getInstance(TimeZone.getDefault(), Locale.ROOT);
    calendar.setTime(new Date());
    long timeStartInMillis = getTimeStartInMillis(calendar, timeFilter);
    long timeEndInMillis = Long.MAX_VALUE;
    Set<ExecutableState> states = convertStatusEnumToStates(statusList);
    final Map<String, Output> allOutputs = getExecutableManager().getAllOutputs(timeStartInMillis, timeEndInMillis);

    return Lists
            .newArrayList(FluentIterable
                    .from(innerSearchCheckpointJobs(cubeName, jobName, states, timeStartInMillis, timeEndInMillis,
                            allOutputs, false, projectName))
                    .transform(new Function<CheckpointExecutable, JobInstance>() {
                        @Override
                        public JobInstance apply(CheckpointExecutable checkpointExecutable) {
                            return JobInfoConverter.parseToJobInstanceQuietly(checkpointExecutable, allOutputs);
                        }
                    }));
}
 
Example #23
Source File: JobService.java    From kylin with Apache License 2.0 6 votes vote down vote up
public List<JobInstance> innerSearchJobs(final String cubeName, final String jobName, final String projectName,
        final List<JobStatusEnum> statusList, final JobTimeFilterEnum timeFilter, JobSearchMode jobSearchMode) {
    List<JobInstance> result = Lists.newArrayList();
    switch (jobSearchMode) {
    case ALL:
        result.addAll(innerSearchCubingJobs(cubeName, jobName, projectName, statusList, timeFilter));
        result.addAll(innerSearchCheckpointJobs(cubeName, jobName, projectName, statusList, timeFilter));
        break;
    case CHECKPOINT_ONLY:
        result.addAll(innerSearchCheckpointJobs(cubeName, jobName, projectName, statusList, timeFilter));
        break;
    case CUBING_ONLY:
    default:
        result.addAll(innerSearchCubingJobs(cubeName, jobName, projectName, statusList, timeFilter));
    }
    return result;
}
 
Example #24
Source File: JobService.java    From kylin with Apache License 2.0 6 votes vote down vote up
/**
* currently only support substring match
*
* @return
*/
public List<JobInstance> searchJobs(final String cubeNameSubstring, final String projectName,
        final List<JobStatusEnum> statusList, final Integer limitValue, final Integer offsetValue,
        final JobTimeFilterEnum timeFilter, JobSearchMode jobSearchMode) {
    Integer limit = (null == limitValue) ? 30 : limitValue;
    Integer offset = (null == offsetValue) ? 0 : offsetValue;
    List<JobInstance> jobs = searchJobsByCubeName(cubeNameSubstring, projectName, statusList, timeFilter,
            jobSearchMode);

    Collections.sort(jobs);

    if (jobs.size() <= offset) {
        return Collections.emptyList();
    }

    if ((jobs.size() - offset) < limit) {
        return jobs.subList(offset, jobs.size());
    }

    return jobs.subList(offset, offset + limit);
}
 
Example #25
Source File: JobInfoConverterTest.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void testStatusConvert() {
    assertEquals(JobStatusEnum.PENDING, JobInfoConverter.parseToJobStatus(ExecutableState.READY));
    assertEquals(JobStatusEnum.RUNNING, JobInfoConverter.parseToJobStatus(ExecutableState.RUNNING));
    assertEquals(JobStatusEnum.DISCARDED, JobInfoConverter.parseToJobStatus(ExecutableState.DISCARDED));
    assertEquals(JobStatusEnum.ERROR, JobInfoConverter.parseToJobStatus(ExecutableState.ERROR));
    assertEquals(JobStatusEnum.STOPPED, JobInfoConverter.parseToJobStatus(ExecutableState.STOPPED));
    assertEquals(JobStatusEnum.FINISHED, JobInfoConverter.parseToJobStatus(ExecutableState.SUCCEED));

    assertEquals(JobStepStatusEnum.PENDING, JobInfoConverter.parseToJobStepStatus(ExecutableState.READY));
    assertEquals(JobStepStatusEnum.RUNNING, JobInfoConverter.parseToJobStepStatus(ExecutableState.RUNNING));
    assertEquals(JobStepStatusEnum.DISCARDED, JobInfoConverter.parseToJobStepStatus(ExecutableState.DISCARDED));
    assertEquals(JobStepStatusEnum.ERROR, JobInfoConverter.parseToJobStepStatus(ExecutableState.ERROR));
    assertEquals(JobStepStatusEnum.STOPPED, JobInfoConverter.parseToJobStepStatus(ExecutableState.STOPPED));
    assertEquals(JobStepStatusEnum.FINISHED, JobInfoConverter.parseToJobStepStatus(ExecutableState.SUCCEED));
}
 
Example #26
Source File: JobControllerTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testBasics() throws IOException, PersistentException {
    CubeDesc cubeDesc = cubeDescManager.getCubeDesc("test_kylin_cube_with_slr_left_join_desc");
    CubeInstance cube = cubeManager.createCube(CUBE_NAME, "DEFAULT", cubeDesc, "test");
    Assert.assertNotNull(cube);

    JobListRequest jobRequest = new JobListRequest();
    jobRequest.setTimeFilter(4);
    Assert.assertNotNull(jobSchedulerController.list(jobRequest));

    jobRequest.setJobSearchMode("ALL");
    Assert.assertNotNull(jobSchedulerController.list(jobRequest));

    jobRequest.setJobSearchMode("");
    Assert.assertNotNull(jobSchedulerController.list(jobRequest));

    jobRequest.setJobSearchMode("wrong-input");
    Assert.assertNotNull(jobSchedulerController.list(jobRequest));

    JobBuildRequest jobBuildRequest = new JobBuildRequest();
    jobBuildRequest.setBuildType("BUILD");
    jobBuildRequest.setStartTime(0L);
    jobBuildRequest.setEndTime(new Date().getTime());
    JobInstance job = cubeController.rebuild(CUBE_NAME, jobBuildRequest);

    Assert.assertNotNull(jobSchedulerController.get(job.getId()));

    job = jobSchedulerController.cancel(job.getId());
    Assert.assertEquals(JobStatusEnum.DISCARDED, job.getStatus());

    executableDAO.deleteJob(job.getId());
    if (cubeManager.getCube(CUBE_NAME) != null) {
        cubeManager.dropCube(CUBE_NAME, false);
    }
}
 
Example #27
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);
}
 
Example #28
Source File: JobService.java    From kylin with Apache License 2.0 5 votes vote down vote up
private Set<ExecutableState> convertStatusEnumToStates(List<JobStatusEnum> statusList) {
    Set<ExecutableState> states;
    if (statusList == null || statusList.isEmpty()) {
        states = EnumSet.allOf(ExecutableState.class);
    } else {
        states = Sets.newHashSet();
        for (JobStatusEnum status : statusList) {
            states.add(parseToExecutableState(status));
        }
    }
    return states;
}
 
Example #29
Source File: CubeService.java    From kylin with Apache License 2.0 5 votes vote down vote up
public boolean isOrphonSegment(CubeInstance cube, String segId) {
    List<JobInstance> jobInstances = jobService.searchJobsByCubeName(
            cube.getName(), cube.getProject(), Lists.newArrayList(JobStatusEnum.NEW, JobStatusEnum.PENDING,
                    JobStatusEnum.RUNNING, JobStatusEnum.ERROR, JobStatusEnum.STOPPED),
            JobTimeFilterEnum.ALL, JobService.JobSearchMode.CUBING_ONLY);
    for (JobInstance jobInstance : jobInstances) {
        // if there are segment related jobs, can not delete this segment.
        if (segId.equals(jobInstance.getRelatedSegment())) {
            return false;
        }
    }
    return true;
}
 
Example #30
Source File: JobInfoConverterTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testParseToJobStatusReturnsJobStatusFinished() {
    ExecutableState executableState = ExecutableState.SUCCEED;
    JobStatusEnum jobStatusEnum = JobInfoConverter.parseToJobStatus(executableState);

    assertEquals(4, jobStatusEnum.getCode());
    assertEquals(JobStatusEnum.FINISHED, jobStatusEnum);
}