[server][ executor]- 完成同步调用命令的部分代码 - 1
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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<String> SyncSendCommandToAgent(String agentTopicName, List<String> commandList) {
|
||||
@@ -179,10 +177,14 @@ public class SyncExecutionServiceImpl implements SyncExecutionService {
|
||||
ArrayList<String> 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,
|
||||
|
||||
Reference in New Issue
Block a user