From 0ac193f6993fe9c8faddae494900d5fbb344371f Mon Sep 17 00:00:00 2001 From: ikiler Date: Thu, 25 Jan 2024 22:37:10 +0800 Subject: [PATCH 1/2] Fixed the issue that the address of the jobmanager was not changed --- .../dinky/data/dto/ClusterInstanceDTO.java | 23 ++------------ .../org/dinky/data/model/ClusterInstance.java | 13 -------- .../dinky/job/handler/Job2MysqlHandler.java | 30 ++++++++++--------- .../impl/ClusterInstanceServiceImpl.java | 14 ++++----- .../JobDetail/JobOperator/JobOperator.tsx | 2 +- 5 files changed, 26 insertions(+), 56 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/data/dto/ClusterInstanceDTO.java b/dinky-admin/src/main/java/org/dinky/data/dto/ClusterInstanceDTO.java index 3f6cf6eb70..e540a1fd34 100644 --- a/dinky-admin/src/main/java/org/dinky/data/dto/ClusterInstanceDTO.java +++ b/dinky-admin/src/main/java/org/dinky/data/dto/ClusterInstanceDTO.java @@ -19,6 +19,7 @@ package org.dinky.data.dto; +import lombok.Builder; import org.dinky.data.model.ClusterInstance; import org.dinky.mybatis.annotation.Save; @@ -40,6 +41,7 @@ @NoArgsConstructor @AllArgsConstructor @ApiModel(value = "ClusterInstanceDTO", description = "API Cluster Instance Data Transfer Object") +@Builder public class ClusterInstanceDTO { @ApiModelProperty(value = "id", required = true, dataType = "Integer", example = "id") @@ -67,14 +69,6 @@ public class ClusterInstanceDTO { @ApiModelProperty(value = "hosts", required = true, dataType = "String", example = "test", notes = "cluster hosts") private String hosts; - @ApiModelProperty( - value = "jobManagerHost", - required = true, - dataType = "String", - example = "test", - notes = "job manager host") - private String jobManagerHost; - @ApiModelProperty( value = "autoRegisters", required = true, @@ -106,17 +100,4 @@ public ClusterInstance toBean() { return clusterInstance; } - public static ClusterInstanceDTO autoRegistersClusterDTO( - String hosts, String name, String alias, String type, Integer clusterConfigurationId, Integer taskId) { - ClusterInstanceDTO clusterInstanceDTO = new ClusterInstanceDTO(); - clusterInstanceDTO.setName(name); - clusterInstanceDTO.setAlias(alias); - clusterInstanceDTO.setHosts(hosts); - clusterInstanceDTO.setType(type); - clusterInstanceDTO.setClusterConfigurationId(clusterConfigurationId); - clusterInstanceDTO.setTaskId(taskId); - clusterInstanceDTO.setAutoRegisters(true); - clusterInstanceDTO.setEnabled(true); - return clusterInstanceDTO; - } } diff --git a/dinky-admin/src/main/java/org/dinky/data/model/ClusterInstance.java b/dinky-admin/src/main/java/org/dinky/data/model/ClusterInstance.java index 5bc81ecd1f..fa90c4de6a 100644 --- a/dinky-admin/src/main/java/org/dinky/data/model/ClusterInstance.java +++ b/dinky-admin/src/main/java/org/dinky/data/model/ClusterInstance.java @@ -112,17 +112,4 @@ public class ClusterInstance extends SuperEntity { @ApiModelProperty(value = "taskId", required = true, dataType = "Integer", example = "test", notes = "task id") private Integer taskId; - public static ClusterInstance autoRegistersCluster( - String hosts, String name, String alias, String type, Integer clusterConfigurationId, Integer taskId) { - ClusterInstance clusterInstance = new ClusterInstance(); - clusterInstance.setName(name); - clusterInstance.setAlias(alias); - clusterInstance.setHosts(hosts); - clusterInstance.setType(type); - clusterInstance.setClusterConfigurationId(clusterConfigurationId); - clusterInstance.setTaskId(taskId); - clusterInstance.setAutoRegisters(true); - clusterInstance.setEnabled(true); - return clusterInstance; - } } diff --git a/dinky-admin/src/main/java/org/dinky/job/handler/Job2MysqlHandler.java b/dinky-admin/src/main/java/org/dinky/job/handler/Job2MysqlHandler.java index feeb154d34..2a59300bc5 100644 --- a/dinky-admin/src/main/java/org/dinky/job/handler/Job2MysqlHandler.java +++ b/dinky-admin/src/main/java/org/dinky/job/handler/Job2MysqlHandler.java @@ -132,26 +132,28 @@ public boolean success() { ClusterInstance clusterInstance; final Integer clusterConfigurationId = job.getJobConfig().getClusterConfigurationId(); if (job.isUseGateway()) { - clusterInstance = clusterInstanceService.registersCluster(ClusterInstanceDTO.autoRegistersClusterDTO( - job.getJobManagerAddress(), - job.getJobId(), - job.getJobConfig().getJobName() + "_" + LocalDateTime.now(), - job.getType().getLongValue(), - clusterConfigurationId, - taskId)); + clusterInstance = clusterInstanceService.registersCluster(ClusterInstanceDTO.builder() + .hosts(job.getJobManagerAddress()) + .name(job.getJobId()) + .alias(job.getJobConfig().getJobName() + "_" + LocalDateTime.now()) + .type(job.getType().getLongValue()) + .clusterConfigurationId(clusterConfigurationId) + .taskId(taskId).autoRegisters(true).enabled(true) + .build()); + if (Asserts.isNotNull(clusterInstance)) { clusterId = clusterInstance.getId(); } } else if (GatewayType.LOCAL.equalsValue(job.getJobConfig().getType()) && Asserts.isNotNullString(job.getJobManagerAddress()) && Asserts.isNotNullString(job.getJobId())) { - clusterInstance = clusterInstanceService.registersCluster(ClusterInstanceDTO.autoRegistersClusterDTO( - job.getJobManagerAddress(), - job.getJobId(), - job.getJobConfig().getJobName() + "_" + LocalDateTime.now(), - job.getType().getLongValue(), - null, - taskId)); + clusterInstance = clusterInstanceService.registersCluster(ClusterInstanceDTO.builder() + .hosts(job.getJobManagerAddress()) + .name(job.getJobId()) + .alias(job.getJobConfig().getJobName() + "_" + LocalDateTime.now()) + .type(job.getType().getLongValue()) + .taskId(taskId).autoRegisters(true).enabled(true) + .build()); if (Asserts.isNotNull(clusterInstance)) { clusterId = clusterInstance.getId(); } diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/ClusterInstanceServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/ClusterInstanceServiceImpl.java index 6805406e13..a0a5494ed0 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/ClusterInstanceServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/ClusterInstanceServiceImpl.java @@ -233,13 +233,13 @@ public ClusterInstance deploySessionCluster(Integer id) { GatewayResult gatewayResult = JobManager.deploySessionCluster(gatewayConfig); if (gatewayResult.isSuccess()) { Asserts.checkNullString(gatewayResult.getWebURL(), "Unable to obtain Web URL."); - return registersCluster(ClusterInstanceDTO.autoRegistersClusterDTO( - gatewayResult.getWebURL().replace("http://", ""), - gatewayResult.getId(), - clusterCfg.getName() + "_" + LocalDateTime.now(), - gatewayConfig.getType().getLongValue(), - id, - null)); + return registersCluster(ClusterInstanceDTO.builder() + .hosts(gatewayResult.getWebURL().replace("http://", "")) + .name(gatewayResult.getId()) + .alias(clusterCfg.getName() + "_" + LocalDateTime.now()) + .type(gatewayConfig.getType().getLongValue()) + .clusterConfigurationId(id).autoRegisters(true).enabled(true) + .build()); } throw new DinkyException("Deploy session cluster error: " + gatewayResult.getError()); } diff --git a/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx b/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx index 4d9982f777..ffa724fbab 100644 --- a/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx +++ b/dinky-web/src/pages/DevOps/JobDetail/JobOperator/JobOperator.tsx @@ -39,7 +39,7 @@ export type OperatorType = { }; const JobOperator = (props: OperatorType) => { const { jobDetail, refesh } = props; - const webUri = `/api/flink/${jobDetail?.history?.jobManagerAddress}/#/job/running/${jobDetail?.instance?.jid}/overview`; + const webUri = `/api/flink/${jobDetail?.clusterInstance?.jobManagerHost}/#/job/running/${jobDetail?.instance?.jid}/overview`; const handleJobOperator = (key: string) => { Modal.confirm({ From 73f07221da71ff6823fafaf5631b662fa367a6db Mon Sep 17 00:00:00 2001 From: gaoyan1998 Date: Thu, 25 Jan 2024 14:39:31 +0000 Subject: [PATCH 2/2] Spotless Apply --- .../main/java/org/dinky/data/dto/ClusterInstanceDTO.java | 3 +-- .../main/java/org/dinky/data/model/ClusterInstance.java | 1 - .../main/java/org/dinky/job/handler/Job2MysqlHandler.java | 8 ++++++-- .../dinky/service/impl/ClusterInstanceServiceImpl.java | 4 +++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/data/dto/ClusterInstanceDTO.java b/dinky-admin/src/main/java/org/dinky/data/dto/ClusterInstanceDTO.java index e540a1fd34..47a5509539 100644 --- a/dinky-admin/src/main/java/org/dinky/data/dto/ClusterInstanceDTO.java +++ b/dinky-admin/src/main/java/org/dinky/data/dto/ClusterInstanceDTO.java @@ -19,7 +19,6 @@ package org.dinky.data.dto; -import lombok.Builder; import org.dinky.data.model.ClusterInstance; import org.dinky.mybatis.annotation.Save; @@ -29,6 +28,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; @@ -99,5 +99,4 @@ public ClusterInstance toBean() { BeanUtil.copyProperties(this, clusterInstance); return clusterInstance; } - } diff --git a/dinky-admin/src/main/java/org/dinky/data/model/ClusterInstance.java b/dinky-admin/src/main/java/org/dinky/data/model/ClusterInstance.java index fa90c4de6a..269a3fe757 100644 --- a/dinky-admin/src/main/java/org/dinky/data/model/ClusterInstance.java +++ b/dinky-admin/src/main/java/org/dinky/data/model/ClusterInstance.java @@ -111,5 +111,4 @@ public class ClusterInstance extends SuperEntity { @ApiModelProperty(value = "taskId", required = true, dataType = "Integer", example = "test", notes = "task id") private Integer taskId; - } diff --git a/dinky-admin/src/main/java/org/dinky/job/handler/Job2MysqlHandler.java b/dinky-admin/src/main/java/org/dinky/job/handler/Job2MysqlHandler.java index 2a59300bc5..b30f667cf0 100644 --- a/dinky-admin/src/main/java/org/dinky/job/handler/Job2MysqlHandler.java +++ b/dinky-admin/src/main/java/org/dinky/job/handler/Job2MysqlHandler.java @@ -138,7 +138,9 @@ public boolean success() { .alias(job.getJobConfig().getJobName() + "_" + LocalDateTime.now()) .type(job.getType().getLongValue()) .clusterConfigurationId(clusterConfigurationId) - .taskId(taskId).autoRegisters(true).enabled(true) + .taskId(taskId) + .autoRegisters(true) + .enabled(true) .build()); if (Asserts.isNotNull(clusterInstance)) { @@ -152,7 +154,9 @@ public boolean success() { .name(job.getJobId()) .alias(job.getJobConfig().getJobName() + "_" + LocalDateTime.now()) .type(job.getType().getLongValue()) - .taskId(taskId).autoRegisters(true).enabled(true) + .taskId(taskId) + .autoRegisters(true) + .enabled(true) .build()); if (Asserts.isNotNull(clusterInstance)) { clusterId = clusterInstance.getId(); diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/ClusterInstanceServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/ClusterInstanceServiceImpl.java index a0a5494ed0..4c56bae45f 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/ClusterInstanceServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/ClusterInstanceServiceImpl.java @@ -238,7 +238,9 @@ public ClusterInstance deploySessionCluster(Integer id) { .name(gatewayResult.getId()) .alias(clusterCfg.getName() + "_" + LocalDateTime.now()) .type(gatewayConfig.getType().getLongValue()) - .clusterConfigurationId(id).autoRegisters(true).enabled(true) + .clusterConfigurationId(id) + .autoRegisters(true) + .enabled(true) .build()); } throw new DinkyException("Deploy session cluster error: " + gatewayResult.getError());