Commit 16b2a979 authored by joliu's avatar joliu

Merge branch 'feature-cnf' into 'master'

Feature cnf

See merge request !7
parents b1cf359b 3c8e74e7
...@@ -17,4 +17,10 @@ ...@@ -17,4 +17,10 @@
* 谢建斌 * 谢建斌
* 王一鸣 * 王一鸣
* 刘建瓯 * 刘建瓯
* 张夏童 * 张夏童
\ No newline at end of file
## 更新说明
1. 使用域名替换配置中的IP,防止多人多次修改配置类并进行提交,避免合并分支时出现冲突的问题。
如果有需要在自己的电脑上进行部署,需要通过修改本机host的方式来修改对应节点的IP。
2. 测试代码
\ No newline at end of file
# 范例项目说明
## 注意
这是一个范例项目,请勿在此项目中添加新的业务代码
## 平台应用创建流程
1. 当需要创建一个平台应用时,需要在apps目录中创建对应的module,以便进行应用的管理。
2. 新建module中必须包含以下依赖:
```xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>top.ninwoo</groupId>
<artifactId>cnf-client-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
```
其中的`spring-boot-starter-web`可以变更为`spring-boot-starter`,具体根据是否有web应用需求而定。
3. 新建module必须包含以下plugin,以防止打Jar包时出现找不到主类的问题:
```xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
```
4. 应用中必须有主类,主类应该符合SpringBoot项目的主类编写方式。
## 警告
* 所有的应用禁止引用除starter之外的平台Jar包,包括:
* cnf-cloud-center
* cnf-edge-center
* cnf-test
* cnf-cloud-ipservice
* 其他基础工具包
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cnf</artifactId>
<groupId>top.ninwoo</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cnf-app-demo</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>top.ninwoo</groupId>
<artifactId>cnf-client-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package top.ninwoo.cnf.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoMain {
public static void main(String[] args) {
SpringApplication.run(DemoMain.class, args);
}
}
...@@ -3,59 +3,38 @@ ...@@ -3,59 +3,38 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>bishe</artifactId> <artifactId>cnf</artifactId>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>bishe-case-dis</artifactId> <artifactId>cnf-case-dis</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>2.1.2.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<artifactId>bishe-client-starter</artifactId> <artifactId>cnf-client-starter</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<version>2.1.2.RELEASE</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>top.ninwoo.BisheTestMain</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cnf</artifactId>
<groupId>top.ninwoo</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cnf-weixingsim</artifactId>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>top.ninwoo</groupId>
<artifactId>cnf-client-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package top.ninwoo.weixingsim;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class WxMain {
public static void main(String[] args) {
SpringApplication.run(WxMain.class, args);
}
}
...@@ -9,7 +9,7 @@ import top.ninwoo.bishe.starter.entity.ContainerMonitor; ...@@ -9,7 +9,7 @@ import top.ninwoo.bishe.starter.entity.ContainerMonitor;
import top.ninwoo.bishe.starter.service.ClusterService; import top.ninwoo.bishe.starter.service.ClusterService;
import top.ninwoo.bishe.starter.service.NetworkService; import top.ninwoo.bishe.starter.service.NetworkService;
import top.ninwoo.common.entity.*; import top.ninwoo.common.entity.*;
import top.ninwoo.client.BisheTestMain; import top.ninwoo.weixingsim.WxMain;
import top.ninwoo.weixingsim.entity.SimData; import top.ninwoo.weixingsim.entity.SimData;
import top.ninwoo.weixingsim.entity.WeiXingData; import top.ninwoo.weixingsim.entity.WeiXingData;
import top.ninwoo.weixingsim.service.impl.ToponetImpl; import top.ninwoo.weixingsim.service.impl.ToponetImpl;
...@@ -21,8 +21,8 @@ import java.util.ArrayList; ...@@ -21,8 +21,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = BisheTestMain.class) @SpringBootTest(classes = WxMain.class)
public class BisheTests { public class WxTests {
@Autowired @Autowired
private ClusterService clusterService; private ClusterService clusterService;
......
package top.ninwoo.utils;
/**
* @Author joliu
* @Description
* @Date Create in 下午10:50 2019/10/27
*/
public class EntityTests {
}
package top.ninwoo.utils;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import top.ninwoo.utils.config.DockerConfig;
import top.ninwoo.utils.service.IptablesService;
/**
* @Author joliu
* @Description
* @Date Create in 下午3:15 2019/10/30
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = DockerConfig.class)
public class IptablesServiceTests {
@Autowired
IptablesService iptablesService;
}
package top.ninwoo.utils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import top.ninwoo.utils.config.DockerConfig;
public class SpringMain {
public static void main(String[] args) {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(DockerConfig.class);
}
}
package top.ninwoo.utils;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import top.ninwoo.utils.config.DockerConfig;
import top.ninwoo.utils.util.DockerUtils;
/**
* @Author joliu
* @Description 这个测试迁移到集群服务中
* @Date Create in 下午4:06 2019/10/30
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = DockerConfig.class)
public class TcUtilsTests {
@Autowired
DockerUtils dockerUtils;
@Before
public void init() {
// 创建两个容器
// 创建一个ovs网桥
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>bishe</artifactId>
<groupId>top.ninwoo</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>bishe-weixingsim</artifactId>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>bishe</artifactId> <artifactId>cnf</artifactId>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>bishe-client-starter</artifactId> <artifactId>cnf-client-starter</artifactId>
<properties> <properties>
<dubbo.version>2.7.4.1</dubbo.version> <dubbo.version>2.7.4.1</dubbo.version>
</properties> </properties>
...@@ -17,31 +18,26 @@ ...@@ -17,31 +18,26 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId> <artifactId>spring-boot-starter</artifactId>
<version>2.1.2.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.16.18</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId> <artifactId>spring-boot-configuration-processor</artifactId>
<version>2.1.2.RELEASE</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<artifactId>bishe-common-api</artifactId> <artifactId>cnf-common-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId> <artifactId>spring-web</artifactId>
<version>5.2.0.RELEASE</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>bishe</artifactId> <artifactId>cnf</artifactId>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>bishe-cloud-center</artifactId> <artifactId>cnf-cloud-center</artifactId>
<packaging>jar</packaging>
<description>用作集群工的汇总</description> <description>用作集群工的汇总</description>
...@@ -17,7 +18,6 @@ ...@@ -17,7 +18,6 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>2.1.2.RELEASE</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -30,38 +30,64 @@ ...@@ -30,38 +30,64 @@
<dependency> <dependency>
<groupId>org.apache.curator</groupId> <groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId> <artifactId>curator-framework</artifactId>
<version>2.12.0</version>
</dependency> </dependency>
<!-- 封装了一些高级特性,如:Cache事件监听、选举、分布式锁、分布式Barrier --> <!-- 封装了一些高级特性,如:Cache事件监听、选举、分布式锁、分布式Barrier -->
<dependency> <dependency>
<groupId>org.apache.curator</groupId> <groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId> <artifactId>curator-recipes</artifactId>
<version>2.12.0</version>
</dependency> </dependency>
<!--日志模块--> <!--日志模块-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId> <artifactId>spring-boot-starter-log4j2</artifactId>
<version>2.1.2.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<artifactId>bishe-utils</artifactId> <artifactId>cnf-utils</artifactId>
<version>1.0-SNAPSHOT</version> <exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<artifactId>bishe-common-api</artifactId> <artifactId>cnf-common-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<version>2.1.2.RELEASE</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!--自动生成文档-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>
\ No newline at end of file
package top.ninwoo.cloudcenter.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.pathMapping("/")
.select()
.apis(RequestHandlerSelectors.basePackage("top.ninwoo.cloudcenter.controller"))
.paths(PathSelectors.any())
.build().apiInfo(new ApiInfoBuilder().title("CNF云平台Swagger文档")
.description("由Swagger自动生成,仅限测试环境使用")
.version("1.0")
.contact(new Contact("joliu", "opengn.org", "ljo0412@live.com"))
.license("The Apache License")
.licenseUrl("http://git.opensource5g.org/xidiancos/cnf/-/blob/master/LICENSE")
.build());
}
}
package top.ninwoo.cloudcenter.controller; package top.ninwoo.cloudcenter.controller;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import top.ninwoo.cloudcenter.service.CloudService; import top.ninwoo.cloudcenter.service.CloudService;
import top.ninwoo.common.entity.NetworkTopology; import top.ninwoo.common.entity.NetworkTopology;
...@@ -9,19 +10,24 @@ import javax.annotation.Resource; ...@@ -9,19 +10,24 @@ import javax.annotation.Resource;
import java.util.List; import java.util.List;
@RestController @RestController
@Api(tags = "容器集群管理相关接口")
@RequestMapping("/cluster") @RequestMapping("/cluster")
public class ClusterController { public class ClusterController {
@Resource @Resource
CloudService cloudService; CloudService cloudService;
@RequestMapping(value = "/sendClusterConfigToEdgeNode", method = RequestMethod.POST) @ApiOperation("下发集群配置")
@ApiImplicitParam(name = "clusterConfigs", value = "集群配置类", defaultValue = "", dataType = "List" ,required = true)
@PostMapping(value = "/sendClusterConfigToEdgeNode")
public List<SeparatedClusterConfig> sendClusterConfigToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) { public List<SeparatedClusterConfig> sendClusterConfigToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) {
// return cloudService.sendClusterConfigToEdgeNode(clusterConfigs); // return cloudService.sendClusterConfigToEdgeNode(clusterConfigs);
return cloudService.sendClusterConfigToEdgeNodeByThreads(clusterConfigs); return cloudService.sendClusterConfigToEdgeNodeByThreads(clusterConfigs);
} }
@RequestMapping(value = "/removeClusterFromEdgeNode") @ApiOperation("删除集群")
@ApiImplicitParam(name = "clusterId", value = "容器集群ID", defaultValue = "11111", required = true)
@GetMapping(value = "/removeClusterFromEdgeNode")
public String removeClusterFromEdgeNode(Long clusterId) { public String removeClusterFromEdgeNode(Long clusterId) {
boolean res = cloudService.deleteClusterFromEdgeNode(clusterId); boolean res = cloudService.deleteClusterFromEdgeNode(clusterId);
if(res) { if(res) {
...@@ -30,22 +36,29 @@ public class ClusterController { ...@@ -30,22 +36,29 @@ public class ClusterController {
return "fail"; return "fail";
} }
@RequestMapping(value = "/getEdgeNodeIds") @ApiOperation("获取边缘节点")
@GetMapping(value = "/getEdgeNodeIds")
public List<String> getEdgeNodeIds() { public List<String> getEdgeNodeIds() {
return cloudService.getEdgeNodeIds(); return cloudService.getEdgeNodeIds();
} }
@RequestMapping(value = "/adjustCluster", method = RequestMethod.POST) @ApiOperation("调整容器集群")
@ApiImplicitParam(name = "clusterConfigs", value = "集群配置类", defaultValue = "", required = true)
@PostMapping(value = "/adjustCluster")
public Boolean adjustClusterToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) { public Boolean adjustClusterToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) {
return cloudService.adjustCluster(clusterConfigs); return cloudService.adjustCluster(clusterConfigs);
} }
@RequestMapping(value = "/sendLogicTopo", method = RequestMethod.POST) @ApiOperation("下发容器逻辑拓扑")
@ApiImplicitParam(name = "clusterConfigs", value = "集群配置类", defaultValue = "", required = true)
@PostMapping(value = "/sendLogicTopo")
public Boolean sendLogicTopoToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) { public Boolean sendLogicTopoToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) {
return cloudService.sendLogicTopo(clusterConfigs); return cloudService.sendLogicTopo(clusterConfigs);
} }
@RequestMapping(value = "/adjustLogicTopo", method = RequestMethod.POST) @ApiOperation("调整容器逻辑拓扑")
@ApiImplicitParam(name = "clusterConfigs", value = "集群配置类", defaultValue = "", required = true)
@PostMapping(value = "/adjustLogicTopo")
public Boolean adjustLogicTopoToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) { public Boolean adjustLogicTopoToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) {
return cloudService.adjustLogicTopo(clusterConfigs); return cloudService.adjustLogicTopo(clusterConfigs);
} }
......
...@@ -2,10 +2,10 @@ server: ...@@ -2,10 +2,10 @@ server:
port: 9091 port: 9091
zookeeper: zookeeper:
url: 192.168.31.156:2181 url: zk.cnf.org:2181
bs: bs:
cloudcenter: cloudcenter:
name: my-bs-cloud-center name: my-bs-cloud-center
ipservice: ipservice:
url: 192.168.31.156:23333 url: ipservice.cnf.org:23333
\ No newline at end of file \ No newline at end of file
...@@ -3,19 +3,18 @@ ...@@ -3,19 +3,18 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>bishe</artifactId> <artifactId>cnf</artifactId>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>bishe-cloud-ipservice</artifactId> <artifactId>cnf-cloud-ipservice</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>2.1.2.RELEASE</version>
</dependency> </dependency>
</dependencies> </dependencies>
...@@ -24,10 +23,7 @@ ...@@ -24,10 +23,7 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<!--这里写上main方法所在类的路径--> <version>${springboot.version}</version>
<configuration>
<mainClass>top.ninwoo.cloud.ipservice.IpServiceMainApp</mainClass>
</configuration>
<executions> <executions>
<execution> <execution>
<goals> <goals>
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>bishe</artifactId> <artifactId>cnf</artifactId>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>bishe-common-api</artifactId> <artifactId>cnf-common-api</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<dependencies> <dependencies>
...@@ -17,8 +17,11 @@ ...@@ -17,8 +17,11 @@
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
package top.ninwoo.common.entity; package top.ninwoo.common.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@Data @Data
public class SeparatedClusterConfig { public class SeparatedClusterConfig {
@ApiModelProperty
private ClusterConfig clusterConfig; private ClusterConfig clusterConfig;
@ApiModelProperty
private String edgeNodeId; private String edgeNodeId;
} }
# 边缘承载节点
该Module为
\ No newline at end of file
...@@ -3,19 +3,18 @@ ...@@ -3,19 +3,18 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>bishe</artifactId> <artifactId>cnf</artifactId>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>bishe-edge-center</artifactId> <artifactId>cnf-edge-center</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>2.1.2.RELEASE</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -26,75 +25,62 @@ ...@@ -26,75 +25,62 @@
<dependency> <dependency>
<groupId>org.influxdb</groupId> <groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId> <artifactId>influxdb-java</artifactId>
<version>2.9</version>
</dependency> </dependency>
<!--日志模块--> <!--日志模块-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId> <artifactId>spring-boot-starter-log4j2</artifactId>
<version>2.1.2.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId> <artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.1.2.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<version>2.1.2.RELEASE</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<artifactId>bishe-utils</artifactId> <artifactId>cnf-utils</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<artifactId>bishe-common-api</artifactId> <artifactId>cnf-common-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency> </dependency>
<!-- 对zookeeper的底层api的一些封装 --> <!-- 对zookeeper的底层api的一些封装 -->
<dependency> <dependency>
<groupId>org.apache.curator</groupId> <groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId> <artifactId>curator-framework</artifactId>
<version>2.12.0</version>
</dependency> </dependency>
<!-- 封装了一些高级特性,如:Cache事件监听、选举、分布式锁、分布式Barrier --> <!-- 封装了一些高级特性,如:Cache事件监听、选举、分布式锁、分布式Barrier -->
<dependency> <dependency>
<groupId>org.apache.curator</groupId> <groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId> <artifactId>curator-recipes</artifactId>
<version>2.12.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
<version>2.1.2.RELEASE</version>
</dependency> </dependency>
</dependencies> </dependencies>
...@@ -104,10 +90,7 @@ ...@@ -104,10 +90,7 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<!--这里写上main方法所在类的路径--> <version>${springboot.version}</version>
<configuration>
<mainClass>top.ninwoo.edgecenter.EdgeCenterApp</mainClass>
</configuration>
<executions> <executions>
<execution> <execution>
<goals> <goals>
......
...@@ -90,11 +90,16 @@ public class ClusterServiceCheck { ...@@ -90,11 +90,16 @@ public class ClusterServiceCheck {
log.info("创建自检容器集群【Test1_0,Test1_1,Test2】"); log.info("创建自检容器集群【Test1_0,Test1_1,Test2】");
try { try {
clusterService.initContainers(clusterConfig); clusterService.initContainers(clusterConfig);
topologyService.createTopo(clusterConfig.getId(), clusterConfig.getTopology());
} catch (Exception e) { } catch (Exception e) {
log.error("容器启动失败"); log.error("容器启动失败");
throw new RuntimeException("容器启动失败"); throw new RuntimeException("容器启动失败");
} }
try {
topologyService.createTopo(clusterConfig.getId(), clusterConfig.getTopology());
} catch (Exception e) {
log.error("容器网络初始化失败", e);
throw new RuntimeException("容器网络初始化失败");
}
if(!clusterService.getClusterIds().contains(CLUSTERID)) { if(!clusterService.getClusterIds().contains(CLUSTERID)) {
log.error("集群创建失败%", CLUSTERID); log.error("集群创建失败%", CLUSTERID);
} }
......
package top.ninwoo.edgecenter.config; package top.ninwoo.edgecenter.config;
import javafx.scene.control.cell.TextFieldListCell;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.CuratorFrameworkFactory;
...@@ -14,11 +13,9 @@ import org.springframework.context.ApplicationContext; ...@@ -14,11 +13,9 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.support.WebApplicationContextUtils;
import top.ninwoo.edgecenter.check.ClusterServiceCheck; import top.ninwoo.edgecenter.check.ClusterServiceCheck;
import top.ninwoo.edgecenter.register.EdgeNodeRegister; import top.ninwoo.edgecenter.register.EdgeNodeRegister;
import javax.annotation.Resource;
@Slf4j @Slf4j
@Configuration @Configuration
public class ZookeeperConfiguration implements ApplicationContextAware { public class ZookeeperConfiguration implements ApplicationContextAware {
......
...@@ -6,7 +6,7 @@ spring: ...@@ -6,7 +6,7 @@ spring:
username: root username: root
password: Vudo3423ljo password: Vudo3423ljo
influx: influx:
url: http://127.0.0.1:8086 url: http://influxdb.cnf.org:8086
user: admin user: admin
password: admin password: admin
mybatis: mybatis:
...@@ -17,7 +17,7 @@ debug: false ...@@ -17,7 +17,7 @@ debug: false
#边缘节点的端口 #边缘节点的端口
server: server:
port: 8081 port: 18088
bs: bs:
cloudcenter: cloudcenter:
...@@ -26,9 +26,12 @@ bs: ...@@ -26,9 +26,12 @@ bs:
name: random name: random
ip-prefix: 192.168.31 ip-prefix: 192.168.31
ipservice: ipservice:
ip: 192.168.31.238:23333 ip: ipservice.cnf.org:23333
sdn-controller: sdn-controller:
host: 127.0.0.1 host: sdn.cnf.org
port: 6653 port: 6653
zookeeper: zookeeper:
url: 192.168.31.238:2181 url: zk.cnf.org:2181
cnf:
passwd: Vudo3423
...@@ -3,50 +3,49 @@ ...@@ -3,50 +3,49 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>bishe</artifactId> <artifactId>cnf</artifactId>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>bishe-test</artifactId> <artifactId>cnf-test</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<version>2.1.2.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
<artifactId>bishe-client-starter</artifactId> <artifactId>cnf-client-starter</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<version>2.1.2.RELEASE</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.influxdb</groupId> <groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId> <artifactId>influxdb-java</artifactId>
<version>2.9</version>
</dependency>
<dependency>
<groupId>top.ninwoo</groupId>
<artifactId>bishe-weixingsim</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment