diff --git a/.gitignore b/.gitignore
index aa3e64d7..e99a1b64 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,6 +40,7 @@ build/
### Log ###
logs
+tasklogs
*.log
npm-debug.log*
yarn-debug.log*
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 8beffd95..e54bd614 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
@@ -20,7 +20,6 @@
import org.apache.bigtop.manager.agent.holder.SpringContextHolder;
import org.apache.bigtop.manager.common.constants.MessageConstants;
-import org.apache.bigtop.manager.common.message.entity.command.CommandLogMessage;
import org.apache.bigtop.manager.common.message.entity.command.CommandRequestMessage;
import org.apache.bigtop.manager.common.message.entity.command.CommandResponseMessage;
import org.apache.bigtop.manager.common.shell.ShellResult;
@@ -68,15 +67,4 @@ protected void doExecuteOnDevMode() {
}
protected abstract void doExecute();
-
- protected void writeBackCommandLog(String log) {
- CommandLogMessage logMessage = new CommandLogMessage();
- logMessage.setLog(log);
- logMessage.setMessageId(commandRequestMessage.getMessageId());
- logMessage.setHostname(commandRequestMessage.getHostname());
- logMessage.setTaskId(commandRequestMessage.getTaskId());
- logMessage.setStageId(commandRequestMessage.getStageId());
- logMessage.setJobId(commandRequestMessage.getJobId());
- SpringContextHolder.getAgentWebSocket().sendMessage(logMessage);
- }
}
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 6d4fb043..c7af4743 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
@@ -49,7 +49,7 @@ public void doExecute() {
CommandPayload commandPayload =
JsonUtils.readFromString(commandRequestMessage.getMessagePayload(), CommandPayload.class);
log.info("[agent executeTask] taskEvent is: {}", commandRequestMessage);
- ShellResult shellResult = StackExecutor.execute(commandPayload, this::writeBackCommandLog);
+ ShellResult shellResult = StackExecutor.execute(commandPayload);
commandResponseMessage.setCode(shellResult.getExitCode());
commandResponseMessage.setResult(shellResult.getResult());
diff --git a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/scheduler/DefaultCommandScheduler.java b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/scheduler/DefaultCommandScheduler.java
index 230a62e4..55eb8ba1 100644
--- a/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/scheduler/DefaultCommandScheduler.java
+++ b/bigtop-manager-agent/src/main/java/org/apache/bigtop/manager/agent/scheduler/DefaultCommandScheduler.java
@@ -22,6 +22,7 @@
import org.apache.bigtop.manager.agent.executor.CommandExecutors;
import org.apache.bigtop.manager.common.message.entity.command.CommandRequestMessage;
+import org.slf4j.MDC;
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
@@ -45,10 +46,13 @@ public class DefaultCommandScheduler implements CommandScheduler {
public void submit(CommandRequestMessage message) {
queue.offer(() -> {
try {
+ MDC.put("taskId", message.getTaskId().toString());
CommandExecutor commandExecutor = CommandExecutors.getCommandExecutor(message.getCommandMessageType());
commandExecutor.execute(message);
} catch (Exception e) {
log.error("Error when running command", e);
+ } finally {
+ MDC.clear();
}
});
}
diff --git a/bigtop-manager-agent/src/main/resources/logback-spring.xml b/bigtop-manager-agent/src/main/resources/logback-spring.xml
index 5f50ee16..dbde0dbb 100644
--- a/bigtop-manager-agent/src/main/resources/logback-spring.xml
+++ b/bigtop-manager-agent/src/main/resources/logback-spring.xml
@@ -19,76 +19,58 @@
-->
-
-
+
+
- [%-5level] %date{yyyy-MM-dd HH:mm:ss.SSS Z} [%thread] %logger{96}:[%line] - %msg%n
+ [%-5level] %date{yyyy-MM-dd HH:mm:ss.SSS Z} [%thread] %logger{1}:[%line] - %m%n
UTF-8
-
- ${log.base}/ws.log
-
- ${log.base}/ws.%d{yyyy-MM-dd}.%i.log
- 30
- 200MB
- 10GB
- true
-
-
- [%-5level] %date{yyyy-MM-dd HH:mm:ss.SSS Z} [%thread] %logger{96}:[%line] - %msg%n
- UTF-8
-
-
-
- ${log.base}/bigtop-manager-stack.log
+
+ ${log.base}/bigtop-manager-agent.log
- ${log.base}/bigtop-manager-stack.%d{yyyy-MM-dd}.%i.log
+ ${log.base}/bigtop-manager-agent.%d{yyyy-MM-dd}.%i.log
30
200MB
10GB
true
- [%-5level] %date{yyyy-MM-dd HH:mm:ss.SSS Z} [%thread] %logger{96}:[%line] - %msg%n
+ [%-5level] %date{yyyy-MM-dd HH:mm:ss.SSS Z} [%thread] %logger{1}:[%line] - %m%n
UTF-8
-
- ${log.base}/bigtop-manager-agent.log
+
+
- logger.contains("org.apache.bigtop.manager.stack")
+ mdc.get("taskId") != null
- DENY
- ACCEPT
+ ACCEPT
+ DENY
-
- ${log.base}/bigtop-manager-agent.%d{yyyy-MM-dd}.%i.log
- 30
- 200MB
- 10GB
- true
-
-
- [%-5level] %date{yyyy-MM-dd HH:mm:ss.SSS Z} [%thread] %logger{96}:[%line] - %msg%n
- UTF-8
-
+
+ taskId
+ 0
+
+
+
+ tasklogs/task-${taskId}.log
+
+ [%-5level] %date{yyyy-MM-dd HH:mm:ss.SSS Z} - %m%n
+ UTF-8
+
+ true
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/command/CommandLogMessage.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/command/CommandLogMessage.java
deleted file mode 100644
index a092d964..00000000
--- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/entity/command/CommandLogMessage.java
+++ /dev/null
@@ -1,45 +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.message.entity.command;
-
-import org.apache.bigtop.manager.common.message.entity.BaseMessage;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-import lombok.ToString;
-
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-@NoArgsConstructor
-@AllArgsConstructor
-public class CommandLogMessage extends BaseMessage {
-
- private String log;
-
- private String hostname;
-
- private Long jobId;
-
- private Long stageId;
-
- private Long taskId;
-}
diff --git a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/serializer/KryoPoolHolder.java b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/serializer/KryoPoolHolder.java
index e036967b..b690d379 100644
--- a/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/serializer/KryoPoolHolder.java
+++ b/bigtop-manager-common/src/main/java/org/apache/bigtop/manager/common/message/serializer/KryoPoolHolder.java
@@ -23,7 +23,6 @@
import org.apache.bigtop.manager.common.message.entity.BaseRequestMessage;
import org.apache.bigtop.manager.common.message.entity.BaseResponseMessage;
import org.apache.bigtop.manager.common.message.entity.HeartbeatMessage;
-import org.apache.bigtop.manager.common.message.entity.command.CommandLogMessage;
import org.apache.bigtop.manager.common.message.entity.command.CommandMessageType;
import org.apache.bigtop.manager.common.message.entity.command.CommandRequestMessage;
import org.apache.bigtop.manager.common.message.entity.command.CommandResponseMessage;
@@ -62,7 +61,6 @@ protected Kryo create() {
kryo.register(HeartbeatMessage.class);
kryo.register(CommandResponseMessage.class);
kryo.register(CommandRequestMessage.class);
- kryo.register(CommandLogMessage.class);
// message pojo
kryo.register(HostInfo.class);
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/entity/CommandLog.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/entity/CommandLog.java
deleted file mode 100644
index 728bbff8..00000000
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/entity/CommandLog.java
+++ /dev/null
@@ -1,81 +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.dao.entity;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-import jakarta.persistence.Basic;
-import jakarta.persistence.Column;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
-import jakarta.persistence.Index;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.Lob;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.Table;
-import jakarta.persistence.TableGenerator;
-
-@Data
-@EqualsAndHashCode(callSuper = true)
-@Entity
-@Table(
- name = "command_log",
- indexes = {
- @Index(name = "idx_cl_job_id", columnList = "job_id"),
- @Index(name = "idx_cl_stage_id", columnList = "stage_id"),
- @Index(name = "idx_cl_task_id", columnList = "task_id")
- })
-@TableGenerator(
- name = "command_log_generator",
- table = "sequence",
- pkColumnName = "seq_name",
- valueColumnName = "seq_count")
-public class CommandLog extends BaseEntity {
-
- @Id
- @GeneratedValue(strategy = GenerationType.TABLE, generator = "command_log_generator")
- @Column(name = "id")
- private Long id;
-
- @Lob
- @Basic(fetch = FetchType.LAZY)
- @Column(name = "\"log\"", length = 16777216)
- private String log;
-
- @Column(name = "hostname")
- private String hostname;
-
- @ManyToOne
- @JoinColumn(name = "job_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private Job job;
-
- @ManyToOne
- @JoinColumn(name = "stage_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private Stage stage;
-
- @ManyToOne
- @JoinColumn(name = "task_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
- private Task task;
-}
diff --git a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/CommandLogRepository.java b/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/CommandLogRepository.java
deleted file mode 100644
index 65eb7062..00000000
--- a/bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/repository/CommandLogRepository.java
+++ /dev/null
@@ -1,28 +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.dao.repository;
-
-import org.apache.bigtop.manager.dao.entity.CommandLog;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-
-public interface CommandLogRepository extends JpaRepository {
-
- CommandLog findByTaskIdEquals(Long taskId);
-}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/runner/AbstractStageRunner.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/runner/AbstractStageRunner.java
index 57f1563f..d7c085bf 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/runner/AbstractStageRunner.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/stage/runner/AbstractStageRunner.java
@@ -89,8 +89,10 @@ public void run() {
boolean taskSuccess = res != null && res.getCode() == MessageConstants.SUCCESS_CODE;
if (taskSuccess) {
+ commandLogService.onLogReceived(task.getId(), task.getHostname(), "Success!");
onTaskSuccess(task);
} else {
+ commandLogService.onLogReceived(task.getId(), task.getHostname(), "Failed!");
onTaskFailure(task);
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/CommandLogServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/CommandLogServiceImpl.java
index 67d340e6..945eb47d 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/CommandLogServiceImpl.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/CommandLogServiceImpl.java
@@ -18,10 +18,6 @@
*/
package org.apache.bigtop.manager.server.service.impl;
-import org.apache.bigtop.manager.dao.entity.CommandLog;
-import org.apache.bigtop.manager.dao.entity.Task;
-import org.apache.bigtop.manager.dao.repository.CommandLogRepository;
-import org.apache.bigtop.manager.dao.repository.TaskRepository;
import org.apache.bigtop.manager.server.service.CommandLogService;
import org.apache.commons.collections4.CollectionUtils;
@@ -30,7 +26,6 @@
import reactor.core.publisher.FluxSink;
-import jakarta.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -39,12 +34,6 @@
@Service
public class CommandLogServiceImpl implements CommandLogService {
- @Resource
- private TaskRepository taskRepository;
-
- @Resource
- private CommandLogRepository commandLogRepository;
-
private final Map> taskSinks = new HashMap<>();
private final Map> logs = new HashMap<>();
@@ -60,16 +49,7 @@ public void registerSink(Long taskId, FluxSink sink) {
}
} else {
// Task already completed, get logs from database
- CommandLog commandLog = commandLogRepository.findByTaskIdEquals(taskId);
- if (commandLog != null && commandLog.getLog() != null) {
- list = List.of(commandLog.getLog().split("\n"));
- for (String log : list) {
- sink.next(log);
- }
- } else {
- sink.next("Cannot find log for task: " + taskId + ", there might be something wrong.");
- }
-
+ sink.next("Task finished, please check the log details on agent machine.");
sink.complete();
}
}
@@ -80,15 +60,6 @@ public void unregisterSink(Long taskId) {
@Override
public void onLogStarted(Long taskId, String hostname) {
- Task task = taskRepository.getReferenceById(taskId);
-
- CommandLog commandLog = new CommandLog();
- commandLog.setHostname(hostname);
- commandLog.setTask(task);
- commandLog.setStage(task.getStage());
- commandLog.setJob(task.getJob());
- commandLogRepository.save(commandLog);
-
logs.put(taskId, new ArrayList<>());
}
@@ -116,14 +87,5 @@ public void onLogEnded(Long taskId, String hostname) {
}
logs.remove(taskId);
- if (CollectionUtils.isNotEmpty(list)) {
- CommandLog commandLog = commandLogRepository.findByTaskIdEquals(taskId);
- commandLog.setLog(String.join("\n", list));
- commandLogRepository.save(commandLog);
- }
- }
-
- public static void sink(Long taskId, FluxSink sink) {
- sink.next("aaa");
}
}
diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/ws/ServerWebSocketHandler.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/ws/ServerWebSocketHandler.java
index 1ad30c06..b1c163ca 100644
--- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/ws/ServerWebSocketHandler.java
+++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/ws/ServerWebSocketHandler.java
@@ -21,11 +21,9 @@
import org.apache.bigtop.manager.common.message.entity.BaseMessage;
import org.apache.bigtop.manager.common.message.entity.BaseRequestMessage;
import org.apache.bigtop.manager.common.message.entity.HeartbeatMessage;
-import org.apache.bigtop.manager.common.message.entity.command.CommandLogMessage;
import org.apache.bigtop.manager.common.message.entity.command.CommandResponseMessage;
import org.apache.bigtop.manager.common.message.entity.pojo.HostInfo;
import org.apache.bigtop.manager.common.ws.AbstractBinaryWebSocketHandler;
-import org.apache.bigtop.manager.server.service.CommandLogService;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.BinaryMessage;
@@ -35,7 +33,6 @@
import lombok.extern.slf4j.Slf4j;
import jakarta.annotation.Nonnull;
-import jakarta.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -48,9 +45,6 @@
@Component
public class ServerWebSocketHandler extends AbstractBinaryWebSocketHandler {
- @Resource
- private CommandLogService commandLogService;
-
private final Map sessions = new ConcurrentHashMap<>();
public static final Map HEARTBEAT_MESSAGE_MAP = new ConcurrentHashMap<>();
@@ -93,9 +87,6 @@ private void handleMessage(WebSocketSession session, BaseMessage baseMessage) {
handleHeartbeatMessage(session, heartbeatMessage);
} else if (baseMessage instanceof CommandResponseMessage commandResponseMessage) {
super.handleResponseMessage(commandResponseMessage);
- } else if (baseMessage instanceof CommandLogMessage commandLogMessage) {
- commandLogService.onLogReceived(
- commandLogMessage.getTaskId(), commandLogMessage.getHostname(), commandLogMessage.getLog());
} else {
log.error("Unrecognized message type: {}", baseMessage.getClass().getSimpleName());
}
diff --git a/bigtop-manager-server/src/main/resources/logback-spring.xml b/bigtop-manager-server/src/main/resources/logback-spring.xml
index c4a1add7..4a42d857 100644
--- a/bigtop-manager-server/src/main/resources/logback-spring.xml
+++ b/bigtop-manager-server/src/main/resources/logback-spring.xml
@@ -19,40 +19,18 @@
-->
-
-
+
+
- [%-5level] %date{yyyy-MM-dd HH:mm:ss.SSS Z} [%thread] %logger{96}:[%line] - %msg%n
+ [%-5level] %date{yyyy-MM-dd HH:mm:ss.SSS Z} [%thread] %logger{1}:[%line] - %m%n
UTF-8
-
- ${log.base}/ws.log
-
- ${log.base}/ws.%d{yyyy-MM-dd}.%i.log
- 30
- 200MB
- 10GB
- true
-
-
- [%-5level] %date{yyyy-MM-dd HH:mm:ss.SSS Z} [%thread] %logger{96}:[%line] - %msg%n
- UTF-8
-
-
-
-
+
${log.base}/bigtop-manager-server.log
-
-
- logger.contains("org.apache.bigtop.manager.server.ws.ServerWebSocketHandler")
-
- DENY
- ACCEPT
-
${log.base}/bigtop-manager-server.%d{yyyy-MM-dd}.%i.log
30
@@ -61,20 +39,15 @@
true
- [%-5level] %date{yyyy-MM-dd HH:mm:ss.SSS Z} [%thread] %logger{96}:[%line] - %msg%n
+ [%-5level] %date{yyyy-MM-dd HH:mm:ss.SSS Z} [%thread] %logger{1}:[%line] - %m%n
UTF-8
-
-
-
-
-
-
+
-
-
+
+
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 90466b5b..0fca2f6e 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
@@ -24,7 +24,6 @@
import org.apache.bigtop.manager.stack.bigtop.v3_3_0.kafka.KafkaParams;
import org.apache.bigtop.manager.stack.common.enums.ConfigType;
import org.apache.bigtop.manager.stack.common.exception.StackException;
-import org.apache.bigtop.manager.stack.common.log.TaskLogWriter;
import org.apache.bigtop.manager.stack.common.utils.linux.LinuxFileUtils;
import org.apache.bigtop.manager.stack.common.utils.linux.LinuxOSUtils;
@@ -47,7 +46,7 @@ public static ShellResult config(Params params) {
}
public static ShellResult config(Params params, String componentName) {
- TaskLogWriter.info("starting HDFS config");
+ log.info("starting HDFS config");
HdfsParams hdfsParams = (HdfsParams) params;
String confDir = hdfsParams.confDir();
@@ -177,7 +176,7 @@ public static boolean isNameNodeFormatted(HdfsParams hdfsParams) {
for (String nameNodeFormattedDir : hdfsParams.getNameNodeFormattedDirs()) {
File file = new File(nameNodeFormattedDir);
if (file.exists() && file.isDirectory()) {
- TaskLogWriter.info(nameNodeFormattedDir + "exists. Namenode DFS already formatted");
+ log.info("{} exists. Namenode DFS already formatted", nameNodeFormattedDir);
isFormatted = true;
}
}
@@ -196,14 +195,14 @@ public static boolean isNameNodeFormatted(HdfsParams hdfsParams) {
for (String nameNodeDir : nameNodeDirs) {
File file = new File(nameNodeDir);
if (!file.exists()) {
- TaskLogWriter.info("NameNode will not be formatted because the directory " + nameNodeDir
- + " is missing or cannot be checked for content.");
+ log.info(
+ "NameNode will not be formatted because the directory {} is missing or cannot be checked for content.",
+ nameNodeDir);
return true;
} else {
File[] files = file.listFiles();
if (files != null && files.length > 0) {
- TaskLogWriter.info(
- "NameNode will not be formatted since " + nameNodeDir + " exists and contains content");
+ log.info("NameNode will not be formatted since {} exists and contains content", nameNodeDir);
return true;
}
}
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 380c3e53..57ee2204 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
@@ -22,7 +22,6 @@
import org.apache.bigtop.manager.common.utils.NetUtils;
import org.apache.bigtop.manager.spi.stack.Params;
import org.apache.bigtop.manager.stack.common.enums.ConfigType;
-import org.apache.bigtop.manager.stack.common.log.TaskLogWriter;
import org.apache.bigtop.manager.stack.common.utils.LocalSettings;
import org.apache.bigtop.manager.stack.common.utils.linux.LinuxFileUtils;
@@ -43,7 +42,7 @@
public class ZookeeperSetup {
public static ShellResult config(Params params) {
- TaskLogWriter.info("ZookeeperSetup config");
+ log.info("ZookeeperSetup 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/log/TaskLogWriter.java b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/log/TaskLogWriter.java
deleted file mode 100644
index cff92658..00000000
--- a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/log/TaskLogWriter.java
+++ /dev/null
@@ -1,66 +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.stack.common.log;
-
-import java.time.ZoneId;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.function.Consumer;
-
-public class TaskLogWriter {
-
- private static Consumer writer;
-
- public static void setWriter(Consumer writer) {
- TaskLogWriter.writer = writer;
- }
-
- public static void info(String str) {
- if (TaskLogWriter.writer != null) {
- TaskLogWriter.writer.accept("[INFO ] " + getFormattedTime() + " - " + str);
- }
- }
-
- public static void warn(String str) {
- if (TaskLogWriter.writer != null) {
- TaskLogWriter.writer.accept("[WARN ] " + getFormattedTime() + " - " + str);
- }
- }
-
- public static void error(String str) {
- if (TaskLogWriter.writer != null) {
- TaskLogWriter.writer.accept("[ERROR] " + getFormattedTime() + " - " + str);
- }
- }
-
- private static String getFormattedTime() {
- ZoneId zoneId = ZoneOffset.systemDefault();
- ZonedDateTime zonedDateTime = ZonedDateTime.now(zoneId);
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
- String time = zonedDateTime.format(formatter);
- String offset = zonedDateTime.getOffset().getId().replace("Z", "+00:00");
-
- return time + " " + offset;
- }
-
- public static void clearWriter() {
- TaskLogWriter.writer = null;
- }
-}
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 3b239e5b..cf2ebd3c 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
@@ -23,7 +23,6 @@
import org.apache.bigtop.manager.spi.stack.PackageManager;
import org.apache.bigtop.manager.stack.common.enums.PackageManagerType;
import org.apache.bigtop.manager.stack.common.exception.StackException;
-import org.apache.bigtop.manager.stack.common.log.TaskLogWriter;
import com.google.auto.service.AutoService;
import lombok.extern.slf4j.Slf4j;
@@ -50,7 +49,7 @@ public ShellResult installPackage(Collection packages) {
try {
ShellResult output = ShellExecutor.execCommand(builderParameters, log::info);
- TaskLogWriter.info("[AptPackageManager] [installPackage] output: " + output);
+ log.info("[AptPackageManager] [installPackage] output: {}", output);
return output;
} catch (IOException e) {
throw new StackException(e);
@@ -67,7 +66,7 @@ public ShellResult uninstallPackage(Collection packages) {
try {
ShellResult output = ShellExecutor.execCommand(builderParameters, log::info);
- TaskLogWriter.info("[AptPackageManager] [uninstallPackage] output: " + output);
+ log.info("[AptPackageManager] [uninstallPackage] output: {}", output);
return output;
} catch (IOException e) {
throw new StackException(e);
@@ -82,7 +81,7 @@ public String listPackages() {
try {
ShellResult output = ShellExecutor.execCommand(builderParameters, log::info);
- TaskLogWriter.info("[AptPackageManager] [listPackages] output: " + output);
+ log.info("[AptPackageManager] [listPackages] output: {}", output);
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 a800da38..59a5fb88 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
@@ -23,7 +23,6 @@
import org.apache.bigtop.manager.spi.stack.PackageManager;
import org.apache.bigtop.manager.stack.common.enums.PackageManagerType;
import org.apache.bigtop.manager.stack.common.exception.StackException;
-import org.apache.bigtop.manager.stack.common.log.TaskLogWriter;
import com.google.auto.service.AutoService;
import lombok.extern.slf4j.Slf4j;
@@ -49,7 +48,7 @@ public ShellResult installPackage(Collection packages) {
try {
ShellResult output = ShellExecutor.execCommand(builderParameters, log::info);
- TaskLogWriter.info("[DnfPackageManager] [installPackage] output: " + output);
+ log.info("[DnfPackageManager] [installPackage] output: {}", output);
return output;
} catch (IOException e) {
throw new StackException(e);
@@ -66,7 +65,7 @@ public ShellResult uninstallPackage(Collection packages) {
try {
ShellResult output = ShellExecutor.execCommand(builderParameters, log::info);
- TaskLogWriter.info("[DnfPackageManager] [uninstallPackage] output: " + output);
+ log.info("[DnfPackageManager] [uninstallPackage] output: {}", output);
return output;
} catch (IOException e) {
throw new StackException(e);
@@ -81,7 +80,7 @@ public String listPackages() {
try {
ShellResult output = ShellExecutor.execCommand(builderParameters, log::info);
- TaskLogWriter.info("[DnfPackageManager] [listPackages] output: " + output);
+ log.info("[DnfPackageManager] [listPackages] output: {}", output);
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 acbee9cb..2df789cf 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
@@ -23,7 +23,6 @@
import org.apache.bigtop.manager.spi.stack.PackageManager;
import org.apache.bigtop.manager.stack.common.enums.PackageManagerType;
import org.apache.bigtop.manager.stack.common.exception.StackException;
-import org.apache.bigtop.manager.stack.common.log.TaskLogWriter;
import com.google.auto.service.AutoService;
import lombok.extern.slf4j.Slf4j;
@@ -49,7 +48,7 @@ public ShellResult installPackage(Collection packages) {
try {
ShellResult output = ShellExecutor.execCommand(builderParameters, log::info);
- TaskLogWriter.info("[RpmPackageManager] [installPackage] output: " + output);
+ log.info("[RpmPackageManager] [installPackage] output: {}", output);
return output;
} catch (IOException e) {
throw new StackException(e);
@@ -66,7 +65,7 @@ public ShellResult uninstallPackage(Collection packages) {
try {
ShellResult output = ShellExecutor.execCommand(builderParameters, log::info);
- TaskLogWriter.info("[RpmPackageManager] [uninstallPackage] output: " + output);
+ log.info("[RpmPackageManager] [uninstallPackage] output: {}", output);
return output;
} catch (IOException e) {
throw new StackException(e);
@@ -81,7 +80,7 @@ public String listPackages() {
try {
ShellResult output = ShellExecutor.execCommand(builderParameters, log::info);
- TaskLogWriter.info("[RpmPackageManager] [listPackages] output: " + output);
+ log.info("[RpmPackageManager] [listPackages] output: {}", output);
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/BaseParams.java b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/BaseParams.java
index 34681e4c..9bf2d600 100644
--- a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/BaseParams.java
+++ b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/BaseParams.java
@@ -25,7 +25,6 @@
import org.apache.bigtop.manager.common.utils.os.OSDetection;
import org.apache.bigtop.manager.spi.stack.Params;
import org.apache.bigtop.manager.stack.common.annotations.GlobalParams;
-import org.apache.bigtop.manager.stack.common.log.TaskLogWriter;
import org.apache.commons.lang3.StringUtils;
@@ -67,7 +66,7 @@ protected BaseParams(CommandPayload commandPayload) {
globalParamsMap.putAll(invoke);
}
} catch (Exception e) {
- TaskLogWriter.warn("Get " + declaredMethod + " Params error: " + e.getMessage());
+ log.warn("Get {} Params error", declaredMethod, e);
}
}
globalParamsMap.remove("content");
diff --git a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/LocalSettings.java b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/LocalSettings.java
index fa04b221..5d444651 100644
--- a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/LocalSettings.java
+++ b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/LocalSettings.java
@@ -24,7 +24,6 @@
import org.apache.bigtop.manager.common.message.entity.pojo.ComponentInfo;
import org.apache.bigtop.manager.common.message.entity.pojo.RepoInfo;
import org.apache.bigtop.manager.common.utils.JsonUtils;
-import org.apache.bigtop.manager.stack.common.log.TaskLogWriter;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.extern.slf4j.Slf4j;
@@ -58,7 +57,7 @@ public static Map configurations(String service, String type) {
}
}
} catch (Exception e) {
- TaskLogWriter.warn(CacheFiles.CONFIGURATIONS_INFO + " parse error: " + e.getMessage());
+ log.warn("{} parse error", CacheFiles.CONFIGURATIONS_INFO, e);
}
return configDataMap;
diff --git a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/PropertiesUtils.java b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/PropertiesUtils.java
index 23738bce..14348da0 100644
--- a/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/PropertiesUtils.java
+++ b/bigtop-manager-stack/bigtop-manager-stack-common/src/main/java/org/apache/bigtop/manager/stack/common/utils/PropertiesUtils.java
@@ -19,7 +19,6 @@
package org.apache.bigtop.manager.stack.common.utils;
import org.apache.bigtop.manager.stack.common.exception.StackException;
-import org.apache.bigtop.manager.stack.common.log.TaskLogWriter;
import lombok.extern.slf4j.Slf4j;
@@ -48,7 +47,7 @@ public static Map