Commit 9d293a90 authored by Elf's avatar Elf

解决端口错误的问题

parent ce5d2893
bishe.app.app-name=joliu
bishe.app.cloud-url=127.0.0.1:9091
\ No newline at end of file
......@@ -258,13 +258,14 @@ public class WxTests {
}
//测试连续传输
//测试生成所有的逻辑topo
@Test
public void test3() throws IllegalAccessException, InterruptedException {
ArrayList<SeparatedClusterConfig> clusterConfigs = new ArrayList<>();
SeparatedClusterConfig separatedClusterConfig = new SeparatedClusterConfig();
List<ContainerDescription> cds = new ArrayList<>();
// TODO: 这个ID应该是从借口获取的
separatedClusterConfig.setEdgeNodeId("192.168.190.135:8081");
separatedClusterConfig.setEdgeNodeId("192.168.190.135:18088");
ClusterConfig clusterConfig = new ClusterConfig();
clusterConfig.setId(11111l);
clusterConfig.setOwner("joliu");
......@@ -309,7 +310,7 @@ public class WxTests {
//下发逻辑拓扑
clusterService.sendLogicTopoToEdgeNode(clusterConfigs);
for (int i = 1; ; i++) {
out:for (int i = 1; ; i++) {
Thread.sleep(2000);
int time = i * sd.getJiange();
List<WeiXingData> changetp = wx.changeTopo(wxData,time);
......@@ -318,8 +319,21 @@ public class WxTests {
//下发修改后逻辑拓扑
clusterService.adjustLogicTopoToEdgeNode(clusterConfigs);
Boolean tag = false;
for(int k=1;k<toponet[0].length;k++){
for (int j=0;j<k;j++){
if(toponet[k][j] == tp.getTopology(changetp, sd)[k][j]){
tag = true;
}
}
}
if(tag){
break out;
}
}
System.out.println("所有topo完成");
}
//测试历史功能,需要提前定义好输出文本地址
......@@ -394,7 +408,7 @@ public class WxTests {
ArrayList<SeparatedClusterConfig> clusterConfigs = new ArrayList<>();
SeparatedClusterConfig separatedClusterConfig = new SeparatedClusterConfig();
//需修改为下发的IP地址
separatedClusterConfig.setEdgeNodeId("192.168.190.135:8081");
separatedClusterConfig.setEdgeNodeId("192.168.190.135:18088");
ClusterConfig clusterConfig = new ClusterConfig();
clusterConfig.setId(11111l);
......@@ -468,4 +482,84 @@ public class WxTests {
*/
}
@Test
public void test6() {
ArrayList<SeparatedClusterConfig> clusterConfigs = new ArrayList<>();
SeparatedClusterConfig separatedClusterConfig = new SeparatedClusterConfig();
//需修改为下发的IP地址
separatedClusterConfig.setEdgeNodeId("192.168.190.135:18088");
ClusterConfig clusterConfig = new ClusterConfig();
clusterConfig.setId(11111l);
clusterConfig.setOwner("joliu");
ContainerDescription containerDescription = new ContainerDescription();
containerDescription.setMode("normal");
containerDescription.setReplicas(1);
DockerContainer container = new DockerContainer();
container.setName("D1");
container.setCommand("sh");
container.setImage("test2");
containerDescription.setDockerContainer(container);
List<ContainerDescription> cds = new ArrayList<>();
cds.add(containerDescription);
ContainerDescription dis = new ContainerDescription();
dis.setMode("normal");
dis.setReplicas(1);
DockerContainer disContainer = new DockerContainer();
disContainer.setName("D2");
disContainer.setCommand("sh");
disContainer.setImage("test2");
dis.setDockerContainer(disContainer);
cds.add(dis);
ContainerDescription dis2 = new ContainerDescription();
dis2.setMode("normal");
dis2.setReplicas(1);
DockerContainer disContainer2 = new DockerContainer();
disContainer2.setName("D3");
disContainer2.setCommand("sh");
disContainer2.setImage("test2");
dis2.setDockerContainer(disContainer2);
cds.add(dis2);
String[] appnames = new String[]{"D1", "D2", "D3", "br:ovs"};
int[][] topology = new int[][]{
{0, 0, 0 ,0},
{1, 0, 0 ,0},
{0, 1, 0 ,0},
{1, 1, 1 ,0}};
clusterConfig.setDockers(cds);
NetworkTopology topo = new NetworkTopology();
topo.setAppNames(appnames);
// 这个参数好像没啥用
topo.setTopologyId(11);
topo.setTopology(topology);
clusterConfig.setTopology(topo);
separatedClusterConfig.setClusterConfig(clusterConfig);
clusterConfigs.add(separatedClusterConfig);
clusterService.sendClusterConfigToEdgeNode(clusterConfigs);
//下发逻辑拓扑
clusterService.sendLogicTopoToEdgeNode(clusterConfigs);
/*
//改变逻辑拓扑
int[][] newtopology = new int[][]{
{0, 0, 0, 0 },
{1, 0, 0, 0 },
{1, 1, 0, 0 },
{1, 1, 1, 0 }};
topo.setTopology(newtopology);
//下发修改后的逻辑拓扑
clusterService.adjustLogicTopoToEdgeNode(clusterConfigs);
*/
}
}
......@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RestController;
import top.ninwoo.edgecenter.service.LogicTopoService;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
@RestController
@RequestMapping("/dockerData")
......@@ -29,4 +30,10 @@ public class TransferTopoController {
return logicTopoService.getTopo(clusterId);
}
@GetMapping("/getTopoAll")
public ConcurrentHashMap<Long, int[][]> getTopoList() {
//System.out.println("已返回topo");
return logicTopoService.getTopoAll();
}
}
......@@ -3,6 +3,7 @@ package top.ninwoo.edgecenter.service;
import top.ninwoo.common.entity.NetworkTopology;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
//逻辑网络
public interface LogicTopoService {
......@@ -16,5 +17,8 @@ public interface LogicTopoService {
int[][] getTopo(long clusterId);
//返回IPlist到docker容器端
List<String> getIPlist(long clusterId);
//返回所有topo
ConcurrentHashMap<Long, int[][]> getTopoAll();
}
......@@ -3,7 +3,6 @@ package top.ninwoo.edgecenter.service.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import top.ninwoo.common.entity.NetworkTopology;
import top.ninwoo.edgecenter.service.ClusterService;
......@@ -12,6 +11,7 @@ import top.ninwoo.edgecenter.service.LogicTopoService;
import top.ninwoo.utils.service.IptablesService;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
......@@ -23,6 +23,10 @@ public class LogicTopoServiceImpl implements LogicTopoService {
private ConcurrentHashMap<Long, NetworkTopology> clustersTopo = new ConcurrentHashMap<>();
//根据appnames来存储IP
private ConcurrentHashMap<Long, List<String>> clustersIPlist = new ConcurrentHashMap<>();
//全部的topo网络
private ConcurrentHashMap<Long, int[][]> topoAll = new ConcurrentHashMap<>();
//
private long time;
@Autowired
private ClusterService clusterService;
......@@ -45,7 +49,6 @@ public class LogicTopoServiceImpl implements LogicTopoService {
// 校验信息
String[] cNames = logictopo.getAppNames();
int[][] topo = logictopo.getTopology();
if (cNames == null || cNames.length <= 1) {
return "集群创建失败";
}
......@@ -67,6 +70,10 @@ public class LogicTopoServiceImpl implements LogicTopoService {
}
clustersTopo.put(clusterId, logictopo);
clustersIPlist.put(clusterId,IPlist);
Date date = new Date();
time = date.getTime();
topoAll.put(time,logictopo.getTopology());
return "success";
}
......@@ -81,7 +88,7 @@ public class LogicTopoServiceImpl implements LogicTopoService {
// 获取clusterId的网络拓扑
if (!clustersTopo.containsKey(clusterId)) {
System.out.println("该集群没有设置topo");
LOG.error("该集群没有设置topo");
return "该集群没有设置topo";
}
......@@ -110,6 +117,11 @@ public class LogicTopoServiceImpl implements LogicTopoService {
}
clustersTopo.put(clusterId, logictopo);
//这里修改间隔
time = time + 10;
topoAll.put(time,logictopo.getTopology());
return "success";
}
......@@ -119,7 +131,7 @@ public class LogicTopoServiceImpl implements LogicTopoService {
int flag = 0;
//获取appnames
for (int i = 0; i < oritopo.getAppNames().length - 1; i++) {
for (int i = 0; i < oritopo.getAppNames().length; i++) {
if (oritopo.getAppNames()[i].startsWith("br:")) {
break;
}
......@@ -187,4 +199,11 @@ public class LogicTopoServiceImpl implements LogicTopoService {
}
return clustersIPlist.get(clusterId);
}
//todo,后续要加上集群ID并且防止NPE
@Override
public ConcurrentHashMap<Long, int[][]> getTopoAll() {
return topoAll;
}
}
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