Skip to content

Commit

Permalink
[INLONG-11389][Manager] Installation log display operation time (#11390)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuweng11 authored Oct 23, 2024
1 parent 15ae01a commit 8ec51cb
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.inlong.manager.service.cluster.node;

import org.apache.inlong.manager.common.consts.InlongConstants;
import org.apache.inlong.manager.common.enums.ClusterType;
import org.apache.inlong.manager.common.enums.ModuleType;
import org.apache.inlong.manager.common.enums.NodeStatus;
Expand Down Expand Up @@ -47,6 +48,8 @@
import org.springframework.stereotype.Service;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -96,18 +99,21 @@ public String getClusterNodeType() {
@Override
public boolean install(ClusterNodeRequest clusterNodeRequest, String operator) {
LOGGER.info("begin to insert agent cluster node={}", clusterNodeRequest);
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String currentTime = dateFormat.format(now);
try {
clusterNodeEntityMapper.updateOperateLogById(clusterNodeRequest.getId(), NodeStatus.INSTALLING.getStatus(),
"begin to install");
currentTime + InlongConstants.BLANK + "begin to install");
AgentClusterNodeRequest request = (AgentClusterNodeRequest) clusterNodeRequest;
deployInstaller(request, operator);
String startCmd = agentInstallPath + INSTALLER_START_CMD;
commandExecutor.execRemote(request, startCmd);
clusterNodeEntityMapper.updateOperateLogById(clusterNodeRequest.getId(),
NodeStatus.INSTALL_SUCCESS.getStatus(), "success to install");
NodeStatus.INSTALL_SUCCESS.getStatus(), currentTime + InlongConstants.BLANK + "success to install");
} catch (Exception e) {
clusterNodeEntityMapper.updateOperateLogById(clusterNodeRequest.getId(),
NodeStatus.INSTALL_FAILED.getStatus(), e.getMessage());
NodeStatus.INSTALL_FAILED.getStatus(), currentTime + InlongConstants.BLANK + e.getMessage());
String errMsg = String.format("install agent cluster node failed for ip=%s", clusterNodeRequest.getIp());
LOGGER.error(errMsg, e);
throw new BusinessException(errMsg);
Expand All @@ -119,19 +125,22 @@ public boolean install(ClusterNodeRequest clusterNodeRequest, String operator) {
@Override
public boolean reInstall(ClusterNodeRequest clusterNodeRequest, String operator) {
LOGGER.info("begin to reInstall agent cluster node={}", clusterNodeRequest);
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String currentTime = dateFormat.format(now);
try {
clusterNodeEntityMapper.updateOperateLogById(clusterNodeRequest.getId(), NodeStatus.INSTALLING.getStatus(),
"begin to reinstall");
currentTime + InlongConstants.BLANK + "begin to reinstall");
AgentClusterNodeRequest request = (AgentClusterNodeRequest) clusterNodeRequest;
commandExecutor.rmDir(request, agentInstallPath.substring(0, agentInstallPath.lastIndexOf(File.separator)));
deployInstaller(request, operator);
String reStartCmd = agentInstallPath + INSTALLER_RESTART_CMD;
commandExecutor.execRemote(request, reStartCmd);
clusterNodeEntityMapper.updateOperateLogById(clusterNodeRequest.getId(), NodeStatus.NORMAL.getStatus(),
"success to reinstall");
currentTime + InlongConstants.BLANK + "success to reinstall");
} catch (Exception e) {
clusterNodeEntityMapper.updateOperateLogById(clusterNodeRequest.getId(),
NodeStatus.INSTALL_FAILED.getStatus(), e.getMessage());
NodeStatus.INSTALL_FAILED.getStatus(), currentTime + InlongConstants.BLANK + e.getMessage());
String errMsg = String.format("reInstall agent cluster node failed for ip=%s", clusterNodeRequest.getIp());
LOGGER.error(errMsg, e);
throw new BusinessException(errMsg);
Expand Down

0 comments on commit 8ec51cb

Please sign in to comment.