diff --git a/agent/src/main/java/io/wdd/agent/initialization/bootup/OctopusAgentInitService.java b/agent/src/main/java/io/wdd/agent/initialization/bootup/OctopusAgentInitService.java index 985eed0..857b885 100644 --- a/agent/src/main/java/io/wdd/agent/initialization/bootup/OctopusAgentInitService.java +++ b/agent/src/main/java/io/wdd/agent/initialization/bootup/OctopusAgentInitService.java @@ -94,16 +94,22 @@ public class OctopusAgentInitService { } catch (Exception e) { - // reject the message - channel.basicNack(deliveryTag, false, true); + // 拒绝信息,然后重新发送回队列 + channel.basicNack( + deliveryTag, + false, + true + ); + // long deliveryTag, boolean requeue // channel.basicReject(deliveryTag,true); - log.error("Octopus Agent Initialization Error, please check ! Waiting for 5 seconds"); - // 这里只是便于出现死循环时查看 + // 等待5秒钟,让其他的主机能够找到自己的信息 TimeUnit.SECONDS.sleep(5); + // 需要返回 重新获取 + return; } // handle init message ok 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 c94ffdf..7d2ba39 100644 --- a/server/src/main/java/io/wdd/rpc/controller/ExecutionController.java +++ b/server/src/main/java/io/wdd/rpc/controller/ExecutionController.java @@ -40,7 +40,8 @@ public class ExecutionController { @RequestParam(value = "commandList", required = false) @Nullable List commandList, @RequestParam(value = "completeCommandList", required = false) @ApiParam(name = "completeCommandList", value = "完整命令行,优先,可为空") @Nullable List> completeCommandList, - @RequestParam(value = "type", required = false) @Nullable String type + @RequestParam(value = "type", required = false) @Nullable String type, + @ApiParam(name = "isDurationTask", value = "是否是持久化任务") @RequestParam(value = "isDurationTask", defaultValue = "false", required = false) boolean isDurationTask ) { String streamKey = asyncExecutionService @@ -51,7 +52,7 @@ public class ExecutionController { completeCommandList, false, null, - false + isDurationTask ); return R.ok(streamKey); @@ -66,14 +67,16 @@ public class ExecutionController { @ApiParam(name = "commandList", value = "命令行") @Nullable List commandList, @RequestParam(value = "completeCommandList", required = false) @ApiParam(name = "completeCommandList", value = "完整命令行,优先,可为空") @Nullable List> completeCommandList, - @RequestParam(value = "type", required = false) @Nullable String type + @RequestParam(value = "type", required = false) @Nullable String type, + @ApiParam(name = "isDurationTask", value = "是否是持久化任务") @RequestParam(value = "isDurationTask", defaultValue = "false", required = false) boolean isDurationTask ) { return R.ok(asyncExecutionService.SendCommandToAgentComplete( topicNameList, type, commandList, - completeCommandList + completeCommandList, + isDurationTask )); } @@ -85,14 +88,16 @@ public class ExecutionController { @ApiParam(name = "commandList", value = "命令行") @Nullable List commandList, @RequestParam(value = "completeCommandList", required = false) @ApiParam(name = "completeCommandList", value = "完整命令行,优先,可为空") @Nullable List> completeCommandList, - @RequestParam(value = "type", required = false) @Nullable String type + @RequestParam(value = "type", required = false) @Nullable String type, + @ApiParam(name = "isDurationTask", value = "是否是持久化任务") @RequestParam(value = "isDurationTask", defaultValue = "false", required = false) boolean isDurationTask ) { return R.ok(asyncExecutionService.SendCommandToAgentComplete( ALL_AGENT_TOPIC_NAME_LIST, type, commandList, - completeCommandList + completeCommandList, + isDurationTask )); } @@ -103,14 +108,16 @@ public class ExecutionController { @ApiParam(name = "commandList", value = "命令行") @Nullable List commandList, @RequestParam(value = "completeCommandList", required = false) @ApiParam(name = "completeCommandList", value = "完整命令行,优先,可为空") @Nullable List> completeCommandList, - @RequestParam(value = "type", required = false) @Nullable String type + @RequestParam(value = "type", required = false) @Nullable String type, + @ApiParam(name = "isDurationTask", value = "是否是持久化任务") @RequestParam(value = "isDurationTask", defaultValue = "false", required = false) boolean isDurationTask ) { return R.ok(asyncExecutionService.SendCommandToAgentComplete( ALL_HEALTHY_AGENT_TOPIC_NAME_LIST, type, commandList, - completeCommandList + completeCommandList, + isDurationTask )); } @@ -144,7 +151,8 @@ public class ExecutionController { @ApiParam(name = "commandList", value = "命令行") @Nullable List commandList, @RequestParam(value = "completeCommandList", required = false) @ApiParam(name = "completeCommandList", value = "完整命令行,优先,可为空") @Nullable List> completeCommandList, - @RequestParam(value = "type", required = false) @ApiParam(name = "type", value = "执行命令类型") @Nullable String type + @RequestParam(value = "type", required = false) @ApiParam(name = "type", value = "执行命令类型") @Nullable String type, + @ApiParam(name = "isDurationTask", value = "是否是持久化任务") @RequestParam(value = "isDurationTask", defaultValue = "false", required = false) boolean isDurationTask ) { return R.ok( @@ -152,7 +160,8 @@ public class ExecutionController { topicNameList, type, commandList, - completeCommandList + completeCommandList, + isDurationTask ) ); } @@ -164,7 +173,8 @@ public class ExecutionController { @ApiParam(name = "commandList", value = "命令行") @Nullable List commandList, @RequestParam(value = "completeCommandList", required = false) @ApiParam(name = "completeCommandList", value = "完整命令行,优先,可为空") @Nullable List> completeCommandList, - @RequestParam(value = "type", required = false) @ApiParam(name = "type", value = "执行命令类型") @Nullable String type + @RequestParam(value = "type", required = false) @ApiParam(name = "type", value = "执行命令类型") @Nullable String type, + @ApiParam(name = "isDurationTask", value = "是否是持久化任务") @RequestParam(value = "isDurationTask", defaultValue = "false", required = false) boolean isDurationTask ) { return R.ok( @@ -172,7 +182,8 @@ public class ExecutionController { ALL_AGENT_TOPIC_NAME_LIST, type, commandList, - completeCommandList + completeCommandList, + isDurationTask ) ); } @@ -207,7 +218,10 @@ public class ExecutionController { .SendCommandToAgent( topicNameList, "AgentUpdate", - null + null, + false, + null, + true )); } @@ -223,7 +237,10 @@ public class ExecutionController { .SendCommandToAgent( topicNameList, "AgentReboot", - null + null, + false, + null, + true )); } @@ -239,7 +256,10 @@ public class ExecutionController { .SendCommandToAgent( topicNameList, "AgentShutdown", - null + null, + false, + null, + true )); } @@ -255,7 +275,10 @@ public class ExecutionController { .SendCommandToAgent( topicNameList, "AgentBootUp", - null + null, + false, + null, + true )); } diff --git a/server/src/main/java/io/wdd/rpc/execute/service/AsyncExecutionService.java b/server/src/main/java/io/wdd/rpc/execute/service/AsyncExecutionService.java index 5fddc6e..dee0fa2 100644 --- a/server/src/main/java/io/wdd/rpc/execute/service/AsyncExecutionService.java +++ b/server/src/main/java/io/wdd/rpc/execute/service/AsyncExecutionService.java @@ -14,7 +14,7 @@ public interface AsyncExecutionService { String SendCommandToAgent(String agentTopicName, String type, List commandList); - List SendCommandToAgent(List agentTopicNameList, String type, List command); + List SendCommandToAgent(List agentTopicNameList, String type, List commandList, boolean needResultReplay, String futureKey, boolean durationTask); /** * 调用 单行命令脚本的 最底层函数 @@ -43,19 +43,12 @@ public interface AsyncExecutionService { String SendCommandToAgentComplete(String agentTopicName, String type, List commandList, List> commandListComplete); - List SendCommandToAgentComplete(List agentTopicNameList, String type, List commandList, List> commandListComplete); - /** - * 通常为 页面定时脚本任务调用 - * - * @param agentTopicNameList 目标Agent的TopicName列表 - * @param type 任务类型 - * @param completeCommandList 完整的类型 - * @return 每个Agent只返回一个 ResultKey(Script脚本的结果全部拼接到一起),全部的resultKey - */ + List SendCommandToAgentComplete(List agentTopicNameList, String type, List commandList, List> commandListComplete, boolean isDurationTask); + + List SendCommandToAgentComplete(List agentTopicNameList, String type, List> completeCommandList); - /** * 通常为 页面定时脚本任务调用 * diff --git a/server/src/main/java/io/wdd/rpc/execute/service/AsyncExecutionServiceImpl.java b/server/src/main/java/io/wdd/rpc/execute/service/AsyncExecutionServiceImpl.java index f7555a1..3d8bafc 100644 --- a/server/src/main/java/io/wdd/rpc/execute/service/AsyncExecutionServiceImpl.java +++ b/server/src/main/java/io/wdd/rpc/execute/service/AsyncExecutionServiceImpl.java @@ -93,7 +93,7 @@ public class AsyncExecutionServiceImpl implements AsyncExecutionService { } @Override - public List SendCommandToAgentComplete(List agentTopicNameList, String type, List commandList, List> commandListComplete) { + public List SendCommandToAgentComplete(List agentTopicNameList, String type, List commandList, List> commandListComplete, boolean isDurationTask) { return agentTopicNameList .stream() .map( @@ -104,7 +104,7 @@ public class AsyncExecutionServiceImpl implements AsyncExecutionService { commandListComplete, false, null, - false + isDurationTask ) ) .collect(Collectors.toList()); @@ -257,7 +257,7 @@ public class AsyncExecutionServiceImpl implements AsyncExecutionService { @Override - public List SendCommandToAgent(List agentagentTopicNameList, String type, List command) { + public List SendCommandToAgent(List agentagentTopicNameList, String type, List commandList, boolean needResultReplay, String futureKey, boolean durationTask) { return agentagentTopicNameList .stream() @@ -267,7 +267,11 @@ public class AsyncExecutionServiceImpl implements AsyncExecutionService { ( agentTopicName, type, - command + commandList, + null, + needResultReplay, + futureKey, + durationTask ) ) .collect(Collectors.toList()); diff --git a/server/src/main/java/io/wdd/rpc/execute/service/SyncExecutionService.java b/server/src/main/java/io/wdd/rpc/execute/service/SyncExecutionService.java index f46d593..ed1548d 100644 --- a/server/src/main/java/io/wdd/rpc/execute/service/SyncExecutionService.java +++ b/server/src/main/java/io/wdd/rpc/execute/service/SyncExecutionService.java @@ -46,7 +46,7 @@ public interface SyncExecutionService { ArrayList SyncSendCommandToAgent(String agentTopicName, String type, List commandList, List> completeCommandList); - List> SyncSendCommandToAgentComplete(List agentTopicNameList, String type, List commandList, List> completeCommandList); + List> SyncSendCommandToAgentComplete(List agentTopicNameList, String type, List commandList, List> completeCommandList, boolean isDurationTask); /** * 通常为 页面定时脚本任务调用 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 15d364c..06cb143 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 @@ -109,7 +109,7 @@ public class SyncExecutionServiceImpl implements SyncExecutionService { } @Override - public List> SyncSendCommandToAgentComplete(List agentTopicNameList, String type, List commandList, List> completeCommandList) { + public List> SyncSendCommandToAgentComplete(List agentTopicNameList, String type, List commandList, List> completeCommandList, boolean isDurationTask) { return agentTopicNameList .stream() .map( @@ -120,7 +120,7 @@ public class SyncExecutionServiceImpl implements SyncExecutionService { completeCommandList, COMMAND_EXEC_NEED_REPLAY, null, - false + isDurationTask ) ) .collect(Collectors.toList());