[Exec] modify sync and async execution function
This commit is contained in:
@@ -15,11 +15,12 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static io.wdd.rpc.execute.result.RedisStreamReaderConfig.AGENT_STATUS_REDIS_STREAM_LISTENER_CONTAINER;
|
||||
import static io.wdd.rpc.init.ServerCacheAgentStatus.ALL_AGENT_TOPIC_NAME_LIST;
|
||||
import static io.wdd.rpc.init.ServerCacheAgentStatus.ALL_HEALTHY_AGENT_TOPIC_NAME_LIST;
|
||||
import static io.wdd.rpc.init.AgentStatusCacheService.ALL_AGENT_TOPIC_NAME_LIST;
|
||||
import static io.wdd.rpc.init.AgentStatusCacheService.ALL_HEALTHY_AGENT_TOPIC_NAME_LIST;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/octopus/server/executor")
|
||||
@@ -27,11 +28,11 @@ import static io.wdd.rpc.init.ServerCacheAgentStatus.ALL_HEALTHY_AGENT_TOPIC_NAM
|
||||
public class ExecutionController {
|
||||
|
||||
@Resource
|
||||
AsyncExecutionService asyncExecutionService;
|
||||
SyncExecutionService syncExecutionService;
|
||||
@Resource
|
||||
BuildStreamReader buildStreamReader;
|
||||
@Resource
|
||||
SyncExecutionService syncExecutionService;
|
||||
AsyncExecutionService asyncExecutionService;
|
||||
|
||||
@PostMapping("/command/one")
|
||||
@ApiOperation("[命令] [异步]- 单台主机")
|
||||
@@ -44,8 +45,8 @@ public class ExecutionController {
|
||||
@ApiParam(name = "isDurationTask", value = "是否是持久化任务") @RequestParam(value = "isDurationTask", defaultValue = "false", required = false) boolean isDurationTask
|
||||
) {
|
||||
|
||||
String streamKey = asyncExecutionService
|
||||
.SendCommandToAgent(
|
||||
ArrayList<String> streamKeyList = asyncExecutionService
|
||||
.AsyncSendCommandToAgentComplete(
|
||||
topicName,
|
||||
type,
|
||||
commandList,
|
||||
@@ -55,12 +56,13 @@ public class ExecutionController {
|
||||
isDurationTask
|
||||
);
|
||||
|
||||
return R.ok(streamKey);
|
||||
|
||||
return R.ok(streamKeyList.toString());
|
||||
}
|
||||
|
||||
@PostMapping("/command/batch")
|
||||
@ApiOperation("[命令] [异步] - 批量主机")
|
||||
public R<List<String>> patchCommandToAgentList(
|
||||
public R<List<ArrayList<String>>> patchCommandToAgentList(
|
||||
@RequestParam(value = "topicNameList")
|
||||
@ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList,
|
||||
@RequestParam(value = "commandList", required = false)
|
||||
@@ -71,19 +73,20 @@ public class ExecutionController {
|
||||
@ApiParam(name = "isDurationTask", value = "是否是持久化任务") @RequestParam(value = "isDurationTask", defaultValue = "false", required = false) boolean isDurationTask
|
||||
) {
|
||||
|
||||
return R.ok(asyncExecutionService.SendCommandToAgentComplete(
|
||||
List<ArrayList<String>> arrayListList = asyncExecutionService.AsyncSendCommandToAgentComplete(
|
||||
topicNameList,
|
||||
type,
|
||||
commandList,
|
||||
completeCommandList,
|
||||
isDurationTask
|
||||
));
|
||||
);
|
||||
return R.ok(arrayListList);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/command/all")
|
||||
@ApiOperation("[命令] [异步] - 所有的主机")
|
||||
public R<List<String>> patchCommandToAllAgent(
|
||||
public R<List<ArrayList<String>>> patchCommandToAllAgent(
|
||||
@RequestParam(value = "commandList", required = false)
|
||||
@ApiParam(name = "commandList", value = "命令行") @Nullable List<String> commandList,
|
||||
@RequestParam(value = "completeCommandList", required = false)
|
||||
@@ -92,7 +95,7 @@ public class ExecutionController {
|
||||
@ApiParam(name = "isDurationTask", value = "是否是持久化任务") @RequestParam(value = "isDurationTask", defaultValue = "false", required = false) boolean isDurationTask
|
||||
) {
|
||||
|
||||
return R.ok(asyncExecutionService.SendCommandToAgentComplete(
|
||||
return R.ok(asyncExecutionService.AsyncSendCommandToAgentComplete(
|
||||
ALL_AGENT_TOPIC_NAME_LIST,
|
||||
type,
|
||||
commandList,
|
||||
@@ -103,7 +106,7 @@ public class ExecutionController {
|
||||
|
||||
@PostMapping("/command/healthy")
|
||||
@ApiOperation("[命令] [异步] - 健康的主机")
|
||||
public R<List<String>> patchCommandToHealthyAgent(
|
||||
public R<List<ArrayList<String>>> patchCommandToHealthyAgent(
|
||||
@RequestParam(value = "commandList", required = false)
|
||||
@ApiParam(name = "commandList", value = "命令行") @Nullable List<String> commandList,
|
||||
@RequestParam(value = "completeCommandList", required = false)
|
||||
@@ -112,7 +115,7 @@ public class ExecutionController {
|
||||
@ApiParam(name = "isDurationTask", value = "是否是持久化任务") @RequestParam(value = "isDurationTask", defaultValue = "false", required = false) boolean isDurationTask
|
||||
) {
|
||||
|
||||
return R.ok(asyncExecutionService.SendCommandToAgentComplete(
|
||||
return R.ok(asyncExecutionService.AsyncSendCommandToAgentComplete(
|
||||
ALL_HEALTHY_AGENT_TOPIC_NAME_LIST,
|
||||
type,
|
||||
commandList,
|
||||
@@ -133,18 +136,18 @@ public class ExecutionController {
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
syncExecutionService.SyncSendCommandToAgent(
|
||||
Collections.singletonList(syncExecutionService.SyncSendCommandToAgentComplete(
|
||||
topicName,
|
||||
type,
|
||||
commandList,
|
||||
completeCommandList
|
||||
)
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
@PostMapping("/command/sync/batch")
|
||||
@ApiOperation("[命令] [同步] - 批量-等待命令结果")
|
||||
public R<List<ArrayList<String>>> SyncPatchCommandToAgentBatch(
|
||||
public R<List<String>> SyncPatchCommandToAgentBatch(
|
||||
@RequestParam(value = "topicNameList")
|
||||
@ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList,
|
||||
@RequestParam(value = "commandList", required = false)
|
||||
@@ -168,7 +171,7 @@ public class ExecutionController {
|
||||
|
||||
@PostMapping("/command/sync/all")
|
||||
@ApiOperation("[命令] [同步] - 全部-同步等待命令结果")
|
||||
public R<List<ArrayList<String>>> SyncPatchCommandToAgentAll(
|
||||
public R<List<String>> SyncPatchCommandToAgentAll(
|
||||
@RequestParam(value = "commandList", required = false)
|
||||
@ApiParam(name = "commandList", value = "命令行") @Nullable List<String> commandList,
|
||||
@RequestParam(value = "completeCommandList", required = false)
|
||||
@@ -206,81 +209,81 @@ public class ExecutionController {
|
||||
|
||||
|
||||
// auth required
|
||||
@PostMapping("/function/update")
|
||||
@ApiOperation("升级")
|
||||
public R<List<String>> AgentUpdate(
|
||||
@RequestParam(value = "topicNameList")
|
||||
@ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
asyncExecutionService
|
||||
.SendCommandToAgent(
|
||||
topicNameList,
|
||||
"AgentUpdate",
|
||||
null,
|
||||
false,
|
||||
null,
|
||||
true
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/function/reboot")
|
||||
@ApiOperation("重启")
|
||||
public R<List<String>> AgentReboot(
|
||||
@RequestParam(value = "topicNameList")
|
||||
@ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
asyncExecutionService
|
||||
.SendCommandToAgent(
|
||||
topicNameList,
|
||||
"AgentReboot",
|
||||
null,
|
||||
false,
|
||||
null,
|
||||
true
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/function/shutdown")
|
||||
@ApiOperation("关闭")
|
||||
public R<List<String>> AgentShutdown(
|
||||
@RequestParam(value = "topicNameList")
|
||||
@ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
asyncExecutionService
|
||||
.SendCommandToAgent(
|
||||
topicNameList,
|
||||
"AgentShutdown",
|
||||
null,
|
||||
false,
|
||||
null,
|
||||
true
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/function/bootUp")
|
||||
@ApiOperation("重新部署")
|
||||
public R<List<String>> AgentBootUp(
|
||||
@RequestParam(value = "topicNameList")
|
||||
@ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
asyncExecutionService
|
||||
.SendCommandToAgent(
|
||||
topicNameList,
|
||||
"AgentBootUp",
|
||||
null,
|
||||
false,
|
||||
null,
|
||||
true
|
||||
));
|
||||
}
|
||||
// @PostMapping("/function/update")
|
||||
// @ApiOperation("升级")
|
||||
// public R<List<String>> AgentUpdate(
|
||||
// @RequestParam(value = "topicNameList")
|
||||
// @ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList
|
||||
// ) {
|
||||
//
|
||||
// return R.ok(
|
||||
// syncExecutionService
|
||||
// .SyncSendCommandToAgent(
|
||||
// topicNameList,
|
||||
// "AgentUpdate",
|
||||
// null,
|
||||
// false,
|
||||
// null,
|
||||
// true
|
||||
// ));
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/function/reboot")
|
||||
// @ApiOperation("重启")
|
||||
// public R<List<String>> AgentReboot(
|
||||
// @RequestParam(value = "topicNameList")
|
||||
// @ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList
|
||||
// ) {
|
||||
//
|
||||
// return R.ok(
|
||||
// asyncExecutionService
|
||||
// .SyncSendCommandToAgent(
|
||||
// topicNameList,
|
||||
// "AgentReboot",
|
||||
// null,
|
||||
// false,
|
||||
// null,
|
||||
// true
|
||||
// ));
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/function/shutdown")
|
||||
// @ApiOperation("关闭")
|
||||
// public R<List<String>> AgentShutdown(
|
||||
// @RequestParam(value = "topicNameList")
|
||||
// @ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList
|
||||
// ) {
|
||||
//
|
||||
// return R.ok(
|
||||
// syncExecutionService
|
||||
// .SyncSendCommandToAgent(
|
||||
// topicNameList,
|
||||
// "AgentShutdown",
|
||||
// null,
|
||||
// false,
|
||||
// null,
|
||||
// true
|
||||
// ));
|
||||
// }
|
||||
//
|
||||
// @PostMapping("/function/bootUp")
|
||||
// @ApiOperation("重新部署")
|
||||
// public R<List<String>> AgentBootUp(
|
||||
// @RequestParam(value = "topicNameList")
|
||||
// @ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList
|
||||
// ) {
|
||||
//
|
||||
// return R.ok(
|
||||
// asyncExecutionService
|
||||
// .SyncSendCommandToAgent(
|
||||
// topicNameList,
|
||||
// "AgentBootUp",
|
||||
// null,
|
||||
// false,
|
||||
// null,
|
||||
// true
|
||||
// ));
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user