This is an automated email from the ASF dual-hosted git repository.
houyu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/bigtop-manager.git
The following commit(s) were added to refs/heads/main by this push:
new 7c861424 BIGTOP-4502: Check required by services when removing a
service (#273)
7c861424 is described below
commit 7c8614245f9992c4afe9ca85316297eeb1392822
Author: Zhiguo Wu <[email protected]>
AuthorDate: Thu Sep 18 20:24:58 2025 +0800
BIGTOP-4502: Check required by services when removing a service (#273)
---
.../manager/server/enums/ApiExceptionEnum.java | 1 +
.../bigtop/manager/server/enums/LocaleKeys.java | 1 +
.../server/service/impl/ServiceServiceImpl.java | 20 +++++++++-
.../bigtop/manager/server/utils/StackUtils.java | 14 +++++++
.../main/resources/i18n/messages_en_US.properties | 1 +
.../main/resources/i18n/messages_zh_CN.properties | 1 +
.../stacks/bigtop/3.3.0/services/hive/metainfo.xml | 2 +-
.../stack/bigtop/v3_3_0/hadoop/HadoopParams.java | 46 ++--------------------
8 files changed, 42 insertions(+), 44 deletions(-)
diff --git
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/ApiExceptionEnum.java
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/ApiExceptionEnum.java
index 798b1281..abe3ae61 100644
---
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/ApiExceptionEnum.java
+++
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/ApiExceptionEnum.java
@@ -62,6 +62,7 @@ public enum ApiExceptionEnum {
SERVICE_REQUIRED_NOT_FOUND(14001, LocaleKeys.SERVICE_REQUIRED_NOT_FOUND),
SERVICE_HAS_COMPONENTS(14002, LocaleKeys.SERVICE_HAS_COMPONENTS),
SERVICE_IS_RUNNING(14003, LocaleKeys.SERVICE_IS_RUNNING),
+ SERVICE_REQUIRED_BY(14004, LocaleKeys.SERVICE_REQUIRED_BY),
// Component Exceptions -- 15000 ~ 15999
COMPONENT_NOT_FOUND(15000, LocaleKeys.COMPONENT_NOT_FOUND),
diff --git
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/LocaleKeys.java
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/LocaleKeys.java
index df63566a..933d8459 100644
---
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/LocaleKeys.java
+++
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/enums/LocaleKeys.java
@@ -62,6 +62,7 @@ public enum LocaleKeys {
SERVICE_REQUIRED_NOT_FOUND("service.required.not.found"),
SERVICE_HAS_COMPONENTS("service.has.components"),
SERVICE_IS_RUNNING("service.is.running"),
+ SERVICE_REQUIRED_BY("service.required.by"),
COMPONENT_NOT_FOUND("component.not.found"),
COMPONENT_IS_RUNNING("component.is.running"),
diff --git
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ServiceServiceImpl.java
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ServiceServiceImpl.java
index eeb10968..1b8a7f1c 100644
---
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ServiceServiceImpl.java
+++
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ServiceServiceImpl.java
@@ -150,6 +150,24 @@ public class ServiceServiceImpl implements ServiceService {
throw new ApiException(ApiExceptionEnum.SERVICE_NOT_FOUND);
}
+ // Check if required by other installed services
+ List<String> requiredBy =
StackUtils.getServiceRequiredBy(servicePO.getName());
+ if (CollectionUtils.isNotEmpty(requiredBy)) {
+ boolean isInfra = servicePO.getClusterId() == 0;
+ List<ServicePO> servicePOList;
+ if (isInfra) {
+ servicePOList = serviceDao.findByClusterIdAndNames(null,
requiredBy);
+ } else {
+ servicePOList =
serviceDao.findByClusterIdAndNames(servicePO.getClusterId(), requiredBy);
+ }
+
+ if (CollectionUtils.isNotEmpty(servicePOList)) {
+ throw new ApiException(
+ ApiExceptionEnum.SERVICE_REQUIRED_BY,
+ servicePOList.get(0).getDisplayName());
+ }
+ }
+
// Check service status - only allow deletion when service is stopped
if (!Objects.equals(servicePO.getStatus(),
HealthyStatusEnum.UNHEALTHY.getCode())) {
throw new ApiException(ApiExceptionEnum.SERVICE_IS_RUNNING);
@@ -165,7 +183,7 @@ public class ServiceServiceImpl implements ServiceService {
continue;
}
if (!Objects.equals(componentPO.getStatus(),
HealthyStatusEnum.UNHEALTHY.getCode())) {
- throw new ApiException(ApiExceptionEnum.SERVICE_IS_RUNNING);
+ throw new ApiException(ApiExceptionEnum.COMPONENT_IS_RUNNING);
}
}
diff --git
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/StackUtils.java
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/StackUtils.java
index c00f57ee..edd38fd6 100644
---
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/StackUtils.java
+++
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/StackUtils.java
@@ -272,6 +272,20 @@ public class StackUtils {
throw new ServerException("Service not found: " + serviceName);
}
+ public static List<String> getServiceRequiredBy(String serviceName) {
+ List<String> requiredBy = new ArrayList<>();
+ for (Map.Entry<StackDTO, List<ServiceDTO>> entry :
STACK_SERVICE_MAP.entrySet()) {
+ for (ServiceDTO serviceDTO : entry.getValue()) {
+ if (serviceDTO.getRequiredServices() != null
+ &&
serviceDTO.getRequiredServices().contains(serviceName)) {
+ requiredBy.add(serviceDTO.getName());
+ }
+ }
+ }
+
+ return requiredBy;
+ }
+
public static ComponentDTO getComponentDTO(String componentName) {
for (Map.Entry<StackDTO, List<ServiceDTO>> entry :
STACK_SERVICE_MAP.entrySet()) {
for (ServiceDTO serviceDTO : entry.getValue()) {
diff --git
a/bigtop-manager-server/src/main/resources/i18n/messages_en_US.properties
b/bigtop-manager-server/src/main/resources/i18n/messages_en_US.properties
index f17fa31e..04707978 100644
--- a/bigtop-manager-server/src/main/resources/i18n/messages_en_US.properties
+++ b/bigtop-manager-server/src/main/resources/i18n/messages_en_US.properties
@@ -56,6 +56,7 @@ service.not.found=Service not exist
service.required.not.found=Required Service [{0}] not exist
service.has.components=Service still has components, please remove them first
service.is.running=Service is running, please stop it first
+service.required.by=Service [{0}] is required by this, please remove it first
component.not.found=Component not exist
component.is.running=Component is running, please stop it first
diff --git
a/bigtop-manager-server/src/main/resources/i18n/messages_zh_CN.properties
b/bigtop-manager-server/src/main/resources/i18n/messages_zh_CN.properties
index edfe6d4a..cd193042 100644
--- a/bigtop-manager-server/src/main/resources/i18n/messages_zh_CN.properties
+++ b/bigtop-manager-server/src/main/resources/i18n/messages_zh_CN.properties
@@ -56,6 +56,7 @@ service.not.found=服务不存在
service.required.not.found=依赖服务 [{0}] 不存在
service.has.components=服务上仍有组件,请先移除
service.is.running=服务正在运行,请先停止
+service.required.by=服务 [{0}] 依赖于该服务,请先移除
component.not.found=组件不存在
component.is.running=组件正在运行,请先停止
diff --git
a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/hive/metainfo.xml
b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/hive/metainfo.xml
index 4c4af284..af28e844 100644
---
a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/hive/metainfo.xml
+++
b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/hive/metainfo.xml
@@ -72,7 +72,7 @@
<templates>
<template>
<src>hive-service.sh</src>
- <dest>bin</dest>
+ <dest>bin/hive-service.sh</dest>
</template>
</templates>
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hadoop/HadoopParams.java
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hadoop/HadoopParams.java
index ced14bad..cbfb5684 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hadoop/HadoopParams.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hadoop/HadoopParams.java
@@ -222,10 +222,12 @@ public class HadoopParams extends BigtopParams {
log.info("Detected glibc version >= 2.34, enabling
short-circuit read optimization");
// Get recommended domain socket path and append port
placeholder
- domainSocketPath = findOptimalDomainSocketPath();
+ domainSocketPath = (String)
hdfsSite.get("dfs.domain.socket.path");
if (domainSocketPath != null) {
// _PORT placeholder will be replaced with actual port
number by DataNode at runtime
- domainSocketPath = domainSocketPath + "/dn._PORT";
+ if (!domainSocketPath.endsWith("dn._PORT")) {
+ domainSocketPath = domainSocketPath + "/dn._PORT";
+ }
log.info("Enabling short-circuit reads with domain socket
path: {}", domainSocketPath);
}
} else {
@@ -363,46 +365,6 @@ public class HadoopParams extends BigtopParams {
return minor1 - minor2;
}
- /**
- * Find the optimal domain socket path.
- * <p>
- * Path selection strategy:
- * 1. Check candidate paths in priority order for existence and writability
- * 2. If none are available, attempt to create default directory
- * 3. Finally fall back to /tmp directory
- *
- * @return Recommended domain socket base path
- */
- private String findOptimalDomainSocketPath() {
- // Candidate paths in priority order
- String[] candidatePaths = {"/var/run/hadoop", "/tmp/hadoop", "/tmp"};
-
- // Check availability of existing paths
- for (String path : candidatePaths) {
- java.io.File dir = new java.io.File(path);
- if (dir.exists() && dir.canWrite()) {
- log.info("Selected domain socket path: {}", path);
- return path;
- }
- }
-
- // Try to create default hadoop directory
- java.io.File defaultDir = new java.io.File("/tmp/hadoop");
- if (!defaultDir.exists()) {
- try {
- if (defaultDir.mkdirs()) {
- log.info("Created and using domain socket path:
/tmp/hadoop");
- return "/tmp/hadoop";
- }
- } catch (Exception e) {
- log.warn("Cannot create directory /tmp/hadoop, using /tmp as
fallback", e);
- }
- }
-
- log.info("Using fallback domain socket path: /tmp");
- return "/tmp";
- }
-
/**
* Apply short-circuit read settings in HDFS site configuration.
* <p>