diff --git a/agent-go/a_agent/AgentServerInfo.go b/agent-go/a_agent/AgentServerInfo.go index e30c599..7cfb54c 100644 --- a/agent-go/a_agent/AgentServerInfo.go +++ b/agent-go/a_agent/AgentServerInfo.go @@ -13,7 +13,7 @@ type AgentServerInfo struct { ServerIPPbV6 string `json:"serverIpPbV6" yaml:"serverIpPbV6"` ServerIPInV6 string `json:"serverIpInV6" yaml:"serverIpInV6"` City string `json:"city" yaml:"city"` - Region string `json:"region" yaml:"region"` + Province string `json:"province" yaml:"province"` Country string `json:"country" yaml:"country"` Organization string `json:"organization" yaml:"organization"` TimeZone string `json:"timeZone" yaml:"timeZone"` @@ -31,6 +31,7 @@ type AgentServerInfo struct { PlatformVersion string `json:"platformVersion"` // version of the complete OS KernelVersion string `json:"kernelVersion"` // version of the OS kernel (if available) KernelArch string `json:"kernelArch"` // native cpu architecture queried at runtime, as returned by `uname -m` or empty string in case of error + CPUArch string `json:"cpuArch"` // native cpu architecture queried at runtime, as returned by `uname -m` or empty string in case of error IoSpeed string `json:"ioSpeed" yaml:"ioSpeed"` MemoryTotal string `json:"memoryTotal" yaml:"memoryTotal"` SwapTotal string `json:"swapTotal" yaml:"swapTotal"` @@ -39,5 +40,5 @@ type AgentServerInfo struct { Comment string `json:"comment" yaml:"comment"` MachineID string `json:"machineId" yaml:"machineId"` AgentVersion string `json:"agentVersion" yaml:"agentVersion"` - TopicName string `json:"topicName" yaml:"topicName"` + AgentTopicName string `json:"agentTopicName" yaml:"agentTopicName"` } diff --git a/agent-go/a_init/AgentInitialization.go b/agent-go/a_init/AgentInitialization.go index a2ddf7f..c9f1b5b 100644 --- a/agent-go/a_init/AgentInitialization.go +++ b/agent-go/a_init/AgentInitialization.go @@ -92,7 +92,7 @@ func INIT(octopusAgentConfigFileName string) chan bool { } // 建立 运行时 RabbitMQ连接 - runtimeConnectorQueue := buildAndStartBusinessRuntimeQueue(a_agent.AgentServerInfoCache.TopicName) + runtimeConnectorQueue := buildAndStartBusinessRuntimeQueue(a_agent.AgentServerInfoCache.AgentTopicName) // 激活子模块 activatedOctopusAgentModules() @@ -318,6 +318,8 @@ func uniformAgentServerName(agentInfo *a_status.AgentInfo, agentServerInfo *a_ag // linux host architecture arch := getMachineType(agentInfo.HostInfo.KernelArch) + agentServerInfo.CPUArch = arch + var numS string if agentServerInfo.ServerIPInV4 != "" { split := strings.Split(agentServerInfo.ServerIPInV4, ".") @@ -433,7 +435,7 @@ func refreshAgentNetworkInfo(agentInfo *a_status.AgentInfo, agentServerInfo *a_a if publicNetworkInfo.IP != "" { agentServerInfo.ServerIPPbV4 = publicNetworkInfo.IP - agentServerInfo.Region = publicNetworkInfo.Region + agentServerInfo.Province = publicNetworkInfo.Region agentServerInfo.City = publicNetworkInfo.City agentServerInfo.Country = publicNetworkInfo.Country agentServerInfo.Location = publicNetworkInfo.Loc @@ -507,7 +509,7 @@ func handleInitMsgFromServer(initFromServerMsg *rabbitmq.OctopusMessage, initToS g.G.AgentHasRegister = true // 保存真实的AgentTopicName - a_agent.AgentServerInfoCache.TopicName = serverInfo.TopicName + a_agent.AgentServerInfoCache.AgentTopicName = serverInfo.AgentTopicName } else { // 不是自身的 注册回复信息 -- 拒绝 2023年6月19日 此处存在错误! 会死循环Nack 导致异常 diff --git a/agent-go/octopus-agent-cmii.yaml b/agent-go/octopus-agent-cmii.yaml new file mode 100644 index 0000000..86db169 --- /dev/null +++ b/agent-go/octopus-agent-cmii.yaml @@ -0,0 +1,68 @@ +server: + port: 8000 + +logging: + level: + web: info + +octopus: + message: + # agent boot up default common exchange + init_exchange: InitExchange + # server will send message to agent using this common queue + init_to_server: InitToServer + # agent boot up default common exchange routing key + init_to_server_key: InitToServerKey + # server will receive message from agent using this common queue + init_from_server: InitFromServer + # agent boot up default common exchange routing key + init_from_server_key: InitFromServerKey + # initialization register time out (unit ms) default is 5 min + init_ttl: "3000000" + # Octopus Exchange Name == server comunicate with agent + octopus_exchange: OctopusExchange + # Octopus Message To Server == all agent send info to server queue and topic + octopus_to_server: OctopusToServer + executor: + name: executor-functions + status: + name: octopus-agent + healthy: + type: cron + cron: 10 */1 * * * ? * + start-delay: 30 + metric: + pinch: 20 + agent: + executor: + # agent执行一条Command的最长超时时间 + processMaxTimeOut: 60 + status: + app: + - Nginx/nginx + - MySQL/mysql + - Xray/xray + - OctopusAgent/octopus-agent + - Redis/redis + - RabbitMQ/rabbitmq + +spring: + main: + allow-circular-references: true + allow-bean-definition-overriding: true + rabbitmq: + # host: 42.192.52.227 + host: 192.168.35.71 + port: 20672 + username: boge + password: boge8tingH + virtual-host: / + listener: + simple: + retry: + # ack failed will reentrant the Rabbit Listener + max-attempts: 2 + enabled: true + # retry interval unit ms + max-interval: 65000 + initial-interval: 65000 \ No newline at end of file diff --git a/agent-go/octopus-agent-dev.yaml b/agent-go/octopus-agent-local.yaml similarity index 76% rename from agent-go/octopus-agent-dev.yaml rename to agent-go/octopus-agent-local.yaml index 0a9af19..b3d6da8 100644 --- a/agent-go/octopus-agent-dev.yaml +++ b/agent-go/octopus-agent-local.yaml @@ -65,27 +65,4 @@ spring: enabled: true # retry interval unit ms max-interval: 65000 - initial-interval: 65000 - -#spring: -# application: -# name: octopus-agent -# profiles: -# active: dev -# cloud: -# nacos: -# config: -# group: dev -# config-retry-time: 3000 -# file-extension: yaml -# max-retry: 3 -# # server-addr: "150.230.198.103:21060" -# server-addr: "42.192.52.227:21060" -# timeout: 5000 -# config-long-poll-timeout: 5000 -# extension-configs: -# - group: dev -# data-id: "common-dev.yaml" -# -#server: -# port: 8000 \ No newline at end of file + initial-interval: 65000 \ No newline at end of file diff --git a/server/src/main/java/io/wdd/common/utils/FakeDataUtils.java b/server/src/main/java/io/wdd/common/utils/FakeDataUtils.java index 445ce8e..c7137ff 100644 --- a/server/src/main/java/io/wdd/common/utils/FakeDataUtils.java +++ b/server/src/main/java/io/wdd/common/utils/FakeDataUtils.java @@ -91,7 +91,7 @@ public class FakeDataUtils { ServerInfoVO serverInfoVO = ServerInfoVO .builder() - .topicName(agentTopicName) + .agentTopicName(agentTopicName) .serverName(serverName) .serverIpPbV4(publicIpV4) .serverIpPbV6(publicIpV6) diff --git a/server/src/main/java/io/wdd/func/auto/service/AppFuncScheduler.java b/server/src/main/java/io/wdd/func/auto/service/AppFuncScheduler.java index e2cc3aa..4ee989a 100644 --- a/server/src/main/java/io/wdd/func/auto/service/AppFuncScheduler.java +++ b/server/src/main/java/io/wdd/func/auto/service/AppFuncScheduler.java @@ -118,7 +118,7 @@ public class AppFuncScheduler { String masterTopicName = projectDeployContext .getMasterNode() - .getTopicName(); + .getAgentTopicName(); List masterAppProcedure = projectDeployContext.getMasterAppProcedure(); if (CollectionUtils.isEmpty(masterAppProcedure)) { diff --git a/server/src/main/java/io/wdd/func/auto/service/BaseFuncScheduler.java b/server/src/main/java/io/wdd/func/auto/service/BaseFuncScheduler.java index 3400886..b0124e2 100644 --- a/server/src/main/java/io/wdd/func/auto/service/BaseFuncScheduler.java +++ b/server/src/main/java/io/wdd/func/auto/service/BaseFuncScheduler.java @@ -61,7 +61,7 @@ public class BaseFuncScheduler { String masterTopicName = projectDeployContext .getMasterNode() - .getTopicName(); + .getAgentTopicName(); return serverDoRunProcedure( true, @@ -105,7 +105,7 @@ public class BaseFuncScheduler { List agentTopicNameList = projectDeployContext .getAgentNodeList() .stream() - .map(ServerInfoPO::getTopicName) + .map(ServerInfoPO::getAgentTopicName) .collect(Collectors.toList()); for (String agentTopicName : agentTopicNameList) { diff --git a/server/src/main/java/io/wdd/func/auto/service/HarborFuncScheduler.java b/server/src/main/java/io/wdd/func/auto/service/HarborFuncScheduler.java index 17bc29a..12da5ca 100644 --- a/server/src/main/java/io/wdd/func/auto/service/HarborFuncScheduler.java +++ b/server/src/main/java/io/wdd/func/auto/service/HarborFuncScheduler.java @@ -53,7 +53,7 @@ public class HarborFuncScheduler { // 执行 基础功能施工的内容 String masterTopicName = projectDeployContext .getMasterNode() - .getTopicName(); + .getAgentTopicName(); // create harbor project if (!CreateHarborProject(projectDeployContext)) { @@ -123,7 +123,7 @@ public class HarborFuncScheduler { // send harbor create message boolean createProjectOK = funcService.callHarborFuncAndJudge( - masterNode.getTopicName(), + masterNode.getAgentTopicName(), HarborFunctionEnum.CREATE_PROJECT, createProjectArgList ); @@ -156,7 +156,7 @@ public class HarborFuncScheduler { // send harbor create message boolean listProjectOK = funcService.callHarborFuncAndJudge( - masterNode.getTopicName(), + masterNode.getAgentTopicName(), HarborFunctionEnum.LIST_PROJECT, listProjectArgList ); @@ -202,7 +202,7 @@ public class HarborFuncScheduler { ); boolean syncHarborProjectOk = funcService.callHarborFuncAndJudge( - masterNode.getTopicName(), + masterNode.getAgentTopicName(), HarborFunctionEnum.SYNC_PROJECT_BETWEEN_HARBOR, syncHarborArgList ); @@ -269,7 +269,7 @@ public class HarborFuncScheduler { ); return funcService.callHarborFuncAndJudge( - masterNode.getTopicName(), + masterNode.getAgentTopicName(), HarborFunctionEnum.SYNC_STATUS_HARBOR, syncHarborArgList ); diff --git a/server/src/main/java/io/wdd/func/auto/service/ImageFuncScheduler.java b/server/src/main/java/io/wdd/func/auto/service/ImageFuncScheduler.java index 7b7189c..2d130cb 100644 --- a/server/src/main/java/io/wdd/func/auto/service/ImageFuncScheduler.java +++ b/server/src/main/java/io/wdd/func/auto/service/ImageFuncScheduler.java @@ -116,7 +116,7 @@ public class ImageFuncScheduler { ArrayList imageSyncFuncArgs = imageSyncContext.getImageSyncFuncArgs(); - String outsideAgentTopicName = imageSyncContext.getProjectMasterNode().getTopicName(); + String outsideAgentTopicName = imageSyncContext.getProjectMasterNode().getAgentTopicName(); // 设置消息体 ImageSyncMessage imageSyncMessage = imageSyncContext.getImageSyncMessage(); @@ -124,7 +124,7 @@ public class ImageFuncScheduler { imageSyncMessage.setProjectNameSpace(imageSyncContext.getProjectInfoPO().getProjectNamespace()); imageSyncMessage.setProjectName(imageSyncContext.getProjectInfoPO().getProjectName()); imageSyncMessage.setInnerWorkTopicName(imageSyncContext.getInnerWorkerAgentName()); - imageSyncMessage.setProjectMasterTopicName(imageSyncContext.getProjectMasterNode().getTopicName()); + imageSyncMessage.setProjectMasterTopicName(imageSyncContext.getProjectMasterNode().getAgentTopicName()); imageSyncMessage.setProjectMasterIP(imageSyncContext.getProjectMasterNode().getServerIpInV4()); // diff --git a/server/src/main/java/io/wdd/func/controller/XrayController.java b/server/src/main/java/io/wdd/func/controller/XrayController.java index dfff82a..6c736b3 100644 --- a/server/src/main/java/io/wdd/func/controller/XrayController.java +++ b/server/src/main/java/io/wdd/func/controller/XrayController.java @@ -9,7 +9,10 @@ import io.wdd.func.xray.beans.node.ProxyNode; import io.wdd.func.xray.beans.node.XrayConfigInfo; import io.wdd.func.xray.service.XrayCallAgent; import io.wdd.func.xray.service.XrayCoreService; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import javax.annotation.Resource; import java.util.HashMap; @@ -17,7 +20,7 @@ import java.util.List; import static io.wdd.func.xray.persisit.cache.ProxyNodeCache.PROXY_NODE_TOPIC_NAME_MAP; -@RestController +//@RestController @RequestMapping("/server/func/xray") @Api(tags = "Xray控制") public class XrayController { diff --git a/server/src/main/java/io/wdd/func/xray/persisit/XrayDBOperator.java b/server/src/main/java/io/wdd/func/xray/persisit/XrayDBOperator.java index 547869b..e2ec4b2 100644 --- a/server/src/main/java/io/wdd/func/xray/persisit/XrayDBOperator.java +++ b/server/src/main/java/io/wdd/func/xray/persisit/XrayDBOperator.java @@ -65,12 +65,14 @@ public class XrayDBOperator { .getLocation() .split(" ")[0]; + serverCity = "Chengdu"; + // fix bug for Seoul的情况 tmd - if (!ALL_SERVER_CITY_INDEX.containsKey(serverCity)) { - serverCity = serverInfoVO - .getLocation() - .split(" ")[1]; - } +// if (!ALL_SERVER_CITY_INDEX.containsKey(serverCity) && serverInfoVO) { +// serverCity = serverInfoVO +// .getLocation() +// .split(" ")[1]; +// } int cityBitMapBase = ALL_SERVER_CITY_INDEX.get(serverCity) * 10; int serverGraphNum = cityBitMapBase; @@ -84,7 +86,7 @@ public class XrayDBOperator { return ProxyNode .builder() - .agentTopicName(serverInfoVO.getTopicName()) + .agentTopicName(serverInfoVO.getAgentTopicName()) .num(serverGraphNum) .publicIPv4(serverInfoVO.getServerIpPbV4()) .publicIPv6(serverInfoVO.getServerIpPbV6()) diff --git a/server/src/main/java/io/wdd/rpc/init/AcceptAgentInitInfo.java b/server/src/main/java/io/wdd/rpc/init/AcceptAgentInitInfo.java index c36f485..7a6e25f 100644 --- a/server/src/main/java/io/wdd/rpc/init/AcceptAgentInitInfo.java +++ b/server/src/main/java/io/wdd/rpc/init/AcceptAgentInitInfo.java @@ -3,7 +3,6 @@ package io.wdd.rpc.init; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.rabbitmq.client.Channel; import io.wdd.common.handler.MyRuntimeException; import io.wdd.common.utils.TimeUtils; import io.wdd.rpc.message.OctopusMessage; @@ -12,20 +11,17 @@ import io.wdd.rpc.message.sender.OMessageToAgentSender; import io.wdd.rpc.status.deprecate.AgentStatus; import io.wdd.server.beans.vo.ServerInfoVO; import io.wdd.server.utils.DaemonDatabaseOperator; -import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.annotation.Queue; import org.springframework.amqp.rabbit.annotation.*; -import org.springframework.amqp.support.AmqpHeaders; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.messaging.handler.annotation.Header; +import org.springframework.messaging.handler.annotation.Payload; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.io.IOException; import java.util.*; -import java.util.concurrent.TimeUnit; import static io.wdd.common.config.OctopusObjectMapperConfig.OctopusObjectMapper; @@ -103,7 +99,6 @@ public class AcceptAgentInitInfo { * * @param message the message */ - @SneakyThrows @RabbitHandler @RabbitListener( bindings = @@ -113,14 +108,14 @@ public class AcceptAgentInitInfo { key = {"${octopus.message.init_to_server_key}"} ) , - ackMode = "MANUAL" + ackMode = "AUTO" ) - public void handleOctopusAgentBootUpInfo(Message message, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) { + public void handleOctopusAgentBootUpInfo(@Payload Message message) { // manual ack the rabbit message // https://stackoverflow.com/questions/38728668/spring-rabbitmq-using-manual-channel-acknowledgement-on-a-service-with-rabbit - ServerInfoVO serverInfoVO; + ServerInfoVO serverInfoVO = null; try { @@ -141,19 +136,17 @@ public class AcceptAgentInitInfo { // 2. generate the unique topic for agent String agentQueueTopic = generateAgentQueueTopic(serverInfoVO); - serverInfoVO.setTopicName(agentQueueTopic); - - // cache enabled for agent re-register -// if (!checkAgentAlreadyRegister(agentQueueTopic)) { -// log.info("[AGENT INIT] - agent not exist ! start to register !"); -// } + if (StringUtils.isBlank(agentQueueTopic)) { + throw new RuntimeException("agent topic name generate error!"); + } + serverInfoVO.setAgentTopicName(agentQueueTopic); // whether agent is registered already // save or update the octopus agent server info // 3. save the agent info into database // backend fixed thread daemon to operate the database ensuring the operation is correct ! if (!databaseOperator.saveInitOctopusAgentInfo(serverInfoVO)) { - throw new MyRuntimeException("database save agent info error !"); + throw new RuntimeException("database save agent info error !"); } // 4. generate the Octopus Agent Status Redis Stream Key & Consumer-Group @@ -162,55 +155,14 @@ public class AcceptAgentInitInfo { // 5. send InitMessage to agent sendInitMessageToAgent(serverInfoVO); - - } catch (IOException e) { - - /** - * 有异常就绝收消息 - * basicNack(long deliveryTag, boolean multiple, boolean requeue) - * requeue:true为将消息重返当前消息队列,还可以重新发送给消费者; - * false:将消息丢弃 - */ - - // long deliveryTag, boolean multiple, boolean requeue - - channel.basicNack( - deliveryTag, - false, - true - ); - // long deliveryTag, boolean requeue - // channel.basicReject(deliveryTag,true); - - // 这里只是便于出现死循环时查看 - TimeUnit.SECONDS.sleep(5); - - /* - * 一般实际异常情况下的处理过程:记录出现异常的业务数据,将它单独插入到一个单独的模块, - * 然后尝试3次,如果还是处理失败的话,就进行人工介入处理 - */ - - - throw new MyRuntimeException("Octopus Server Initialization Error, please check !"); + } catch (Exception e) { + log.error("handle init_to_server queue error => {}", e.getMessage()); + return; } - /** - * 无异常就确认消息 - * 无异常就确认消息 - * basicAck(long deliveryTag, boolean multiple) - * deliveryTag:取出来当前消息在队列中的的索引; - * multiple:为true的话就是批量确认,如果当前deliveryTag为5,那么就会确认 - * deliveryTag为5及其以下的消息;一般设置为false - */ - // ack the rabbitmq info - // If all logic is successful log.info( "Agent [ {} ] has init successfully !", - serverInfoVO.getTopicName() - ); - channel.basicAck( - deliveryTag, - false + serverInfoVO.getAgentTopicName() ); } @@ -259,7 +211,7 @@ public class AcceptAgentInitInfo { // should be the OctopusExchange Name .content(serverInfoContent) .init_time(TimeUtils.currentFormatTime()) - .uuid(serverInfoVO.getTopicName()) + .uuid(serverInfoVO.getAgentTopicName()) .build(); oMessageToAgentSender.sendINIT(octopusMessage); @@ -303,7 +255,7 @@ public class AcceptAgentInitInfo { "city are not validated from agent are {}", serverInfoVO ); - throw new MyRuntimeException("server name not validated !"); + return ""; } String machineIdPrefixSixBytes = String.valueOf( @@ -311,7 +263,7 @@ public class AcceptAgentInitInfo { .getMachineId() .toCharArray(), 0, - 6 + 8 ); return serverName + "-" + machineIdPrefixSixBytes; diff --git a/server/src/main/java/io/wdd/rpc/status/AllAgentStatusCache.java b/server/src/main/java/io/wdd/rpc/status/AllAgentStatusCache.java index 087c3e7..90ff65a 100644 --- a/server/src/main/java/io/wdd/rpc/status/AllAgentStatusCache.java +++ b/server/src/main/java/io/wdd/rpc/status/AllAgentStatusCache.java @@ -179,7 +179,7 @@ public class AllAgentStatusCache { List collect = allAgentInfo .stream() - .map(ServerInfoPO::getTopicName) + .map(ServerInfoPO::getAgentTopicName) .collect(Collectors.toList()); ALL_AGENT_TOPIC_NAME_LIST.addAll(collect); diff --git a/server/src/main/java/io/wdd/server/beans/po/ServerInfoPO.java b/server/src/main/java/io/wdd/server/beans/po/ServerInfoPO.java index 45cb18d..af07dab 100644 --- a/server/src/main/java/io/wdd/server/beans/po/ServerInfoPO.java +++ b/server/src/main/java/io/wdd/server/beans/po/ServerInfoPO.java @@ -31,8 +31,8 @@ public class ServerInfoPO implements Serializable { /** * octopus message unique key name */ - @TableField(value = "topic_name") - private String topicName; + @TableField(value = "agent_topic_name") + private String agentTopicName; /** * server host name @@ -93,11 +93,35 @@ public class ServerInfoPO implements Serializable { private LocalDateTime createTime; /** - * server location , type City Country + * 服务器所在的城市信息 + */ + @TableField(value = "city") + private String city; + + /** + * 省份 + */ + @TableField(value = "province") + private String province; + + /** + * 国家 + */ + @TableField(value = "country") + private String country; + + /** + * 经纬度 */ @TableField(value = "location") private String location; + /** + * 时区 + */ + @TableField(value = "timezone") + private String timezone; + /** * server isp manager */ @@ -116,12 +140,24 @@ public class ServerInfoPO implements Serializable { @TableField(value = "cpu_core") private String cpuCore; + /** + * cpu架构 amd64 + */ + @TableField(value = "cpu_arch") + private String cpuArch; + /** * */ @TableField(value = "memory_total") private String memoryTotal; + /** + * + */ + @TableField(value = "swap_total") + private String swapTotal; + /** * */ @@ -152,6 +188,36 @@ public class ServerInfoPO implements Serializable { @TableField(value = "virtualization") private String virtualization; + /** + * 操作系统平台 + */ + @TableField(value = "platform") + private String platform; + + /** + * 操作系统具体类别 + */ + @TableField(value = "platform_family") + private String platformFamily; + + /** + * 操作系统的版本 + */ + @TableField(value = "platform_version") + private String platformVersion; + + /** + * 内核版本 + */ + @TableField(value = "kernel_version") + private String kernelVersion; + + /** + * 内核的架构 x86_64 + */ + @TableField(value = "kernel_arch") + private String kernelArch; + /** * */ @@ -189,10 +255,10 @@ public class ServerInfoPO implements Serializable { private Integer isDelete; /** - * optimistic lock for concurrent + * Agent的版本信息 */ - @TableField(value = "version") - private Integer version; + @TableField(value = "agent_version") + private String agentVersion; /** * 服务器的角色信息 diff --git a/server/src/main/java/io/wdd/server/beans/vo/ServerInfoVO.java b/server/src/main/java/io/wdd/server/beans/vo/ServerInfoVO.java index b81e7ff..a9c57d8 100644 --- a/server/src/main/java/io/wdd/server/beans/vo/ServerInfoVO.java +++ b/server/src/main/java/io/wdd/server/beans/vo/ServerInfoVO.java @@ -1,8 +1,6 @@ package io.wdd.server.beans.vo; -import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -22,134 +20,246 @@ public class ServerInfoVO { */ private Integer id; + @TableField(value = "tenant_name") + private String tenantName; + + /** + * octopus message unique key name + */ + @TableField(value = "agent_topic_name") + private String agentTopicName; + /** * server host name */ + @TableField(value = "server_name") private String serverName; /** * server public ipv4 + */ + @TableField(value = "server_ip_pb_v4") private String serverIpPbV4; /** * server inner ipv4 */ + @TableField(value = "server_ip_in_v4") private String serverIpInV4; /** * server public ipv6 */ + @TableField(value = "server_ip_pb_v6") private String serverIpPbV6; /** * server inner ipv6 */ + @TableField(value = "server_ip_in_v6") private String serverIpInV6; + /** + * server register time + */ + @TableField(value = "register_time") + private LocalDateTime registerTime; + + /** + * expire time + */ + @TableField(value = "expire_time") + private LocalDateTime expireTime; + /** * */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime registerTime; - - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime expireTime; - - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @TableField(fill = FieldFill.INSERT) - private LocalDateTime createTime; - - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @TableField(fill = FieldFill.INSERT_UPDATE) + @TableField(value = "update_time") private LocalDateTime updateTime; - private Integer proxyType; + /** + * + */ + @TableField(value = "create_time") + private LocalDateTime createTime; /** - * server location , type City Country + * 服务器所在的城市信息 */ + @TableField(value = "city") + private String city; + + /** + * 省份 + */ + @TableField(value = "province") + private String province; + + /** + * 国家 + */ + @TableField(value = "country") + private String country; + + /** + * 经纬度 + */ + @TableField(value = "location") private String location; + /** + * 时区 + */ + @TableField(value = "timezone") + private String timezone; + /** * server isp manager */ + @TableField(value = "provider") private String provider; - /** - * split by , - */ - private String managePort; - /** * */ + @TableField(value = "cpu_brand") private String cpuBrand; /** * */ + @TableField(value = "cpu_core") private String cpuCore; + /** + * cpu架构 amd64 + */ + @TableField(value = "cpu_arch") + private String cpuArch; + /** * */ + @TableField(value = "memory_total") private String memoryTotal; /** * */ + @TableField(value = "swap_total") + private String swapTotal; + + /** + * + */ + @TableField(value = "disk_total") private String diskTotal; /** * */ + @TableField(value = "disk_usage") private String diskUsage; /** * */ + @TableField(value = "io_speed") private String ioSpeed; /** * */ + @TableField(value = "tcp_control") private String tcpControl; /** * server virtualization method */ + @TableField(value = "virtualization") private String virtualization; + /** + * 操作系统平台 + */ + @TableField(value = "platform") + private String platform; + + /** + * 操作系统具体类别 + */ + @TableField(value = "platform_family") + private String platformFamily; + + /** + * 操作系统的版本 + */ + @TableField(value = "platform_version") + private String platformVersion; + + /** + * 内核版本 + */ + @TableField(value = "kernel_version") + private String kernelVersion; + + /** + * 内核的架构 x86_64 + */ + @TableField(value = "kernel_arch") + private String kernelArch; + /** * */ + @TableField(value = "os_info") private String osInfo; /** * */ + @TableField(value = "os_kernel_info") private String osKernelInfo; + /** + * 服务器能否访问公网 + */ + @TableField(value = "can_access_public") + private Integer canAccessPublic; + /** * machine uuid from /etc/machineid */ + @TableField(value = "machine_id") private String machineId; - /** - * octopus message unique key name - */ - private String topicName; /** * */ + @TableField(value = "comment") private String comment; + /** + * 0 alive || 1 deleted + */ + @TableField(value = "is_delete") + private Integer isDelete; + /** + * Agent的版本信息 + */ + @TableField(value = "agent_version") private String agentVersion; + /** + * 服务器的角色信息 + */ + @TableField(value = "role") + private String role; + } diff --git a/server/src/main/java/io/wdd/server/mapper/ServerInfoMapper.java b/server/src/main/java/io/wdd/server/mapper/ServerInfoMapper.java index 6fe891e..d31e262 100644 --- a/server/src/main/java/io/wdd/server/mapper/ServerInfoMapper.java +++ b/server/src/main/java/io/wdd/server/mapper/ServerInfoMapper.java @@ -6,7 +6,7 @@ import io.wdd.server.beans.po.ServerInfoPO; /** * @author wddsh * @description 针对表【server_info】的数据库操作Mapper - * @createDate 2024-03-26 18:11:29 + * @createDate 2024-04-29 16:46:02 * @Entity io.wdd.server.beans.po.ServerInfoPO */ public interface ServerInfoMapper extends BaseMapper { diff --git a/server/src/main/java/io/wdd/server/service/ServerInfoService.java b/server/src/main/java/io/wdd/server/service/ServerInfoService.java index f51d195..c5330f3 100644 --- a/server/src/main/java/io/wdd/server/service/ServerInfoService.java +++ b/server/src/main/java/io/wdd/server/service/ServerInfoService.java @@ -6,7 +6,7 @@ import io.wdd.server.beans.po.ServerInfoPO; /** * @author wddsh * @description 针对表【server_info】的数据库操作Service - * @createDate 2024-03-26 18:11:29 + * @createDate 2024-04-29 16:46:02 */ public interface ServerInfoService extends IService { diff --git a/server/src/main/java/io/wdd/server/service/impl/ServerInfoServiceImpl.java b/server/src/main/java/io/wdd/server/service/impl/ServerInfoServiceImpl.java index 45cacef..1b90fa3 100644 --- a/server/src/main/java/io/wdd/server/service/impl/ServerInfoServiceImpl.java +++ b/server/src/main/java/io/wdd/server/service/impl/ServerInfoServiceImpl.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Service; /** * @author wddsh * @description 针对表【server_info】的数据库操作Service实现 - * @createDate 2024-03-26 18:11:29 + * @createDate 2024-04-29 16:46:02 */ @Service public class ServerInfoServiceImpl extends ServiceImpl diff --git a/server/src/main/resources/application.yml b/server/src/main/resources/application.yml index a4b7a35..56b30b6 100644 --- a/server/src/main/resources/application.yml +++ b/server/src/main/resources/application.yml @@ -9,7 +9,7 @@ spring: allow-circular-references: true allow-bean-definition-overriding: true rabbitmq: - host: 42.192.52.227 + host: 10.250.0.100 port: 20672 username: boge password: boge8tingH @@ -22,9 +22,9 @@ spring: enabled: true # retry interval unit ms max-interval: 65000 - initial-interval: 65000 + initial-interval: 2000 redis: - host: 42.192.52.227 + host: 10.250.0.100 port: 21370 database: 0 password: boge8tingH @@ -46,7 +46,7 @@ spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://42.192.52.227:21306/octopus_server?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 + url: jdbc:mysql://10.250.0.100:21306/octopus_server?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 username: boge password: boge8tingH type: com.zaxxer.hikari.HikariDataSource diff --git a/server/src/main/resources/mapper/ServerInfoMapper.xml b/server/src/main/resources/mapper/ServerInfoMapper.xml index 4589227..2d15b79 100644 --- a/server/src/main/resources/mapper/ServerInfoMapper.xml +++ b/server/src/main/resources/mapper/ServerInfoMapper.xml @@ -7,7 +7,7 @@ - + @@ -17,37 +17,52 @@ + + + + + + + + + + + - + server_id - ,tenant_name,topic_name, + ,tenant_name,agent_topic_name, server_name,server_ip_pb_v4,server_ip_in_v4, server_ip_pb_v6,server_ip_in_v6,register_time, expire_time,update_time,create_time, - location,provider,cpu_brand, - cpu_core,memory_total,disk_total, + city,province,country, + location,timezone,provider, + cpu_brand,cpu_core,cpu_arch, + memory_total,swap_total,disk_total, disk_usage,io_speed,tcp_control, - virtualization,os_info,os_kernel_info, - can_access_public,machine_id,comment, - is_delete,version,role + virtualization,platform,platform_family, + platform_version,kernel_version,kernel_arch, + os_info,os_kernel_info,can_access_public, + machine_id,comment,is_delete, + agent_version,role diff --git a/server/src/test/java/io/wdd/server/func/TestImageSyncScheduler.java b/server/src/test/java/io/wdd/server/func/TestImageSyncScheduler.java index 29de8ae..d7ab197 100644 --- a/server/src/test/java/io/wdd/server/func/TestImageSyncScheduler.java +++ b/server/src/test/java/io/wdd/server/func/TestImageSyncScheduler.java @@ -44,7 +44,7 @@ public class TestImageSyncScheduler { ArrayList ImageFullNameList = new ArrayList<>(List.of( // "harbor.cdcyy.com.cn/cmii/cmii-live-operator:5.2.0", // "harbor.cdcyy.com.cn/cmii/cmii/srs:v5.0.195" - "harbor.cdcyy.com.cn/cmii/cmii-uav-platform:5.3.0-cqly-042901" + "harbor.cdcyy.com.cn/cmii/cmii-uav-platform:5.3.0-cqly-042902" )); Boolean downloadAndCompressOnly = false;