Java Code Examples for org.apache.kylin.cube.CubeSegment#getStatus()
The following examples show how to use
org.apache.kylin.cube.CubeSegment#getStatus() .
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: AfterMergeOrRefreshResourceMerger.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
List<CubeSegment> getToRemoveSegs(CubeInstance cube, CubeSegment mergedSegment) { Segments tobe = cube.calculateToBeSegments(mergedSegment); if (!tobe.contains(mergedSegment)) throw new IllegalStateException( "For Cube " + cube + ", segment " + mergedSegment + " is expected but not in the tobe " + tobe); if (mergedSegment.getStatus() == SegmentStatusEnum.NEW) mergedSegment.setStatus(SegmentStatusEnum.READY); List<CubeSegment> toRemoveSegs = Lists.newArrayList(); for (CubeSegment s : cube.getSegments()) { if (!tobe.contains(s)) toRemoveSegs.add(s); } return toRemoveSegs; }
Example 2
Source File: JobService.java From kylin with Apache License 2.0 | 6 votes |
private void cancelCheckpointJobInner(CheckpointExecutable checkpointExecutable) throws IOException { List<String> segmentIdList = Lists.newLinkedList(); List<String> jobIdList = Lists.newLinkedList(); jobIdList.add(checkpointExecutable.getId()); setRelatedIdList(checkpointExecutable, segmentIdList, jobIdList); CubeInstance cubeInstance = getCubeManager() .getCube(CubingExecutableUtil.getCubeName(checkpointExecutable.getParams())); if (!segmentIdList.isEmpty()) { List<CubeSegment> toRemoveSegments = Lists.newLinkedList(); for (String segmentId : segmentIdList) { final CubeSegment segment = cubeInstance.getSegmentById(segmentId); if (segment != null && segment.getStatus() != SegmentStatusEnum.READY) { toRemoveSegments.add(segment); } } getCubeManager().dropOptmizingSegments(cubeInstance, toRemoveSegments.toArray(new CubeSegment[] {})); } for (String jobId : jobIdList) { getExecutableManager().discardJob(jobId); } }
Example 3
Source File: JobService.java From kylin with Apache License 2.0 | 6 votes |
private void cancelCubingJobInner(CubingJob cubingJob) throws IOException { CubeInstance cubeInstance = getCubeManager().getCube(CubingExecutableUtil.getCubeName(cubingJob.getParams())); // might not a cube job final String segmentIds = CubingExecutableUtil.getSegmentId(cubingJob.getParams()); if (!StringUtils.isEmpty(segmentIds)) { for (String segmentId : StringUtils.split(segmentIds)) { final CubeSegment segment = cubeInstance.getSegmentById(segmentId); if (segment != null && (segment.getStatus() == SegmentStatusEnum.NEW || segment.getTSRange().end.v == 0)) { // Remove this segment getCubeManager().updateCubeDropSegments(cubeInstance, segment); } } } getExecutableManager().discardJob(cubingJob.getId()); }
Example 4
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 5
Source File: JobService.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
private void cancelCheckpointJobInner(CheckpointExecutable checkpointExecutable) throws IOException { List<String> segmentIdList = Lists.newLinkedList(); List<String> jobIdList = Lists.newLinkedList(); jobIdList.add(checkpointExecutable.getId()); setRelatedIdList(checkpointExecutable, segmentIdList, jobIdList); CubeInstance cubeInstance = getCubeManager() .getCube(CubingExecutableUtil.getCubeName(checkpointExecutable.getParams())); if (!segmentIdList.isEmpty()) { List<CubeSegment> toRemoveSegments = Lists.newLinkedList(); for (String segmentId : segmentIdList) { final CubeSegment segment = cubeInstance.getSegmentById(segmentId); if (segment != null && segment.getStatus() != SegmentStatusEnum.READY) { toRemoveSegments.add(segment); } } getCubeManager().dropOptmizingSegments(cubeInstance, toRemoveSegments.toArray(new CubeSegment[] {})); } for (String jobId : jobIdList) { getExecutableManager().discardJob(jobId); } }
Example 6
Source File: JobService.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
private void cancelCubingJobInner(CubingJob cubingJob) throws IOException { CubeInstance cubeInstance = getCubeManager().getCube(CubingExecutableUtil.getCubeName(cubingJob.getParams())); // might not a cube job final String segmentIds = CubingExecutableUtil.getSegmentId(cubingJob.getParams()); if (!StringUtils.isEmpty(segmentIds)) { for (String segmentId : StringUtils.split(segmentIds)) { final CubeSegment segment = cubeInstance.getSegmentById(segmentId); if (segment != null && (segment.getStatus() == SegmentStatusEnum.NEW || segment.getTSRange().end.v == 0)) { // Remove this segment getCubeManager().updateCubeDropSegments(cubeInstance, segment); } } } getExecutableManager().discardJob(cubingJob.getId()); }
Example 7
Source File: KylinHealthCheckJob.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
private void checkHBaseTables(List<CubeInstance> cubes) throws IOException { reporter.log("## Checking HBase Table of segments"); HBaseAdmin hbaseAdmin = new HBaseAdmin(HBaseConfiguration.create()); try { for (CubeInstance cube : cubes) { for (CubeSegment segment : cube.getSegments()) { if (segment.getStatus() != SegmentStatusEnum.NEW) { String tableName = segment.getStorageLocationIdentifier(); if ((!hbaseAdmin.tableExists(tableName)) || (!hbaseAdmin.isTableEnabled(tableName))) { reporter.log("HBase table: {} not exist for segment: {}, project: {}", tableName, segment, cube.getProject()); reporter.log( "The rebuild url: -d '{\"startTime\":{}, \"endTime\":{}, \"buildType\":\"REFRESH\"}' /kylin/api/cubes/{}/build", segment.getTSRange().start, segment.getTSRange().end, cube.getName()); } } } } } finally { if (null != hbaseAdmin) { hbaseAdmin.close(); } } }
Example 8
Source File: CubeService.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
public void updateOnNewSegmentReady(String cubeName) { final KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv(); String serverMode = kylinConfig.getServerMode(); if (Constant.SERVER_MODE_JOB.equals(serverMode.toLowerCase(Locale.ROOT)) || Constant.SERVER_MODE_ALL.equals(serverMode.toLowerCase(Locale.ROOT))) { CubeInstance cube = getCubeManager().getCube(cubeName); if (cube != null) { CubeSegment seg = cube.getLatestBuiltSegment(); if (seg != null && seg.getStatus() == SegmentStatusEnum.READY) { keepCubeRetention(cubeName); mergeCubeSegment(cubeName); } } } }
Example 9
Source File: CubeService.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#cube, 'ADMINISTRATION') or hasPermission(#cube, 'MANAGEMENT')") public void migrateCube(CubeInstance cube, String projectName) { KylinConfig config = KylinConfig.getInstanceFromEnv(); if (!config.isAllowAutoMigrateCube()) { throw new InternalErrorException("One click migration is disabled, please contact your ADMIN"); } for (CubeSegment segment : cube.getSegments()) { if (segment.getStatus() != SegmentStatusEnum.READY) { throw new InternalErrorException( "At least one segment is not in READY state. Please check whether there are Running or Error jobs."); } } String srcCfgUri = config.getAutoMigrateCubeSrcConfig(); String dstCfgUri = config.getAutoMigrateCubeDestConfig(); Preconditions.checkArgument(StringUtils.isNotEmpty(srcCfgUri), "Source configuration should not be empty."); Preconditions.checkArgument(StringUtils.isNotEmpty(dstCfgUri), "Destination configuration should not be empty."); String stringBuilder = ("%s/bin/kylin.sh org.apache.kylin.tool.CubeMigrationCLI %s %s %s %s %s %s true true"); String cmd = String.format(Locale.ROOT, stringBuilder, KylinConfig.getKylinHome(), srcCfgUri, dstCfgUri, cube.getName(), projectName, config.isAutoMigrateCubeCopyAcl(), config.isAutoMigrateCubePurge()); logger.info("One click migration cmd: " + cmd); CliCommandExecutor exec = new CliCommandExecutor(); PatternedLogger patternedLogger = new PatternedLogger(logger); try { exec.execute(cmd, patternedLogger, null); } catch (IOException e) { throw new InternalErrorException("Failed to perform one-click migrating", e); } }
Example 10
Source File: CubeMigrationCLI.java From kylin with Apache License 2.0 | 5 votes |
protected void checkCubeState(CubeInstance cube) { if (cube.getStatus() != RealizationStatusEnum.READY) throw new IllegalStateException("Cannot migrate cube that is not in READY state."); for (CubeSegment segment : cube.getSegments()) { if (segment.getStatus() != SegmentStatusEnum.READY) { throw new IllegalStateException("At least one segment is not in READY state"); } } }
Example 11
Source File: CubeMigrationCLI.java From Kylin with Apache License 2.0 | 5 votes |
public static void moveCube(KylinConfig srcCfg, KylinConfig dstCfg, String cubeName, String projectName, String overwriteIfExists, String realExecute) throws IOException, InterruptedException { srcConfig = srcCfg; srcStore = ResourceStore.getStore(srcConfig); dstConfig = dstCfg; dstStore = ResourceStore.getStore(dstConfig); CubeManager cubeManager = CubeManager.getInstance(srcConfig); CubeInstance cube = cubeManager.getCube(cubeName); logger.info("cube to be moved is : " + cubeName); if (cube.getStatus() != RealizationStatusEnum.READY) throw new IllegalStateException("Cannot migrate cube that is not in READY state."); for (CubeSegment segment : cube.getSegments()) { if (segment.getStatus() != SegmentStatusEnum.READY) { throw new IllegalStateException("At least one segment is not in READY state"); } } checkAndGetHbaseUrl(); Configuration conf = HBaseConfiguration.create(); hbaseAdmin = new HBaseAdmin(conf); hdfsFS = FileSystem.get(new Configuration()); operations = new ArrayList<Opt>(); copyFilesInMetaStore(cube, overwriteIfExists); renameFoldersInHdfs(cube); changeHtableHost(cube); addCubeIntoProject(cubeName, projectName); if (realExecute.equalsIgnoreCase("true")) { doOpts(); } else { showOpts(); } }
Example 12
Source File: CubeService.java From kylin with Apache License 2.0 | 5 votes |
public void updateOnNewSegmentReady(String cubeName) { final KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv(); String serverMode = kylinConfig.getServerMode(); if (Constant.SERVER_MODE_JOB.equals(serverMode.toLowerCase(Locale.ROOT)) || Constant.SERVER_MODE_ALL.equals(serverMode.toLowerCase(Locale.ROOT))) { CubeInstance cube = getCubeManager().getCube(cubeName); if (cube != null) { CubeSegment seg = cube.getLatestBuiltSegment(); if (seg != null && seg.getStatus() == SegmentStatusEnum.READY) { keepCubeRetention(cubeName); mergeCubeSegment(cubeName); } } } }
Example 13
Source File: CubeMigrationCLI.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
protected void checkCubeState(CubeInstance cube) { if (cube.getStatus() != RealizationStatusEnum.READY) throw new IllegalStateException("Cannot migrate cube that is not in READY state."); for (CubeSegment segment : cube.getSegments()) { if (segment.getStatus() != SegmentStatusEnum.READY) { throw new IllegalStateException("At least one segment is not in READY state"); } } }
Example 14
Source File: CubeService.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
public CubeInstance deleteSegment(CubeInstance cube, String segmentName) throws IOException { aclEvaluate.checkProjectOperationPermission(cube); Message msg = MsgPicker.getMsg(); if (cube.getStatus() == RealizationStatusEnum.READY) { throw new BadRequestException( String.format(Locale.ROOT, msg.getDELETE_SEG_FROM_READY_CUBE(), segmentName, cube.getName())); } CubeSegment toDelete = null; for (CubeSegment seg : cube.getSegments()) { if (seg.getName().equals(segmentName)) { toDelete = seg; break; } } if (toDelete == null) { throw new BadRequestException(String.format(Locale.ROOT, msg.getSEG_NOT_FOUND(), segmentName)); } if (toDelete.getStatus() != SegmentStatusEnum.READY) { if (toDelete.getStatus() == SegmentStatusEnum.NEW) { if (!isOrphonSegment(cube, toDelete.getUuid())) { throw new BadRequestException( String.format(Locale.ROOT, msg.getDELETE_NOT_READY_SEG(), segmentName)); } } else { throw new BadRequestException(String.format(Locale.ROOT, msg.getDELETE_NOT_READY_SEG(), segmentName)); } } if (!segmentName.equals(cube.getSegments().get(0).getName()) && !segmentName.equals(cube.getSegments().get(cube.getSegments().size() - 1).getName())) { logger.warn(String.format(Locale.ROOT, msg.getDELETE_SEGMENT_CAUSE_GAPS(), cube.getName(), segmentName)); } CubeInstance cubeInstance = CubeManager.getInstance(getConfig()).updateCubeDropSegments(cube, toDelete); cleanSegmentStorage(Collections.singletonList(toDelete)); return cubeInstance; }
Example 15
Source File: Coordinator.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
private List<String> findSegmentsCanBuild(String cubeName) { List<String> result = Lists.newArrayList(); CubeInstance cubeInstance = CubeManager.getInstance(KylinConfig.getInstanceFromEnv()).getCube(cubeName); // in optimization if (isInOptimize(cubeInstance)) { return result; } int allowMaxBuildingSegments = cubeInstance.getConfig().getMaxBuildingSegments(); CubeSegment latestHistoryReadySegment = cubeInstance.getLatestReadySegment(); long minSegmentStart = -1; if (latestHistoryReadySegment != null) { minSegmentStart = latestHistoryReadySegment.getTSRange().end.v; } else { // there is no ready segment, to make cube planner work, only 1 segment can build logger.info("there is no ready segments for cube:{}, so only allow 1 segment build concurrently", cubeName); allowMaxBuildingSegments = 1; } CubeAssignment assignments = streamMetadataStore.getAssignmentsByCube(cubeName); Set<Integer> cubeAssignedReplicaSets = assignments.getReplicaSetIDs(); List<SegmentBuildState> segmentStates = streamMetadataStore.getSegmentBuildStates(cubeName); Collections.sort(segmentStates); // TODO need to check whether it is in optimization int inBuildingSegments = cubeInstance.getBuildingSegments().size(); int leftQuota = allowMaxBuildingSegments - inBuildingSegments; for (int i = 0; i < segmentStates.size(); i++) { SegmentBuildState segmentState = segmentStates.get(i); Pair<Long, Long> segmentRange = CubeSegment.parseSegmentName(segmentState.getSegmentName()); if (segmentRange.getFirst() < minSegmentStart) { logger.warn("the cube segment state is not clear correctly, cube:{} segment:{}, clear it", cubeName, segmentState.getSegmentName()); streamMetadataStore.removeSegmentBuildState(cubeName, segmentState.getSegmentName()); continue; } if (segmentState.isInBuilding()) { inBuildingSegments++; String jobId = segmentState.getState().getJobId(); logger.info("there is segment in building, cube:{} segment:{} jobId:{}", cubeName, segmentState.getSegmentName(), jobId); long buildStartTime = segmentState.getState().getBuildStartTime(); if (buildStartTime != 0 && jobId != null) { long buildDuration = System.currentTimeMillis() - buildStartTime; if (buildDuration < 40 * 60 * 1000) { // if build time larger than 40 minutes, check the job status continue; } CubingJob cubingJob = (CubingJob) getExecutableManager().getJob(jobId); ExecutableState jobState = cubingJob.getStatus(); if (ExecutableState.SUCCEED.equals(jobState)) { // job is already succeed, remove the build state CubeSegment cubeSegment = cubeInstance.getSegment(segmentState.getSegmentName(), null); if (cubeSegment != null && SegmentStatusEnum.READY == cubeSegment.getStatus()) { logger.info( "job:{} is already succeed, and segment:{} is ready, remove segment build state", jobId, segmentState.getSegmentName()); streamMetadataStore.removeSegmentBuildState(cubeName, segmentState.getSegmentName()); } continue; } else if (ExecutableState.ERROR.equals(jobState)) { logger.info("job:{} is error, resume the job", jobId); getExecutableManager().resumeJob(jobId); continue; } else if (ExecutableState.DISCARDED.equals(jobState)) { // if the job has been discard manually, just think that the segment is not in building logger.info("job:{} is discard, reset the job state in metaStore", jobId); SegmentBuildState.BuildState state = new SegmentBuildState.BuildState(); state.setBuildStartTime(0); state.setState(SegmentBuildState.BuildState.State.WAIT); state.setJobId(cubingJob.getId()); streamMetadataStore.updateSegmentBuildState(cubeName, segmentState.getSegmentName(), state); segmentState.setState(state); logger.info("segment:{} is discard", segmentState.getSegmentName()); continue; } else { logger.info("job:{} is in running, job state: {}", jobId, jobState); continue; } } } if (leftQuota <= 0) { logger.info("No left quota to build segments for cube:{}", cubeName); return result; } if (!checkSegmentIsReadyToBuild(segmentStates, i, cubeAssignedReplicaSets)) { break; } result.add(segmentState.getSegmentName()); leftQuota--; } return result; }
Example 16
Source File: Coordinator.java From kylin with Apache License 2.0 | 4 votes |
private List<String> findSegmentsCanBuild(String cubeName) { List<String> result = Lists.newArrayList(); CubeInstance cubeInstance = CubeManager.getInstance(KylinConfig.getInstanceFromEnv()).getCube(cubeName); // in optimization if (isInOptimize(cubeInstance)) { return result; } int allowMaxBuildingSegments = cubeInstance.getConfig().getMaxBuildingSegments(); CubeSegment latestHistoryReadySegment = cubeInstance.getLatestReadySegment(); long minSegmentStart = -1; if (latestHistoryReadySegment != null) { minSegmentStart = latestHistoryReadySegment.getTSRange().end.v; } else { // there is no ready segment, to make cube planner work, only 1 segment can build logger.info("there is no ready segments for cube:{}, so only allow 1 segment build concurrently", cubeName); allowMaxBuildingSegments = 1; } CubeAssignment assignments = streamMetadataStore.getAssignmentsByCube(cubeName); Set<Integer> cubeAssignedReplicaSets = assignments.getReplicaSetIDs(); List<SegmentBuildState> segmentStates = streamMetadataStore.getSegmentBuildStates(cubeName); Collections.sort(segmentStates); // TODO need to check whether it is in optimization int inBuildingSegments = cubeInstance.getBuildingSegments().size(); int leftQuota = allowMaxBuildingSegments - inBuildingSegments; for (int i = 0; i < segmentStates.size(); i++) { SegmentBuildState segmentState = segmentStates.get(i); Pair<Long, Long> segmentRange = CubeSegment.parseSegmentName(segmentState.getSegmentName()); if (segmentRange.getFirst() < minSegmentStart) { logger.warn("the cube segment state is not clear correctly, cube:{} segment:{}, clear it", cubeName, segmentState.getSegmentName()); streamMetadataStore.removeSegmentBuildState(cubeName, segmentState.getSegmentName()); continue; } if (segmentState.isInBuilding()) { inBuildingSegments++; String jobId = segmentState.getState().getJobId(); logger.info("there is segment in building, cube:{} segment:{} jobId:{}", cubeName, segmentState.getSegmentName(), jobId); long buildStartTime = segmentState.getState().getBuildStartTime(); if (buildStartTime != 0 && jobId != null) { long buildDuration = System.currentTimeMillis() - buildStartTime; if (buildDuration < 40 * 60 * 1000) { // if build time larger than 40 minutes, check the job status continue; } CubingJob cubingJob = (CubingJob) getExecutableManager().getJob(jobId); ExecutableState jobState = cubingJob.getStatus(); if (ExecutableState.SUCCEED.equals(jobState)) { // job is already succeed, remove the build state CubeSegment cubeSegment = cubeInstance.getSegment(segmentState.getSegmentName(), null); if (cubeSegment != null && SegmentStatusEnum.READY == cubeSegment.getStatus()) { logger.info( "job:{} is already succeed, and segment:{} is ready, remove segment build state", jobId, segmentState.getSegmentName()); streamMetadataStore.removeSegmentBuildState(cubeName, segmentState.getSegmentName()); } continue; } else if (ExecutableState.ERROR.equals(jobState)) { logger.info("job:{} is error, resume the job", jobId); getExecutableManager().resumeJob(jobId); continue; } else if (ExecutableState.DISCARDED.equals(jobState)) { // if the job has been discard manually, just think that the segment is not in building logger.info("job:{} is discard, reset the job state in metaStore", jobId); SegmentBuildState.BuildState state = new SegmentBuildState.BuildState(); state.setBuildStartTime(0); state.setState(SegmentBuildState.BuildState.State.WAIT); state.setJobId(cubingJob.getId()); streamMetadataStore.updateSegmentBuildState(cubeName, segmentState.getSegmentName(), state); segmentState.setState(state); logger.info("segment:{} is discard", segmentState.getSegmentName()); continue; } else { logger.info("job:{} is in running, job state: {}", jobId, jobState); continue; } } } if (leftQuota <= 0) { logger.info("No left quota to build segments for cube:{}", cubeName); return result; } if (!checkSegmentIsReadyToBuild(segmentStates, i, cubeAssignedReplicaSets)) { break; } result.add(segmentState.getSegmentName()); leftQuota--; } return result; }
Example 17
Source File: BuildJobSubmitter.java From kylin with Apache License 2.0 | 4 votes |
/** * Check segment which in building state * * @return true if we need to resubmit a new build job, else false */ boolean checkSegmentBuildingJob(SegmentBuildState segmentState, String cubeName, CubeInstance cubeInstance) { String jobId = segmentState.getState().getJobId(); logger.debug("There is segment in building, cube:{} segment:{} jobId:{}", cubeName, segmentState.getSegmentName(), jobId); long buildStartTime = segmentState.getState().getBuildStartTime(); if (buildStartTime != 0 && jobId != null) { long buildDuration = System.currentTimeMillis() - buildStartTime; // Check build state after 15 minutes if (buildDuration < 15 * 60 * 1000) { return false; } CubingJob cubingJob = (CubingJob) coordinator.getExecutableManager().getJob(jobId); if (cubingJob == null) { // Cubing job is dropped manually, or metadata is broken. logger.warn("Looks like cubing job is dropped manually, it will be submitted a new one."); return true; } ExecutableState jobState = cubingJob.getStatus(); // If job is already succeed and HBase segment in ready state, remove the build state if (ExecutableState.SUCCEED.equals(jobState)) { CubeSegment cubeSegment = cubeInstance.getSegment(segmentState.getSegmentName(), null); if (cubeSegment != null && SegmentStatusEnum.READY == cubeSegment.getStatus()) { logger.info("Job:{} is already succeed, and segment:{} is ready, remove segment build state", jobId, segmentState.getSegmentName()); coordinator.getStreamMetadataStore().removeSegmentBuildState(cubeName, segmentState.getSegmentName()); } return false; } // If a job is in error state, just retry it if (ExecutableState.ERROR.equals(jobState)) { logger.info("Job:{} is error, resume the job.", jobId); coordinator.getExecutableManager().resumeJob(jobId); return false; } // If a job is discard, we will try to resumbit it later. if (ExecutableState.DISCARDED.equals(jobState)) { if (KylinConfig.getInstanceFromEnv().isAutoResubmitDiscardJob()) { logger.debug("Job:{} is discard, resubmit it later.", jobId); return true; } else { logger.debug("Job:{} is discard, please resubmit yourself.", jobId); return false; } } else { logger.info("Job:{} is in running, job state: {}.", jobId, jobState); } } else { logger.info("Unknown state {}", segmentState); } return false; }
Example 18
Source File: CubeMigrationCLI.java From kylin with Apache License 2.0 | 4 votes |
public static void moveCube(KylinConfig srcCfg, KylinConfig dstCfg, String cubeName, String projectName, String copyAcl, String purgeAndDisable, String overwriteIfExists, String realExecute) throws IOException, InterruptedException { srcConfig = srcCfg; srcStore = ResourceStore.getStore(srcConfig); dstConfig = dstCfg; dstStore = ResourceStore.getStore(dstConfig); CubeManager cubeManager = CubeManager.getInstance(srcConfig); CubeInstance cube = cubeManager.getCube(cubeName); logger.info("cube to be moved is : " + cubeName); if (cube.getStatus() != RealizationStatusEnum.READY) throw new IllegalStateException("Cannot migrate cube that is not in READY state."); for (CubeSegment segment : cube.getSegments()) { if (segment.getStatus() != SegmentStatusEnum.READY) { throw new IllegalStateException("At least one segment is not in READY state"); } } checkAndGetHbaseUrl(); Connection conn = HBaseConnection.get(srcConfig.getStorageUrl()); hbaseAdmin = conn.getAdmin(); hdfsFS = HadoopUtil.getWorkingFileSystem(); operations = new ArrayList<Opt>(); copyFilesInMetaStore(cube, overwriteIfExists); renameFoldersInHdfs(cube); changeHtableHost(cube); addCubeAndModelIntoProject(cube, cubeName, projectName); if (Boolean.parseBoolean(copyAcl) == true) { copyACL(cube, projectName); } if (Boolean.parseBoolean(purgeAndDisable) == true) { purgeAndDisable(cubeName); // this should be the last action } if (realExecute.equalsIgnoreCase("true")) { doOpts(); checkMigrationSuccess(dstConfig, cubeName, true); updateMeta(dstConfig); } else { showOpts(); } }
Example 19
Source File: CubeMigrationCLI.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
public static void moveCube(KylinConfig srcCfg, KylinConfig dstCfg, String cubeName, String projectName, String copyAcl, String purgeAndDisable, String overwriteIfExists, String realExecute) throws IOException, InterruptedException { srcConfig = srcCfg; srcStore = ResourceStore.getStore(srcConfig); dstConfig = dstCfg; dstStore = ResourceStore.getStore(dstConfig); CubeManager cubeManager = CubeManager.getInstance(srcConfig); CubeInstance cube = cubeManager.getCube(cubeName); logger.info("cube to be moved is : " + cubeName); if (cube.getStatus() != RealizationStatusEnum.READY) throw new IllegalStateException("Cannot migrate cube that is not in READY state."); for (CubeSegment segment : cube.getSegments()) { if (segment.getStatus() != SegmentStatusEnum.READY) { throw new IllegalStateException("At least one segment is not in READY state"); } } checkAndGetHbaseUrl(); Connection conn = HBaseConnection.get(srcConfig.getStorageUrl()); hbaseAdmin = conn.getAdmin(); hdfsFS = HadoopUtil.getWorkingFileSystem(); operations = new ArrayList<Opt>(); copyFilesInMetaStore(cube, overwriteIfExists); renameFoldersInHdfs(cube); changeHtableHost(cube); addCubeAndModelIntoProject(cube, cubeName, projectName); if (Boolean.parseBoolean(copyAcl) == true) { copyACL(cube, projectName); } if (Boolean.parseBoolean(purgeAndDisable) == true) { purgeAndDisable(cubeName); // this should be the last action } if (realExecute.equalsIgnoreCase("true")) { doOpts(); checkMigrationSuccess(dstConfig, cubeName, true); updateMeta(dstConfig); } else { showOpts(); } }
Example 20
Source File: BuildJobSubmitter.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
/** * Check segment which in building state * * @return true if we need to resubmit a new build job, else false */ boolean checkSegmentBuildingJob(SegmentBuildState segmentState, String cubeName, CubeInstance cubeInstance) { String jobId = segmentState.getState().getJobId(); logger.debug("There is segment in building, cube:{} segment:{} jobId:{}", cubeName, segmentState.getSegmentName(), jobId); long buildStartTime = segmentState.getState().getBuildStartTime(); if (buildStartTime != 0 && jobId != null) { long buildDuration = System.currentTimeMillis() - buildStartTime; // Check build state after 15 minutes if (buildDuration < 15 * 60 * 1000) { return false; } CubingJob cubingJob = (CubingJob) coordinator.getExecutableManager().getJob(jobId); if (cubingJob == null) { // Cubing job is dropped manually, or metadata is broken. logger.warn("Looks like cubing job is dropped manually, it will be submitted a new one."); return true; } ExecutableState jobState = cubingJob.getStatus(); // If job is already succeed and HBase segment in ready state, remove the build state if (ExecutableState.SUCCEED.equals(jobState)) { CubeSegment cubeSegment = cubeInstance.getSegment(segmentState.getSegmentName(), null); if (cubeSegment != null && SegmentStatusEnum.READY == cubeSegment.getStatus()) { logger.info("Job:{} is already succeed, and segment:{} is ready, remove segment build state", jobId, segmentState.getSegmentName()); coordinator.getStreamMetadataStore().removeSegmentBuildState(cubeName, segmentState.getSegmentName()); } return false; } // If a job is in error state, just retry it if (ExecutableState.ERROR.equals(jobState)) { logger.info("Job:{} is error, resume the job.", jobId); coordinator.getExecutableManager().resumeJob(jobId); return false; } // If a job is discard, we will try to resumbit it later. if (ExecutableState.DISCARDED.equals(jobState)) { if (KylinConfig.getInstanceFromEnv().isAutoResubmitDiscardJob()) { logger.debug("Job:{} is discard, resubmit it later.", jobId); return true; } else { logger.debug("Job:{} is discard, please resubmit yourself.", jobId); return false; } } else { logger.info("Job:{} is in running, job state: {}.", jobId, jobState); } } else { logger.info("Unknown state {}", segmentState); } return false; }