parent
ac3aa82ef4
commit
e6100a1318
103
pom.xml
103
pom.xml
|
@ -38,6 +38,7 @@
|
||||||
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
||||||
<mqttv3.version>1.2.5</mqttv3.version>
|
<mqttv3.version>1.2.5</mqttv3.version>
|
||||||
<spring-kafka.version>2.8.0</spring-kafka.version>
|
<spring-kafka.version>2.8.0</spring-kafka.version>
|
||||||
|
<aliyun.ecs.version>3.1.12</aliyun.ecs.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖声明 -->
|
<!-- 依赖声明 -->
|
||||||
|
@ -263,7 +264,17 @@
|
||||||
<artifactId>zhilian-common-business</artifactId>
|
<artifactId>zhilian-common-business</artifactId>
|
||||||
<version>${zhilian.version}</version>
|
<version>${zhilian.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 阿里云ESC服务版本控制-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>ecs20140526</artifactId>
|
||||||
|
<version>${aliyun.ecs.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
@ -317,57 +328,57 @@
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- 要将源码放上去,需要加入这个插件 -->
|
<!-- 要将源码放上去,需要加入这个插件 -->
|
||||||
<plugin>
|
<!-- <plugin>-->
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<!-- <groupId>org.apache.maven.plugins</groupId>-->
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<!-- <artifactId>maven-source-plugin</artifactId>-->
|
||||||
<version>3.0.1</version>
|
<!-- <version>3.0.1</version>-->
|
||||||
<configuration>
|
<!-- <configuration>-->
|
||||||
<attach>true</attach>
|
<!-- <attach>true</attach>-->
|
||||||
</configuration>
|
<!-- </configuration>-->
|
||||||
<executions>
|
<!-- <executions>-->
|
||||||
<execution>
|
<!-- <execution>-->
|
||||||
<phase>compile</phase>
|
<!-- <phase>compile</phase>-->
|
||||||
<goals>
|
<!-- <goals>-->
|
||||||
<goal>jar</goal>
|
<!-- <goal>jar</goal>-->
|
||||||
</goals>
|
<!-- </goals>-->
|
||||||
</execution>
|
<!-- </execution>-->
|
||||||
</executions>
|
<!-- </executions>-->
|
||||||
</plugin>
|
<!-- </plugin>-->
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<distributionManagement>
|
<!-- <distributionManagement>-->
|
||||||
<repository>
|
<!-- <repository>-->
|
||||||
<id>releases</id>
|
<!-- <id>releases</id>-->
|
||||||
<name>releases</name>
|
<!-- <name>releases</name>-->
|
||||||
<url>http://nexus.zhilian.com:8081/repository/maven-releases/</url>
|
<!-- <url>http://nexus.zhilian.com:8081/repository/maven-releases/</url>-->
|
||||||
</repository>
|
<!-- </repository>-->
|
||||||
</distributionManagement>
|
<!-- </distributionManagement>-->
|
||||||
|
|
||||||
<repositories>
|
<!-- <repositories>-->
|
||||||
<repository>
|
<!-- <repository>-->
|
||||||
<id>public</id>
|
<!-- <id>public</id>-->
|
||||||
<name>aliyun nexus</name>
|
<!-- <name>aliyun nexus</name>-->
|
||||||
<url>http://nexus.zhilian.com:8081/repository/maven-public/</url>
|
<!-- <url>http://nexus.zhilian.com:8081/repository/maven-public/</url>-->
|
||||||
<releases>
|
<!-- <releases>-->
|
||||||
<enabled>true</enabled>
|
<!-- <enabled>true</enabled>-->
|
||||||
</releases>
|
<!-- </releases>-->
|
||||||
</repository>
|
<!-- </repository>-->
|
||||||
</repositories>
|
<!-- </repositories>-->
|
||||||
|
|
||||||
<pluginRepositories>
|
<!-- <pluginRepositories>-->
|
||||||
<pluginRepository>
|
<!-- <pluginRepository>-->
|
||||||
<id>public</id>
|
<!-- <id>public</id>-->
|
||||||
<name>aliyun nexus</name>
|
<!-- <name>aliyun nexus</name>-->
|
||||||
<url>http://nexus.zhilian.com:8081/repository/maven-public/</url>
|
<!-- <url>http://nexus.zhilian.com:8081/repository/maven-public/</url>-->
|
||||||
<releases>
|
<!-- <releases>-->
|
||||||
<enabled>true</enabled>
|
<!-- <enabled>true</enabled>-->
|
||||||
</releases>
|
<!-- </releases>-->
|
||||||
<snapshots>
|
<!-- <snapshots>-->
|
||||||
<enabled>false</enabled>
|
<!-- <enabled>false</enabled>-->
|
||||||
</snapshots>
|
<!-- </snapshots>-->
|
||||||
</pluginRepository>
|
<!-- </pluginRepository>-->
|
||||||
</pluginRepositories>
|
<!-- </pluginRepositories>-->
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -98,12 +98,18 @@
|
||||||
<artifactId>spring-kafka</artifactId>
|
<artifactId>spring-kafka</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 业务系统远程调用-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.zhilian</groupId>
|
<groupId>com.zhilian</groupId>
|
||||||
<artifactId>zhilian-common-business</artifactId>
|
<artifactId>zhilian-common-business</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 阿里云Ecs服务依赖(openAPI)-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>ecs20140526</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -4,6 +4,8 @@ import com.zhilian.common.security.annotation.EnableCustomConfig;
|
||||||
import com.zhilian.common.security.annotation.EnableMyFeignClients;
|
import com.zhilian.common.security.annotation.EnableMyFeignClients;
|
||||||
import com.zhilian.common.swagger.annotation.EnableCustomSwagger2;
|
import com.zhilian.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import com.zhilian.online.controller.OnlineLoadCenterController;
|
import com.zhilian.online.controller.OnlineLoadCenterController;
|
||||||
|
import com.zhilian.online.uitls.AliyunOpenAPIUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
@ -20,9 +22,17 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class ZhiLianOnlineApplication{
|
@Slf4j
|
||||||
|
public class ZhiLianOnlineApplication implements ApplicationRunner{
|
||||||
|
@Autowired
|
||||||
|
private AliyunOpenAPIUtils aliyunOpenAPIUtils;
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ZhiLianOnlineApplication.class,args);
|
SpringApplication.run(ZhiLianOnlineApplication.class,args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
log.info("项目启动,调用创建实例方法");
|
||||||
|
// aliyunOpenAPIUtils.createInstance();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.zhilian.online.config;
|
||||||
|
|
||||||
|
import com.aliyun.ecs20140526.Client;
|
||||||
|
import com.aliyun.teaopenapi.models.Config;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import com.aliyun.ecs20140526.Client;
|
||||||
|
import com.aliyun.teaopenapi.models.Config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: smart-cloud-server
|
||||||
|
* @BelongsPackage: com.zhilian.online.config
|
||||||
|
* @Author: LiYuan
|
||||||
|
* @CreateTime: 2024-04-12 14:43
|
||||||
|
* @Description: 阿里云Ecs服务账号配置
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties("aliyun.ecs")
|
||||||
|
@Slf4j
|
||||||
|
public class AliyunEcsConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌账号
|
||||||
|
*/
|
||||||
|
private String accessKeyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌密码
|
||||||
|
*/
|
||||||
|
private String accessKeySecret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里云端点地址
|
||||||
|
*/
|
||||||
|
private String endpoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用AK&SK初始化账号Client
|
||||||
|
* @return Client
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Bean("AliyunClient")
|
||||||
|
public Client createClient() throws Exception {
|
||||||
|
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
||||||
|
// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
||||||
|
Config config = new Config()
|
||||||
|
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||||
|
.setAccessKeyId(accessKeyId)
|
||||||
|
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||||
|
.setAccessKeySecret(accessKeySecret);
|
||||||
|
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
||||||
|
config.endpoint = endpoint;
|
||||||
|
Client aliyunClient = new Client(config);
|
||||||
|
return aliyunClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,24 +2,16 @@ package com.zhilian.online.consumer;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.zhilian.common.core.constant.Constants;
|
import com.zhilian.common.core.constant.Constants;
|
||||||
import com.zhilian.common.core.domain.Result;
|
|
||||||
import com.zhilian.common.redis.service.RedisService;
|
import com.zhilian.common.redis.service.RedisService;
|
||||||
import com.zhilian.online.config.RabbitConfig;
|
import com.zhilian.online.config.RabbitConfig;
|
||||||
import com.zhilian.online.constans.OnlineConstants;
|
import com.zhilian.online.constans.OnlineConstants;
|
||||||
import com.zhilian.online.domain.Gather;
|
|
||||||
import com.zhilian.online.domain.req.GatherRegReq;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @BelongsProject: smart-cloud-server
|
* @BelongsProject: smart-cloud-server
|
||||||
|
@ -44,11 +36,10 @@ public class DeadQueueConsumer {
|
||||||
* 消费死信队列中的消息,确保车辆上线成功
|
* 消费死信队列中的消息,确保车辆上线成功
|
||||||
* 向节点地址的fluxMQ发送http请求,通过响应码来确定节点是否成功上线
|
* 向节点地址的fluxMQ发送http请求,通过响应码来确定节点是否成功上线
|
||||||
*/
|
*/
|
||||||
@RabbitListener(queues = RabbitConfig.DEAD_QUEUE_NAME)
|
// @RabbitListener(queues = RabbitConfig.DEAD_QUEUE_NAME)
|
||||||
public void SecureOnline(String gatherMsg) {
|
public void SecureOnline(String gatherMsg) {
|
||||||
Gather gather = JSON.parseObject(gatherMsg, Gather.class);
|
|
||||||
log.info("开始检查节点{}的上线状态......", gatherMsg);
|
log.info("开始检查节点{}的上线状态......", gatherMsg);
|
||||||
String ipAddress = gather.getIpAddress();
|
String ipAddress = "";
|
||||||
HttpURLConnection connection = null;
|
HttpURLConnection connection = null;
|
||||||
try {
|
try {
|
||||||
ipAddress = "http://" + ipAddress;
|
ipAddress = "http://" + ipAddress;
|
||||||
|
@ -63,8 +54,8 @@ public class DeadQueueConsumer {
|
||||||
if (Constants.FAIL == responseCode){
|
if (Constants.FAIL == responseCode){
|
||||||
log.error("节点{}上线失败",gatherMsg);
|
log.error("节点{}上线失败",gatherMsg);
|
||||||
//上线失败需要将该节点的负载均衡缓存删除
|
//上线失败需要将该节点的负载均衡缓存删除
|
||||||
if (redisService.hasKey(OnlineConstants.ONLINE_TOKEN_PREFIX + gather.getClientId())){
|
if (redisService.hasKey(OnlineConstants.ONLINE_TOKEN_PREFIX + "")){
|
||||||
redisService.removeCacheZsetBatch(OnlineConstants.ONLINE_TOKEN_PREFIX + gather.getClientId());
|
redisService.removeCacheZsetBatch(OnlineConstants.ONLINE_TOKEN_PREFIX + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.zhilian.common.core.domain.Result;
|
||||||
import com.zhilian.common.core.utils.ip.IpUtils;
|
import com.zhilian.common.core.utils.ip.IpUtils;
|
||||||
import com.zhilian.common.core.web.controller.BaseController;
|
import com.zhilian.common.core.web.controller.BaseController;
|
||||||
|
|
||||||
import com.zhilian.online.domain.Gather;
|
import com.zhilian.online.domain.ApifoxModel;
|
||||||
import com.zhilian.online.service.OnlineLoadCenterService;
|
import com.zhilian.online.service.OnlineLoadCenterService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -40,14 +40,14 @@ public class OnlineLoadCenterController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 节点申请注解令牌接口, 仅限内网访问
|
* @description: 节点申请注解令牌接口, 仅限内网访问
|
||||||
* @author: LiYuan
|
* @author: LiY
|
||||||
* @param: vehicle
|
* @param: vehicle
|
||||||
* @return: Result<OnlineAccount>
|
* @return: Result<OnlineAccount>
|
||||||
**/
|
**/
|
||||||
@GetMapping("/applyForReg")
|
@GetMapping("/applyForReg")
|
||||||
public Result<String> applyForReg(Gather gather) {
|
public Result<String> applyForReg() {
|
||||||
log.info("申请注册令牌{}", JSON.toJSONString(gather));
|
log.info("申请注册令牌");
|
||||||
return onlineLoadCenterService.applyForReg(gather);
|
return onlineLoadCenterService.applyForReg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,11 +58,9 @@ public class OnlineLoadCenterController extends BaseController {
|
||||||
* @return: Result
|
* @return: Result
|
||||||
**/
|
**/
|
||||||
@PostMapping("/regGather")
|
@PostMapping("/regGather")
|
||||||
public Result regGather(@Validated @RequestBody Gather gather) {
|
public Result regGather(@Validated @RequestBody ApifoxModel apifoxModel) {
|
||||||
String ipAddr = IpUtils.getIpAddr(request);
|
log.info("节点{}正在上线", JSON.toJSONString(apifoxModel));
|
||||||
gather.setIpAddress(ipAddr);
|
return onlineLoadCenterService.regGather(apifoxModel);
|
||||||
log.info("节点{}正在上线", JSON.toJSONString(gather));
|
|
||||||
return onlineLoadCenterService.regGather(gather);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,7 +74,8 @@ public class OnlineLoadCenterController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/applyForConnectToGather")
|
@GetMapping("/applyForConnectToGather")
|
||||||
public Result applyForConnectToGather(@RequestParam("vin") String vin) {
|
public Result applyForConnectToGather(@RequestParam("vin") String vin) {
|
||||||
return Result.success(onlineLoadCenterService.applyForConnectToGather(vin));
|
onlineLoadCenterService.applyForConnectToGather(vin);
|
||||||
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.zhilian.online.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApifoxModel {
|
||||||
|
/**
|
||||||
|
* 节点ID
|
||||||
|
*/
|
||||||
|
private String clusterId;
|
||||||
|
/**
|
||||||
|
* CPU使用信息
|
||||||
|
*/
|
||||||
|
private CPUInfo cpuInfo;
|
||||||
|
/**
|
||||||
|
* 节点状态
|
||||||
|
*/
|
||||||
|
private FlowInfo flowInfo;
|
||||||
|
/**
|
||||||
|
* HTTP请求地址
|
||||||
|
*/
|
||||||
|
private String httpUrl;
|
||||||
|
/**
|
||||||
|
* JVM使用信息
|
||||||
|
*/
|
||||||
|
private JVMInfo jvmInfo;
|
||||||
|
/**
|
||||||
|
* MQTT事件信息
|
||||||
|
*/
|
||||||
|
private MqttInfo mqttInfo;
|
||||||
|
/**
|
||||||
|
* MQTTS请求地址
|
||||||
|
*/
|
||||||
|
private String mqttsUrl;
|
||||||
|
/**
|
||||||
|
* MQTT请求地址
|
||||||
|
*/
|
||||||
|
private String mqttUrl;
|
||||||
|
/**
|
||||||
|
* 节点名称
|
||||||
|
*/
|
||||||
|
private String nodeName;
|
||||||
|
/**
|
||||||
|
* 启动时间
|
||||||
|
*/
|
||||||
|
private String startJvmTime;
|
||||||
|
/**
|
||||||
|
* 节点版本
|
||||||
|
*/
|
||||||
|
private String version;
|
||||||
|
/**
|
||||||
|
* websocket请求地址
|
||||||
|
*/
|
||||||
|
private String websocketUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请令牌
|
||||||
|
*/
|
||||||
|
private String token;
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.zhilian.online.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CPU使用信息
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CPUInfo {
|
||||||
|
/**
|
||||||
|
* CPU核数
|
||||||
|
*/
|
||||||
|
private long cpuNum;
|
||||||
|
/**
|
||||||
|
* 内核态使用率
|
||||||
|
*/
|
||||||
|
private String cSys;
|
||||||
|
/**
|
||||||
|
* 空闲率
|
||||||
|
*/
|
||||||
|
private String idle;
|
||||||
|
/**
|
||||||
|
* I/O等待
|
||||||
|
*/
|
||||||
|
private String iowait;
|
||||||
|
/**
|
||||||
|
* 用户态使用率
|
||||||
|
*/
|
||||||
|
private String user;
|
||||||
|
}
|
|
@ -0,0 +1,261 @@
|
||||||
|
package com.zhilian.online.domain;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: smart-cloud-server
|
||||||
|
* @BelongsPackage: com.zhilian.online.domain
|
||||||
|
* @Author: LiYuan
|
||||||
|
* @CreateTime: 2024-04-12 15:01
|
||||||
|
* @Description: 阿里云ECS服务器实体类
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@ToString
|
||||||
|
public class EcsInstance {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例创建时间。以 ISO 8601 为标准,并使用 UTC+0 时间,格式为 yyyy-MM-ddTHH:mmZ
|
||||||
|
*/
|
||||||
|
private String creationTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例序列号
|
||||||
|
*/
|
||||||
|
private String serialNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部署集ID
|
||||||
|
*/
|
||||||
|
private String deploymentSetId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密钥对名称。
|
||||||
|
*/
|
||||||
|
private String keyPairName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按量实例的竞价策略。可能值:
|
||||||
|
* NoSpot:正常按量付费实例。
|
||||||
|
* SpotWithPriceLimit:设置上限价格的抢占式实例。
|
||||||
|
* SpotAsPriceGo:系统自动出价
|
||||||
|
*/
|
||||||
|
private String spotStrategy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例是否支持挂载磁盘。
|
||||||
|
*/
|
||||||
|
private Boolean deviceAvailable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例挂载的本地存储容量。单位:GiB
|
||||||
|
*/
|
||||||
|
private Long localStorageCapacity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抢占式实例的保留时长,单位为小时。可能值:
|
||||||
|
* 1:创建后阿里云会保证实例运行 1 小时不会被自动释放;超过 1 小时后,系统会自动比较出价与市场价格、检查资源库存,来决定实例的持有和回收。
|
||||||
|
* 0:创建后,阿里云不保证实例运行 1 小时,系统会自动比较出价与市场价格、检查资源库存,来决定实例的持有和回收。
|
||||||
|
*/
|
||||||
|
private Integer spotDuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例网络类型。可能值:
|
||||||
|
* classic:经典网络。
|
||||||
|
* vpc:专有网络 VPC。
|
||||||
|
*/
|
||||||
|
private String instanceNetworkType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例名称
|
||||||
|
*/
|
||||||
|
private String instanceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例ID
|
||||||
|
*/
|
||||||
|
private String instanceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例操作系统的英文名称
|
||||||
|
*/
|
||||||
|
private String osNameEn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*实例所属的 HPC 集群 ID。
|
||||||
|
*/
|
||||||
|
private String hpcClusterId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例的每小时最高价格。支持最大 3 位小数,参数 SpotStrategy=SpotWithPriceLimit 时,该参数生效。
|
||||||
|
*/
|
||||||
|
private Number spotPriceLimit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内存大小,单位为 MiB。
|
||||||
|
*/
|
||||||
|
private Integer memory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例的操作系统名称
|
||||||
|
*/
|
||||||
|
private String osName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ECS 实例绑定部署集分散部署时,实例在部署集中的分组位置。
|
||||||
|
*/
|
||||||
|
private String deploymentSetGroupNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例运行的镜像 ID。
|
||||||
|
*/
|
||||||
|
private String imageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例的 GPU 类型。
|
||||||
|
*/
|
||||||
|
private String gpuSpec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例释放保护属性,指定是否支持通过控制台或 API(DeleteInstance)释放实例。
|
||||||
|
* true:已开启实例释放保护。
|
||||||
|
* false:未开启实例释放保护。
|
||||||
|
*/
|
||||||
|
private Boolean deletionProtection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例停机后是否继续收费。可能值:
|
||||||
|
* KeepCharging:停机后继续收费,为您继续保留库存资源。
|
||||||
|
* StopCharging:停机后不收费。停机后,我们释放实例对应的资源,例如 vCPU、内存和公网 IP 等资源。重启是否成功依赖于当前地域中是否仍有资源库存。
|
||||||
|
* Not-applicable:本实例不支持停机不收费功能。
|
||||||
|
*/
|
||||||
|
private String stoppedMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例规格附带的 GPU 数量。
|
||||||
|
*/
|
||||||
|
private Integer gpuAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例主机名
|
||||||
|
*/
|
||||||
|
private String hostName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公网出带宽最大值,单位:Mbit/s
|
||||||
|
*/
|
||||||
|
private Integer internetMaxBandwidthOut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公网入带宽最大值,单位:Mbit/s
|
||||||
|
*/
|
||||||
|
private Integer internetMaxBandwidthIn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例规格
|
||||||
|
*/
|
||||||
|
private String instanceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例的计费方式。可能值:
|
||||||
|
* PrePaid:包年包月。
|
||||||
|
* PostPaid:按量付费。
|
||||||
|
*/
|
||||||
|
private String instanceChargeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例所属地域 ID。
|
||||||
|
*/
|
||||||
|
private String regionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为 I/O 优化型实例。
|
||||||
|
*/
|
||||||
|
private Boolean ioOptimized;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例最近一次的启动时间。以 ISO 8601 为标准,并使用 UTC+0 时间,格式为 yyyy-MM-ddTHH:mmZ
|
||||||
|
*/
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vCPU 数
|
||||||
|
*/
|
||||||
|
private Integer cpu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例挂载的本地存储数量。
|
||||||
|
*/
|
||||||
|
private Integer localStorageAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过期时间。以 ISO 8601 为标准,并使用 UTC+0 时间,格式为 yyyy-MM-ddTHH:mmZ
|
||||||
|
*/
|
||||||
|
private String expiredTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例所属可用区。
|
||||||
|
*/
|
||||||
|
private String zoneId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例是否可以回收。
|
||||||
|
*/
|
||||||
|
private Boolean recyclable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 突发性能实例的运行模式。可能值:
|
||||||
|
* Standard:标准模式。有关实例性能的更多信息,请参见什么是突发性能实例中的性能约束模式章节。
|
||||||
|
* Unlimited:无性能约束模式,有关实例性能的更多信息,请参见什么是突发性能实例中的无性能约束模式章节。
|
||||||
|
*/
|
||||||
|
private String creditSpecification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例规格族。
|
||||||
|
*/
|
||||||
|
private String instanceTypeFamily;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例的操作系统类型,分为 Windows Server 和 Linux 两种。可能值:
|
||||||
|
* windows。
|
||||||
|
* linux。
|
||||||
|
*/
|
||||||
|
private String osType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公网IP地址
|
||||||
|
*/
|
||||||
|
private List<String> publicIpAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内网IP地址
|
||||||
|
*/
|
||||||
|
private List<String> privateIpAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 专有网络ID
|
||||||
|
*/
|
||||||
|
private String vpcId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全组ID
|
||||||
|
*/
|
||||||
|
private List<String> securityGroupIds;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.zhilian.online.domain;
|
||||||
|
|
||||||
|
import lombok.Data; /**
|
||||||
|
* 节点状态
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FlowInfo {
|
||||||
|
/**
|
||||||
|
* 上次读取吞吐量
|
||||||
|
*/
|
||||||
|
private String lastReadThroughput;
|
||||||
|
/**
|
||||||
|
* 上次写入吞吐量
|
||||||
|
*/
|
||||||
|
private String lastWriteThroughput;
|
||||||
|
/**
|
||||||
|
* 读取总吞吐量
|
||||||
|
*/
|
||||||
|
private String readBytesHistory;
|
||||||
|
/**
|
||||||
|
* 实写字节
|
||||||
|
*/
|
||||||
|
private String realWriteBytes;
|
||||||
|
/**
|
||||||
|
* 写入总吞吐量
|
||||||
|
*/
|
||||||
|
private String writeBytesHistory;
|
||||||
|
}
|
|
@ -1,70 +0,0 @@
|
||||||
package com.zhilian.online.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.zhilian.common.core.web.domain.BaseEntity;
|
|
||||||
import lombok.*;
|
|
||||||
import org.bouncycastle.util.IPAddress;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @BelongsProject: smart-cloud-server
|
|
||||||
* @BelongsPackage: com.zhilian.online.domain
|
|
||||||
* @Author: LiYuan
|
|
||||||
* @CreateTime: 2024-03-31 08:58
|
|
||||||
* @Description: 收集节点实体类
|
|
||||||
* @Version: 1.0
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@ToString
|
|
||||||
public class Gather extends BaseEntity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 收集节点ID
|
|
||||||
*/
|
|
||||||
private String clientId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 收集节点登录令牌
|
|
||||||
*/
|
|
||||||
private String token;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* broker
|
|
||||||
*/
|
|
||||||
@NotBlank
|
|
||||||
private String broker;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* username
|
|
||||||
*/
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* password
|
|
||||||
*/
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* qos
|
|
||||||
*/
|
|
||||||
private Integer qos;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* topic
|
|
||||||
*/
|
|
||||||
@NotBlank
|
|
||||||
private String topic;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ip地址
|
|
||||||
*/
|
|
||||||
private String ipAddress;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.zhilian.online.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JVM使用信息
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class JVMInfo {
|
||||||
|
/**
|
||||||
|
* 文件描述(句柄)
|
||||||
|
*/
|
||||||
|
private String fileDescriptors;
|
||||||
|
/**
|
||||||
|
* 堆内存
|
||||||
|
*/
|
||||||
|
private String heapCommit;
|
||||||
|
/**
|
||||||
|
* 堆初始化空间
|
||||||
|
*/
|
||||||
|
private String heapInit;
|
||||||
|
/**
|
||||||
|
* 堆最大内存
|
||||||
|
*/
|
||||||
|
private String heapMax;
|
||||||
|
/**
|
||||||
|
* 堆使用空间
|
||||||
|
*/
|
||||||
|
private String heapUsed;
|
||||||
|
/**
|
||||||
|
* JAVA目录
|
||||||
|
*/
|
||||||
|
private String jdkHome;
|
||||||
|
/**
|
||||||
|
* JDK版本
|
||||||
|
*/
|
||||||
|
private String jdkVersion;
|
||||||
|
/**
|
||||||
|
* 非堆空间
|
||||||
|
*/
|
||||||
|
private String noHeapCommit;
|
||||||
|
/**
|
||||||
|
* 非堆初始化空间
|
||||||
|
*/
|
||||||
|
private String noHeapInit;
|
||||||
|
/**
|
||||||
|
* 非堆最大空间
|
||||||
|
*/
|
||||||
|
private String noHeapMax;
|
||||||
|
/**
|
||||||
|
* 非堆使用空间
|
||||||
|
*/
|
||||||
|
private String noHeapUsed;
|
||||||
|
/**
|
||||||
|
* 线程数量
|
||||||
|
*/
|
||||||
|
private long threadCount;
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.zhilian.online.domain;// ApifoxModel.java
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
// JVMInfo.java
|
||||||
|
|
||||||
|
|
||||||
|
// MqttInfo.java
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MQTT事件信息
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MqttInfo {
|
||||||
|
/**
|
||||||
|
* 关闭事件数量
|
||||||
|
*/
|
||||||
|
private long closeEventSize;
|
||||||
|
/**
|
||||||
|
* 连接事件数量
|
||||||
|
*/
|
||||||
|
private long connectEventSize;
|
||||||
|
/**
|
||||||
|
* 链接总数
|
||||||
|
*/
|
||||||
|
private long connectSize;
|
||||||
|
/**
|
||||||
|
* 断开链接数量
|
||||||
|
*/
|
||||||
|
private long disconnectEventSize;
|
||||||
|
/**
|
||||||
|
* 推送数量
|
||||||
|
*/
|
||||||
|
private long publishEventSize;
|
||||||
|
/**
|
||||||
|
* 发布重试事件数量
|
||||||
|
*/
|
||||||
|
private long publishRetryEventSize;
|
||||||
|
/**
|
||||||
|
* 保留消息数量
|
||||||
|
*/
|
||||||
|
private long retainSize;
|
||||||
|
/**
|
||||||
|
* 订阅事件数量
|
||||||
|
*/
|
||||||
|
private long subscribeEventSize;
|
||||||
|
/**
|
||||||
|
* 订阅数量
|
||||||
|
*/
|
||||||
|
private long subscribeSize;
|
||||||
|
/**
|
||||||
|
* 主题数量
|
||||||
|
*/
|
||||||
|
private long topicSize;
|
||||||
|
/**
|
||||||
|
* 取消订阅数量
|
||||||
|
*/
|
||||||
|
private long unSubscribeEventSize;
|
||||||
|
}
|
|
@ -1,37 +0,0 @@
|
||||||
//package com.zhilian.online.domain;/**
|
|
||||||
// * @version:
|
|
||||||
// * @Author: LiYuan
|
|
||||||
// * @description:
|
|
||||||
// * @date: 2024/3/29 21:44
|
|
||||||
// */
|
|
||||||
//
|
|
||||||
//import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
//import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
//import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
//import com.zhilian.common.core.web.domain.BaseEntity;
|
|
||||||
//import lombok.*;
|
|
||||||
//
|
|
||||||
//import javax.validation.constraints.NotBlank;
|
|
||||||
//import javax.validation.constraints.NotNull;
|
|
||||||
//import java.util.Date;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// *@BelongsProject: smart-cloud-server
|
|
||||||
// *@BelongsPackage: com.zhilian.online.domain
|
|
||||||
// *@Author: LiYuan
|
|
||||||
// *@CreateTime: 2024-03-29 21:44
|
|
||||||
// *@Description: 汽车类,测试使用
|
|
||||||
// *@Version: 1.0
|
|
||||||
// */
|
|
||||||
//@Data
|
|
||||||
////@AllArgsConstructor
|
|
||||||
////@NoArgsConstructor
|
|
||||||
//@Builder
|
|
||||||
//@ToString
|
|
||||||
//@EqualsAndHashCode(callSuper = true)
|
|
||||||
//@TableName("vehicle")
|
|
||||||
//public class Vehicle extends BaseEntity {
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//}
|
|
|
@ -1,70 +0,0 @@
|
||||||
package com.zhilian.online.domain;/**
|
|
||||||
* @version:
|
|
||||||
* @Author: LiYuan
|
|
||||||
* @description:
|
|
||||||
* @date: 2024/3/29 21:49
|
|
||||||
*/
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.zhilian.common.core.web.domain.BaseEntity;
|
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*@BelongsProject: smart-cloud-server
|
|
||||||
*@BelongsPackage: com.zhilian.online.domain
|
|
||||||
*@Author: LiYuan
|
|
||||||
*@CreateTime: 2024-03-29 21:49
|
|
||||||
*@Description: 车辆申请注册成功后返回的一次性账户数据
|
|
||||||
*@Version: 1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NotBlank
|
|
||||||
@ToString
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@TableName("vehicle_account")
|
|
||||||
public class VehicleAccount extends BaseEntity{
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆VIN
|
|
||||||
*/
|
|
||||||
@TableId(type = IdType.INPUT)
|
|
||||||
private String vin;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 申请时间
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
private Date applyTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 申请唯一标识
|
|
||||||
*/
|
|
||||||
@NotBlank
|
|
||||||
private String applyCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 一次性用户名
|
|
||||||
*/
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 一次性密码
|
|
||||||
*/
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 可以进行连接的收集节点id
|
|
||||||
*/
|
|
||||||
private String clientId;
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
package com.zhilian.online.domain.req;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: smart-cloud-server
|
||||||
|
* @BelongsPackage: com.zhilian.online.domain.req
|
||||||
|
* @Author: LiYuan
|
||||||
|
* @CreateTime: 2024-04-16 20:23
|
||||||
|
* @Description: 阿里openAPI创建实例请求
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@ToString
|
||||||
|
@Builder
|
||||||
|
public class EcsCreateReq {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 磁盘大小
|
||||||
|
*/
|
||||||
|
private String systemDiskSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 磁盘类型
|
||||||
|
*/
|
||||||
|
private String systemDickCategory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地域ID
|
||||||
|
*/
|
||||||
|
private String regionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 镜像ID
|
||||||
|
*/
|
||||||
|
private String ImageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例规格
|
||||||
|
*/
|
||||||
|
private String InstanceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全组ID
|
||||||
|
*/
|
||||||
|
private String securityGroupId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 专有网络ID
|
||||||
|
*/
|
||||||
|
private String vSwitchId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例名称
|
||||||
|
*/
|
||||||
|
private String instanceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公网入网流量大小
|
||||||
|
*/
|
||||||
|
private Integer internetMaxBandwidthIn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公网出网流量大小
|
||||||
|
*/
|
||||||
|
private Integer internetMaxBandwidthOut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 唯一后缀
|
||||||
|
*/
|
||||||
|
private Boolean uniqueSuffix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 专有网络ID
|
||||||
|
*/
|
||||||
|
private String zoneId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String internetChargeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private Integer amount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private Integer minAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String periodUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private Integer period;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String instanceChargeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String privateIpAddress;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
package com.zhilian.online.domain.req;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: smart-cloud-server
|
||||||
|
* @BelongsPackage: com.zhilian.online.domain.req
|
||||||
|
* @Author: LiYuan
|
||||||
|
* @CreateTime: 2024-04-12 15:37
|
||||||
|
* @Description: 调用阿里云openAPI查询实例请求实体类
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@ToString
|
||||||
|
@Builder
|
||||||
|
public class EcsQueryReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例所属地域 ID。
|
||||||
|
*/
|
||||||
|
@NotBlank
|
||||||
|
private String regionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 专有网络ID
|
||||||
|
*/
|
||||||
|
private String vpcId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交换机ID
|
||||||
|
*/
|
||||||
|
private String vSwitchId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 可用区ID。
|
||||||
|
*/
|
||||||
|
private String zoneId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例网络类型。可能值:
|
||||||
|
* classic:经典网络。
|
||||||
|
* vpc:专有网络 VPC。
|
||||||
|
*/
|
||||||
|
private String instanceNetworkType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全组ID
|
||||||
|
*/
|
||||||
|
private String securityGroupId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例ID ["i-bp67acfmxazb4p****", "i-bp67acfmxazb4p****", … "i-bp67acfmxazb4p****"]
|
||||||
|
*/
|
||||||
|
private String instanceIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页码
|
||||||
|
*/
|
||||||
|
private Integer pageNumber = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页条数
|
||||||
|
*/
|
||||||
|
private Integer pageSize = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内网IP地址集 ["172.16.1.1", "172.16.2.1", … "172.16.10.1"]
|
||||||
|
*/
|
||||||
|
private String privateIpAddresses;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内网IP地址集 ["172.16.1.1", "172.16.2.1", … "172.16.10.1"]
|
||||||
|
*/
|
||||||
|
private String publicIpAddresses;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例名称,支持使用通配符*进行模糊搜索。
|
||||||
|
*/
|
||||||
|
private String instanceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 镜像ID
|
||||||
|
*/
|
||||||
|
private String imageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例规格
|
||||||
|
*/
|
||||||
|
private String instanceType;
|
||||||
|
|
||||||
|
}
|
|
@ -1,34 +0,0 @@
|
||||||
package com.zhilian.online.domain.req;
|
|
||||||
|
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @BelongsProject: smart-cloud-server
|
|
||||||
* @BelongsPackage: com.zhilian.online.domain.req
|
|
||||||
* @Author: LiYuan
|
|
||||||
* @CreateTime: 2024-03-31 09:03
|
|
||||||
* @Description: 节点申请注册请求体
|
|
||||||
* @Version: 1.0
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@ToString
|
|
||||||
@Builder
|
|
||||||
public class GatherRegReq {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户端ID
|
|
||||||
*/
|
|
||||||
@NotBlank
|
|
||||||
private String clientId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 令牌
|
|
||||||
*/
|
|
||||||
private String token;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.zhilian.online.mapper;
|
package com.zhilian.online.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.zhilian.online.domain.VehicleAccount;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +10,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
* @date: 2024/3/29 20:45
|
* @date: 2024/3/29 20:45
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface OnlineLoadCenterMapper extends BaseMapper<VehicleAccount> {
|
public interface OnlineLoadCenterMapper{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package com.zhilian.online.service;
|
package com.zhilian.online.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.zhilian.common.core.domain.Result;
|
import com.zhilian.common.core.domain.Result;
|
||||||
import com.zhilian.online.domain.Gather;
|
import com.zhilian.online.domain.ApifoxModel;
|
||||||
import com.zhilian.online.domain.VehicleAccount;
|
|
||||||
import com.zhilian.online.domain.req.GatherRegReq;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @version:
|
* @version:
|
||||||
|
@ -12,7 +9,7 @@ import com.zhilian.online.domain.req.GatherRegReq;
|
||||||
* @description: 车辆负载中心服务接口
|
* @description: 车辆负载中心服务接口
|
||||||
* @date: 2024/3/29 20:42
|
* @date: 2024/3/29 20:42
|
||||||
*/
|
*/
|
||||||
public interface OnlineLoadCenterService extends IService<VehicleAccount> {
|
public interface OnlineLoadCenterService{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 车辆申请注解令牌接口,仅限内网访问
|
* @description: 车辆申请注解令牌接口,仅限内网访问
|
||||||
|
@ -20,7 +17,7 @@ public interface OnlineLoadCenterService extends IService<VehicleAccount> {
|
||||||
* @param: vehicle
|
* @param: vehicle
|
||||||
* @return: Result<OnlineAccount>
|
* @return: Result<OnlineAccount>
|
||||||
**/
|
**/
|
||||||
Result<String> applyForReg(Gather gather);
|
Result<String> applyForReg();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 车辆使用申请的一次性账户连接收集节点
|
* @description: 车辆使用申请的一次性账户连接收集节点
|
||||||
|
@ -28,7 +25,7 @@ public interface OnlineLoadCenterService extends IService<VehicleAccount> {
|
||||||
* @param:
|
* @param:
|
||||||
* @return: Result
|
* @return: Result
|
||||||
**/
|
**/
|
||||||
Result regGather(Gather gather);
|
Result regGather(ApifoxModel apifoxModel);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +34,7 @@ public interface OnlineLoadCenterService extends IService<VehicleAccount> {
|
||||||
* @param: vin
|
* @param: vin
|
||||||
* @return gather
|
* @return gather
|
||||||
*/
|
*/
|
||||||
Gather applyForConnectToGather(String vin);
|
void applyForConnectToGather(String vin);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
package com.zhilian.online.service.impl;
|
package com.zhilian.online.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.zhilian.common.core.domain.Result;
|
import com.zhilian.common.core.domain.Result;
|
||||||
import com.zhilian.common.core.utils.uuid.IdUtils;
|
import com.zhilian.common.core.utils.uuid.IdUtils;
|
||||||
import com.zhilian.common.redis.service.RedisService;
|
import com.zhilian.common.redis.service.RedisService;
|
||||||
import com.zhilian.online.config.RabbitConfig;
|
import com.zhilian.online.config.RabbitConfig;
|
||||||
import com.zhilian.online.constans.OnlineConstants;
|
import com.zhilian.online.constans.OnlineConstants;
|
||||||
import com.zhilian.online.domain.Gather;
|
import com.zhilian.online.domain.ApifoxModel;
|
||||||
import com.zhilian.online.domain.VehicleAccount;
|
|
||||||
import com.zhilian.online.mapper.OnlineLoadCenterMapper;
|
import com.zhilian.online.mapper.OnlineLoadCenterMapper;
|
||||||
import com.zhilian.online.service.OnlineLoadCenterService;
|
import com.zhilian.online.service.OnlineLoadCenterService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -17,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.ZSetOperations;
|
import org.springframework.data.redis.core.ZSetOperations;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -30,7 +27,7 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class OnlineLoadCenterServiceImpl extends ServiceImpl<OnlineLoadCenterMapper, VehicleAccount> implements OnlineLoadCenterService {
|
public class OnlineLoadCenterServiceImpl implements OnlineLoadCenterService{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆负载中心数据层
|
* 车辆负载中心数据层
|
||||||
|
@ -57,13 +54,13 @@ public class OnlineLoadCenterServiceImpl extends ServiceImpl<OnlineLoadCenterMap
|
||||||
* @return: Result<OnlineAccount>
|
* @return: Result<OnlineAccount>
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public Result<String> applyForReg(Gather gather) {
|
public Result<String> applyForReg() {
|
||||||
|
|
||||||
//生成一次性令牌
|
//生成一次性令牌
|
||||||
String token = IdUtils.fastSimpleUUID();
|
String token = IdUtils.fastSimpleUUID();
|
||||||
|
|
||||||
//将令牌信息缓存到Redis中
|
//将令牌信息缓存到Redis中
|
||||||
redisService.setCacheObject(OnlineConstants.ONLINE_TOKEN_PREFIX+gather.getClientId(),token, OnlineConstants.ONLINE_TOKEN_EXPIRE, TimeUnit.SECONDS);
|
redisService.setCacheObject(OnlineConstants.ONLINE_TOKEN_PREFIX + token,token, OnlineConstants.ONLINE_TOKEN_EXPIRE, TimeUnit.SECONDS);
|
||||||
|
|
||||||
//将令牌信息返回客户端
|
//将令牌信息返回客户端
|
||||||
return Result.success(token);
|
return Result.success(token);
|
||||||
|
@ -77,21 +74,21 @@ public class OnlineLoadCenterServiceImpl extends ServiceImpl<OnlineLoadCenterMap
|
||||||
* @return: Result
|
* @return: Result
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public Result regGather(Gather gather) {
|
public Result regGather(ApifoxModel apifoxModel) {
|
||||||
//判断登录令牌是否过期,一致
|
//判断登录令牌是否过期,一致
|
||||||
if (!redisService.hasKey(OnlineConstants.ONLINE_TOKEN_PREFIX + gather.getClientId())) {
|
if (!redisService.hasKey(OnlineConstants.ONLINE_TOKEN_PREFIX + apifoxModel.getToken())) {
|
||||||
return Result.error("令牌已过期");
|
return Result.error("令牌已过期");
|
||||||
}
|
}
|
||||||
String token = redisService.getCacheObject(OnlineConstants.ONLINE_TOKEN_PREFIX + gather.getClientId());
|
String token = redisService.getCacheObject(OnlineConstants.ONLINE_TOKEN_PREFIX + apifoxModel.getToken());
|
||||||
if (!token.equals(gather.getToken())){
|
if (!token.equals(apifoxModel.getToken())){
|
||||||
return Result.error("令牌错误");
|
return Result.error("令牌错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
//为该节点创建负载均衡缓存
|
//为该节点创建负载均衡缓存
|
||||||
redisService.setCacheZsetValue(OnlineConstants.GATHER_LOAD_CONTROL + gather.getClientId(), JSON.toJSONString(gather), 0.0);
|
redisService.setCacheZsetValue(OnlineConstants.GATHER_LOAD_CONTROL + apifoxModel.getClusterId(), JSON.toJSONString(apifoxModel), 0.0);
|
||||||
|
|
||||||
//向RabbitMQ||RocketMQ发送30s延迟消息,确保后续节点上线
|
//向RabbitMQ||RocketMQ发送30s延迟消息,确保后续节点上线
|
||||||
rabbitTemplate.convertAndSend(RabbitConfig.DELAY_EXCHANGE_NAME, RabbitConfig.DELAY_ROUTING_KEY, JSON.toJSONString(gather));
|
rabbitTemplate.convertAndSend(RabbitConfig.DELAY_EXCHANGE_NAME, RabbitConfig.DELAY_ROUTING_KEY, JSON.toJSONString(apifoxModel));
|
||||||
|
|
||||||
return Result.success("节点上线");
|
return Result.success("节点上线");
|
||||||
}
|
}
|
||||||
|
@ -103,7 +100,7 @@ public class OnlineLoadCenterServiceImpl extends ServiceImpl<OnlineLoadCenterMap
|
||||||
* @return gather
|
* @return gather
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Gather applyForConnectToGather(String vin) {
|
public void applyForConnectToGather(String vin) {
|
||||||
//判断车辆是否是我们的车
|
//判断车辆是否是我们的车
|
||||||
List<Object> cacheList = redisService.getCacheList("our_car");
|
List<Object> cacheList = redisService.getCacheList("our_car");
|
||||||
List<String> list = cacheList.stream().map(item -> {
|
List<String> list = cacheList.stream().map(item -> {
|
||||||
|
@ -114,13 +111,13 @@ public class OnlineLoadCenterServiceImpl extends ServiceImpl<OnlineLoadCenterMap
|
||||||
}
|
}
|
||||||
//获取负载最少的车辆进行链接
|
//获取负载最少的车辆进行链接
|
||||||
ZSetOperations.TypedTuple cacheZsetMin = redisService.getCacheZsetMin(OnlineConstants.GATHER_LOAD_CONTROL);
|
ZSetOperations.TypedTuple cacheZsetMin = redisService.getCacheZsetMin(OnlineConstants.GATHER_LOAD_CONTROL);
|
||||||
Gather gather = JSON.parseObject((String) cacheZsetMin.getValue(), Gather.class);
|
|
||||||
//存放节点车辆信息
|
//存放节点车辆信息
|
||||||
redisService.setCacheObject(OnlineConstants.ONLINE_VEHICLE+vin,gather.getClientId());
|
redisService.setCacheObject(OnlineConstants.ONLINE_VEHICLE+vin,1);
|
||||||
//发送延迟队列确定车辆上线
|
//发送延迟队列确定车辆上线
|
||||||
rabbitTemplate.convertAndSend(RabbitConfig.DELAY_EXCHANGE_FOR_CAR, RabbitConfig.DELAY_ROUTING_FOR_CAR,vin);
|
rabbitTemplate.convertAndSend(RabbitConfig.DELAY_EXCHANGE_FOR_CAR, RabbitConfig.DELAY_ROUTING_FOR_CAR,vin);
|
||||||
|
|
||||||
return gather;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,197 @@
|
||||||
|
package com.zhilian.online.uitls;
|
||||||
|
|
||||||
|
import com.aliyun.ecs20140526.models.*;
|
||||||
|
import com.aliyun.tea.TeaException;
|
||||||
|
import com.aliyun.teautil.models.RuntimeOptions;
|
||||||
|
import com.zhilian.online.domain.EcsInstance;
|
||||||
|
import com.zhilian.online.domain.req.EcsCreateReq;
|
||||||
|
import com.zhilian.online.domain.req.EcsQueryReq;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import com.aliyun.ecs20140526.Client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: smart-cloud-server
|
||||||
|
* @BelongsPackage: com.zhilian.online.uitls
|
||||||
|
* @Author: LiYuan
|
||||||
|
* @CreateTime: 2024-04-12 14:57
|
||||||
|
* @Description: 阿里云OpenApi调用工具类
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class AliyunOpenAPIUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里云ECS客户端
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
@Qualifier(value = "AliyunClient")
|
||||||
|
private Client aliyunClient;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询实例方法
|
||||||
|
*
|
||||||
|
* @param: ecsQueryReq
|
||||||
|
* @return: List<EcsInstance>
|
||||||
|
*/
|
||||||
|
public List<EcsInstance> queryEcsInstances(@Validated EcsQueryReq ecsQueryReq) {
|
||||||
|
log.info("开始创建实例");
|
||||||
|
List<EcsInstance> ecsInstances = new ArrayList<>();
|
||||||
|
DescribeInstancesResponse describeInstancesResponse = null;
|
||||||
|
|
||||||
|
//将请求参数写入查询请求中
|
||||||
|
DescribeInstancesRequest describeInstancesRequest = setQueryReq(ecsQueryReq);
|
||||||
|
|
||||||
|
RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||||
|
try {
|
||||||
|
// 复制代码运行请自行打印 API 的返回值
|
||||||
|
describeInstancesResponse = aliyunClient.describeInstancesWithOptions(describeInstancesRequest, runtime);
|
||||||
|
DescribeInstancesResponseBody body = describeInstancesResponse.getBody();
|
||||||
|
DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstances instances = body.getInstances();
|
||||||
|
|
||||||
|
ecsInstances = takeQueryInstances(instances);
|
||||||
|
|
||||||
|
} catch (TeaException error) {
|
||||||
|
log.error("code:[{}],message:[{}],data:[{}]", error.getCode(), error.getMessage(), error.getData());
|
||||||
|
} catch (Exception aError) {
|
||||||
|
TeaException error = new TeaException(aError.getMessage(), aError);
|
||||||
|
log.error("code:[{}],message:[{}],data:[{}]", error.getCode(), error.getMessage(), error.getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ecsInstances;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 创建阿里云实例
|
||||||
|
* @author: LiYuan
|
||||||
|
* @param:
|
||||||
|
* @return: void
|
||||||
|
**/
|
||||||
|
public void createInstance(EcsCreateReq ecsCreateReq) {
|
||||||
|
//创建实例请求
|
||||||
|
RunInstancesRequest runInstancesRequest = makeRunInstancesRequest(ecsCreateReq);
|
||||||
|
|
||||||
|
RuntimeOptions runtime = new RuntimeOptions();
|
||||||
|
try {
|
||||||
|
// 复制代码运行请自行打印 API 的返回值
|
||||||
|
RunInstancesResponse res = aliyunClient.runInstancesWithOptions(runInstancesRequest, runtime);
|
||||||
|
|
||||||
|
//打印执行结果
|
||||||
|
RunInstancesResponseBody body = res.getBody();
|
||||||
|
log.info("执行结果:[{}],请求ID:[{}],创建实例ID:[{}]",
|
||||||
|
200 == res.getStatusCode() ? "创建成功" : "创建失败",
|
||||||
|
body.getRequestId(), body.getInstanceIdSets().getInstanceIdSet());
|
||||||
|
} catch (TeaException error) {
|
||||||
|
log.error("code:[{}],message:[{}],data:[{}]",
|
||||||
|
error.getCode(), error.getMessage(), error.getData());
|
||||||
|
} catch (Exception aError) {
|
||||||
|
TeaException error = new TeaException(aError.getMessage(), aError);
|
||||||
|
log.error("code:[{}],message:[{}],data:[{}]",
|
||||||
|
error.getCode(), error.getMessage(), error.getData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 将请求参数写入查询请求中
|
||||||
|
* @author: LiYuan
|
||||||
|
* @param: EcsQueryReq
|
||||||
|
* @return: DescribeInstancesRequest
|
||||||
|
**/
|
||||||
|
public DescribeInstancesRequest setQueryReq(EcsQueryReq ecsQueryReq) {
|
||||||
|
return new DescribeInstancesRequest()
|
||||||
|
.setRegionId(ecsQueryReq.getRegionId())
|
||||||
|
.setInstanceName(ecsQueryReq.getInstanceName())
|
||||||
|
.setPageNumber(ecsQueryReq.getPageNumber())
|
||||||
|
.setPageSize(ecsQueryReq.getPageSize())
|
||||||
|
.setVpcId(ecsQueryReq.getVpcId())
|
||||||
|
.setVSwitchId(ecsQueryReq.getVSwitchId())
|
||||||
|
.setZoneId(ecsQueryReq.getZoneId())
|
||||||
|
.setInstanceNetworkType(ecsQueryReq.getInstanceNetworkType())
|
||||||
|
.setSecurityGroupId(ecsQueryReq.getSecurityGroupId())
|
||||||
|
.setInstanceIds(ecsQueryReq.getInstanceIds())
|
||||||
|
.setPrivateIpAddresses(ecsQueryReq.getPrivateIpAddresses())
|
||||||
|
.setPublicIpAddresses(ecsQueryReq.getPublicIpAddresses())
|
||||||
|
.setInstanceName(ecsQueryReq.getInstanceName())
|
||||||
|
.setImageId(ecsQueryReq.getImageId())
|
||||||
|
.setInstanceType(ecsQueryReq.getInstanceType())
|
||||||
|
.setStatus(ecsQueryReq.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 取出查询结果
|
||||||
|
* @author: LiYuan
|
||||||
|
* @param: DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstances
|
||||||
|
* @return: List<EcsInstance>
|
||||||
|
**/
|
||||||
|
public List<EcsInstance> takeQueryInstances(DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstances instances) {
|
||||||
|
ArrayList<EcsInstance> ecsInstances = new ArrayList<>();
|
||||||
|
//遍历请求结果,取出查询到的Ecs实例
|
||||||
|
instances.getInstance().stream().forEach(item -> {
|
||||||
|
EcsInstance ecsInstance = EcsInstance.builder()
|
||||||
|
.instanceId(item.getInstanceId())
|
||||||
|
.instanceName(item.getInstanceName())
|
||||||
|
.regionId(item.getRegionId())
|
||||||
|
.status(item.getStatus())
|
||||||
|
.instanceType(item.getInstanceType())
|
||||||
|
.cpu(item.getCpu())
|
||||||
|
.memory(item.getMemory())
|
||||||
|
.localStorageCapacity(item.getLocalStorageCapacity())
|
||||||
|
.osName(item.getOSName())
|
||||||
|
.instanceNetworkType(item.getInstanceNetworkType())
|
||||||
|
.internetMaxBandwidthOut(item.getInternetMaxBandwidthOut())
|
||||||
|
.internetMaxBandwidthIn(item.getInternetMaxBandwidthIn())
|
||||||
|
.publicIpAddress(item.getPublicIpAddress().getIpAddress())
|
||||||
|
.privateIpAddress(item.getVpcAttributes().getPrivateIpAddress().getIpAddress())
|
||||||
|
.vpcId(item.getVpcAttributes().getVpcId())
|
||||||
|
.securityGroupIds(item.getSecurityGroupIds().getSecurityGroupId())
|
||||||
|
.creationTime(item.getCreationTime())
|
||||||
|
.expiredTime(item.getExpiredTime())
|
||||||
|
.recyclable(item.getRecyclable())
|
||||||
|
.build();
|
||||||
|
ecsInstances.add(ecsInstance);
|
||||||
|
});
|
||||||
|
|
||||||
|
return ecsInstances;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RunInstancesRequest makeRunInstancesRequest(EcsCreateReq ecsCreateReq){
|
||||||
|
//构建磁盘配置
|
||||||
|
RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk = new RunInstancesRequest.RunInstancesRequestSystemDisk()
|
||||||
|
.setSize(ecsCreateReq.getSystemDiskSize())
|
||||||
|
.setCategory(ecsCreateReq.getSystemDickCategory());
|
||||||
|
//构建创建实例请求
|
||||||
|
RunInstancesRequest runInstancesRequest = new RunInstancesRequest()
|
||||||
|
.setRegionId(ecsCreateReq.getRegionId())
|
||||||
|
.setImageId(ecsCreateReq.getImageId())
|
||||||
|
.setInstanceType(ecsCreateReq.getInstanceType())
|
||||||
|
.setSecurityGroupId(ecsCreateReq.getSecurityGroupId())
|
||||||
|
.setVSwitchId(ecsCreateReq.getVSwitchId())
|
||||||
|
.setInstanceName(ecsCreateReq.getInstanceName())
|
||||||
|
.setInternetMaxBandwidthIn(ecsCreateReq.getInternetMaxBandwidthIn())
|
||||||
|
.setInternetMaxBandwidthOut(ecsCreateReq.getInternetMaxBandwidthOut())
|
||||||
|
.setUniqueSuffix(ecsCreateReq.getUniqueSuffix())
|
||||||
|
.setPassword(ecsCreateReq.getPassword())
|
||||||
|
.setZoneId(ecsCreateReq.getZoneId())
|
||||||
|
.setInternetChargeType(ecsCreateReq.getInternetChargeType())
|
||||||
|
.setSystemDisk(systemDisk)
|
||||||
|
.setAmount(ecsCreateReq.getAmount())
|
||||||
|
.setMinAmount(ecsCreateReq.getMinAmount())
|
||||||
|
.setPeriodUnit(ecsCreateReq.getPeriodUnit())
|
||||||
|
.setPeriod(ecsCreateReq.getPeriod())
|
||||||
|
.setInstanceChargeType(ecsCreateReq.getInstanceChargeType())
|
||||||
|
.setPrivateIpAddress(ecsCreateReq.getPrivateIpAddress());
|
||||||
|
return runInstancesRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue