[ Cmii ] [ Octopus ] - add tcp portforwarding part
This commit is contained in:
@@ -2,6 +2,7 @@ package io.wdd.func.auto.service;
|
||||
|
||||
import io.wdd.func.auto.beans.BaseFunctionEnum;
|
||||
import io.wdd.func.auto.beans.ProjectDeployContext;
|
||||
import io.wdd.server.beans.po.ServerInfoPO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -25,10 +26,9 @@ public class BaseFuncScheduler {
|
||||
beforeRunProcedure(projectDeployContext);
|
||||
|
||||
|
||||
// during run
|
||||
// during running
|
||||
doRunProcedure(projectDeployContext);
|
||||
|
||||
|
||||
// after run
|
||||
afterRunProcedure();
|
||||
|
||||
@@ -63,15 +63,12 @@ public class BaseFuncScheduler {
|
||||
.getMasterNode()
|
||||
.getTopicName();
|
||||
|
||||
if (agentNodeRunProcedure(
|
||||
return serverDoRunProcedure(
|
||||
true,
|
||||
masterTopicName,
|
||||
projectDeployContext
|
||||
)) {
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,41 +105,40 @@ public class BaseFuncScheduler {
|
||||
List<String> agentTopicNameList = projectDeployContext
|
||||
.getAgentNodeList()
|
||||
.stream()
|
||||
.map(agentNode -> agentNode.getTopicName())
|
||||
.map(ServerInfoPO::getTopicName)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
agentTopicNameList.forEach(
|
||||
agentTopicName -> {
|
||||
if (!agentNodeRunProcedure(
|
||||
false,
|
||||
agentTopicName,
|
||||
projectDeployContext
|
||||
)) {
|
||||
log.error("{} agent run base func failed !", agentTopicName);
|
||||
}
|
||||
}
|
||||
);
|
||||
for (String agentTopicName : agentTopicNameList) {
|
||||
if (!serverDoRunProcedure(
|
||||
false,
|
||||
agentTopicName,
|
||||
projectDeployContext
|
||||
)) {
|
||||
log.error("{} agent run base func failed !", agentTopicName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean agentNodeRunProcedure(boolean masterNode, String agentTopicName, ProjectDeployContext projectDeployContext) {
|
||||
private boolean serverDoRunProcedure(boolean masterNode, String agentTopicName, ProjectDeployContext projectDeployContext) {
|
||||
|
||||
List<BaseFunctionEnum> agentNodeProcedureList;
|
||||
List<BaseFunctionEnum> serverRunProcedureList;
|
||||
if (masterNode) {
|
||||
agentNodeProcedureList = projectDeployContext.getMasterNodeBaseProcedure();
|
||||
serverRunProcedureList = projectDeployContext.getMasterNodeBaseProcedure();
|
||||
} else {
|
||||
agentNodeProcedureList = projectDeployContext.getAgentNodeBaseProcedure();
|
||||
serverRunProcedureList = projectDeployContext.getAgentNodeBaseProcedure();
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(agentNodeProcedureList)) {
|
||||
if (CollectionUtils.isEmpty(serverRunProcedureList)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ArrayList<String> baseFuncArgList = projectDeployContext.getBaseFunctionArgs();
|
||||
|
||||
for (BaseFunctionEnum durationBaseFunc : agentNodeProcedureList) {
|
||||
for (BaseFunctionEnum durationBaseFunc : serverRunProcedureList) {
|
||||
|
||||
// add op name
|
||||
baseFuncArgList.add(
|
||||
@@ -157,7 +153,8 @@ public class BaseFuncScheduler {
|
||||
true
|
||||
)) {
|
||||
log.error(
|
||||
"Agent Base Func Failed ! => {}",
|
||||
"Agent {} Base Func Failed ! => {}",
|
||||
agentTopicName,
|
||||
durationBaseFunc
|
||||
);
|
||||
return false;
|
||||
@@ -171,5 +168,4 @@ public class BaseFuncScheduler {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SpringBootTest
|
||||
public class TestBaseFuncScheduler {
|
||||
@@ -51,47 +51,24 @@ public class TestBaseFuncScheduler {
|
||||
projectDeployContext.setProjectId(projectServerId);
|
||||
|
||||
|
||||
// ServerQueryEntity serverQueryEntity = new ServerQueryEntity();
|
||||
// // exsi server
|
||||
//// serverQueryEntity.setServerName("Chengdu-amd64-99");
|
||||
// // lappro
|
||||
//// serverQueryEntity.setServerName("Chengdu-amd64-65");
|
||||
//
|
||||
// // cqga
|
||||
// serverQueryEntity.setServerName();
|
||||
// ServerInfoPO serverInfoPO = serverService
|
||||
// .serverGetByPage(serverQueryEntity)
|
||||
// .getRecords()
|
||||
// .get(0);
|
||||
|
||||
String masterNodeServerName = "Chongqing-amd64-01"; // cgga
|
||||
// String masterNodeServerName = "Chengdu-amd64-99"; // lap pro
|
||||
|
||||
ProjectServerVO projectServerVO = coreProjectServerService.projectServerOne(projectServerId);
|
||||
Map<Boolean, List<ServerInfoPO>> collect = projectServerVO.getBindingServerList().stream().collect(
|
||||
Collectors.groupingBy(
|
||||
serverInfoPO -> StringUtils.contains(serverInfoPO.getServerName(), masterNodeServerName)
|
||||
)
|
||||
);
|
||||
|
||||
Optional<ServerInfoPO> serverInfoPOOptional = projectServerVO.getBindingServerList().stream().filter(
|
||||
serverInfoPO -> StringUtils.contains(serverInfoPO.getServerName(), masterNodeServerName)
|
||||
).findFirst();
|
||||
|
||||
if (serverInfoPOOptional.isEmpty()) {
|
||||
System.out.printf("project of %s server of %s is empty", projectServerVO, masterNodeServerName);
|
||||
if (collect.get(Boolean.TRUE) == null) {
|
||||
System.out.printf("project of %s master server of %s is empty", projectServerVO, masterNodeServerName);
|
||||
return;
|
||||
}
|
||||
projectDeployContext.setMasterNode(collect.get(Boolean.TRUE).get(0));
|
||||
|
||||
ServerInfoPO serverInfoPO = serverInfoPOOptional.get();
|
||||
System.out.println("serverInfoPO = " + serverInfoPO);
|
||||
|
||||
projectDeployContext.setMasterNode(serverInfoPO);
|
||||
ArrayList<ServerInfoPO> agentNodeList = new ArrayList<>();
|
||||
|
||||
projectServerVO.getBindingServerList().forEach(
|
||||
po -> {
|
||||
if (!StringUtils.contains(po.getServerName(), masterNodeServerName)) {
|
||||
agentNodeList.add(po);
|
||||
}
|
||||
}
|
||||
);
|
||||
projectDeployContext.setAgentNodeList(agentNodeList);
|
||||
projectDeployContext.setAgentNodeList(collect.get(Boolean.FALSE));
|
||||
|
||||
|
||||
List<BaseFunctionEnum> masterNodeProcedure = List.of(
|
||||
|
||||
Reference in New Issue
Block a user