From 65ed1416971acd96eab5c5995d7ea0c331a0ca3d Mon Sep 17 00:00:00 2001 From: zeaslity Date: Tue, 28 Feb 2023 15:55:05 +0800 Subject: [PATCH] =?UTF-8?q?[server][=20executor]-=20=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=B0=83=E7=94=A8=E5=91=BD=E4=BB=A4=E7=9A=84?= =?UTF-8?q?=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81=20-=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/wdd/rpc/controller/AgentController.java | 2 +- .../wdd/rpc/controller/ExecutionController.java | 15 ++++++++++----- .../wdd/rpc/controller/SchedulerController.java | 2 +- .../io/wdd/rpc/controller/StatusController.java | 2 +- .../service/SyncExecutionServiceImpl.java | 16 +++++++++------- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/server/src/main/java/io/wdd/rpc/controller/AgentController.java b/server/src/main/java/io/wdd/rpc/controller/AgentController.java index 8e5f110..ed1c9c4 100644 --- a/server/src/main/java/io/wdd/rpc/controller/AgentController.java +++ b/server/src/main/java/io/wdd/rpc/controller/AgentController.java @@ -14,7 +14,7 @@ import java.util.Map; @RestController @RequestMapping("/octopus/server/agent") -@Api("处理Agent核心内容的Controller") +@Api(value = "处理Agent核心内容的Controller", tags = "Agent") public class AgentController { @Resource diff --git a/server/src/main/java/io/wdd/rpc/controller/ExecutionController.java b/server/src/main/java/io/wdd/rpc/controller/ExecutionController.java index d907e5c..9a6156f 100644 --- a/server/src/main/java/io/wdd/rpc/controller/ExecutionController.java +++ b/server/src/main/java/io/wdd/rpc/controller/ExecutionController.java @@ -6,6 +6,7 @@ import io.swagger.annotations.ApiParam; import io.wdd.common.beans.response.R; import io.wdd.rpc.execute.result.BuildStreamReader; import io.wdd.rpc.execute.service.AsyncExecutionService; +import io.wdd.rpc.execute.service.SyncExecutionService; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -28,6 +29,8 @@ public class ExecutionController { AsyncExecutionService asyncExecutionService; @Resource BuildStreamReader buildStreamReader; + @Resource + SyncExecutionService syncExecutionService; @PostMapping("/command/one") @ApiOperation("[命令] - 手动发送命令") @@ -104,11 +107,13 @@ public class ExecutionController { @RequestParam(value = "type", required = false) @ApiParam(name = "type", value = "执行命令类型") @Nullable String type ) { - return R.ok(asyncExecutionService.SendCommandToAgent( - ALL_HEALTHY_AGENT_TOPIC_NAME_LIST, - type, - commandList - )); + return R.ok( + syncExecutionService.SyncSendCommandToAgent( + topicName, + type, + commandList + ) + ); } diff --git a/server/src/main/java/io/wdd/rpc/controller/SchedulerController.java b/server/src/main/java/io/wdd/rpc/controller/SchedulerController.java index e52195a..c06d1d1 100644 --- a/server/src/main/java/io/wdd/rpc/controller/SchedulerController.java +++ b/server/src/main/java/io/wdd/rpc/controller/SchedulerController.java @@ -17,7 +17,7 @@ import java.util.List; import java.util.Map; @RestController -@Api(value = "定时任务控制中心的Controller") +@Api(value = "定时任务控制中心的Controller", tags = "Scheduler") @RequestMapping(value = "/octopus/server/scheduler") public class SchedulerController { diff --git a/server/src/main/java/io/wdd/rpc/controller/StatusController.java b/server/src/main/java/io/wdd/rpc/controller/StatusController.java index 068e6f9..bcaf7b4 100644 --- a/server/src/main/java/io/wdd/rpc/controller/StatusController.java +++ b/server/src/main/java/io/wdd/rpc/controller/StatusController.java @@ -18,7 +18,7 @@ import static io.wdd.rpc.init.ServerCacheAgentStatus.*; @RestController -@Api("Agent运行状态Controller") +@Api(value = "Agent运行状态Controller", tags = "Status") @RequestMapping("/octopus/server/status") public class StatusController { diff --git a/server/src/main/java/io/wdd/rpc/execute/service/SyncExecutionServiceImpl.java b/server/src/main/java/io/wdd/rpc/execute/service/SyncExecutionServiceImpl.java index cfddef8..5949c89 100644 --- a/server/src/main/java/io/wdd/rpc/execute/service/SyncExecutionServiceImpl.java +++ b/server/src/main/java/io/wdd/rpc/execute/service/SyncExecutionServiceImpl.java @@ -5,7 +5,6 @@ import io.wdd.common.beans.rabbitmq.OctopusMessageType; import io.wdd.rpc.message.handler.AsyncWaitOMResult; import io.wdd.rpc.message.handler.OMReplayContend; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -32,8 +31,7 @@ public class SyncExecutionServiceImpl implements SyncExecutionService { /** * 一个命令执行的最长等待时间 */ - @Value("${octopus.agent.executor.processMaxTimeOut}") - Integer processMaxWaitSeconds; + int processMaxWaitSeconds = 10; @Override public ArrayList SyncSendCommandToAgent(String agentTopicName, List commandList) { @@ -179,10 +177,14 @@ public class SyncExecutionServiceImpl implements SyncExecutionService { ArrayList result = new ArrayList<>(); // 构造消息等待对象 - int commandCount = Math.max( - commandListComplete.size(), - 1 - ); + int commandCount = 1; + if (null != commandListComplete) { + commandCount = Math.max( + commandListComplete.size(), + 1 + ); + } + OMReplayContend omReplayContend = OMReplayContend.build( commandCount, CurrentAppOctopusMessageType,