From cc604704bb9d48c37fc958d211cf34bac91ceef4 Mon Sep 17 00:00:00 2001 From: gaoyan Date: Fri, 26 Jan 2024 09:43:53 +0800 Subject: [PATCH] [Fix] Fixed the issue that the address of the jobmanager was not changed in modify cluster instance (#3070) Co-authored-by: gaoyan1998 --- .../dinky/data/dto/ClusterInstanceDTO.java | 24 ++----------- .../org/dinky/data/model/ClusterInstance.java | 14 -------- .../dinky/job/handler/Job2MysqlHandler.java | 34 +++++++++++-------- .../impl/ClusterInstanceServiceImpl.java | 16 +++++---- .../JobDetail/JobOperator/JobOperator.tsx | 2 +- 5 files changed, 32 insertions(+), 58 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..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 @@ -28,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; @@ -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, @@ -105,18 +99,4 @@ public ClusterInstance toBean() { BeanUtil.copyProperties(this, clusterInstance); 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..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,18 +111,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..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 @@ -132,26 +132,32 @@ 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..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 @@ -233,13 +233,15 @@ 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({