[ Server ] [ Server ] - 增加服务器角色部分的内容

This commit is contained in:
zeaslity
2023-10-08 14:30:17 +08:00
parent 9197031e81
commit 2594514a87
29 changed files with 416 additions and 209 deletions

View File

@@ -34,13 +34,14 @@ public class ExecutionMessage {
/**
* 用于区分 ExecutionMessage的类型
* BASE APP
* 执行预定义的脚本内容 BASE
* 执行k8s应用相关的内容 APP
*/
@Nullable
private String executionType;
/**
* 执行功能脚本时需要的参数
* 执行 上述预定义脚本 时需要的参数
*/
@Nullable
private List<String> funcContent;
@@ -50,6 +51,7 @@ public class ExecutionMessage {
*/
@Nullable
private List<String> singleLineCommand;
/**
* add in 2023-1-17
* 页面定时脚本任务 需要传递完整的命令列表

View File

@@ -3,10 +3,10 @@ package io.wdd.rpc.execute;
public enum ExecutionMessageType {
// 基础类型,执行基础脚本类
// 执行预定义的脚本内容 BASE
BASE,
// 应用类,执行特定功能
// 执行k8s应用相关的内容 APP
APP,

View File

@@ -7,7 +7,10 @@ public interface ExecutionService {
/**
* 发送 指令 给Agent, 正确错误信息全都会被接收
* ⭐⭐⭐⭐⭐
* 发送命令给Agent, 同步等待处理返回的消息
* 超时等待时间为 COMMAND_MAX_WAIT_TIMEOUT
* 如果为durationTask那么则没有返回结果
*/
ArrayList<String> SendCommandToAgent(
String agentTopicName,

View File

@@ -63,6 +63,7 @@ public class ExecutionServiceImpl implements ExecutionService {
// send the message
oMessageToAgentSender.send(octopusMessage);
// debug
log.debug(
"发送的 matchKey为 {}, 内容为 {}",
GenerateOMessageMatchKey(
@@ -75,7 +76,7 @@ public class ExecutionServiceImpl implements ExecutionService {
// 需要返回结果
if (!durationTask) {
// 等待结果
// countDownLatch的个数约定为1
// countDownLatch的个数约定为1, agent会合并多行命令的结果一并返回
OMessageReplayContent replayContent = WaitFromAgent(
octopusMessage,
1
@@ -85,8 +86,15 @@ public class ExecutionServiceImpl implements ExecutionService {
boolean waitOK = false;
try {
// 2023年10月8日 根据执行的命令数量设定超时等待时间
int commandMaxWaitTimeout = COMMAND_MAX_WAIT_TIMEOUT;
if (commandListComplete.size() > 0) {
commandMaxWaitTimeout = COMMAND_MAX_WAIT_TIMEOUT * commandListComplete.size();
}
waitOK = replayLatch.await(
COMMAND_MAX_WAIT_TIMEOUT,
commandMaxWaitTimeout,
TimeUnit.SECONDS
);

View File

@@ -65,7 +65,7 @@ public class OMessageHandler {
);
//debug
log.info(
log.debug(
"wait from agent map is => {}",
FROM_AGENT_MATCH_TO_AGENT_MAP
);
@@ -141,7 +141,6 @@ public class OMessageHandler {
originOMessage.setResultCode(replayOMessage.getResultCode());
originOMessage.setResult(replayOMessage.getResult());
// 通知等待线程
oMessageReplayContent
.getCountDownLatch()

View File

@@ -49,8 +49,6 @@ public class OMessageToServerListener {
@Resource
RedisTemplate redisTemplate;
@Resource
OMessageHandler oMessageHandler;
@RabbitHandler
@RabbitListener(queues = "${octopus.message.octopus_to_server}"
@@ -99,5 +97,6 @@ public class OMessageToServerListener {
// 将收到的消息,直接存储到 缓存队列中
log.debug("cache the octopus message to inner cache list !");
OCTOPUS_MESSAGE_FROM_AGENT.offer(octopusMessage);
}
}