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 65b0771 BIGTOP-4166: Make task log messages more user friendly (#23)
65b0771 is described below
commit 65b077197dc633bc29c2e358c30194364e301449
Author: Zhiguo Wu <[email protected]>
AuthorDate: Tue Jul 23 11:00:50 2024 +0800
BIGTOP-4166: Make task log messages more user friendly (#23)
---
.../agent/executor/AbstractCommandExecutor.java | 1 +
.../executor/CacheDistributeCommandExecutor.java | 1 -
.../manager/agent/executor/CommandExecutors.java | 4 -
.../agent/executor/ComponentCommandExecutor.java | 1 -
.../agent/executor/HostCheckCommandExecutor.java | 6 +-
.../bigtop/manager/common/shell/ShellExecutor.java | 89 +++++++++-------------
.../manager/common/utils/os/TimeSyncDetection.java | 22 ++++--
.../common/utils/shell/ShellExecutorTests.java | 41 ----------
.../bigtop/manager/common/utils/shell/test.bat | 26 -------
.../stack/bigtop/v3_3_0/hdfs/HdfsSetup.java | 2 +-
.../stack/bigtop/v3_3_0/yarn/YarnSetup.java | 2 +-
.../bigtop/v3_3_0/zookeeper/ZookeeperSetup.java | 2 +-
.../stack/common/repo/AptPackageManager.java | 11 +--
.../stack/common/repo/DnfPackageManager.java | 11 +--
.../stack/common/repo/YumPackageManager.java | 11 +--
.../common/utils/linux/LinuxAccountUtils.java | 14 +---
.../stack/common/utils/linux/LinuxFileUtils.java | 16 ++--
.../manager/stack/core/hook/AbstractHook.java | 8 +-
18 files changed, 88 insertions(+), 180 deletions(-)
diff --git
a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/AbstractCommandExecutor.java
b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/AbstractCommandExecutor.java
index fda8b75..ccbd2a9 100644
---
a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/AbstractCommandExecutor.java
+++
b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/AbstractCommandExecutor.java
@@ -35,6 +35,7 @@ public abstract class AbstractCommandExecutor implements
CommandExecutor {
@Override
public CommandReply execute(CommandRequest request) {
+ log.info("Running task: {}", request.getTaskId());
commandRequest = request;
commandReplyBuilder = CommandReply.newBuilder();
diff --git
a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/CacheDistributeCommandExecutor.java
b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/CacheDistributeCommandExecutor.java
index 2900f17..0098fdd 100644
---
a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/CacheDistributeCommandExecutor.java
+++
b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/CacheDistributeCommandExecutor.java
@@ -54,7 +54,6 @@ public class CacheDistributeCommandExecutor extends
AbstractCommandExecutor {
public void doExecute() {
CacheMessagePayload cacheMessagePayload =
JsonUtils.readFromString(commandRequest.getPayload(),
CacheMessagePayload.class);
- log.info("[agent executeTask] taskEvent is: {}", commandRequest);
String cacheDir = Constants.STACK_CACHE_DIR;
LinuxFileUtils.createDirectories(cacheDir, "root", "root",
"rwxr-xr-x", false);
diff --git
a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/CommandExecutors.java
b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/CommandExecutors.java
index 0170441..f7d174a 100644
---
a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/CommandExecutors.java
+++
b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/CommandExecutors.java
@@ -58,10 +58,6 @@ public class CommandExecutors {
}
COMMAND_EXECUTORS.put(commandExecutor.getCommandType(), beanName);
- log.info(
- "Load JobRunner: {} with identifier: {}",
- commandExecutor.getClass().getName(),
- commandExecutor.getCommandType());
}
LOADED.set(true);
diff --git
a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/ComponentCommandExecutor.java
b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/ComponentCommandExecutor.java
index 9ec7020..7df2bd3 100644
---
a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/ComponentCommandExecutor.java
+++
b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/ComponentCommandExecutor.java
@@ -47,7 +47,6 @@ public class ComponentCommandExecutor extends
AbstractCommandExecutor {
@Override
public void doExecute() {
CommandPayload commandPayload =
JsonUtils.readFromString(commandRequest.getPayload(), CommandPayload.class);
- log.info("[agent executeTask] taskEvent is: {}", commandRequest);
ShellResult shellResult = StackExecutor.execute(commandPayload);
commandReplyBuilder.setCode(shellResult.getExitCode());
diff --git
a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/HostCheckCommandExecutor.java
b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/HostCheckCommandExecutor.java
index 90b2f43..c0c58dc 100644
---
a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/HostCheckCommandExecutor.java
+++
b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/executor/HostCheckCommandExecutor.java
@@ -44,7 +44,6 @@ public class HostCheckCommandExecutor extends
AbstractCommandExecutor {
@Override
public void doExecute() {
- log.info("[agent executeTask] taskEvent is: {}", commandRequest);
ShellResult shellResult = runChecks(List.of(this::checkTimeSync));
commandReplyBuilder.setCode(shellResult.getExitCode());
commandReplyBuilder.setResult(shellResult.getResult());
@@ -63,9 +62,6 @@ public class HostCheckCommandExecutor extends
AbstractCommandExecutor {
}
private ShellResult checkTimeSync() {
- ShellResult shellResult = TimeSyncDetection.checkTimeSync();
- log.info("Time sync check result: {}", shellResult.getResult());
-
- return shellResult;
+ return TimeSyncDetection.checkTimeSync();
}
}
diff --git
a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/shell/ShellExecutor.java
b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/shell/ShellExecutor.java
index 64bd648..fe0493c 100644
---
a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/shell/ShellExecutor.java
+++
b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/shell/ShellExecutor.java
@@ -20,6 +20,8 @@ package org.apache.bigtop.manager.common.shell;
import org.apache.bigtop.manager.common.thread.TaskLogThreadDecorator;
+import org.apache.commons.lang3.StringUtils;
+
import lombok.extern.slf4j.Slf4j;
import java.io.BufferedReader;
@@ -36,7 +38,7 @@ import java.util.function.Consumer;
/**
* shell command executor.
- *
+ * <br />
* <code>ShellExecutor</code> should be used in cases where the output
* of the command needs no explicit parsing and where the command, working
* directory and the environment remains unchanged. The output of the command
@@ -59,7 +61,10 @@ public class ShellExecutor {
*/
private final long timeoutInterval;
- private final Consumer<String> consumer;
+ /**
+ * Whether we should append log to log file
+ */
+ private final Boolean appendLog;
/**
* Whether script timed out
@@ -91,15 +96,13 @@ public class ShellExecutor {
* @param timeout Specifies the time in milliseconds, after which the
* command will be killed and the status marked as
timedout.
* If 0, the command will not be timed out.
- * @param consumer the consumer to consume the output of the executed
command.
*/
- private ShellExecutor(
- String[] execString, File dir, Map<String, String> env, long
timeout, Consumer<String> consumer) {
+ private ShellExecutor(String[] execString, File dir, Map<String, String>
env, long timeout, Boolean appendLog) {
this.command = execString.clone();
this.dir = dir;
this.environment = env;
this.timeoutInterval = timeout;
- this.consumer = consumer;
+ this.appendLog = appendLog;
}
/**
@@ -111,7 +114,7 @@ public class ShellExecutor {
* @throws IOException errors
*/
public static ShellResult execCommand(List<String> builderParameters)
throws IOException {
- return execCommand(builderParameters, s -> {});
+ return execCommand(null, builderParameters, 0L, false);
}
/**
@@ -119,13 +122,12 @@ public class ShellExecutor {
* Covers most of the simple cases for user.
*
* @param builderParameters shell command to execute.
- * @param consumer the consumer to consume the output of the executed
command.
+ * @param appendLog append stream log to log file if true.
* @return the output of the executed command.
* @throws IOException errors
*/
- public static ShellResult execCommand(List<String> builderParameters,
Consumer<String> consumer)
- throws IOException {
- return execCommand(null, builderParameters, 0L, consumer);
+ public static ShellResult execCommand(List<String> builderParameters,
Boolean appendLog) throws IOException {
+ return execCommand(null, builderParameters, 0L, appendLog);
}
/**
@@ -138,40 +140,9 @@ public class ShellExecutor {
* @return the output of the executed command.
* @throws IOException errors
*/
- public static ShellResult execCommand(Map<String, String> env,
List<String> builderParameters) throws IOException {
- return execCommand(env, builderParameters, s -> {});
- }
-
- /**
- * Static method to execute a shell command.
- * Covers most of the simple cases without requiring the user to implement
- * the <code>AbstractShell</code> interface.
- *
- * @param env the map of environment key=value
- * @param builderParameters shell command to execute.
- * @param consumer the consumer to consume the output of the executed
command.
- * @return the output of the executed command.
- * @throws IOException errors
- */
- public static ShellResult execCommand(
- Map<String, String> env, List<String> builderParameters,
Consumer<String> consumer) throws IOException {
- return execCommand(env, builderParameters, 0L, consumer);
- }
-
- /**
- * Static method to execute a shell command.
- * Covers most of the simple cases without requiring the user to implement
- * the <code>AbstractShell</code> interface.
- *
- * @param env the map of environment key=value
- * @param builderParameters shell command to execute.
- * @param timeout time in milliseconds after which script should be marked
timeout
- * @return the output of the executed command.
- * @throws IOException errors
- */
- public static ShellResult execCommand(Map<String, String> env,
List<String> builderParameters, long timeout)
+ public static ShellResult execCommand(Map<String, String> env,
List<String> builderParameters, Boolean appendLog)
throws IOException {
- return execCommand(env, builderParameters, timeout, s -> {});
+ return execCommand(env, builderParameters, 0L, appendLog);
}
/**
@@ -182,17 +153,28 @@ public class ShellExecutor {
* @param env the map of environment key=value
* @param builderParameters shell command to execute.
* @param timeout time in milliseconds after which script should be marked
timeout
- * @param consumer the consumer to consume the output of the executed
command.
* @return the output of the executed command.
* @throws IOException errors
*/
public static ShellResult execCommand(
- Map<String, String> env, List<String> builderParameters, long
timeout, Consumer<String> consumer)
+ Map<String, String> env, List<String> builderParameters, long
timeout, Boolean appendLog)
throws IOException {
String[] cmd = builderParameters.toArray(new String[0]);
+ ShellExecutor shellExecutor = new ShellExecutor(cmd, null, env,
timeout, appendLog);
+
+ if (appendLog) {
+ log.info(StringUtils.EMPTY);
+ log.info("********** Running: {} **********", String.join(" ",
builderParameters));
+ }
+
+ ShellResult result = shellExecutor.execute();
- ShellExecutor shellExecutor = new ShellExecutor(cmd, null, env,
timeout, consumer);
- return shellExecutor.execute();
+ if (appendLog) {
+ log.info("********** Finished: {} **********", String.join(" ",
builderParameters));
+ log.info(StringUtils.EMPTY);
+ }
+
+ return result;
}
/**
@@ -224,11 +206,11 @@ public class ShellExecutor {
// free the error stream buffer
BufferedReader errReader =
createBufferedReader(process.getErrorStream());
StringBuilder errMsg = new StringBuilder();
- Thread errThread = createReaderThread(errReader, errMsg);
+ Thread errThread = createReaderThread(errReader, errMsg, log::error);
BufferedReader inReader =
createBufferedReader(process.getInputStream());
StringBuilder inMsg = new StringBuilder();
- Thread inThread = createReaderThread(inReader, inMsg);
+ Thread inThread = createReaderThread(inReader, inMsg, log::info);
try {
errThread.start();
@@ -306,13 +288,16 @@ public class ShellExecutor {
return new BufferedReader(new InputStreamReader(inputStream));
}
- private Thread createReaderThread(BufferedReader reader, StringBuilder
msg) {
+ private Thread createReaderThread(BufferedReader reader, StringBuilder
msg, Consumer<String> consumer) {
TaskLogThreadDecorator decorator = new TaskLogThreadDecorator();
return decorator.decorate(() -> {
try {
String line = reader.readLine();
while ((line != null)) {
- consumer.accept(line);
+ if (appendLog) {
+ consumer.accept(line);
+ }
+
msg.append(line);
msg.append(System.lineSeparator());
line = reader.readLine();
diff --git
a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/os/TimeSyncDetection.java
b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/os/TimeSyncDetection.java
index f6cab06..c436d35 100644
---
a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/os/TimeSyncDetection.java
+++
b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/utils/os/TimeSyncDetection.java
@@ -21,10 +21,13 @@ package org.apache.bigtop.manager.common.utils.os;
import org.apache.bigtop.manager.common.shell.ShellExecutor;
import org.apache.bigtop.manager.common.shell.ShellResult;
+import lombok.extern.slf4j.Slf4j;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+@Slf4j
public class TimeSyncDetection {
public static ShellResult checkTimeSync() {
@@ -34,18 +37,27 @@ public class TimeSyncDetection {
params.add("chronyd");
ShellResult shellResult;
try {
+ log.info("Checking service chronyd status");
shellResult = ShellExecutor.execCommand(params);
+ if (shellResult.getExitCode() == 0) {
+ log.info("Service chronyd is enabled");
+ return shellResult;
+ }
- if (shellResult.getExitCode() != 0) {
- params.remove(params.size() - 1);
- params.add("ntpd");
- shellResult = ShellExecutor.execCommand(params);
+ log.info("Service chronyd is not enabled, checking ntpd status");
+ params.remove(params.size() - 1);
+ params.add("ntpd");
+ shellResult = ShellExecutor.execCommand(params);
+ if (shellResult.getExitCode() == 0) {
+ log.info("Service ntpd is enabled");
+ return shellResult;
}
+ log.info("Service ntpd is not enabled");
} catch (IOException e) {
shellResult = new ShellResult();
shellResult.setExitCode(-1);
- shellResult.setErrMsg("Neither chronyd nor ntpd check failed.");
+ shellResult.setErrMsg("Neither chronyd nor ntpd check failed");
}
return shellResult;
diff --git
a/bigtop-manager-common/src/test/java/org/apache/bigtop/manager/common/utils/shell/ShellExecutorTests.java
b/bigtop-manager-common/src/test/java/org/apache/bigtop/manager/common/utils/shell/ShellExecutorTests.java
deleted file mode 100644
index cf6f0ed..0000000
---
a/bigtop-manager-common/src/test/java/org/apache/bigtop/manager/common/utils/shell/ShellExecutorTests.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.bigtop.manager.common.utils.shell;
-
-import org.apache.bigtop.manager.common.shell.ShellExecutor;
-import org.apache.bigtop.manager.common.shell.ShellResult;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ShellExecutorTests {
-
- public static void main(String[] args) throws Exception {
- List<String> builderParameters = new ArrayList<>();
- builderParameters.add("cmd");
- builderParameters.add("/c");
- builderParameters.add(
-
"E:\\Projects\\GitHub\\bigtop-manager\\bigtop-manager-common\\src\\test\\java\\org\\apache\\bigtop\\manager\\common\\utils\\shell\\test.bat");
-
- List<String> res = new ArrayList<>();
- ShellResult shellResult = ShellExecutor.execCommand(builderParameters,
System.out::println);
- System.out.println("-----------");
- System.out.println(shellResult.getResult());
- }
-}
diff --git
a/bigtop-manager-common/src/test/java/org/apache/bigtop/manager/common/utils/shell/test.bat
b/bigtop-manager-common/src/test/java/org/apache/bigtop/manager/common/utils/shell/test.bat
deleted file mode 100644
index 17fa0e6..0000000
---
a/bigtop-manager-common/src/test/java/org/apache/bigtop/manager/common/utils/shell/test.bat
+++ /dev/null
@@ -1,26 +0,0 @@
-@REM
----------------------------------------------------------------------------
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements. See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership. The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License. You may obtain a copy of the License at
-@REM
-@REM https://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied. See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM
----------------------------------------------------------------------------
-
-@echo off
-for /L %%i in (1,1,30) do (
- echo %%i
- ping 127.0.0.1 -n 2 > nul
-)
-
-echo This is an error message >&2
\ No newline at end of file
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 0fca2f6..274eac1 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
@@ -46,7 +46,7 @@ public class HdfsSetup {
}
public static ShellResult config(Params params, String componentName) {
- log.info("starting HDFS config");
+ log.info("Setting hdfs config");
HdfsParams hdfsParams = (HdfsParams) params;
String confDir = hdfsParams.confDir();
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/yarn/YarnSetup.java
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/yarn/YarnSetup.java
index 236dda9..f11c908 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/yarn/YarnSetup.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-bigtop/src/main/java/org/apache/bigtop/manager/stack/bigtop/v3_3_0/yarn/YarnSetup.java
@@ -43,7 +43,7 @@ public class YarnSetup {
}
public static ShellResult config(Params params, String componentName) {
- log.info("starting YARN config");
+ log.info("Setting yarn config");
YarnParams yarnParams = (YarnParams) params;
String confDir = yarnParams.confDir();
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 57ee220..9d1346e 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
@@ -42,7 +42,7 @@ import static
org.apache.bigtop.manager.common.constants.Constants.PERMISSION_75
public class ZookeeperSetup {
public static ShellResult config(Params params) {
- log.info("ZookeeperSetup config");
+ log.info("Setting zookeeper config");
ZookeeperParams zookeeperParams = (ZookeeperParams) params;
String confDir = zookeeperParams.confDir();
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/repo/AptPackageManager.java
b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/repo/AptPackageManager.java
index cf2ebd3..86212d2 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/repo/AptPackageManager.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/repo/AptPackageManager.java
@@ -48,9 +48,7 @@ public class AptPackageManager implements PackageManager {
builderParameters.addAll(packages);
try {
- ShellResult output = ShellExecutor.execCommand(builderParameters,
log::info);
- log.info("[AptPackageManager] [installPackage] output: {}",
output);
- return output;
+ return ShellExecutor.execCommand(builderParameters, true);
} catch (IOException e) {
throw new StackException(e);
}
@@ -65,9 +63,7 @@ public class AptPackageManager implements PackageManager {
builderParameters.addAll(packages);
try {
- ShellResult output = ShellExecutor.execCommand(builderParameters,
log::info);
- log.info("[AptPackageManager] [uninstallPackage] output: {}",
output);
- return output;
+ return ShellExecutor.execCommand(builderParameters, true);
} catch (IOException e) {
throw new StackException(e);
}
@@ -80,8 +76,7 @@ public class AptPackageManager implements PackageManager {
builderParameters.add("list");
try {
- ShellResult output = ShellExecutor.execCommand(builderParameters,
log::info);
- log.info("[AptPackageManager] [listPackages] output: {}", output);
+ ShellResult output = ShellExecutor.execCommand(builderParameters);
return output.getOutput();
} catch (IOException e) {
throw new StackException(e);
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/repo/DnfPackageManager.java
b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/repo/DnfPackageManager.java
index 59a5fb8..628267f 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/repo/DnfPackageManager.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/repo/DnfPackageManager.java
@@ -47,9 +47,7 @@ public class DnfPackageManager implements PackageManager {
builderParameters.addAll(packages);
try {
- ShellResult output = ShellExecutor.execCommand(builderParameters,
log::info);
- log.info("[DnfPackageManager] [installPackage] output: {}",
output);
- return output;
+ return ShellExecutor.execCommand(builderParameters, true);
} catch (IOException e) {
throw new StackException(e);
}
@@ -64,9 +62,7 @@ public class DnfPackageManager implements PackageManager {
builderParameters.addAll(packages);
try {
- ShellResult output = ShellExecutor.execCommand(builderParameters,
log::info);
- log.info("[DnfPackageManager] [uninstallPackage] output: {}",
output);
- return output;
+ return ShellExecutor.execCommand(builderParameters, true);
} catch (IOException e) {
throw new StackException(e);
}
@@ -79,8 +75,7 @@ public class DnfPackageManager implements PackageManager {
builderParameters.add("list");
try {
- ShellResult output = ShellExecutor.execCommand(builderParameters,
log::info);
- log.info("[DnfPackageManager] [listPackages] output: {}", output);
+ ShellResult output = ShellExecutor.execCommand(builderParameters);
return output.getOutput();
} catch (IOException e) {
throw new StackException(e);
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/repo/YumPackageManager.java
b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/repo/YumPackageManager.java
index 2df789c..35a0a3e 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/repo/YumPackageManager.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/repo/YumPackageManager.java
@@ -47,9 +47,7 @@ public class YumPackageManager implements PackageManager {
builderParameters.addAll(packages);
try {
- ShellResult output = ShellExecutor.execCommand(builderParameters,
log::info);
- log.info("[RpmPackageManager] [installPackage] output: {}",
output);
- return output;
+ return ShellExecutor.execCommand(builderParameters, true);
} catch (IOException e) {
throw new StackException(e);
}
@@ -64,9 +62,7 @@ public class YumPackageManager implements PackageManager {
builderParameters.addAll(packages);
try {
- ShellResult output = ShellExecutor.execCommand(builderParameters,
log::info);
- log.info("[RpmPackageManager] [uninstallPackage] output: {}",
output);
- return output;
+ return ShellExecutor.execCommand(builderParameters, true);
} catch (IOException e) {
throw new StackException(e);
}
@@ -79,8 +75,7 @@ public class YumPackageManager implements PackageManager {
builderParameters.add("list");
try {
- ShellResult output = ShellExecutor.execCommand(builderParameters,
log::info);
- log.info("[RpmPackageManager] [listPackages] output: {}", output);
+ ShellResult output = ShellExecutor.execCommand(builderParameters);
return output.getOutput();
} catch (IOException e) {
throw new StackException(e);
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/linux/LinuxAccountUtils.java
b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/linux/LinuxAccountUtils.java
index 1e9467f..bd9db98 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/linux/LinuxAccountUtils.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/linux/LinuxAccountUtils.java
@@ -64,8 +64,7 @@ public class LinuxAccountUtils {
builderParameters.add(user);
try {
- ShellResult output = ShellExecutor.execCommand(builderParameters);
- log.info("[AccountGroupUtils] [userDel] output: {}", output);
+ ShellExecutor.execCommand(builderParameters);
} catch (IOException e) {
throw new StackException(e);
}
@@ -152,8 +151,7 @@ public class LinuxAccountUtils {
builderParameters.add(user);
try {
- ShellResult output = ShellExecutor.execCommand(builderParameters);
- log.info("[AccountGroupUtils] [userAdd] output: {}", output);
+ ShellExecutor.execCommand(builderParameters);
} catch (IOException e) {
throw new StackException(e);
}
@@ -178,8 +176,7 @@ public class LinuxAccountUtils {
builderParameters.add(group);
try {
- ShellResult output = ShellExecutor.execCommand(builderParameters);
- log.info("[AccountGroupUtils] [addGroup] output: {}", output);
+ ShellExecutor.execCommand(builderParameters);
} catch (IOException e) {
throw new StackException(e);
}
@@ -227,8 +224,7 @@ public class LinuxAccountUtils {
builderParameters.add(group);
try {
- ShellResult output = ShellExecutor.execCommand(builderParameters);
- log.info("[AccountGroupUtils] [addGroup] output: {}", output);
+ ShellExecutor.execCommand(builderParameters);
} catch (IOException e) {
throw new StackException(e);
}
@@ -251,7 +247,6 @@ public class LinuxAccountUtils {
try {
ShellResult output = ShellExecutor.execCommand(builderParameters);
- log.info("[AccountGroupUtils] [checkIfExistsGroup] output: {}",
output);
return output.getExitCode() == 0;
} catch (IOException e) {
throw new StackException(e);
@@ -274,7 +269,6 @@ public class LinuxAccountUtils {
try {
ShellResult output = ShellExecutor.execCommand(builderParameters);
- log.info("[AccountGroupUtils] [checkIfExistsUser] output: {}",
output);
return output.getExitCode() == 0;
} catch (IOException e) {
throw new StackException(e);
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/linux/LinuxFileUtils.java
b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/linux/LinuxFileUtils.java
index 028be6e..a84e8c6 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/linux/LinuxFileUtils.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/linux/LinuxFileUtils.java
@@ -146,10 +146,10 @@ public class LinuxFileUtils {
Path path = Paths.get(dir);
Set<PosixFilePermission> perms =
PosixFilePermissions.fromString(permissions);
try {
+ log.info("Changing permissions to [{}] for [{}]", permissions,
dir);
Files.setPosixFilePermissions(path, perms);
- log.info("Permissions set successfully.");
} catch (IOException e) {
- log.error("[updatePermissions] error", e);
+ log.error("Error when change permissions", e);
}
// When is a directory, recursive update
@@ -159,7 +159,7 @@ public class LinuxFileUtils {
updatePermissions(dir + File.separator +
subPath.getFileName(), permissions, true);
}
} catch (IOException e) {
- log.error("[updatePermissions] error", e);
+ log.error("Error when change permissions", e);
}
}
}
@@ -182,6 +182,7 @@ public class LinuxFileUtils {
Path path = Paths.get(dir);
try {
+ log.info("Changing owner to [{}:{}] for [{}]", owner, group, dir);
UserPrincipal userPrincipal =
path.getFileSystem().getUserPrincipalLookupService().lookupPrincipalByName(owner);
@@ -192,7 +193,7 @@ public class LinuxFileUtils {
fileAttributeView.setOwner(userPrincipal);
fileAttributeView.setGroup(groupPrincipal);
} catch (IOException e) {
- log.error("[updateOwner] error", e);
+ log.error("Error when change owner", e);
}
// When it is a directory, recursively set the file owner
@@ -202,7 +203,7 @@ public class LinuxFileUtils {
updateOwner(dir + File.separator + subPath.getFileName(),
owner, group, true);
}
} catch (IOException e) {
- log.error("[updateOwner] error", e);
+ log.error("Error when change owner", e);
}
}
}
@@ -225,14 +226,15 @@ public class LinuxFileUtils {
Path path = Paths.get(dirPath);
if (Files.isSymbolicLink(path)) {
- log.warn("unable to create symbolic link: {}", dirPath);
+ log.warn("unable to create symbolic link: [{}]", dirPath);
return;
}
try {
+ log.info("Creating directory: [{}]", path);
Files.createDirectories(path);
} catch (IOException e) {
- log.error("[createDirectories] error", e);
+ log.error("Error when create directory", e);
}
updateOwner(dirPath, owner, group, recursive);
diff --git
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/hook/AbstractHook.java
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/hook/AbstractHook.java
index 361f905..c07b5ec 100644
---
a/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/hook/AbstractHook.java
+++
b/bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/hook/AbstractHook.java
@@ -52,10 +52,16 @@ public abstract class AbstractHook implements Hook {
for (Map.Entry<String, Set<String>> user : users.entrySet()) {
Set<String> groups = user.getValue();
- log.info("user: {}, groups: {}", user.getKey(), user.getValue());
for (String group : groups) {
+ log.info("Adding group: {}", group);
LinuxAccountUtils.groupAdd(group);
}
+
+ log.info(
+ "Adding user: {} to group: {} and groups: [{}]",
+ user.getKey(),
+ userGroup,
+ String.join(",", groups));
LinuxAccountUtils.userAdd(user.getKey(), userGroup, groups);
}
}