From 773c3a38ccfb81bfa64c8f4cb1aa813beec4da78 Mon Sep 17 00:00:00 2001 From: hawk9821 <39961809+hawk9821@users.noreply.github.com> Date: Sat, 11 May 2024 23:17:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=9B=86=E7=BE=A4=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E6=9C=8D=E5=8A=A1=EF=BC=8C=E6=9C=AA=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E6=9C=8D=E5=8A=A1=E7=9A=84=E5=8F=82=E6=95=B0?= =?UTF-8?q?=EF=BC=88t=5Fddh=5Fcluster=5Fvariable=EF=BC=8CGlobalVariables?= =?UTF-8?q?=EF=BC=89=20(#546)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Bug] Doris] DDP1.2.2,使用doris官方包安装be失败 #539 * [Bug] [datasophon-api] 集群安装服务失败,删除服务重新安装,因为没有删除失败服务的全局参数(t_ddh_cluster_variable,GlobalVariables), 重新安装任然使用安装失败时配置的参数(Doirs2.0.7) #545 --- .../db/migration/1.2.1/V1.2.1__DDL.sql | 1 + .../meta/DDP-1.2.2/DORIS/service_ddl.json | 7 +- .../dao/entity/ClusterVariable.java | 20 +-- .../api/service/ClusterVariableService.java | 6 +- .../ClusterServiceInstanceServiceImpl.java | 19 ++- .../impl/ClusterVariableServiceImpl.java | 11 +- .../api/service/impl/InstallServiceImpl.java | 28 ++--- .../impl/ServiceInstallServiceImpl.java | 12 +- .../strategy/AlertManagerHandlerStrategy.java | 7 +- .../api/strategy/BEHandlerStartegy.java | 4 +- .../ElasticSearchHandlerStrategy.java | 8 +- .../api/strategy/FEHandlerStartegy.java | 6 +- .../strategy/FEObserverHandlerStartegy.java | 5 +- .../api/strategy/FlinkHandlerStrategy.java | 4 +- .../api/strategy/GrafanaHandlerStrategy.java | 6 +- .../api/strategy/HBaseHandlerStrategy.java | 4 +- .../HistoryServerHandlerStrategy.java | 6 +- .../HiveMetaStroreHandlerStrategy.java | 6 +- .../strategy/HiveServer2HandlerStrategy.java | 11 +- .../api/strategy/HttpFsHandlerStrategy.java | 6 +- .../strategy/JournalNodeHandlerStrategy.java | 10 +- .../api/strategy/KAdminHandlerStrategy.java | 14 +-- .../api/strategy/KafkaHandlerStrategy.java | 4 +- .../api/strategy/KerberosHandlerStrategy.java | 12 +- .../api/strategy/Krb5KdcHandlerStrategy.java | 14 +-- .../strategy/KyuubiServerHandlerStrategy.java | 10 +- .../api/strategy/NameNodeHandlerStrategy.java | 8 +- .../strategy/PrometheusHandlerStrategy.java | 4 +- .../api/strategy/RMHandlerStrategy.java | 18 +-- .../strategy/RangerAdminHandlerStrategy.java | 14 +-- .../api/strategy/ServiceHandlerAbstract.java | 8 +- .../api/strategy/ServiceRoleStrategy.java | 4 +- .../strategy/ServiceRoleStrategyContext.java | 114 ++++++++++++------ .../api/strategy/TSHandlerStrategy.java | 6 +- .../api/strategy/TrinoHandlerStrategy.java | 6 +- .../api/strategy/ZKFCHandlerStrategy.java | 13 +- .../api/strategy/ZkServerHandlerStrategy.java | 17 ++- .../datasophon/api/utils/ProcessUtils.java | 4 +- 38 files changed, 262 insertions(+), 195 deletions(-) diff --git a/datasophon-api/src/main/resources/db/migration/1.2.1/V1.2.1__DDL.sql b/datasophon-api/src/main/resources/db/migration/1.2.1/V1.2.1__DDL.sql index e69de29b..e7add5c8 100644 --- a/datasophon-api/src/main/resources/db/migration/1.2.1/V1.2.1__DDL.sql +++ b/datasophon-api/src/main/resources/db/migration/1.2.1/V1.2.1__DDL.sql @@ -0,0 +1 @@ +ALTER TABLE t_ddh_cluster_variable ADD service_name VARCHAR(128) DEFAULT '' COMMENT '服务名'; diff --git a/datasophon-api/src/main/resources/meta/DDP-1.2.2/DORIS/service_ddl.json b/datasophon-api/src/main/resources/meta/DDP-1.2.2/DORIS/service_ddl.json index ec316e88..a7749d8d 100644 --- a/datasophon-api/src/main/resources/meta/DDP-1.2.2/DORIS/service_ddl.json +++ b/datasophon-api/src/main/resources/meta/DDP-1.2.2/DORIS/service_ddl.json @@ -90,11 +90,6 @@ "from": "script/status_be.sh", "to": "be/bin/status_be.sh", "md5": "cb2df48c72383f61613660da7e942ef7" - }, { - "type": "replace", - "source": "be/bin/start_be.sh", - "regex":"\/bin\/limit3", - "replacement": "/usr/bin/ulimit" }], "startRunner": { "timeout": "600", @@ -367,4 +362,4 @@ "defaultValue": "" } ] -} \ No newline at end of file +} diff --git a/datasophon-infrastructure/src/main/java/com/datasophon/dao/entity/ClusterVariable.java b/datasophon-infrastructure/src/main/java/com/datasophon/dao/entity/ClusterVariable.java index 6e587b9f..81525458 100644 --- a/datasophon-infrastructure/src/main/java/com/datasophon/dao/entity/ClusterVariable.java +++ b/datasophon-infrastructure/src/main/java/com/datasophon/dao/entity/ClusterVariable.java @@ -17,12 +17,11 @@ package com.datasophon.dao.entity; -import java.io.Serializable; - -import lombok.Data; - import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; @Data @TableName("t_ddh_cluster_variable") @@ -31,21 +30,26 @@ public class ClusterVariable implements Serializable { private static final long serialVersionUID = 1L; /** - * + * */ @TableId private Integer id; /** - * + * */ private Integer clusterId; /** - * + * */ private String variableName; /** - * + * */ private String variableValue; + /** + * + */ + private String serviceName; + } diff --git a/datasophon-service/src/main/java/com/datasophon/api/service/ClusterVariableService.java b/datasophon-service/src/main/java/com/datasophon/api/service/ClusterVariableService.java index 7a202850..eb9cee00 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/service/ClusterVariableService.java +++ b/datasophon-service/src/main/java/com/datasophon/api/service/ClusterVariableService.java @@ -20,8 +20,10 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.datasophon.dao.entity.ClusterVariable; +import java.util.List; + /** - * + * * * @author gaodayu * @email gaodayu2022@163.com @@ -30,4 +32,6 @@ public interface ClusterVariableService extends IService { ClusterVariable getVariableByVariableName(String variableName, Integer clusterId); + + List getVariables(Integer clusterId, String serviceName); } diff --git a/datasophon-service/src/main/java/com/datasophon/api/service/impl/ClusterServiceInstanceServiceImpl.java b/datasophon-service/src/main/java/com/datasophon/api/service/impl/ClusterServiceInstanceServiceImpl.java index e5c61903..286ead36 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/service/impl/ClusterServiceInstanceServiceImpl.java +++ b/datasophon-service/src/main/java/com/datasophon/api/service/impl/ClusterServiceInstanceServiceImpl.java @@ -25,6 +25,7 @@ import com.datasophon.api.service.*; import com.datasophon.common.Constants; import com.datasophon.common.model.SimpleServiceConfig; +import com.datasophon.common.utils.CollectionUtils; import com.datasophon.common.utils.PlaceholderUtils; import com.datasophon.common.utils.Result; import com.datasophon.dao.entity.*; @@ -46,9 +47,9 @@ @Transactional public class ClusterServiceInstanceServiceImpl extends - ServiceImpl + ServiceImpl implements - ClusterServiceInstanceService { + ClusterServiceInstanceService { @Autowired private ClusterServiceInstanceMapper serviceInstanceMapper; @@ -77,6 +78,9 @@ public class ClusterServiceInstanceServiceImpl @Autowired private ClusterServiceRoleInstanceWebuisService webuisService; + @Autowired + private ClusterVariableService variableService; + @Override public ClusterServiceInstanceEntity getServiceInstanceByClusterIdAndServiceName(Integer clusterId, String serviceName) { @@ -243,6 +247,15 @@ public Result delServiceInstance(Integer serviceInstanceId) { // del service instance this.removeById(serviceInstanceId); + // del variable + roleGroups.forEach(roleGroup -> { + List variables = variableService.getVariables(roleGroup.getClusterId(), roleGroup.getServiceName()); + if (CollectionUtils.isNotEmpty(variables)) { + Map variablesMap = GlobalVariables.get(roleGroup.getClusterId()); + variables.forEach(var -> variablesMap.remove(var.getVariableName())); + variableService.removeByIds(variables.stream().map(ClusterVariable::getId).collect(Collectors.toList())); + } + }); return Result.success(); } @@ -256,6 +269,6 @@ public List listRunningServiceInstance(Integer clu public boolean hasRunningRoleInstance(Integer serviceInstanceId) { List list = roleInstanceService.getRunningServiceRoleInstanceListByServiceId(serviceInstanceId); - return !list.isEmpty(); + return !list.isEmpty(); } } diff --git a/datasophon-service/src/main/java/com/datasophon/api/service/impl/ClusterVariableServiceImpl.java b/datasophon-service/src/main/java/com/datasophon/api/service/impl/ClusterVariableServiceImpl.java index 0e3e9770..9077c46d 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/service/impl/ClusterVariableServiceImpl.java +++ b/datasophon-service/src/main/java/com/datasophon/api/service/impl/ClusterVariableServiceImpl.java @@ -17,6 +17,7 @@ package com.datasophon.api.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.datasophon.api.service.ClusterVariableService; @@ -31,7 +32,7 @@ @Service("clusterVariableService") public class ClusterVariableServiceImpl extends ServiceImpl implements - ClusterVariableService { + ClusterVariableService { @Override public ClusterVariable getVariableByVariableName(String variableName, Integer clusterId) { @@ -42,4 +43,12 @@ public ClusterVariable getVariableByVariableName(String variableName, Integer cl } return null; } + + @Override + public List getVariables(Integer clusterId, String serviceName) { + return this.list(new LambdaQueryWrapper() + .eq(ClusterVariable::getClusterId, clusterId) + .eq(ClusterVariable::getServiceName, serviceName) + ); + } } diff --git a/datasophon-service/src/main/java/com/datasophon/api/service/impl/InstallServiceImpl.java b/datasophon-service/src/main/java/com/datasophon/api/service/impl/InstallServiceImpl.java index 74e515cc..8953d8af 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/service/impl/InstallServiceImpl.java +++ b/datasophon-service/src/main/java/com/datasophon/api/service/impl/InstallServiceImpl.java @@ -106,14 +106,14 @@ public Result getInstallStep(Integer type) { */ @Override public Result analysisHostList( - Integer clusterId, - String hosts, - String sshUser, - Integer sshPort, - Integer page, - Integer pageSize) { + Integer clusterId, + String hosts, + String sshUser, + Integer sshPort, + Integer page, + Integer pageSize) { Map globalVariables = GlobalVariables.get(clusterId); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, SSHUSER, sshUser); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, null, SSHUSER, sshUser); List list = new ArrayList<>(); hosts = hosts.replace(" ", ""); @@ -199,7 +199,7 @@ private void tellHostCheck(String clusterCode, HostInfo hostInfo) { } public HostInfo createHostInfo( - String host, Integer sshPort, String sshUser, String clusterCode) { + String host, Integer sshPort, String sshUser, String clusterCode) { HostInfo hostInfo = new HostInfo(); hostInfo.setHostname(HostUtils.getHostName(host)); @@ -248,7 +248,7 @@ public Result getHostCheckStatus(Integer clusterId, String sshUser, Integer sshP @Override public Result rehostCheck( - Integer clusterId, String hostnames, String sshUser, Integer sshPort) { + Integer clusterId, String hostnames, String sshUser, Integer sshPort) { // 开启主机校验 ClusterInfoEntity clusterInfo = clusterInfoService.getById(clusterId); String clusterCode = clusterInfo.getClusterCode(); @@ -271,7 +271,7 @@ public Result rehostCheck( @Override public Result dispatcherHostAgentList( - Integer clusterId, Integer installStateCode, Integer page, Integer pageSize) { + Integer clusterId, Integer installStateCode, Integer page, Integer pageSize) { ClusterInfoEntity clusterInfo = clusterInfoService.getById(clusterId); String clusterCode = clusterInfo.getClusterCode(); @@ -380,7 +380,7 @@ public Result hostCheckCompleted(Integer clusterId) { HostInfo value = hostInfoEntry.getValue(); if (Objects.isNull(value.getCheckResult()) || (Objects.nonNull(value.getCheckResult()) - && value.getCheckResult().getCode() != 10001)) { + && value.getCheckResult().getCode() != 10001)) { return Result.success().put("hostCheckCompleted", false); } } @@ -389,7 +389,7 @@ public Result hostCheckCompleted(Integer clusterId) { @Override public Result cancelDispatcherHostAgent( - Integer clusterId, String hostname, Integer installStateCode) { + Integer clusterId, String hostname, Integer installStateCode) { return null; } @@ -430,7 +430,7 @@ public Result generateHostAgentCommand(String clusterHostIds, String commandType MinaUtils.execCmdWithResult(session, "service datasophon-worker " + commandType); logger.info("hostAgent command:{}", "service datasophon-worker " + commandType); if (ObjectUtil.isNotEmpty(session)) { - session.close(); + session.close(); } } return Result.success(); @@ -456,7 +456,7 @@ public Result generateHostServiceCommand(String clusterHostIds, String commandTy CommandType serviceCommandType = "start".equalsIgnoreCase(commandType) ? CommandType.START_SERVICE : CommandType.STOP_SERVICE; for (ClusterHostDO clusterHostDO : clusterHostList) { WorkerServiceMessage serviceMessage = new WorkerServiceMessage( - clusterHostDO.getHostname(), clusterHostDO.getClusterId(), serviceCommandType); + clusterHostDO.getHostname(), clusterHostDO.getClusterId(), serviceCommandType); try { ActorRef actor = ActorUtils.getLocalActor(WorkerStartActor.class, "workerStartActor"); diff --git a/datasophon-service/src/main/java/com/datasophon/api/service/impl/ServiceInstallServiceImpl.java b/datasophon-service/src/main/java/com/datasophon/api/service/impl/ServiceInstallServiceImpl.java index a48fc15b..126a5abb 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/service/impl/ServiceInstallServiceImpl.java +++ b/datasophon-service/src/main/java/com/datasophon/api/service/impl/ServiceInstallServiceImpl.java @@ -157,7 +157,7 @@ public Result saveServiceConfig( ServiceRoleStrategy serviceRoleHandler = ServiceRoleStrategyContext.getServiceRoleHandler(serviceName); if (Objects.nonNull(serviceRoleHandler)) { - serviceRoleHandler.handlerConfig(clusterId, list); + serviceRoleHandler.handlerConfig(clusterId, list, ServiceRoleStrategyContext.getServiceName(serviceName)); } // add variable FrameServiceEntity frameServiceEntity = @@ -170,7 +170,7 @@ public Result saveServiceConfig( String variableValue = String.valueOf(serviceConfig.getValue()); // add to global variable if (Constants.INPUT.equals(serviceConfig.getType())) { - addToGlobalVariable(clusterId, variableName, variableValue); + addToGlobalVariable(clusterId, serviceName, variableName, variableValue); } globalVariables.put(variableName, variableValue); map.put(serviceConfig.getName(), serviceConfig); @@ -264,8 +264,10 @@ public Result saveServiceRoleHostMapping(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/BEHandlerStartegy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/BEHandlerStartegy.java index 38e705f7..71fedef7 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/BEHandlerStartegy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/BEHandlerStartegy.java @@ -37,12 +37,12 @@ public class BEHandlerStartegy implements ServiceRoleStrategy { private static final Logger logger = LoggerFactory.getLogger(BEHandlerStartegy.class); @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/ElasticSearchHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/ElasticSearchHandlerStrategy.java index 3479a550..d4be8a93 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/ElasticSearchHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/ElasticSearchHandlerStrategy.java @@ -46,18 +46,18 @@ public class ElasticSearchHandlerStrategy implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${initMasterNodes}", String.join(",", hosts)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${initMasterNodes}", String.join(",", hosts)); String join = String.join(":9300,", hosts); String seedHosts = join + ":9300"; - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${seedHosts}", seedHosts); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${seedHosts}", seedHosts); } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/FEHandlerStartegy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/FEHandlerStartegy.java index b8afd3a8..ea91ba32 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/FEHandlerStartegy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/FEHandlerStartegy.java @@ -38,19 +38,19 @@ public class FEHandlerStartegy implements ServiceRoleStrategy { private static final Logger logger = LoggerFactory.getLogger(FEHandlerStartegy.class); @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); // if feMaster is null, set the first host as feMaster //Prevent FE Observer nodes from starting and FE Master nodes from changing if (!globalVariables.containsKey("${feMaster}") || ObjUtil.isNull(globalVariables.get("${feMaster}"))) { if (!hosts.isEmpty()) { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${feMaster}", hosts.get(0)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${feMaster}", hosts.get(0)); } } } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/FEObserverHandlerStartegy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/FEObserverHandlerStartegy.java index cfeac1e6..b5dc4cff 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/FEObserverHandlerStartegy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/FEObserverHandlerStartegy.java @@ -17,7 +17,6 @@ package com.datasophon.api.strategy; -import cn.hutool.core.util.ObjUtil; import com.datasophon.api.load.GlobalVariables; import com.datasophon.api.utils.ProcessUtils; import com.datasophon.common.model.ProcInfo; @@ -38,12 +37,12 @@ public class FEObserverHandlerStartegy implements ServiceRoleStrategy { private static final Logger logger = LoggerFactory.getLogger(FEObserverHandlerStartegy.class); @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/FlinkHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/FlinkHandlerStrategy.java index 2a638a18..a533aef8 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/FlinkHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/FlinkHandlerStrategy.java @@ -33,12 +33,12 @@ public class FlinkHandlerStrategy extends ServiceHandlerAbstract implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); ClusterInfoEntity clusterInfo = ProcessUtils.getClusterInfo(clusterId); boolean enableJM2HA = false; diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/GrafanaHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/GrafanaHandlerStrategy.java index c688b325..d66ebc98 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/GrafanaHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/GrafanaHandlerStrategy.java @@ -30,16 +30,16 @@ public class GrafanaHandlerStrategy implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); if (hosts.size() == 1) { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${grafanaHost}", + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${grafanaHost}", HostUtils.getIp(hosts.get(0))); } } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/HBaseHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/HBaseHandlerStrategy.java index 565d789c..96afe0b3 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/HBaseHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/HBaseHandlerStrategy.java @@ -33,12 +33,12 @@ public class HBaseHandlerStrategy extends ServiceHandlerAbstract implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); ClusterInfoEntity clusterInfo = ProcessUtils.getClusterInfo(clusterId); boolean enableKerberos = false; diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/HistoryServerHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/HistoryServerHandlerStrategy.java index c2db103d..48f693ea 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/HistoryServerHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/HistoryServerHandlerStrategy.java @@ -29,15 +29,15 @@ public class HistoryServerHandlerStrategy implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); if (hosts.size() == 1) { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${historyserverHost}", hosts.get(0)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${historyserverHost}", hosts.get(0)); } } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/HiveMetaStroreHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/HiveMetaStroreHandlerStrategy.java index e2f25870..80c657c3 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/HiveMetaStroreHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/HiveMetaStroreHandlerStrategy.java @@ -29,15 +29,15 @@ public class HiveMetaStroreHandlerStrategy implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); if (hosts.size() == 1) { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${metastoreHost}", hosts.get(0)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${metastoreHost}", hosts.get(0)); } } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/HiveServer2HandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/HiveServer2HandlerStrategy.java index a1caf812..e831f867 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/HiveServer2HandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/HiveServer2HandlerStrategy.java @@ -27,29 +27,28 @@ import com.datasophon.common.utils.PlaceholderUtils; import com.datasophon.dao.entity.ClusterInfoEntity; import com.datasophon.dao.entity.ClusterServiceRoleInstanceEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class HiveServer2HandlerStrategy extends ServiceHandlerAbstract implements ServiceRoleStrategy { private static final Logger logger = LoggerFactory.getLogger(HiveServer2HandlerStrategy.class); @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); CacheUtils.put("enableHiveServer2HA", false); if (hosts.size() > 1) { CacheUtils.put("enableHiveServer2HA", true); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${masterHiveServer2}", hosts.get(0)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${masterHiveServer2}", hosts.get(0)); } } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); ClusterInfoEntity clusterInfo = ProcessUtils.getClusterInfo(clusterId); boolean enableKerberos = false; diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/HttpFsHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/HttpFsHandlerStrategy.java index 9251436b..15fc7fef 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/HttpFsHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/HttpFsHandlerStrategy.java @@ -13,15 +13,15 @@ public class HttpFsHandlerStrategy implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); if (CollUtil.isNotEmpty(hosts)) { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${httpFs}", hosts.get(0)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${httpFs}", hosts.get(0)); } } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/JournalNodeHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/JournalNodeHandlerStrategy.java index beb7cdaa..ad11f98b 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/JournalNodeHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/JournalNodeHandlerStrategy.java @@ -29,17 +29,17 @@ public class JournalNodeHandlerStrategy implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); if (hosts.size() >= 3) { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${journalNode1}", hosts.get(0)); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${journalNode2}", hosts.get(1)); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${journalNode3}", hosts.get(2)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${journalNode1}", hosts.get(0)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${journalNode2}", hosts.get(1)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${journalNode3}", hosts.get(2)); } } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/KAdminHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/KAdminHandlerStrategy.java index 022965e5..d79bba5a 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/KAdminHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/KAdminHandlerStrategy.java @@ -17,6 +17,9 @@ package com.datasophon.api.strategy; +import akka.actor.ActorSelection; +import akka.pattern.Patterns; +import akka.util.Timeout; import com.datasophon.api.load.GlobalVariables; import com.datasophon.api.load.ServiceInfoMap; import com.datasophon.api.load.ServiceRoleMap; @@ -31,7 +34,6 @@ import com.datasophon.dao.entity.ClusterInfoEntity; import com.datasophon.dao.entity.ClusterServiceRoleInstanceEntity; import com.datasophon.dao.enums.AlertLevel; - import scala.concurrent.Await; import scala.concurrent.Future; import scala.concurrent.duration.Duration; @@ -41,22 +43,18 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import akka.actor.ActorSelection; -import akka.pattern.Patterns; -import akka.util.Timeout; - public class KAdminHandlerStrategy implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); if (hosts.size() >= 1) { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${kadminHost}", hosts.get(0)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName, "${kadminHost}", hosts.get(0)); } } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/KafkaHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/KafkaHandlerStrategy.java index 0ea304c1..ee942ce8 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/KafkaHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/KafkaHandlerStrategy.java @@ -33,12 +33,12 @@ public class KafkaHandlerStrategy extends ServiceHandlerAbstract implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); ClusterInfoEntity clusterInfo = ProcessUtils.getClusterInfo(clusterId); boolean enableKerberos = false; diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/KerberosHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/KerberosHandlerStrategy.java index 5224c2cb..c86c93c5 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/KerberosHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/KerberosHandlerStrategy.java @@ -17,6 +17,9 @@ package com.datasophon.api.strategy; +import akka.actor.ActorSelection; +import akka.pattern.Patterns; +import akka.util.Timeout; import com.datasophon.api.load.ServiceInfoMap; import com.datasophon.api.load.ServiceRoleMap; import com.datasophon.api.master.ActorUtils; @@ -30,7 +33,6 @@ import com.datasophon.dao.entity.ClusterInfoEntity; import com.datasophon.dao.entity.ClusterServiceRoleInstanceEntity; import com.datasophon.dao.enums.AlertLevel; - import scala.concurrent.Await; import scala.concurrent.Future; import scala.concurrent.duration.Duration; @@ -40,19 +42,15 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import akka.actor.ActorSelection; -import akka.pattern.Patterns; -import akka.util.Timeout; - public class KerberosHandlerStrategy implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/Krb5KdcHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/Krb5KdcHandlerStrategy.java index c68c4f4b..5f23c645 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/Krb5KdcHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/Krb5KdcHandlerStrategy.java @@ -17,6 +17,9 @@ package com.datasophon.api.strategy; +import akka.actor.ActorSelection; +import akka.pattern.Patterns; +import akka.util.Timeout; import com.datasophon.api.load.GlobalVariables; import com.datasophon.api.load.ServiceInfoMap; import com.datasophon.api.load.ServiceRoleMap; @@ -31,7 +34,6 @@ import com.datasophon.dao.entity.ClusterInfoEntity; import com.datasophon.dao.entity.ClusterServiceRoleInstanceEntity; import com.datasophon.dao.enums.AlertLevel; - import scala.concurrent.Await; import scala.concurrent.Future; import scala.concurrent.duration.Duration; @@ -41,22 +43,18 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import akka.actor.ActorSelection; -import akka.pattern.Patterns; -import akka.util.Timeout; - public class Krb5KdcHandlerStrategy implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); if (hosts.size() >= 1) { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${kdcHost}", hosts.get(0)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${kdcHost}", hosts.get(0)); } } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/KyuubiServerHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/KyuubiServerHandlerStrategy.java index 9486152e..4a7f0f16 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/KyuubiServerHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/KyuubiServerHandlerStrategy.java @@ -27,12 +27,12 @@ import com.datasophon.common.model.ServiceRoleInfo; import com.datasophon.dao.entity.ClusterInfoEntity; import com.datasophon.dao.entity.ClusterServiceRoleInstanceEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class KyuubiServerHandlerStrategy extends ServiceHandlerAbstract implements ServiceRoleStrategy{ @@ -41,12 +41,12 @@ public class KyuubiServerHandlerStrategy extends ServiceHandlerAbstract impleme private static final String ENABLE_KERBEROS = "enableKerberos"; @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); boolean enableKerberos = false; diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/NameNodeHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/NameNodeHandlerStrategy.java index fc1e46ab..e0ed49f9 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/NameNodeHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/NameNodeHandlerStrategy.java @@ -57,16 +57,16 @@ public class NameNodeHandlerStrategy extends ServiceHandlerAbstract implements S private static final String ACTIVE = "active"; @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${nn1}", hosts.get(0)); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${nn2}", hosts.get(1)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${nn1}", hosts.get(0)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${nn2}", hosts.get(1)); } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); ClusterInfoEntity clusterInfo = ProcessUtils.getClusterInfo(clusterId); diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/PrometheusHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/PrometheusHandlerStrategy.java index dea77502..6e3e5028 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/PrometheusHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/PrometheusHandlerStrategy.java @@ -45,12 +45,12 @@ public class PrometheusHandlerStrategy implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/RMHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/RMHandlerStrategy.java index a3367ce0..5427c255 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/RMHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/RMHandlerStrategy.java @@ -56,18 +56,18 @@ public class RMHandlerStrategy extends ServiceHandlerAbstract implements Service private static final String ACTIVE = "active"; @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${rm1}", hosts.get(0)); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${rm2}", hosts.get(1)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName, "${rm1}", hosts.get(0)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName, "${rm2}", hosts.get(1)); ProcessUtils.generateClusterVariable( - globalVariables, clusterId, "${rmHost}", String.join(",", hosts)); + globalVariables, clusterId, serviceName, "${rmHost}", String.join(",", hosts)); } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { ClusterYarnSchedulerService schedulerService = SpringTool.getApplicationContext().getBean(ClusterYarnSchedulerService.class); Map globalVariables = GlobalVariables.get(clusterId); @@ -122,11 +122,11 @@ public void handlerServiceRoleCheck( Map map) { Map globalVariable = GlobalVariables.get(roleInstanceEntity.getClusterId()); - String commandLine = getRMStateCommand(globalVariable,roleInstanceEntity.getHostname()); + String commandLine = getRMStateCommand(globalVariable, roleInstanceEntity.getHostname()); getRMState(roleInstanceEntity, commandLine); } - private String getRMStateCommand(Map globalVariable,String hostName) { + private String getRMStateCommand(Map globalVariable, String hostName) { String commandLine = null; String yarnAclAdminUser = globalVariable.get("${yarn.admin.acl}"); @@ -135,10 +135,10 @@ private String getRMStateCommand(Map globalVariable,String hostN if (StringUtils.isNotEmpty(yarnAclAdminUser)) { commandLine = String.format("sudo -u %s %s/bin/yarn rmadmin -getServiceState %s", - yarnAclAdminUser, globalVariable.get("${HADOOP_HOME}"),curRm); + yarnAclAdminUser, globalVariable.get("${HADOOP_HOME}"), curRm); } else { commandLine = String.format("%s/bin/yarn rmadmin -getServiceState %s", - globalVariable.get("${HADOOP_HOME}"),curRm); + globalVariable.get("${HADOOP_HOME}"), curRm); } return commandLine; } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/RangerAdminHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/RangerAdminHandlerStrategy.java index f0f3adad..759c29ff 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/RangerAdminHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/RangerAdminHandlerStrategy.java @@ -48,17 +48,17 @@ public class RangerAdminHandlerStrategy extends ServiceHandlerAbstract implement private static final Logger logger = LoggerFactory.getLogger(RangerAdminHandlerStrategy.class); @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); if (hosts.size() == 1) { String rangerAdminUrl = "http://" + hosts.get(0) + ":6080"; logger.info("rangerAdminUrl is {}", rangerAdminUrl); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${rangerAdminUrl}", rangerAdminUrl); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName, "${rangerAdminUrl}", rangerAdminUrl); } } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); ClusterInfoEntity clusterInfo = ProcessUtils.getClusterInfo(clusterId); boolean enableKerberos = false; @@ -67,22 +67,22 @@ public void handlerConfig(Integer clusterId, List list) { for (ServiceConfig config : list) { if ("enableHDFSPlugin".equals(config.getName()) && ((Boolean) config.getValue()).booleanValue()) { logger.info("enableHdfsPlugin"); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${enableHDFSPlugin}", "true"); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName, "${enableHDFSPlugin}", "true"); enableRangerPlugin(clusterId, "HDFS", "NameNode"); } if ("enableHIVEPlugin".equals(config.getName()) && ((Boolean) config.getValue()).booleanValue()) { logger.info("enableHivePlugin"); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${enableHIVEPlugin}", "true"); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName, "${enableHIVEPlugin}", "true"); enableRangerPlugin(clusterId, "HIVE", "HiveServer2"); } if ("enableHBASEPlugin".equals(config.getName()) && ((Boolean) config.getValue()).booleanValue()) { logger.info("enableHbasePlugin"); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${enableHBASEPlugin}", "true"); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${enableHBASEPlugin}", "true"); enableRangerPlugin(clusterId, "HBASE", "HbaseMaster"); } if (config.getName().contains("Plugin") && !(Boolean) config.getValue()) { String configName = config.getName(); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${" + configName + "}", "false"); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${" + configName + "}", "false"); } if ("enableKerberos".equals(config.getName())) { enableKerberos = isEnableKerberos(clusterId, globalVariables, enableKerberos, config, "RANGER"); diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/ServiceHandlerAbstract.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/ServiceHandlerAbstract.java index f5ff06da..aaddb737 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/ServiceHandlerAbstract.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/ServiceHandlerAbstract.java @@ -114,10 +114,10 @@ public boolean isEnableKerberos(Integer clusterId, Map globalVar ServiceConfig config, String serviceName) { if ((Boolean) config.getValue()) { enableKerberos = true; - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${enable" + serviceName + "Kerberos}", + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${enable" + serviceName + "Kerberos}", "true"); } else { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${enable" + serviceName + "Kerberos}", + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${enable" + serviceName + "Kerberos}", "false"); } return enableKerberos; @@ -127,9 +127,9 @@ public boolean isEnableHA(Integer clusterId, Map globalVariables ServiceConfig config, String serviceName) { if ((Boolean) config.getValue()) { enableHA = true; - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${enable" + serviceName + "HA}", "true"); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${enable" + serviceName + "HA}", "true"); } else { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${enable" + serviceName + "HA}", "false"); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${enable" + serviceName + "HA}", "false"); } return enableHA; } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/ServiceRoleStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/ServiceRoleStrategy.java index 496f35a2..f626a07b 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/ServiceRoleStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/ServiceRoleStrategy.java @@ -26,9 +26,9 @@ public interface ServiceRoleStrategy { - void handler(Integer clusterId, List hosts); + void handler(Integer clusterId, List hosts, String serviceName); - void handlerConfig(Integer clusterId, List list); + void handlerConfig(Integer clusterId, List list, String serviceName); void getConfig(Integer clusterId, List list); diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/ServiceRoleStrategyContext.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/ServiceRoleStrategyContext.java index dab65174..ca109680 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/ServiceRoleStrategyContext.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/ServiceRoleStrategyContext.java @@ -24,48 +24,94 @@ public class ServiceRoleStrategyContext { - private static final Map map = new ConcurrentHashMap<>(); + private static final Map strategyMap = new ConcurrentHashMap<>(); + + private static final Map serviceNameMap = new ConcurrentHashMap<>(); static { - map.put("NameNode", new NameNodeHandlerStrategy()); - map.put("ResourceManager", new RMHandlerStrategy()); - map.put("HiveMetaStore", new HiveMetaStroreHandlerStrategy()); - map.put("HiveServer2", new HiveServer2HandlerStrategy()); - map.put("Grafana", new GrafanaHandlerStrategy()); - map.put("ZkServer", new ZkServerHandlerStrategy()); - map.put("HistoryServer", new HistoryServerHandlerStrategy()); - map.put("TimelineServer", new TSHandlerStrategy()); - map.put("TrinoCoordinator", new TrinoHandlerStrategy()); - map.put("JournalNode", new JournalNodeHandlerStrategy()); - map.put("ZKFC", new ZKFCHandlerStrategy()); - map.put("HttpFs", new HttpFsHandlerStrategy()); - map.put("SRFE", new FEHandlerStartegy()); - map.put("DorisFE", new FEHandlerStartegy()); - map.put("DorisFEObserver", new FEObserverHandlerStartegy()); - map.put("SRBE", new BEHandlerStartegy()); - map.put("DorisBE", new BEHandlerStartegy()); - map.put("Krb5Kdc", new Krb5KdcHandlerStrategy()); - map.put("KAdmin", new KAdminHandlerStrategy()); - map.put("RangerAdmin", new RangerAdminHandlerStrategy()); - map.put("ElasticSearch", new ElasticSearchHandlerStrategy()); - map.put("Prometheus", new PrometheusHandlerStrategy()); - map.put("AlertManager", new AlertManagerHandlerStrategy()); + strategyMap.put("NameNode", new NameNodeHandlerStrategy()); + strategyMap.put("ResourceManager", new RMHandlerStrategy()); + strategyMap.put("HiveMetaStore", new HiveMetaStroreHandlerStrategy()); + strategyMap.put("HiveServer2", new HiveServer2HandlerStrategy()); + strategyMap.put("Grafana", new GrafanaHandlerStrategy()); + strategyMap.put("ZkServer", new ZkServerHandlerStrategy()); + strategyMap.put("HistoryServer", new HistoryServerHandlerStrategy()); + strategyMap.put("TimelineServer", new TSHandlerStrategy()); + strategyMap.put("TrinoCoordinator", new TrinoHandlerStrategy()); + strategyMap.put("JournalNode", new JournalNodeHandlerStrategy()); + strategyMap.put("ZKFC", new ZKFCHandlerStrategy()); + strategyMap.put("HttpFs", new HttpFsHandlerStrategy()); + strategyMap.put("SRFE", new FEHandlerStartegy()); + strategyMap.put("DorisFE", new FEHandlerStartegy()); + strategyMap.put("DorisFEObserver", new FEObserverHandlerStartegy()); + strategyMap.put("SRBE", new BEHandlerStartegy()); + strategyMap.put("DorisBE", new BEHandlerStartegy()); + strategyMap.put("Krb5Kdc", new Krb5KdcHandlerStrategy()); + strategyMap.put("KAdmin", new KAdminHandlerStrategy()); + strategyMap.put("RangerAdmin", new RangerAdminHandlerStrategy()); + strategyMap.put("ElasticSearch", new ElasticSearchHandlerStrategy()); + strategyMap.put("Prometheus", new PrometheusHandlerStrategy()); + strategyMap.put("AlertManager", new AlertManagerHandlerStrategy()); + + strategyMap.put("RANGER", new RangerAdminHandlerStrategy()); + strategyMap.put("ZOOKEEPER", new ZkServerHandlerStrategy()); + strategyMap.put("YARN", new RMHandlerStrategy()); + strategyMap.put("HDFS", new NameNodeHandlerStrategy()); + strategyMap.put("HIVE", new HiveServer2HandlerStrategy()); + strategyMap.put("KAFKA", new KafkaHandlerStrategy()); + strategyMap.put("HBASE", new HBaseHandlerStrategy()); + strategyMap.put("FLINK", new FlinkHandlerStrategy()); + strategyMap.put("KYUUBI", new KyuubiServerHandlerStrategy()); + + + // serviceNameMap + serviceNameMap.put("NameNode", "HDFS"); + serviceNameMap.put("ResourceManager", "YARN"); + serviceNameMap.put("HiveMetaStore", "HIVE"); + serviceNameMap.put("HiveServer2", "HIVE"); + serviceNameMap.put("Grafana", "GRAFANA"); + serviceNameMap.put("ZkServer", "ZOOKEEPER"); + serviceNameMap.put("HistoryServer", "YARN"); + serviceNameMap.put("TimelineServer", "YARN"); + serviceNameMap.put("TrinoCoordinator", "TRINO"); + serviceNameMap.put("JournalNode", "HDFS"); + serviceNameMap.put("ZKFC", "HDFS"); + serviceNameMap.put("HttpFs", "HDFS"); + serviceNameMap.put("SRFE", "STARROCKS"); + serviceNameMap.put("DorisFE", "DORIS"); + serviceNameMap.put("DorisFEObserver", "DORIS"); + serviceNameMap.put("SRBE", "STARROCKS"); + serviceNameMap.put("DorisBE", "DORIS"); + serviceNameMap.put("Krb5Kdc", "KERBEROS"); + serviceNameMap.put("KAdmin", "KERBEROS"); + serviceNameMap.put("RangerAdmin", "RANGER"); + serviceNameMap.put("ElasticSearch", "ELASTICSEARCH"); + serviceNameMap.put("Prometheus", "PROMETHEUS"); + serviceNameMap.put("AlertManager", "ALERTMANAGER"); + + + serviceNameMap.put("FLINK","FLINK"); + serviceNameMap.put("RANGER","RANGER"); + serviceNameMap.put("YARN","YARN"); + serviceNameMap.put("HDFS","HDFS"); + serviceNameMap.put("HIVE","HIVE"); + serviceNameMap.put("KAFKA","KAFKA"); + serviceNameMap.put("HBASE","HBASE"); + serviceNameMap.put("KYUUBI","KYUUBI"); - map.put("RANGER", new RangerAdminHandlerStrategy()); - map.put("ZOOKEEPER", new ZkServerHandlerStrategy()); - map.put("YARN", new RMHandlerStrategy()); - map.put("HDFS", new NameNodeHandlerStrategy()); - map.put("HIVE", new HiveServer2HandlerStrategy()); - map.put("KAFKA", new KafkaHandlerStrategy()); - map.put("HBASE", new HBaseHandlerStrategy()); - map.put("FLINK", new FlinkHandlerStrategy()); - map.put("KYUUBI",new KyuubiServerHandlerStrategy()); } public static ServiceRoleStrategy getServiceRoleHandler(String type) { if (StringUtils.isBlank(type)) { return null; } - return map.get(type); + return strategyMap.get(type); + } + + public static String getServiceName(String type) { + if (StringUtils.isBlank(type)) { + return null; + } + return serviceNameMap.get(type); } } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/TSHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/TSHandlerStrategy.java index 482752ed..972f3ddb 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/TSHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/TSHandlerStrategy.java @@ -40,15 +40,15 @@ public class TSHandlerStrategy implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts,String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); if(hosts.size() > 0) { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${yarn_timeline_server}", hosts.get(0)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${yarn_timeline_server}", hosts.get(0)); } } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list,String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/TrinoHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/TrinoHandlerStrategy.java index 0408fc54..6bada0bb 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/TrinoHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/TrinoHandlerStrategy.java @@ -29,15 +29,15 @@ public class TrinoHandlerStrategy implements ServiceRoleStrategy { @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts,String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); if (hosts.size() == 1) { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${coordinatorHost}", hosts.get(0)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${coordinatorHost}", hosts.get(0)); } } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list,String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/ZKFCHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/ZKFCHandlerStrategy.java index eb51ad65..0c736dfc 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/ZKFCHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/ZKFCHandlerStrategy.java @@ -22,28 +22,27 @@ import com.datasophon.common.model.ServiceConfig; import com.datasophon.common.model.ServiceRoleInfo; import com.datasophon.dao.entity.ClusterServiceRoleInstanceEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class ZKFCHandlerStrategy implements ServiceRoleStrategy { private static final Logger logger = LoggerFactory.getLogger(ZKFCHandlerStrategy.class); @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); if (hosts.size() == 2) { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${ZKFC1}", hosts.get(0)); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${ZKFC2}", hosts.get(1)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName, "${ZKFC1}", hosts.get(0)); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName, "${ZKFC2}", hosts.get(1)); } } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list, String serviceName) { } diff --git a/datasophon-service/src/main/java/com/datasophon/api/strategy/ZkServerHandlerStrategy.java b/datasophon-service/src/main/java/com/datasophon/api/strategy/ZkServerHandlerStrategy.java index f419de7e..b44590e4 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/strategy/ZkServerHandlerStrategy.java +++ b/datasophon-service/src/main/java/com/datasophon/api/strategy/ZkServerHandlerStrategy.java @@ -30,31 +30,30 @@ import com.datasophon.common.utils.PlaceholderUtils; import com.datasophon.dao.entity.ClusterInfoEntity; import com.datasophon.dao.entity.ClusterServiceRoleInstanceEntity; - -import java.util.*; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; +import java.util.*; + public class ZkServerHandlerStrategy implements ServiceRoleStrategy { private static final Logger logger = LoggerFactory.getLogger(ZkServerHandlerStrategy.class); @Override - public void handler(Integer clusterId, List hosts) { + public void handler(Integer clusterId, List hosts, String serviceName) { // 保存zkUrls到全局变量 Map globalVariables = GlobalVariables.get(clusterId); String join = String.join(":2181,", hosts); String zkUrls = join + ":2181"; - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${zkUrls}", zkUrls); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${zkUrls}", zkUrls); // 保存hbaseZkUrls到全局变量 String hbaseZkUrls=String.join(",", hosts); - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${zkHostsUrl}", hbaseZkUrls); + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${zkHostsUrl}", hbaseZkUrls); } @Override - public void handlerConfig(Integer clusterId, List list) { + public void handlerConfig(Integer clusterId, List list,String serviceName) { Map globalVariables = GlobalVariables.get(clusterId); ClusterInfoEntity clusterInfo = ProcessUtils.getClusterInfo(clusterId); boolean enableKerberos = false; @@ -64,10 +63,10 @@ public void handlerConfig(Integer clusterId, List list) { if ("enableKerberos".equals(config.getName())) { if ((Boolean) config.getValue()) { enableKerberos = true; - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${enableZOOKEEPERKerberos}", + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${enableZOOKEEPERKerberos}", "true"); } else { - ProcessUtils.generateClusterVariable(globalVariables, clusterId, "${enableZOOKEEPERKerberos}", + ProcessUtils.generateClusterVariable(globalVariables, clusterId, serviceName,"${enableZOOKEEPERKerberos}", "false"); } } diff --git a/datasophon-service/src/main/java/com/datasophon/api/utils/ProcessUtils.java b/datasophon-service/src/main/java/com/datasophon/api/utils/ProcessUtils.java index 4d115ba2..ba9d4cb5 100644 --- a/datasophon-service/src/main/java/com/datasophon/api/utils/ProcessUtils.java +++ b/datasophon-service/src/main/java/com/datasophon/api/utils/ProcessUtils.java @@ -386,17 +386,19 @@ public static void updateServiceRoleState(CommandType commandType, String servic } public static void generateClusterVariable(Map globalVariables, Integer clusterId, - String variableName, String value) { + String serviceName,String variableName, String value) { ClusterVariableService variableService = SpringTool.getApplicationContext().getBean(ClusterVariableService.class); ClusterVariable clusterVariable = variableService.getVariableByVariableName(variableName, clusterId); if (Objects.nonNull(clusterVariable)) { logger.info("update variable {} value {} to {}", variableName, clusterVariable.getVariableValue(), value); + clusterVariable.setServiceName(serviceName); clusterVariable.setVariableValue(value); variableService.updateById(clusterVariable); } else { ClusterVariable newClusterVariable = new ClusterVariable(); newClusterVariable.setClusterId(clusterId); + newClusterVariable.setServiceName(serviceName); newClusterVariable.setVariableName(variableName); newClusterVariable.setVariableValue(value); variableService.save(newClusterVariable);