[server][ executor]- 完成同步调用命令的部分代码 - 1
This commit is contained in:
@@ -14,7 +14,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/octopus/server/agent")
|
@RequestMapping("/octopus/server/agent")
|
||||||
@Api("处理Agent核心内容的Controller")
|
@Api(value = "处理Agent核心内容的Controller", tags = "Agent")
|
||||||
public class AgentController {
|
public class AgentController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiParam;
|
|||||||
import io.wdd.common.beans.response.R;
|
import io.wdd.common.beans.response.R;
|
||||||
import io.wdd.rpc.execute.result.BuildStreamReader;
|
import io.wdd.rpc.execute.result.BuildStreamReader;
|
||||||
import io.wdd.rpc.execute.service.AsyncExecutionService;
|
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.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
@@ -28,6 +29,8 @@ public class ExecutionController {
|
|||||||
AsyncExecutionService asyncExecutionService;
|
AsyncExecutionService asyncExecutionService;
|
||||||
@Resource
|
@Resource
|
||||||
BuildStreamReader buildStreamReader;
|
BuildStreamReader buildStreamReader;
|
||||||
|
@Resource
|
||||||
|
SyncExecutionService syncExecutionService;
|
||||||
|
|
||||||
@PostMapping("/command/one")
|
@PostMapping("/command/one")
|
||||||
@ApiOperation("[命令] - 手动发送命令")
|
@ApiOperation("[命令] - 手动发送命令")
|
||||||
@@ -104,11 +107,13 @@ public class ExecutionController {
|
|||||||
@RequestParam(value = "type", required = false) @ApiParam(name = "type", value = "执行命令类型") @Nullable String type
|
@RequestParam(value = "type", required = false) @ApiParam(name = "type", value = "执行命令类型") @Nullable String type
|
||||||
) {
|
) {
|
||||||
|
|
||||||
return R.ok(asyncExecutionService.SendCommandToAgent(
|
return R.ok(
|
||||||
ALL_HEALTHY_AGENT_TOPIC_NAME_LIST,
|
syncExecutionService.SyncSendCommandToAgent(
|
||||||
type,
|
topicName,
|
||||||
commandList
|
type,
|
||||||
));
|
commandList
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Api(value = "定时任务控制中心的Controller")
|
@Api(value = "定时任务控制中心的Controller", tags = "Scheduler")
|
||||||
@RequestMapping(value = "/octopus/server/scheduler")
|
@RequestMapping(value = "/octopus/server/scheduler")
|
||||||
public class SchedulerController {
|
public class SchedulerController {
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import static io.wdd.rpc.init.ServerCacheAgentStatus.*;
|
|||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Api("Agent运行状态Controller")
|
@Api(value = "Agent运行状态Controller", tags = "Status")
|
||||||
@RequestMapping("/octopus/server/status")
|
@RequestMapping("/octopus/server/status")
|
||||||
public class StatusController {
|
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.AsyncWaitOMResult;
|
||||||
import io.wdd.rpc.message.handler.OMReplayContend;
|
import io.wdd.rpc.message.handler.OMReplayContend;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -32,8 +31,7 @@ public class SyncExecutionServiceImpl implements SyncExecutionService {
|
|||||||
/**
|
/**
|
||||||
* 一个命令执行的最长等待时间
|
* 一个命令执行的最长等待时间
|
||||||
*/
|
*/
|
||||||
@Value("${octopus.agent.executor.processMaxTimeOut}")
|
int processMaxWaitSeconds = 10;
|
||||||
Integer processMaxWaitSeconds;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<String> SyncSendCommandToAgent(String agentTopicName, List<String> commandList) {
|
public ArrayList<String> SyncSendCommandToAgent(String agentTopicName, List<String> commandList) {
|
||||||
@@ -179,10 +177,14 @@ public class SyncExecutionServiceImpl implements SyncExecutionService {
|
|||||||
ArrayList<String> result = new ArrayList<>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
|
|
||||||
// 构造消息等待对象
|
// 构造消息等待对象
|
||||||
int commandCount = Math.max(
|
int commandCount = 1;
|
||||||
commandListComplete.size(),
|
if (null != commandListComplete) {
|
||||||
1
|
commandCount = Math.max(
|
||||||
);
|
commandListComplete.size(),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
OMReplayContend omReplayContend = OMReplayContend.build(
|
OMReplayContend omReplayContend = OMReplayContend.build(
|
||||||
commandCount,
|
commandCount,
|
||||||
CurrentAppOctopusMessageType,
|
CurrentAppOctopusMessageType,
|
||||||
|
|||||||
Reference in New Issue
Block a user