diff --git a/agent-go/AgentInitialization.go b/agent-go/AgentInitialization.go index 1854795..b293f9e 100644 --- a/agent-go/AgentInitialization.go +++ b/agent-go/AgentInitialization.go @@ -46,7 +46,7 @@ func INIT(agentServerInfoConf string) chan bool { initToServerQueue := &rabbitmq.RabbitQueue{ RabbitProp: initToServerProp, } - defer initToServerQueue.Close() + //defer initToServerQueue.Close() // 建立连接 initToServerQueue.Connect() diff --git a/server/pom.xml b/server/pom.xml index 5b4f59b..d25ff7f 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -106,7 +106,7 @@ com.baomidou mybatis-plus-boot-starter - 3.5.2 + 3.5.4 diff --git a/server/src/main/java/io/wdd/func/auto/service/BaseFuncScheduler.java b/server/src/main/java/io/wdd/func/auto/service/BaseFuncScheduler.java index b01cc97..cfeff2f 100644 --- a/server/src/main/java/io/wdd/func/auto/service/BaseFuncScheduler.java +++ b/server/src/main/java/io/wdd/func/auto/service/BaseFuncScheduler.java @@ -4,6 +4,7 @@ import io.wdd.func.auto.beans.BaseFunctionEnum; import io.wdd.func.auto.beans.ProjectDeployContext; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.List; @@ -47,21 +48,24 @@ public class BaseFuncScheduler { .getMasterNode() .getTopicName(); - List agentTopicNameList = projectDeployContext - .getAgentNodeList() - .stream() - .map(agentNode -> agentNode.getTopicName()) - .collect(Collectors.toList()); - - if (!MasterNodeProcedure(masterTopicName)) { log.error("初始化过程错误! 即将终止!"); } - if (!AgentNodeProcedure(agentTopicNameList)) { - log.error("初始化过程错误! 即将终止!"); - } + if (!CollectionUtils.isEmpty(projectDeployContext + .getAgentNodeList())) { + + List agentTopicNameList = projectDeployContext + .getAgentNodeList() + .stream() + .map(agentNode -> agentNode.getTopicName()) + .collect(Collectors.toList()); + + if (!AgentNodeProcedure(agentTopicNameList)) { + log.error("初始化过程错误! 即将终止!"); + } + } log.info("初始化过程完成!"); } diff --git a/server/src/main/java/io/wdd/func/auto/service/FuncServiceImpl.java b/server/src/main/java/io/wdd/func/auto/service/FuncServiceImpl.java index aaf4ba7..7134c7f 100644 --- a/server/src/main/java/io/wdd/func/auto/service/FuncServiceImpl.java +++ b/server/src/main/java/io/wdd/func/auto/service/FuncServiceImpl.java @@ -85,6 +85,9 @@ public class FuncServiceImpl implements FuncService { private List syncCallFunction(String agentTopicName, ExecutionMessageType emType, String funcName, List funcArgs) { // 重新构造内容,增加Function Name + if (CollectionUtils.isEmpty(funcArgs)) { + funcArgs = new ArrayList<>(); + } funcArgs.add( 0, funcName diff --git a/server/src/main/java/io/wdd/func/xray/service/XrayCoreServiceImpl.java b/server/src/main/java/io/wdd/func/xray/service/XrayCoreServiceImpl.java index 0e44c5f..a6d83b0 100644 --- a/server/src/main/java/io/wdd/func/xray/service/XrayCoreServiceImpl.java +++ b/server/src/main/java/io/wdd/func/xray/service/XrayCoreServiceImpl.java @@ -20,7 +20,6 @@ import io.wdd.func.xray.persisit.XrayOssOperator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.lang3.ObjectUtils; -import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Service; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; @@ -61,7 +60,6 @@ public class XrayCoreServiceImpl implements XrayCoreService { * @param allNetworkPathList * @return */ - @NotNull private static Set getAllProxyNodeSet(List> allNetworkPathList, boolean includeSubscribeNode) { // 拿到所有的proxyNode Set proxyNodeSet = allNetworkPathList diff --git a/server/src/main/java/io/wdd/rpc/execute/service/ExecutionServiceImpl.java b/server/src/main/java/io/wdd/rpc/execute/service/ExecutionServiceImpl.java index 474c331..608ea49 100644 --- a/server/src/main/java/io/wdd/rpc/execute/service/ExecutionServiceImpl.java +++ b/server/src/main/java/io/wdd/rpc/execute/service/ExecutionServiceImpl.java @@ -9,6 +9,7 @@ import io.wdd.rpc.message.sender.OMessageToAgentSender; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.ArrayList; @@ -49,6 +50,7 @@ public class ExecutionServiceImpl implements ExecutionService { ExecutionMessage executionMessage = this .generateExecutionMessage( executionType, + funcContent, pipeLineCommand, commandList, commandListComplete, @@ -89,7 +91,7 @@ public class ExecutionServiceImpl implements ExecutionService { // 2023年10月8日 根据执行的命令数量设定超时等待时间 int commandMaxWaitTimeout = COMMAND_MAX_WAIT_TIMEOUT; - if (commandListComplete.size() > 0) { + if (!CollectionUtils.isEmpty(commandListComplete)) { commandMaxWaitTimeout = COMMAND_MAX_WAIT_TIMEOUT * commandListComplete.size(); } @@ -137,11 +139,12 @@ public class ExecutionServiceImpl implements ExecutionService { .build(); } - private ExecutionMessage generateExecutionMessage(String executionType, List> pipeLineCommand, List commandList, List> commandListComplete, boolean needResultReplay, boolean durationTask) { + private ExecutionMessage generateExecutionMessage(String executionType, List funcContent, List> pipeLineCommand, List commandList, List> commandListComplete, boolean needResultReplay, boolean durationTask) { return ExecutionMessage .builder() .executionType(executionType) + .funcContent(funcContent) .singleLineCommand(commandList) .multiLineCommand(commandListComplete) .pipeLineCommand(pipeLineCommand) diff --git a/server/src/main/java/io/wdd/rpc/init/AcceptAgentInitInfo.java b/server/src/main/java/io/wdd/rpc/init/AcceptAgentInitInfo.java index f14c57f..206e5ac 100644 --- a/server/src/main/java/io/wdd/rpc/init/AcceptAgentInitInfo.java +++ b/server/src/main/java/io/wdd/rpc/init/AcceptAgentInitInfo.java @@ -55,7 +55,9 @@ public class AcceptAgentInitInfo { "LosAngeles", 7, "Beijing", - 8 + 8, + "Paripark", + 9 ) ); public static Set ALL_SERVER_ARCH_INFO = new HashSet<>( @@ -288,7 +290,7 @@ public class AcceptAgentInitInfo { String[] split = serverName.split("-"); if (split.length <= 2 || !ALL_SERVER_CITY_INDEX.containsKey(split[0]) || !ALL_SERVER_ARCH_INFO.contains(split[1])) { log.error( - "server info from agent are {}", + "city are not validated from agent are {}", serverInfoVO ); throw new MyRuntimeException("server name not validated !"); diff --git a/server/src/main/java/io/wdd/server/beans/po/ServerInfoPO.java b/server/src/main/java/io/wdd/server/beans/po/ServerInfoPO.java index 3514f09..b1ac154 100644 --- a/server/src/main/java/io/wdd/server/beans/po/ServerInfoPO.java +++ b/server/src/main/java/io/wdd/server/beans/po/ServerInfoPO.java @@ -19,7 +19,7 @@ public class ServerInfoPO implements Serializable { /** * server primary key */ - @TableId(value = "server_id", type = IdType.AUTO) + @TableId(value = "server_id", type = IdType.ASSIGN_ID) private Long serverId; /** diff --git a/server/src/main/java/io/wdd/server/coreService/impl/CoreServerServiceImpl.java b/server/src/main/java/io/wdd/server/coreService/impl/CoreServerServiceImpl.java index f29e5fb..06e71dd 100644 --- a/server/src/main/java/io/wdd/server/coreService/impl/CoreServerServiceImpl.java +++ b/server/src/main/java/io/wdd/server/coreService/impl/CoreServerServiceImpl.java @@ -190,7 +190,7 @@ public class CoreServerServiceImpl implements CoreServerService { ) .one(); - if (po == null) { + if (po != null) { // 已经存在,需要把更新的信息 复制到旧的内容之上 copyProperties( serverInfoVO, diff --git a/server/src/test/java/io/wdd/server/func/TestBaseFuncScheduler.java b/server/src/test/java/io/wdd/server/func/TestBaseFuncScheduler.java index 025b40f..2563413 100644 --- a/server/src/test/java/io/wdd/server/func/TestBaseFuncScheduler.java +++ b/server/src/test/java/io/wdd/server/func/TestBaseFuncScheduler.java @@ -5,7 +5,7 @@ import io.wdd.func.auto.service.BaseFuncScheduler; import io.wdd.server.beans.po.ServerInfoPO; import io.wdd.server.beans.request.ServerQueryEntity; import io.wdd.server.coreService.CoreServerService; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import javax.annotation.Resource; @@ -13,14 +13,12 @@ import javax.annotation.Resource; @SpringBootTest public class TestBaseFuncScheduler { - @Resource BaseFuncScheduler baseFuncScheduler; @Resource CoreServerService serverService; - @Test public void testRunProcedure() { @@ -29,12 +27,14 @@ public class TestBaseFuncScheduler { projectDeployContext.setProjectId(1716372290994155522L); ServerQueryEntity serverQueryEntity = new ServerQueryEntity(); - serverQueryEntity.setServerName("Osaka"); + serverQueryEntity.setServerName("Paripark"); ServerInfoPO serverInfoPO = serverService .serverGetByPage(serverQueryEntity) .getRecords() .get(0); + System.out.println("serverInfoPO = " + serverInfoPO); + projectDeployContext.setMasterNode(serverInfoPO);