Unverified Commit 7e5f22d8 authored by gaoyan's avatar gaoyan Committed by GitHub

Independent batch model field to fix the H 2 SQL incompatibility issue (#2587)

* Independent batch model field to fix the H 2 SQL incompatibility issue * formate code
parent f41358ec
......@@ -76,6 +76,9 @@ public class History implements Serializable {
@ApiModelProperty(value = "Job Manager Address", dataType = "String")
private String jobManagerAddress;
@ApiModelProperty(value = "batchModel", dataType = "Boolean")
private Boolean batchModel;
@ApiModelProperty(value = "Status", dataType = "Integer")
private Integer status;
......
......@@ -86,7 +86,7 @@ public class Job2MysqlHandler implements JobHandler {
}
history.setJobManagerAddress(job.getJobManagerAddress());
history.setJobName(job.getJobConfig().getJobName());
history.setStatus(job.getStatus().ordinal());
history.setStatus(job.getStatus().getCode());
history.setStatement(job.getStatement());
history.setStartTime(job.getStartTime());
history.setTaskId(job.getJobConfig().getTaskId());
......@@ -115,9 +115,10 @@ public class Job2MysqlHandler implements JobHandler {
History history = new History();
history.setId(job.getId());
history.setBatchModel(job.getJobConfig().isBatchModel());
if (job.isUseGateway() && Asserts.isNullString(job.getJobId())) {
job.setJobId("unknown");
history.setStatus(JobStatus.FAILED.ordinal());
history.setStatus(Job.JobStatus.FAILED.getCode());
history.setJobId(job.getJobId());
history.setEndTime(job.getEndTime());
history.setError("没有获取到任何JID,请自行排查原因");
......@@ -125,7 +126,7 @@ public class Job2MysqlHandler implements JobHandler {
return false;
}
history.setStatus(job.getStatus().ordinal());
history.setStatus(job.getStatus().getCode());
history.setJobId(job.getJobId());
history.setEndTime(job.getEndTime());
history.setJobManagerAddress(job.isUseGateway() ? job.getJobManagerAddress() : null);
......@@ -207,9 +208,10 @@ public class Job2MysqlHandler implements JobHandler {
public boolean failed() {
Job job = JobContextHolder.getJob();
History history = new History();
history.setBatchModel(job.getJobConfig().isBatchModel());
history.setId(job.getId());
history.setJobId(job.getJobId());
history.setStatus(job.getStatus().ordinal());
history.setStatus(job.getStatus().getCode());
history.setJobManagerAddress(job.getJobManagerAddress());
history.setEndTime(job.getEndTime());
history.setError(job.getError());
......
......@@ -158,6 +158,7 @@ CREATE TABLE `dinky_history` (
`job_id` varchar(50) null DEFAULT null COMMENT 'Job ID',
`job_name` varchar(255) null DEFAULT null COMMENT 'Job Name',
`job_manager_address` varchar(255) null DEFAULT null COMMENT 'JJobManager Address',
`batch_model` boolean null DEFAULT false COMMENT 'is batch model',
`status` int(11) NOT null DEFAULT 0 COMMENT 'status',
`type` varchar(50) null DEFAULT null COMMENT 'job type',
`statement` text null COMMENT 'statement set',
......
......@@ -73,13 +73,13 @@
</select>
<select id="getJobStreamingOrBatchModelOverview" resultType="org.dinky.data.model.home.JobModelOverview">
select sum(IF(b.batch, 1, 0)) as batchJobCount,
sum(IF(b.batch, 0, 1)) as streamingJobCount
from (select json_extract(dh.config_json, '$.batchModel') as batch
from (select max(ji.id) as id from dinky_job_instance ji group by ji.task_id) as a
select sum(case when b.batch then 1 else 0 end ) as batchJobCount,
sum(case when b.batch then 0 else 1 end ) as streamingJobCount
from (select batch_model as batch
from (select max(ji.id) as id from dinky_job_instance ji group by ji.task_id) as a
left join dinky_job_instance dji on dji.id = a.id
left join dinky.dinky_history dh on dji.history_id = dh.id) b
group by b.batch
left join dinky_history dh on dji.history_id = dh.id) b
group by b.batch;
</select>
<select id="listJobInstanceActive" resultType="org.dinky.data.model.job.JobInstance">
......
......@@ -55,12 +55,18 @@ public class Job {
private boolean useGateway;
private List<String> jids;
@Getter
public enum JobStatus {
INITIALIZE,
RUNNING,
SUCCESS,
FAILED,
CANCEL
INITIALIZE(1),
RUNNING(2),
SUCCESS(3),
FAILED(4),
CANCEL(5);
final int code;
JobStatus(int code) {
this.code = code;
}
}
public Job(
......
......@@ -1158,6 +1158,7 @@ CREATE TABLE `dinky_history` (
`job_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'Job Name',
`job_manager_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'JJobManager Address',
`status` int(11) NOT NULL DEFAULT 0 COMMENT 'status',
`batch_model` boolean NOT NULL DEFAULT false COMMENT 'is batch model',
`type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'job type',
`statement` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'statement set',
`error` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT 'error message',
......
......@@ -1351,6 +1351,7 @@ CREATE TABLE "public"."dinky_history" (
"job_id" varchar(50) COLLATE "pg_catalog"."default",
"job_name" varchar(255) COLLATE "pg_catalog"."default",
"job_manager_address" varchar(255) COLLATE "pg_catalog"."default",
"batch_model" boolean COLLATE "pg_catalog"."default",
"status" int4 NOT null,
"type" varchar(50) COLLATE "pg_catalog"."default",
"statement" text COLLATE "pg_catalog"."default",
......
......@@ -286,7 +286,7 @@ UPDATE dinky_task_version SET task_configure=JSON_REMOVE(task_configure, '$.jarI
UPDATE dinky_history SET config_json=JSON_REMOVE(config_json, '$.jarId');
UPDATE dinky_history SET config_json=JSON_REMOVE(config_json, '$.jarTask');
UPDATE dinky_history SET config_json=JSON_REMOVE(config_json, '$.session');
alter table dinky_history add batch_model boolean default false null after job_manager_address;
insert into `dinky_flink_document`
(id, category, type, subtype, name, description, fill_value, version, like_num, enabled, create_time, update_time)
values (218, 'Reference', '建表语句', 'Streaming', 'EXECUTE CDCSOURCE print', 'Whole library synchronization print', 'EXECUTE CDCSOURCE demo_print WITH (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment