This is an automated email from the ASF dual-hosted git repository.
wuzhiguo 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 8a378943 BIGTOP-4294: Install ZooKeeper with tarball (#117)
8a378943 is described below
commit 8a378943a368045c5404b8499d528a7bbebaf6d1
Author: Zhiguo Wu <[email protected]>
AuthorDate: Fri Dec 6 11:01:35 2024 +0800
BIGTOP-4294: Install ZooKeeper with tarball (#117)
---
bigtop-manager-bom/pom.xml | 2 +-
.../bigtop/manager/common/constants/Constants.java | 20 ---------
.../server/command/task/CacheFileUpdateTask.java | 12 ++++--
.../server/service/impl/HostServiceImpl.java | 2 +-
.../manager/server/timer/ComponentStatusTimer.java | 4 ++
.../services/zookeeper/configuration/zoo.cfg.xml | 6 ---
.../bigtop/3.3.0/services/zookeeper/metainfo.xml | 2 +-
.../stack/bigtop/v3_3_0/hdfs/HdfsSetup.java | 2 +-
.../v3_3_0/zookeeper/ZookeeperClientScript.java | 10 +++++
.../bigtop/v3_3_0/zookeeper/ZookeeperParams.java | 20 ++++-----
.../v3_3_0/zookeeper/ZookeeperServerScript.java | 9 +++++
.../bigtop/v3_3_0/zookeeper/ZookeeperSetup.java | 17 ++++----
.../manager/stack/core/param/BaseParams.java | 2 +-
.../stack/core/spi/script/AbstractScript.java | 8 +---
.../manager/stack/core/utils/LocalSettings.java | 2 +-
.../manager/stack/core/utils/TarballUtils.java | 5 +--
.../stack/core/utils/linux/LinuxAccountUtils.java | 27 -------------
.../stack/core/utils/linux/LinuxFileUtils.java | 47 ++++++++++++++++++++--
.../stack/core/utils/linux/LinuxOSUtils.java | 2 +-
.../infra/v1_0_0/prometheus/PrometheusSetup.java | 5 +--
20 files changed, 102 insertions(+), 102 deletions(-)
diff --git a/bigtop-manager-bom/pom.xml b/bigtop-manager-bom/pom.xml
index 628e6901..726e8444 100644
--- a/bigtop-manager-bom/pom.xml
+++ b/bigtop-manager-bom/pom.xml
@@ -34,7 +34,7 @@
<spring-boot.version>3.1.1</spring-boot.version>
<springdoc.version>2.2.0</springdoc.version>
<freemarker.version>2.3.32</freemarker.version>
- <common-lang3.version>3.12.0</common-lang3.version>
+ <common-lang3.version>3.14.0</common-lang3.version>
<snakeyaml.version>2.0</snakeyaml.version>
<commons-io.version>2.16.1</commons-io.version>
<guava.version>32.1.1-jre</guava.version>
diff --git
a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/constants/Constants.java
b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/constants/Constants.java
index 628929c0..d0dbf94c 100644
---
a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/constants/Constants.java
+++
b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/constants/Constants.java
@@ -24,33 +24,13 @@ public final class Constants {
throw new UnsupportedOperationException("Construct Constants");
}
- /**
- * host key for all hosts
- */
public static final String ALL_HOST_KEY = "all";
- /**
- * permission 644
- */
public static final String PERMISSION_644 = "644";
- /**
- * permission 755
- */
public static final String PERMISSION_755 = "755";
- /**
- * permission 775
- */
- public static final String PERMISSION_775 = "775";
-
- /**
- * permission 777
- */
public static final String PERMISSION_777 = "777";
- /**
- * root user
- */
public static final String ROOT_USER = "root";
}
diff --git
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/CacheFileUpdateTask.java
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/CacheFileUpdateTask.java
index ab26d21a..7ae30501 100644
---
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/CacheFileUpdateTask.java
+++
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/task/CacheFileUpdateTask.java
@@ -118,13 +118,17 @@ public class CacheFileUpdateTask extends AbstractTask {
serviceConfigMap = new HashMap<>();
for (ServiceConfigPO serviceConfigPO : serviceConfigPOList) {
+ List<Map<String, Object>> properties =
JsonUtils.readFromString(serviceConfigPO.getPropertiesJson());
+ Map<String, String> kvMap = properties.stream()
+ .collect(Collectors.toMap(
+ property -> (String) property.get("name"),
property -> (String) property.get("value")));
+ String kvString = JsonUtils.writeAsString(kvMap);
+
if
(serviceConfigMap.containsKey(serviceConfigPO.getServiceName())) {
- serviceConfigMap
- .get(serviceConfigPO.getServiceName())
- .put(serviceConfigPO.getName(),
serviceConfigPO.getPropertiesJson());
+
serviceConfigMap.get(serviceConfigPO.getServiceName()).put(serviceConfigPO.getName(),
kvString);
} else {
Map<String, Object> hashMap = new HashMap<>();
- hashMap.put(serviceConfigPO.getName(),
serviceConfigPO.getPropertiesJson());
+ hashMap.put(serviceConfigPO.getName(), kvString);
serviceConfigMap.put(serviceConfigPO.getServiceName(),
hashMap);
}
}
diff --git
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostServiceImpl.java
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostServiceImpl.java
index c8951f6d..70b37eb9 100644
---
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostServiceImpl.java
+++
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/HostServiceImpl.java
@@ -218,7 +218,7 @@ public class HostServiceImpl implements HostService {
}
// Run agent in background
- command = "nohup " + path + "/bigtop-manager-agent/bin/start.sh >
/dev/null 2>&1 &";
+ command = "nohup " + path + "/bigtop-manager-agent/bin/start.sh
--debug > /dev/null 2>&1 &";
result = execCommandOnRemoteHost(hostDTO, hostDTO.getHostname(),
command);
if (result.getExitCode() != MessageConstants.SUCCESS_CODE) {
hostPO.setErrInfo(result.getErrMsg());
diff --git
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/timer/ComponentStatusTimer.java
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/timer/ComponentStatusTimer.java
index a4edcac6..2eb805ab 100644
---
a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/timer/ComponentStatusTimer.java
+++
b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/timer/ComponentStatusTimer.java
@@ -54,6 +54,10 @@ public class ComponentStatusTimer {
public void execute() {
List<ComponentPO> componentPOList = componentDao.findAll();
for (ComponentPO componentPO : componentPOList) {
+ if (HealthyStatusEnum.fromCode(componentPO.getStatus()) ==
HealthyStatusEnum.UNKNOWN) {
+ continue;
+ }
+
componentPO = componentDao.findDetailsById(componentPO.getId());
HostPO hostPO = hostDao.findById(componentPO.getHostId());
ComponentStatusRequest request =
ComponentStatusRequest.newBuilder()
diff --git
a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/zookeeper/configuration/zoo.cfg.xml
b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/zookeeper/configuration/zoo.cfg.xml
index bd09086c..35ef3490 100644
---
a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/zookeeper/configuration/zoo.cfg.xml
+++
b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/zookeeper/configuration/zoo.cfg.xml
@@ -45,12 +45,6 @@
<display-name>Port for running ZK Server</display-name>
<description>Port for running ZK Server.</description>
</property>
- <property>
- <name>dataDir</name>
- <value>/hadoop/zookeeper</value>
- <display-name>ZooKeeper directory</display-name>
- <description>Data directory for ZooKeeper.</description>
- </property>
<property>
<name>autopurge.snapRetainCount</name>
<value>30</value>
diff --git
a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/zookeeper/metainfo.xml
b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/zookeeper/metainfo.xml
index 29a95f92..7b35ebff 100644
---
a/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/zookeeper/metainfo.xml
+++
b/bigtop-manager-server/src/main/resources/stacks/bigtop/3.3.0/services/zookeeper/metainfo.xml
@@ -54,7 +54,7 @@
<packages>
<package>
<name>zookeeper-3.7.2-1.tar.gz</name>
-
<checksum>380f15d55c0282e33fdc7c2ec551bc5586f0ac126c243cd84347ccb775b846f3</checksum>
+
<checksum>SHA-256:380f15d55c0282e33fdc7c2ec551bc5586f0ac126c243cd84347ccb775b846f3</checksum>
</package>
</packages>
</package-specific>
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hdfs/HdfsSetup.java
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hdfs/HdfsSetup.java
index ba8e8136..db7d0979 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hdfs/HdfsSetup.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/hdfs/HdfsSetup.java
@@ -83,7 +83,7 @@ public class HdfsSetup {
LinuxFileUtils.createDirectories(
hdfsParams.getDfsDataDir(), hdfsUser, hdfsGroup,
Constants.PERMISSION_755, true);
LinuxFileUtils.createDirectories(
- hdfsParams.getHadoopLogDir(), hdfsUser, hdfsGroup,
Constants.PERMISSION_775, true);
+ hdfsParams.getHadoopLogDir(), hdfsUser, hdfsGroup,
Constants.PERMISSION_755, true);
LinuxFileUtils.createDirectories(
hdfsParams.getHadoopPidDir(), hdfsUser, hdfsGroup,
Constants.PERMISSION_755, true);
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperClientScript.java
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperClientScript.java
index 87faa209..80ccfb94 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperClientScript.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperClientScript.java
@@ -26,10 +26,20 @@ import
org.apache.bigtop.manager.stack.core.spi.script.Script;
import com.google.auto.service.AutoService;
import lombok.extern.slf4j.Slf4j;
+import java.util.Properties;
+
@Slf4j
@AutoService(Script.class)
public class ZookeeperClientScript extends AbstractClientScript {
+ @Override
+ public ShellResult add(Params params) {
+ Properties properties = new Properties();
+ properties.setProperty(PROPERTY_KEY_SKIP_LEVELS, "1");
+
+ return super.add(params, properties);
+ }
+
@Override
public ShellResult configure(Params params) {
return ZookeeperSetup.config(params);
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperParams.java
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperParams.java
index cb7f6201..65b7429d 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperParams.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperParams.java
@@ -31,10 +31,10 @@ import java.util.Map;
@Getter
public class ZookeeperParams extends BigtopParams {
- private String zookeeperLogDir = "/var/log/zookeeper";
- private String zookeeperPidDir = "/var/run/zookeeper";
- private String zookeeperDataDir = "/hadoop/zookeeper";
- private String zookeeperPidFile = zookeeperPidDir +
"/zookeeper_server.pid";
+ private final String zookeeperLogDir = "/var/log/zookeeper";
+ private final String zookeeperPidDir = "/var/run/zookeeper";
+ private final String zookeeperDataDir = serviceHome() + "/data";
+ private final String zookeeperPidFile = zookeeperPidDir +
"/zookeeper_server.pid";
public ZookeeperParams(CommandPayload commandPayload) {
super(commandPayload);
@@ -46,17 +46,13 @@ public class ZookeeperParams extends BigtopParams {
@GlobalParams
public Map<String, Object> zooCfg() {
- Map<String, Object> zooCfg =
LocalSettings.configurations(serviceName(), "zoo.cfg");
- zookeeperDataDir = (String) zooCfg.get("dataDir");
- return zooCfg;
+ Map<String, Object> configurations =
LocalSettings.configurations(serviceName(), "zoo.cfg");
+ configurations.put("dataDir", zookeeperDataDir);
+ return configurations;
}
@GlobalParams
public Map<String, Object> zookeeperEnv() {
- Map<String, Object> zookeeperEnv =
LocalSettings.configurations(serviceName(), "zookeeper-env");
- zookeeperLogDir = (String) zookeeperEnv.get("zookeeper_log_dir");
- zookeeperPidDir = (String) zookeeperEnv.get("zookeeper_pid_dir");
- zookeeperPidFile = zookeeperPidDir + "/zookeeper_server.pid";
- return zookeeperEnv;
+ return LocalSettings.configurations(serviceName(), "zookeeper-env");
}
}
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperServerScript.java
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperServerScript.java
index 0a7ed502..8ed887ab 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperServerScript.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperServerScript.java
@@ -30,11 +30,20 @@ import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.text.MessageFormat;
+import java.util.Properties;
@Slf4j
@AutoService(Script.class)
public class ZookeeperServerScript extends AbstractServerScript {
+ @Override
+ public ShellResult add(Params params) {
+ Properties properties = new Properties();
+ properties.setProperty(PROPERTY_KEY_SKIP_LEVELS, "1");
+
+ return super.add(params, properties);
+ }
+
@Override
public ShellResult configure(Params params) {
return ZookeeperSetup.config(params);
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperSetup.java
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperSetup.java
index bb434acb..5aff530f 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperSetup.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/zookeeper/ZookeeperSetup.java
@@ -18,6 +18,7 @@
*/
package org.apache.bigtop.manager.stack.bigtop.v3_3_0.zookeeper;
+import org.apache.bigtop.manager.common.constants.Constants;
import org.apache.bigtop.manager.common.shell.ShellResult;
import org.apache.bigtop.manager.common.utils.NetUtils;
import org.apache.bigtop.manager.stack.core.enums.ConfigType;
@@ -34,9 +35,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static
org.apache.bigtop.manager.common.constants.Constants.PERMISSION_644;
-import static
org.apache.bigtop.manager.common.constants.Constants.PERMISSION_755;
-
@Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ZookeeperSetup {
@@ -53,13 +51,12 @@ public class ZookeeperSetup {
List<String> zkHostList = LocalSettings.hosts("zookeeper_server");
LinuxFileUtils.createDirectories(
- zookeeperParams.getZookeeperDataDir(), zookeeperUser,
zookeeperGroup, PERMISSION_755, true);
+ zookeeperParams.getZookeeperDataDir(), zookeeperUser,
zookeeperGroup, Constants.PERMISSION_755, true);
LinuxFileUtils.createDirectories(
- zookeeperParams.getZookeeperLogDir(), zookeeperUser,
zookeeperGroup, PERMISSION_755, true);
+ zookeeperParams.getZookeeperLogDir(), zookeeperUser,
zookeeperGroup, Constants.PERMISSION_755, true);
LinuxFileUtils.createDirectories(
- zookeeperParams.getZookeeperPidDir(), zookeeperUser,
zookeeperGroup, PERMISSION_755, true);
+ zookeeperParams.getZookeeperPidDir(), zookeeperUser,
zookeeperGroup, Constants.PERMISSION_755, true);
- // 针对zkHostList排序,获取当前hostname的index+1
// server.${host?index+1}=${host}:2888:3888
zkHostList.sort(String::compareToIgnoreCase);
StringBuilder zkServerStr = new StringBuilder();
@@ -75,7 +72,7 @@ public class ZookeeperSetup {
MessageFormat.format("{0}/myid",
zookeeperParams.getZookeeperDataDir()),
zookeeperUser,
zookeeperGroup,
- PERMISSION_644,
+ Constants.PERMISSION_644,
zkHostList.indexOf(NetUtils.getHostname()) + 1 + "");
// zoo.cfg
@@ -87,7 +84,7 @@ public class ZookeeperSetup {
MessageFormat.format("{0}/zoo.cfg", confDir),
zookeeperUser,
zookeeperGroup,
- PERMISSION_644,
+ Constants.PERMISSION_644,
Map.of("model", map),
paramMap);
@@ -97,7 +94,7 @@ public class ZookeeperSetup {
MessageFormat.format("{0}/zookeeper-env.sh", confDir),
zookeeperUser,
zookeeperGroup,
- PERMISSION_644,
+ Constants.PERMISSION_644,
zookeeperParams.getGlobalParamsMap());
return ShellResult.success("ZooKeeper Server Configure success!");
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/param/BaseParams.java
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/param/BaseParams.java
index b0e689c6..39b1af6d 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/param/BaseParams.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/param/BaseParams.java
@@ -81,7 +81,7 @@ public abstract class BaseParams implements Params {
*/
@Override
public String confDir() {
- return "/etc/" + this.commandPayload.getServiceName().toLowerCase() +
"/conf";
+ return serviceHome() + "/conf";
}
@Override
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/script/AbstractScript.java
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/script/AbstractScript.java
index 42f4c39f..14d3733e 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/script/AbstractScript.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/spi/script/AbstractScript.java
@@ -24,7 +24,6 @@ import
org.apache.bigtop.manager.common.message.entity.pojo.RepoInfo;
import org.apache.bigtop.manager.common.shell.ShellResult;
import org.apache.bigtop.manager.stack.core.param.Params;
import org.apache.bigtop.manager.stack.core.utils.TarballUtils;
-import org.apache.bigtop.manager.stack.core.utils.linux.LinuxAccountUtils;
import org.apache.bigtop.manager.stack.core.utils.linux.LinuxFileUtils;
import org.apache.commons.lang3.StringUtils;
@@ -54,17 +53,14 @@ public abstract class AbstractScript implements Script {
if (!Files.exists(Path.of(stackHome))) {
String user = System.getProperty("user.name");
- String group = params.group();
-
- LinuxAccountUtils.assignUserToSupGroups(user, List.of(group));
- LinuxFileUtils.createDirectories(stackHome, user, group,
Constants.PERMISSION_755, true);
+ LinuxFileUtils.createDirectories(stackHome, user, user,
Constants.PERMISSION_755, true);
}
for (PackageInfo packageInfo : packages) {
Integer skipLevels =
Integer.parseInt(properties.getProperty(PROPERTY_KEY_SKIP_LEVELS, "0"));
TarballUtils.installPackage(repo.getBaseUrl(), stackHome,
serviceHome, packageInfo, skipLevels);
- // Dir already created by TarballUtils, this changes the owner and
permission for the service
+ // Dir already created by TarballUtils, this changes the owner and
permission for the service home
LinuxFileUtils.createDirectories(
serviceHome, params.user(), params.group(),
Constants.PERMISSION_755, true);
}
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/LocalSettings.java
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/LocalSettings.java
index 4273cf09..b920bb3c 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/LocalSettings.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/LocalSettings.java
@@ -51,7 +51,7 @@ public class LocalSettings {
Object configData =
configJson.getOrDefault(service, new
HashMap<>()).get(type);
if (configData != null) {
- configDataMap = JsonUtils.readFromString((String)
configData, new TypeReference<>() {});
+ configDataMap =
JsonUtils.readFromString(configData.toString(), new TypeReference<>() {});
}
}
} catch (Exception e) {
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/TarballUtils.java
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/TarballUtils.java
index b05c3c9f..6d231356 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/TarballUtils.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/TarballUtils.java
@@ -23,7 +23,6 @@ import
org.apache.bigtop.manager.stack.core.exception.StackException;
import org.apache.bigtop.manager.stack.core.tarball.ChecksumValidator;
import org.apache.bigtop.manager.stack.core.tarball.TarballDownloader;
import org.apache.bigtop.manager.stack.core.tarball.TarballExtractor;
-import org.apache.bigtop.manager.stack.core.utils.linux.LinuxFileUtils;
import lombok.extern.slf4j.Slf4j;
@@ -38,8 +37,8 @@ public class TarballUtils {
public static void installPackage(
String repoUrl, String stackHome, String serviceHome, PackageInfo
packageInfo, Integer skipLevels) {
if (Files.exists(Path.of(serviceHome))) {
- log.info("Service home [{}] exists, deleting...", serviceHome);
- LinuxFileUtils.removeDirectories(serviceHome);
+ log.info("Service home [{}] exists, skip downloading...",
serviceHome);
+ return;
}
String remoteUrl = repoUrl + File.separator + packageInfo.getName();
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxAccountUtils.java
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxAccountUtils.java
index 0144d134..91bd67c8 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxAccountUtils.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxAccountUtils.java
@@ -246,33 +246,6 @@ public class LinuxAccountUtils {
}
}
- /**
- * Assign user to supplementary groups
- *
- * @param user user
- * @param groups groups
- */
- public static void assignUserToSupGroups(String user, List<String> groups)
{
- Objects.requireNonNull(user);
- Objects.requireNonNull(groups);
-
- List<String> builderParameters = new ArrayList<>();
-
- builderParameters.add("usermod");
- builderParameters.add("-aG");
- builderParameters.add(String.join(",", groups));
- builderParameters.add(user);
-
- try {
- ShellResult shellResult = sudoExecCmd(builderParameters);
- if (shellResult.getExitCode() != MessageConstants.SUCCESS_CODE) {
- throw new StackException(shellResult.getErrMsg());
- }
- } catch (IOException e) {
- throw new StackException(e);
- }
- }
-
/**
* Check if exists group
*
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxFileUtils.java
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxFileUtils.java
index 65b48949..dee884a1 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxFileUtils.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxFileUtils.java
@@ -36,8 +36,11 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
+import java.util.Random;
/**
* Only support Linux
@@ -74,21 +77,23 @@ public class LinuxFileUtils {
return;
}
+ String tmpPath = "/tmp/" + generateRandomFileName();
switch (type) {
case PROPERTIES, XML, ENV, CONTENT:
- TemplateUtils.map2Template(type, filename, content, paramMap);
+ TemplateUtils.map2Template(type, tmpPath, content, paramMap);
break;
case YAML:
- YamlUtils.writeYaml(filename, content);
+ YamlUtils.writeYaml(tmpPath, content);
break;
case JSON:
- JsonUtils.writeToFile(filename, content);
+ JsonUtils.writeToFile(tmpPath, content);
break;
case UNKNOWN:
log.info("no need to write");
break;
}
+ moveFile(tmpPath, filename);
updateOwner(filename, owner, group, false);
updatePermissions(filename, permissions, false);
}
@@ -121,12 +126,25 @@ public class LinuxFileUtils {
log.error("type, filename, content, template must not be null");
return;
}
- TemplateUtils.map2CustomTemplate(template, filename, modelMap,
paramMap);
+ String tmpPath = "/tmp/" + generateRandomFileName();
+ TemplateUtils.map2CustomTemplate(template, tmpPath, modelMap,
paramMap);
+
+ moveFile(tmpPath, filename);
updateOwner(filename, owner, group, false);
updatePermissions(filename, permissions, false);
}
+ public static String generateRandomFileName() {
+ SimpleDateFormat dateFormat = new
SimpleDateFormat("yyyyMMddHHmmssSSS");
+ String timestamp = dateFormat.format(new Date());
+
+ Random random = new Random();
+ int randomNumber = random.nextInt(900) + 100; // Generates a random
number between 100 and 999
+
+ return timestamp + randomNumber;
+ }
+
/**
* create directories
*
@@ -188,6 +206,27 @@ public class LinuxFileUtils {
}
}
+ public static void moveFile(String source, String dest) {
+ if (StringUtils.isBlank(source) || StringUtils.isBlank(dest)) {
+ log.error("source and dest must not be empty");
+ return;
+ }
+
+ List<String> builderParameters = new ArrayList<>();
+ builderParameters.add("mv");
+ builderParameters.add(source);
+ builderParameters.add(dest);
+
+ try {
+ ShellResult shellResult = sudoExecCmd(builderParameters);
+ if (shellResult.getExitCode() != MessageConstants.SUCCESS_CODE) {
+ throw new StackException(shellResult.getErrMsg());
+ }
+ } catch (IOException e) {
+ throw new StackException(e);
+ }
+ }
+
/**
* create symbolic link
*
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxOSUtils.java
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxOSUtils.java
index aa54d096..d123b097 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxOSUtils.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/utils/linux/LinuxOSUtils.java
@@ -110,7 +110,7 @@ public class LinuxOSUtils {
return new ShellResult(-1, "", "Component is not running");
}
try {
- return execCmd("kill -0 " + pid);
+ return execCmd("sudo kill -0 " + pid);
} catch (IOException e) {
log.warn("Process with pid {} is not running. Stale pid file at
{}, error", pid, filepath, e);
return new ShellResult(-1, "", "Component is not running");
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusSetup.java
b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusSetup.java
index b4063b91..7d03b134 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusSetup.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-infra/src/main/java/org/apache/bigtop/manager/stack/infra/v1_0_0/prometheus/PrometheusSetup.java
@@ -18,6 +18,7 @@
*/
package org.apache.bigtop.manager.stack.infra.v1_0_0.prometheus;
+import org.apache.bigtop.manager.common.constants.Constants;
import org.apache.bigtop.manager.common.shell.ShellResult;
import org.apache.bigtop.manager.stack.core.param.Params;
import org.apache.bigtop.manager.stack.core.utils.linux.LinuxFileUtils;
@@ -26,8 +27,6 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import static
org.apache.bigtop.manager.common.constants.Constants.PERMISSION_755;
-
@Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class PrometheusSetup {
@@ -37,7 +36,7 @@ public class PrometheusSetup {
String user = prometheusParams.user();
String group = prometheusParams.group();
- LinuxFileUtils.createDirectories(prometheusParams.dataDir(), user,
group, PERMISSION_755, true);
+ LinuxFileUtils.createDirectories(prometheusParams.dataDir(), user,
group, Constants.PERMISSION_755, true);
return ShellResult.success("Prometheus Configure success!");
}