Java Code Examples for org.apache.kylin.job.JobInstance#getRelatedSegment()
The following examples show how to use
org.apache.kylin.job.JobInstance#getRelatedSegment() .
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 |
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#job, 'ADMINISTRATION') or hasPermission(#job, 'OPERATION') or hasPermission(#job, 'MANAGEMENT')") public JobInstance cancelJob(String jobId) throws IOException, JobException { // CubeInstance cube = this.getCubeManager().getCube(job.getRelatedCube()); // for (BuildCubeJob cubeJob: listAllCubingJobs(cube.getName(), null, EnumSet.of(ExecutableState.READY, ExecutableState.RUNNING))) { // getExecutableManager().stopJob(cubeJob.getId()); // } final JobInstance jobInstance = getJobInstance(jobId); final String segmentId = jobInstance.getRelatedSegment(); CubeInstance cubeInstance = getCubeManager().getCube(jobInstance.getRelatedCube()); final CubeSegment segment = cubeInstance.getSegmentById(segmentId); if (segment.getStatus() == SegmentStatusEnum.NEW) { cubeInstance.getSegments().remove(segment); getCubeManager().updateCube(cubeInstance); } getExecutableManager().discardJob(jobId); return jobInstance; }
Example 2
Source File: JobService.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
public void cancelJob(JobInstance job) throws IOException { aclEvaluate.checkProjectOperationPermission(job); if (null == job.getRelatedCube() || null == getCubeManager().getCube(job.getRelatedCube()) || null == job.getRelatedSegment()) { getExecutableManager().discardJob(job.getId()); } logger.info("Cancel job [" + job.getId() + "] trigger by " + SecurityContextHolder.getContext().getAuthentication().getName()); if (job.getStatus() == JobStatusEnum.FINISHED) { throw new IllegalStateException( "The job " + job.getId() + " has already been finished and cannot be discarded."); } if (job.getStatus() != JobStatusEnum.DISCARDED) { AbstractExecutable executable = getExecutableManager().getJob(job.getId()); if (executable instanceof CubingJob) { cancelCubingJobInner((CubingJob) executable); //release global mr hive dict lock if exists if (executable.getStatus().isFinalState()) { try { DistributedLock lock = KylinConfig.getInstanceFromEnv().getDistributedLockFactory().lockForCurrentThread(); if(lock.isLocked(CubeJobLockUtil.getLockPath(executable.getCubeName(), job.getId()))){//release cube job dict lock if exists lock.purgeLocks(CubeJobLockUtil.getLockPath(executable.getCubeName(), null)); logger.info("{} unlock cube job dict lock path({}) success", job.getId(), CubeJobLockUtil.getLockPath(executable.getCubeName(), null)); if (lock.isLocked(CubeJobLockUtil.getEphemeralLockPath(executable.getCubeName()))) {//release cube job Ephemeral lock if exists lock.purgeLocks(CubeJobLockUtil.getEphemeralLockPath(executable.getCubeName())); logger.info("{} unlock cube job ephemeral lock path({}) success", job.getId(), CubeJobLockUtil.getEphemeralLockPath(executable.getCubeName())); } } }catch (Exception e){ logger.error("get some error when release cube {} job {} job id {} " , executable.getCubeName(), job.getName(), job.getId()); } } } else if (executable instanceof CheckpointExecutable) { cancelCheckpointJobInner((CheckpointExecutable) executable); } else { getExecutableManager().discardJob(executable.getId()); } } }
Example 3
Source File: JobService.java From kylin with Apache License 2.0 | 4 votes |
public void cancelJob(JobInstance job) throws IOException { aclEvaluate.checkProjectOperationPermission(job); if (null == job.getRelatedCube() || null == getCubeManager().getCube(job.getRelatedCube()) || null == job.getRelatedSegment()) { getExecutableManager().discardJob(job.getId()); } logger.info("Cancel job [" + job.getId() + "] trigger by " + SecurityContextHolder.getContext().getAuthentication().getName()); if (job.getStatus() == JobStatusEnum.FINISHED) { throw new IllegalStateException( "The job " + job.getId() + " has already been finished and cannot be discarded."); } if (job.getStatus() != JobStatusEnum.DISCARDED) { AbstractExecutable executable = getExecutableManager().getJob(job.getId()); if (executable instanceof CubingJob) { cancelCubingJobInner((CubingJob) executable); //release global mr hive dict lock if exists if (executable.getStatus().isFinalState()) { try { DistributedLock lock = KylinConfig.getInstanceFromEnv().getDistributedLockFactory().lockForCurrentThread(); if (lock.isLocked(MRHiveDictUtil.getLockPath(executable.getCubeName(), job.getId()))) {//release mr/hive global dict lock if exists lock.purgeLocks(MRHiveDictUtil.getLockPath(executable.getCubeName(), null)); logger.info("{} unlock global MR/Hive dict lock path({}) success", job.getId(), MRHiveDictUtil.getLockPath(executable.getCubeName(), null)); if (lock.isLocked(MRHiveDictUtil.getEphemeralLockPath(executable.getCubeName()))) {//release mr/hive global dict Ephemeral lock if exists lock.purgeLocks(MRHiveDictUtil.getEphemeralLockPath(executable.getCubeName())); logger.info("{} unlock global MR/Hive dict ephemeral lock path({}) success", job.getId(), MRHiveDictUtil.getEphemeralLockPath(executable.getCubeName())); } } if(lock.isLocked(CubeJobLockUtil.getLockPath(executable.getCubeName(), job.getId()))){//release cube job dict lock if exists lock.purgeLocks(CubeJobLockUtil.getLockPath(executable.getCubeName(), null)); logger.info("{} unlock cube job dict lock path({}) success", job.getId(), CubeJobLockUtil.getLockPath(executable.getCubeName(), null)); if (lock.isLocked(CubeJobLockUtil.getEphemeralLockPath(executable.getCubeName()))) {//release cube job Ephemeral lock if exists lock.purgeLocks(CubeJobLockUtil.getEphemeralLockPath(executable.getCubeName())); logger.info("{} unlock cube job ephemeral lock path({}) success", job.getId(), CubeJobLockUtil.getEphemeralLockPath(executable.getCubeName())); } } }catch (Exception e){ logger.error("get some error when release cube {} job {} job id {} " , executable.getCubeName(), job.getName(), job.getId()); } } } else if (executable instanceof CheckpointExecutable) { cancelCheckpointJobInner((CheckpointExecutable) executable); } else { getExecutableManager().discardJob(executable.getId()); } } }