[KYLIN-6087] Support built-in auto scheduled segment build with model-level config and scheduler - #2347
[KYLIN-6087] Support built-in auto scheduled segment build with model-level config and scheduler#2347Mrhs121 wants to merge 4 commits into
Conversation
|
retest this please |
|
@jlfsdtc PTAL, Thanks |
|
Please add "dev design" and create an Apache issue at the same time. @Mrhs121 |
| } | ||
| val parts = key.split("/", 2); | ||
| if (parts.length != 2) { | ||
| return; |
There was a problem hiding this comment.
add error log, identify the abnormal key
| @Getter | ||
| private final AtomicInteger schedulerModelCount = new AtomicInteger(0); | ||
|
|
||
| @Scheduled(cron = "*/30 * * * * ?") |
There was a problem hiding this comment.
Why is it necessary to schedule this operation every 30 minutes? or this crontab expression should be configurable.
| val projectName = project.getName(); | ||
| val modelManager = NDataModelManager.getInstance(KylinConfig.readSystemKylinConfig(), projectName); | ||
| for (NDataModel model : modelManager.listAllModels()) { | ||
| val segmentConfig = model.getSegmentConfig(); |
There was a problem hiding this comment.
skip the offline model or broken model?
|
|
||
| private void startCron(String key, String cron) { | ||
| stopCron(key); | ||
| checkSchedulerThreadPoolSize(); |
There was a problem hiding this comment.
check every time of startCron or every time of schedule?
| if (autoSegmentBuild == null || !autoSegmentBuild.isEnabled()) { | ||
| return; | ||
| } | ||
| if (model.isStreaming() || model.isMultiPartitionModel() |
There was a problem hiding this comment.
model‘s status has been checked when walking through the model list in function reconcile,combine these into one.
| JobTypeEnum[] buildJobTypes = JobTypeEnum.getJobTypeByCategory(JobTypeEnum.Category.BUILD) | ||
| .toArray(new JobTypeEnum[0]); | ||
| List<AbstractExecutable> jobs = executableManager.listExecByModelAndStatus(modelId, | ||
| ExecutableState::isProgressing, buildJobTypes); |
There was a problem hiding this comment.
hasRunningBuildJob of the same segment or any segment?
…el config and scheduler
…el config and scheduler
There was a problem hiding this comment.
Pull request overview
Adds model-level configuration and a built-in scheduler to automatically build segments on a daily schedule, and exposes the configuration through REST + Kystudio UI so users can configure/observe auto scheduled builds per model.
Changes:
- Introduces
AutoSegmentBuildConfigand wires it intoSegmentConfig, project defaults, model config request/response, and open API mapping. - Adds
AutoBuildSegmentSchedulerto periodically dispatch scheduled segment build jobs using project time zones. - Extends
ModelBuildServiceto support scheduler-triggered incremental segment builds with a configurable submitter, plus unit tests for validation and scheduler behavior.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/modeling-service/src/test/java/org/apache/kylin/rest/service/ModelServiceTest.java | Adds tests for auto-segment-build config persistence and parameter validation. |
| src/modeling-service/src/main/java/org/apache/kylin/rest/service/ModelService.java | Adds validation for auto_segment_build and returns/persists it in model config APIs. |
| src/modeling-service/src/main/java/org/apache/kylin/rest/service/ModelBuildService.java | Adds scheduler entrypoint and propagates submitter into job params. |
| src/modeling-service/src/main/java/org/apache/kylin/rest/response/ModelConfigResponse.java | Exposes auto_segment_build in REST response. |
| src/modeling-service/src/main/java/org/apache/kylin/rest/request/ModelConfigRequest.java | Accepts auto_segment_build in REST request. |
| src/metadata-server/src/main/java/org/apache/kylin/rest/controller/open/OpenModelController.java | Maps auto_segment_build between open API model config response/request. |
| src/data-loading-service/src/test/java/org/apache/kylin/rest/scheduler/AutoBuildSegmentSchedulerTest.java | Adds scheduler unit tests (timezone handling, once-per-window dispatch, skip conditions). |
| src/data-loading-service/src/main/java/org/apache/kylin/rest/scheduler/AutoBuildSegmentScheduler.java | New scheduler component that dispatches auto segment builds per project/model. |
| src/core-metadata/src/test/java/org/apache/kylin/metadata/cube/model/NSegmentConfigHelperTest.java | Updates constructor usage due to new SegmentConfig field. |
| src/core-metadata/src/main/java/org/apache/kylin/metadata/project/ProjectInstance.java | Adds project default auto_segment_build config inside default SegmentConfig. |
| src/core-metadata/src/main/java/org/apache/kylin/metadata/model/SegmentConfig.java | Adds auto_segment_build field to segment config. |
| src/core-metadata/src/main/java/org/apache/kylin/metadata/model/AutoSegmentBuildConfig.java | New config model for auto scheduled segment builds. |
| src/core-common/src/main/resources/kylin-defaults0.properties | Adds default cron property for scheduler dispatcher. |
| kystudio/src/components/setting/SettingModel/SettingModel.vue | Adds UI to edit/delete/display auto segment build config. |
| kystudio/src/components/setting/SettingModel/locales.js | Adds UI strings for auto segment build. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| <el-form-item :label="$t('autoSegmentBuildRangeEnd')"> | ||
| <el-time-picker | ||
| style="width: 180px;" | ||
| size="small" | ||
| format="HH:mm:ss" | ||
| value-format="HH:mm:ss" | ||
| v-model="modelSettingForm.autoSegmentBuild.data_range_end_time"> | ||
| </el-time-picker> |
| import java.time.Duration; | ||
| import java.time.Instant; | ||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import java.time.LocalTime; |
| if (StringUtils.isBlank(autoSegmentBuild.getTriggerTime())) { | ||
| log.warn("Skip auto build segment because trigger_time is blank, project: {}, model: {}", project, | ||
| model.getUuid()); | ||
| return; | ||
| } |
| private JobInfoResponse incrementBuildSegmentsInternal(IncrementBuildSegmentParams params, String submitter, | ||
| boolean checkPermission) throws Exception { | ||
| String project = params.getProject(); | ||
| aclEvaluate.checkProjectOperationPermission(project); | ||
| checkModelPermission(project, params.getModelId()); | ||
| if (checkPermission) { | ||
| aclEvaluate.checkProjectOperationPermission(project); | ||
| checkModelPermission(project, params.getModelId()); | ||
| } | ||
| val modelManager = getManager(NDataModelManager.class, project); |
| || StringUtils.isBlank(autoSegmentBuild.getDataRangeStartTime()) | ||
| || StringUtils.isBlank(autoSegmentBuild.getDataRangeEndTime()) | ||
| || autoSegmentBuild.getLogicalDateOffsetDays() == null) { | ||
| throw new KylinException(INVALID_PARAMETER, "Invalid auto_segment_build config."); |
| private final AtomicBoolean dispatching = new AtomicBoolean(false); | ||
| private final AtomicReference<Instant> lastDispatchTime = new AtomicReference<>(); | ||
|
|
||
| @Scheduled(cron = "${kylin.model.auto-segment-build.dispatcher-cron:*/30 * * * * ?}") |
There was a problem hiding this comment.
This indicates that kylin.model.auto-segment-build.dispatcher-cron is a system-level parameter that requires a system restart after each modification. Is it possible to adjust this parameter to the project level or model level?
| return autoSegmentBuild != null && autoSegmentBuild.isEnabled() ? autoSegmentBuild : null; | ||
| } | ||
|
|
||
| @VisibleForTesting |
There was a problem hiding this comment.
This annotation is only added to the code used for unit testing (UT), and no annotation is required for the methods employed in production code.
| return scheduledTime; | ||
| } | ||
|
|
||
| @VisibleForTesting |
There was a problem hiding this comment.
This annotation is only added to the code used for unit testing (UT), and no annotation is required for the methods employed in production code.
| } | ||
| } | ||
|
|
||
| @VisibleForTesting |
There was a problem hiding this comment.
This annotation is only added to the code used for unit testing (UT), and no annotation is required for the methods employed in production code.
| return previousTime; | ||
| } | ||
|
|
||
| @VisibleForTesting |
There was a problem hiding this comment.
This annotation is only added to the code used for unit testing (UT), and no annotation is required for the methods employed in production code.
No description provided.