diff --git a/README.md b/README.md index 528280caf..391f00a62 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Bigtop-Manager is a platform for managing Bigtop components. Inspired by Apache ## Prerequisites JDK: Requires JDK 17 or 21 -Metadata DB: Mariadb or Mysql +Metadata DB: Mariadb or Mysql(8 or above) ### API-DOCS [swagger-ui](http://localhost:8080/swagger-ui/index.html) 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 fda8b755b..ccbd2a991 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 2900f171b..0098fdd41 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 CommandType getCommandType() { 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 01704410c..f7d174add 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 @@ private static synchronized void load() { } 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 9ec70206f..7df2bd350 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 @@ protected void doExecuteOnDevMode() { @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 90b2f4379..c0c58dca0 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 CommandType getCommandType() { @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 @@ private ShellResult runChecks(List> suppliers) { } 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 64bd6489d..fe0493c2d 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 @@ 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 @@ /** * shell command executor. - * + *
* ShellExecutor 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 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 env, long timeout, Consumer consumer) { + private ShellExecutor(String[] execString, File dir, Map 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 @@ private ShellExecutor( * @throws IOException errors */ public static ShellResult execCommand(List builderParameters) throws IOException { - return execCommand(builderParameters, s -> {}); + return execCommand(null, builderParameters, 0L, false); } /** @@ -119,13 +122,12 @@ public static ShellResult execCommand(List builderParameters) throws IOE * 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 builderParameters, Consumer consumer) - throws IOException { - return execCommand(null, builderParameters, 0L, consumer); + public static ShellResult execCommand(List builderParameters, Boolean appendLog) throws IOException { + return execCommand(null, builderParameters, 0L, appendLog); } /** @@ -138,40 +140,9 @@ public static ShellResult execCommand(List builderParameters, Consumer env, List 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 AbstractShell 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 env, List builderParameters, Consumer 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 AbstractShell 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 env, List builderParameters, long timeout) + public static ShellResult execCommand(Map env, List builderParameters, Boolean appendLog) throws IOException { - return execCommand(env, builderParameters, timeout, s -> {}); + return execCommand(env, builderParameters, 0L, appendLog); } /** @@ -182,17 +153,28 @@ public static ShellResult execCommand(Map env, List buil * @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 env, List builderParameters, long timeout, Consumer consumer) + Map env, List 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 @@ private ShellResult execute() throws IOException { // 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 @@ private BufferedReader createBufferedReader(InputStream inputStream) { return new BufferedReader(new InputStreamReader(inputStream)); } - private Thread createReaderThread(BufferedReader reader, StringBuilder msg) { + private Thread createReaderThread(BufferedReader reader, StringBuilder msg, Consumer 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 f6cab063c..c436d35f1 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 @@ 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 static ShellResult checkTimeSync() { 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 cf6f0ed8a..000000000 --- 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 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 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 17fa0e646..000000000 --- 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-server/src/main/resources/ddl/MySQL-DDL-CREATE.sql b/bigtop-manager-server/src/main/resources/ddl/MySQL-DDL-CREATE.sql index 8acb07767..c7a5f5f54 100644 --- a/bigtop-manager-server/src/main/resources/ddl/MySQL-DDL-CREATE.sql +++ b/bigtop-manager-server/src/main/resources/ddl/MySQL-DDL-CREATE.sql @@ -82,11 +82,11 @@ CREATE TABLE `host` `hostname` VARCHAR(255) DEFAULT NULL, `ipv4` VARCHAR(32) DEFAULT NULL, `ipv6` VARCHAR(32) DEFAULT NULL, - `os_arch` VARCHAR(32) NOT NULL, - `os_name` VARCHAR(32) NOT NULL, - `processor_count` INT NOT NULL, - `physical_memory` BIGINT NOT NULL COMMENT 'Total Physical Memory(Bytes)', - `state` VARCHAR(32) NOT NULL, + `arch` VARCHAR(32) DEFAULT NULL, + `os` VARCHAR(32) DEFAULT NULL, + `processor_count` INT DEFAULT NULL, + `physical_memory` BIGINT DEFAULT NULL COMMENT 'Total Physical Memory(Bytes)', + `state` VARCHAR(32) DEFAULT NULL, `create_time` DATETIME DEFAULT NULL, `update_time` DATETIME DEFAULT NULL, PRIMARY KEY (`id`), @@ -98,9 +98,9 @@ CREATE TABLE `repo` ( `cluster_id` BIGINT(20) UNSIGNED NOT NULL, `os` VARCHAR(32) DEFAULT NULL, `arch` VARCHAR(32) DEFAULT NULL, - `base_url` VARCHAR(32) DEFAULT NULL, + `base_url` VARCHAR(64) DEFAULT NULL, `repo_id` VARCHAR(32) DEFAULT NULL, - `repo_name` VARCHAR(32) DEFAULT NULL, + `repo_name` VARCHAR(64) DEFAULT NULL, `create_time` DATETIME DEFAULT NULL, `update_time` DATETIME DEFAULT NULL, PRIMARY KEY (`id`), @@ -123,7 +123,7 @@ CREATE TABLE `job` `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `cluster_id` BIGINT(20) UNSIGNED DEFAULT NULL, `state` VARCHAR(32) NOT NULL, - `context` VARCHAR(32) NOT NULL, + `context` TEXT NOT NULL, `create_time` DATETIME DEFAULT NULL, `update_time` DATETIME DEFAULT NULL, PRIMARY KEY (`id`), 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 0fca2f6e2..274eac183 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 static ShellResult config(Params params) { } 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 236dda91c..f11c908df 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 static ShellResult config(Params params) { } 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 57ee22044..9d1346e7e 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 @@ 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 cf2ebd3c8..86212d27e 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 ShellResult installPackage(Collection packages) { 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 ShellResult uninstallPackage(Collection packages) { 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 String listPackages() { 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 59a5fb88e..628267f1b 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 ShellResult installPackage(Collection packages) { 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 ShellResult uninstallPackage(Collection packages) { 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 String listPackages() { 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 2df789cf4..35a0a3ec0 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 ShellResult installPackage(Collection packages) { 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 ShellResult uninstallPackage(Collection packages) { 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 String listPackages() { 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 1e9467fc8..bd9db98e6 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 static void userDel(String user) { 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 static void userAdd( 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 static void groupDel(String group) { 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 static void groupAdd(String group, String gid, String password) { 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 static boolean isGroupExists(String group) { 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 static boolean isUserExists(String user) { 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 028be6eea..a84e8c656 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 static void updatePermissions(String dir, String permissions, boolean rec Path path = Paths.get(dir); Set 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 static void updatePermissions(String dir, String permissions, boolean rec 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 static void updateOwner(String dir, String owner, String group, boolean r 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 static void updateOwner(String dir, String owner, String group, boolean r 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 static void updateOwner(String dir, String owner, String group, boolean r 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 static void createDirectories( 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 361f90595..c07b5ec88 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 @@ private void addUserAndGroup() { for (Map.Entry> user : users.entrySet()) { Set 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); } }