[server][ executor]- 完成底层的代码
This commit is contained in:
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static io.wdd.rpc.execute.result.RedisStreamReaderConfig.AGENT_STATUS_REDIS_STREAM_LISTENER_CONTAINER;
|
||||
@@ -88,22 +89,27 @@ public class ExecutionController {
|
||||
public R<List<String>> patchCommandToHealthyAgent(
|
||||
@RequestParam(value = "commandList", required = false)
|
||||
@ApiParam(name = "commandList", value = "命令行") @Nullable List<String> commandList,
|
||||
@RequestParam(value = "completeCommandList", required = false)
|
||||
@ApiParam(name = "completeCommandList", value = "完整命令行,优先,可为空") @Nullable List<List<String>> completeCommandList,
|
||||
@RequestParam(value = "type", required = false) @Nullable String type
|
||||
) {
|
||||
|
||||
return R.ok(asyncExecutionService.SendCommandToAgent(
|
||||
return R.ok(asyncExecutionService.SendCommandToAgentComplete(
|
||||
ALL_HEALTHY_AGENT_TOPIC_NAME_LIST,
|
||||
type,
|
||||
commandList
|
||||
commandList,
|
||||
completeCommandList
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/command/sync/one")
|
||||
@ApiOperation("[命令] [同步] - 同步等待命令结果")
|
||||
@ApiOperation("[命令] [同步] - 单机-等待命令结果")
|
||||
public R<List<String>> SyncPatchCommandToAgent(
|
||||
@RequestParam(value = "topicName") @ApiParam(name = "topicName", value = "目标主机名称") String topicName,
|
||||
@RequestParam(value = "commandList", required = false)
|
||||
@ApiParam(name = "commandList", value = "命令行") @Nullable List<String> commandList,
|
||||
@RequestParam(value = "completeCommandList", required = false)
|
||||
@ApiParam(name = "completeCommandList", value = "完整命令行,优先,可为空") @Nullable List<List<String>> completeCommandList,
|
||||
@RequestParam(value = "type", required = false) @ApiParam(name = "type", value = "执行命令类型") @Nullable String type
|
||||
) {
|
||||
|
||||
@@ -111,7 +117,50 @@ public class ExecutionController {
|
||||
syncExecutionService.SyncSendCommandToAgent(
|
||||
topicName,
|
||||
type,
|
||||
commandList
|
||||
commandList,
|
||||
completeCommandList
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@PostMapping("/command/sync/batch")
|
||||
@ApiOperation("[命令] [同步] - 批量-等待命令结果")
|
||||
public R<List<ArrayList<String>>> SyncPatchCommandToAgentBatch(
|
||||
@RequestParam(value = "topicNameList")
|
||||
@ApiParam(name = "topicNameList", value = "目标机器列表") List<String> topicNameList,
|
||||
@RequestParam(value = "commandList", required = false)
|
||||
@ApiParam(name = "commandList", value = "命令行") @Nullable List<String> commandList,
|
||||
@RequestParam(value = "completeCommandList", required = false)
|
||||
@ApiParam(name = "completeCommandList", value = "完整命令行,优先,可为空") @Nullable List<List<String>> completeCommandList,
|
||||
@RequestParam(value = "type", required = false) @ApiParam(name = "type", value = "执行命令类型") @Nullable String type
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
syncExecutionService.SyncSendCommandToAgentComplete(
|
||||
topicNameList,
|
||||
type,
|
||||
commandList,
|
||||
completeCommandList
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@PostMapping("/command/sync/all")
|
||||
@ApiOperation("[命令] [同步] - 全部-同步等待命令结果")
|
||||
public R<List<ArrayList<String>>> SyncPatchCommandToAgentAll(
|
||||
@RequestParam(value = "commandList", required = false)
|
||||
@ApiParam(name = "commandList", value = "命令行") @Nullable List<String> commandList,
|
||||
@RequestParam(value = "completeCommandList", required = false)
|
||||
@ApiParam(name = "completeCommandList", value = "完整命令行,优先,可为空") @Nullable List<List<String>> completeCommandList,
|
||||
@RequestParam(value = "type", required = false) @ApiParam(name = "type", value = "执行命令类型") @Nullable String type
|
||||
) {
|
||||
|
||||
return R.ok(
|
||||
syncExecutionService.SyncSendCommandToAgentComplete(
|
||||
ALL_AGENT_TOPIC_NAME_LIST,
|
||||
type,
|
||||
commandList,
|
||||
completeCommandList
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,9 @@ public interface AsyncExecutionService {
|
||||
* -------------------------------------------------
|
||||
*/
|
||||
|
||||
String SendCommandToAgent(String agentTopicName, String type, List<String> commandList, List<List<String>> commandListComplete);
|
||||
String SendCommandToAgentComplete(String agentTopicName, String type, List<String> commandList, List<List<String>> commandListComplete);
|
||||
|
||||
List<String> SendCommandToAgentComplete(List<String> agentTopicNameList, String type, List<String> commandList, List<List<String>> commandListComplete);
|
||||
|
||||
/**
|
||||
* 通常为 页面定时脚本任务调用
|
||||
|
||||
@@ -79,17 +79,37 @@ public class AsyncExecutionServiceImpl implements AsyncExecutionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String SendCommandToAgent(String agentTopicName, String type, List<String> commandList, List<List<String>> commandListComplete) {
|
||||
public String SendCommandToAgentComplete(String agentTopicName, String type, List<String> commandList, List<List<String>> commandListComplete) {
|
||||
|
||||
return this.SendCommandToAgent(
|
||||
agentTopicName,
|
||||
type,
|
||||
commandList,
|
||||
commandListComplete,
|
||||
null
|
||||
false,
|
||||
null,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> SendCommandToAgentComplete(List<String> agentTopicNameList, String type, List<String> commandList, List<List<String>> commandListComplete) {
|
||||
return agentTopicNameList
|
||||
.stream()
|
||||
.map(
|
||||
agentTopicName -> this.SendCommandToAgent(
|
||||
agentTopicName,
|
||||
type,
|
||||
commandList,
|
||||
commandListComplete,
|
||||
false,
|
||||
null,
|
||||
false
|
||||
)
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String SendCommandToAgent(String agentTopicName, String type, List<String> commandList, List<List<String>> commandListComplete, String futureKey) {
|
||||
|
||||
@@ -265,7 +285,7 @@ public class AsyncExecutionServiceImpl implements AsyncExecutionService {
|
||||
return agentTopicNameList
|
||||
.stream()
|
||||
.map(
|
||||
agentTopicName -> this.SendCommandToAgent(
|
||||
agentTopicName -> this.SendCommandToAgentComplete(
|
||||
agentTopicName,
|
||||
type,
|
||||
null,
|
||||
@@ -287,7 +307,10 @@ public class AsyncExecutionServiceImpl implements AsyncExecutionService {
|
||||
type,
|
||||
null,
|
||||
completeCommandList,
|
||||
atnFutureKey.get(agentTopicName)
|
||||
atnFutureKey.getOrDefault(
|
||||
agentTopicName,
|
||||
null
|
||||
)
|
||||
)
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -44,7 +44,9 @@ public interface SyncExecutionService {
|
||||
* -------------------------------------------------
|
||||
*/
|
||||
|
||||
ArrayList<String> SyncSendCommandToAgent(String agentTopicName, String type, List<String> commandList, List<List<String>> commandListComplete);
|
||||
ArrayList<String> SyncSendCommandToAgent(String agentTopicName, String type, List<String> commandList, List<List<String>> completeCommandList);
|
||||
|
||||
List<ArrayList<String>> SyncSendCommandToAgentComplete(List<String> agentTopicNameList, String type, List<String> commandList, List<List<String>> completeCommandList);
|
||||
|
||||
/**
|
||||
* 通常为 页面定时脚本任务调用
|
||||
|
||||
@@ -96,18 +96,36 @@ public class SyncExecutionServiceImpl implements SyncExecutionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> SyncSendCommandToAgent(String agentTopicName, String type, List<String> commandList, List<List<String>> commandListComplete) {
|
||||
public ArrayList<String> SyncSendCommandToAgent(String agentTopicName, String type, List<String> commandList, List<List<String>> completeCommandList) {
|
||||
return this.SyncSendCommandToAgent(
|
||||
agentTopicName,
|
||||
type,
|
||||
commandList,
|
||||
commandListComplete,
|
||||
completeCommandList,
|
||||
COMMAND_EXEC_NEED_REPLAY,
|
||||
null,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArrayList<String>> SyncSendCommandToAgentComplete(List<String> agentTopicNameList, String type, List<String> commandList, List<List<String>> completeCommandList) {
|
||||
return agentTopicNameList
|
||||
.stream()
|
||||
.map(
|
||||
agentTopicName -> this.SyncSendCommandToAgent(
|
||||
agentTopicName,
|
||||
type,
|
||||
commandList,
|
||||
completeCommandList,
|
||||
COMMAND_EXEC_NEED_REPLAY,
|
||||
null,
|
||||
false
|
||||
)
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArrayList<String>> SyncSendCommandToAgentComplete(List<String> agentTopicNameList, String type, List<List<String>> completeCommandList) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user