[ server ] [ execution ]- optimize some controller - 1
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package io.wdd.rpc.controller;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.wdd.common.beans.response.R;
|
||||
import io.wdd.rpc.execute.result.BuildStreamReader;
|
||||
import io.wdd.rpc.execute.service.CoreExecutionService;
|
||||
@@ -17,7 +19,8 @@ import static io.wdd.rpc.execute.result.RedisStreamReaderConfig.AGENT_STATUS_RED
|
||||
import static io.wdd.rpc.execute.result.RedisStreamReaderConfig.COMMAND_RESULT_REDIS_STREAM_LISTENER_CONTAINER;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("octopus/server/executor")
|
||||
@RequestMapping("/octopus/server/executor")
|
||||
@Api("Agent执行命令的Controller")
|
||||
public class ExecutionController {
|
||||
|
||||
@Resource
|
||||
@@ -37,9 +40,16 @@ public class ExecutionController {
|
||||
String streamKey = "";
|
||||
|
||||
if (StringUtils.isEmpty(type)) {
|
||||
streamKey = coreExecutionService.SendCommandToAgent(topicName, commandList);
|
||||
streamKey = coreExecutionService.SendCommandToAgent(
|
||||
topicName,
|
||||
commandList
|
||||
);
|
||||
} else {
|
||||
streamKey = coreExecutionService.SendCommandToAgent(topicName, type, commandList);
|
||||
streamKey = coreExecutionService.SendCommandToAgent(
|
||||
topicName,
|
||||
type,
|
||||
commandList
|
||||
);
|
||||
}
|
||||
|
||||
return R.ok(streamKey);
|
||||
@@ -50,7 +60,10 @@ public class ExecutionController {
|
||||
@RequestParam(value = "streamKey") String streamKey
|
||||
) {
|
||||
|
||||
buildStreamReader.registerStreamReader(COMMAND_RESULT_REDIS_STREAM_LISTENER_CONTAINER , streamKey);
|
||||
buildStreamReader.registerStreamReader(
|
||||
COMMAND_RESULT_REDIS_STREAM_LISTENER_CONTAINER,
|
||||
streamKey
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,18 +72,58 @@ public class ExecutionController {
|
||||
@RequestParam(value = "streamKey") String streamKey
|
||||
) {
|
||||
|
||||
buildStreamReader.registerStreamReader(AGENT_STATUS_REDIS_STREAM_LISTENER_CONTAINER , streamKey);
|
||||
buildStreamReader.registerStreamReader(
|
||||
AGENT_STATUS_REDIS_STREAM_LISTENER_CONTAINER,
|
||||
streamKey
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/agentUpdate")
|
||||
public void AgentUpdate(
|
||||
// auth required
|
||||
@PostMapping("/AgentUpdate")
|
||||
@ApiOperation("控制Agent升级的接口")
|
||||
public R<String> AgentUpdate(
|
||||
@RequestParam(value = "agentTopicName") String agentTopicName
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
coreExecutionService
|
||||
.SendCommandToAgent(
|
||||
agentTopicName,
|
||||
"AgentUpdate",
|
||||
null
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/AgentReboot")
|
||||
@ApiOperation("控制Agent重启的接口")
|
||||
public R<String> AgentReboot(
|
||||
@RequestParam(value = "agentTopicName") String agentTopicName
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
coreExecutionService
|
||||
.SendCommandToAgent(
|
||||
agentTopicName,
|
||||
"AgentRestart",
|
||||
null
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/AgentShutdown")
|
||||
@ApiOperation("控制Agent关闭的接口")
|
||||
public R<String> AgentShutdown(
|
||||
@RequestParam(value = "agentTopicName") String agentTopicName
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
coreExecutionService
|
||||
.SendCommandToAgent(
|
||||
agentTopicName,
|
||||
"AgentShutdown",
|
||||
null
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user