Commit e4687bc8 authored by ymwang's avatar ymwang

动态网络拓扑下发

parent 76dad701
...@@ -4,7 +4,7 @@ server.port=8999 ...@@ -4,7 +4,7 @@ server.port=8999
#接入云端的端口设置 #接入云端的端口设置
bishe.app.app-name=joliu bishe.app.app-name=joliu
#bishe.app.cloud-url=192.168.31.156:9090 #bishe.app.cloud-url=192.168.31.156:9090
bishe.app.cloud-url=192.168.81.1:9091 bishe.app.cloud-url=192.168.31.190:9091
#容器里的挂载目录 #容器里的挂载目录
dbc.directory.output=/tmp/statics/ dbc.directory.output=/tmp/statics/
......
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
<artifactId>dfs-file-utils</artifactId> <artifactId>dfs-file-utils</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>top.ninwoo</groupId>
<artifactId>dfs-transfer-topology</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>top.ninwoo</groupId> <groupId>top.ninwoo</groupId>
......
...@@ -36,26 +36,37 @@ public class FileService { ...@@ -36,26 +36,37 @@ public class FileService {
@Autowired @Autowired
private TransferService transferService; private TransferService transferService;
private String[] ipList=null; Long clusterId = 11112l;
String[] wxName_list = new String[]{"sate2","sate3","sate4","sate5","sate6","sate7","sate8","sate9","sate10","sate11",
"sate12","sate13","sate14","sate15","sate16","sate17","sate18","sate19","sate20","sate21",
"sate22","sate23","sate24","sate25","sate26","sate27","sate28","sate29","sate30"};//获取卫星名字
private String[] ipList = null;
@PostConstruct @PostConstruct
public void init() { public void init() {
ipList = getIpList(11112l,"dfs_server"); //ipList = getIpList(11112l,"dfs_server");
System.out.println(Arrays.toString(ipList)); for (int k = 0; k < wxName_list.length; k++){
ipList = getIpList(clusterId,wxName_list[k]);//通过卫星名字获取卫星ip
}
} }
/*获取容器ip*/
/* String[] ipList = new String[]{"127.0.0.1:8080","127.0.0.1:8081","127.0.0.1:8082","127.0.0.1:8083","127.0.0.1:8084",
"127.0.0.1:8085","127.0.0.1:8086","127.0.0.1:8087", "127.0.0.1:8088","127.0.0.1:8089",
"127.0.0.1:8180","127.0.0.1:8181","127.0.0.1:8182","127.0.0.1:8183","127.0.0.1:8184"};*/
public String[] getIpList(Long clusterId, String appName) { public String[] getIpList(Long clusterId, String appName) {
List<String> ipListS = networkService.getIpListByAppName(clusterId, appName);//用于存储容器ip的list集合
//List<String> ipListS = networkService.getIpListByAppName(clusterId, appName);//用于存储容器ip的list集合
List<String> ipListS = new ArrayList<>();
for (int k = 1; k < wxName_list.length; k++){
ipListS.add(networkService.getIpListByAppName(clusterId, wxName_list[k]).toString()) ;
}
String[] containerIp = new String[ipListS.size()];//将集合中的元素存在数组里,因为下边用的是数组 String[] containerIp = new String[ipListS.size()];//将集合中的元素存在数组里,因为下边用的是数组
for (int i = 0; i < ipListS.size(); i++) { for (int i = 0; i < ipListS.size(); i++) {
if(!ipListS.isEmpty()){ if(!ipListS.isEmpty()){
String ip_tmp = ipListS.get(i); String ip_tmp = ipListS.get(i);
String[] split_list = ip_tmp.split("/"); String rep = ip_tmp.replaceAll("[\\[\\]]","");
String[] split_list = rep.split("/");
containerIp[i] = split_list[0]+":8084"; containerIp[i] = split_list[0]+":8084";
} }
} }
...@@ -71,7 +82,10 @@ public class FileService { ...@@ -71,7 +82,10 @@ public class FileService {
@Async("taskExecutor") @Async("taskExecutor")
public String sendFile(Long fileId, byte[] fileBytes) { public String sendFile(Long fileId, byte[] fileBytes) {
// 通过集群服务器接口获取当前集群的节点数量 // 通过集群服务器接口获取当前集群的节点数量
ipList = this.getIpList(11112l,"dfs_server"); //ipList = this.getIpList(clusterId,"dfs_server");
for (int i = 0; i < wxName_list.length; i++){
ipList = getIpList(clusterId,wxName_list[i]);//通过卫星名字获取卫星ip
}
int sliceNum = ipList.length; int sliceNum = ipList.length;
//int sliceNum = 30; //int sliceNum = 30;
...@@ -117,7 +131,10 @@ public class FileService { ...@@ -117,7 +131,10 @@ public class FileService {
public String getFile(String fileName, Long fileId) { public String getFile(String fileName, Long fileId) {
ipList = this.getIpList(11112l,"dfs_server"); //ipList = this.getIpList(clusterId,"dfs_server");
for (int i = 0; i < wxName_list.length; i++){
ipList = getIpList(clusterId,wxName_list[i]);//通过卫星名字获取卫星ip
}
int sliceNum = ipList.length; int sliceNum = ipList.length;
//int sliceNum = 30; //int sliceNum = 30;
int origNum = 6; int origNum = 6;
......
...@@ -2,7 +2,7 @@ server.port=8099 ...@@ -2,7 +2,7 @@ server.port=8099
bishe.app.app-name=joliu bishe.app.app-name=joliu
#bishe.app.cloud-url=192.168.31.156:9090 #bishe.app.cloud-url=192.168.31.156:9090
bishe.app.cloud-url=192.168.81.1:9091 bishe.app.cloud-url=192.168.31.190:9091
dfs.directory.output=/tmp/static/ dfs.directory.output=/tmp/static/
......
...@@ -53,9 +53,9 @@ public class CycleTopoUnit { ...@@ -53,9 +53,9 @@ public class CycleTopoUnit {
Iterator<Map.Entry<Integer, int[][]>> iterator = TopoStore.entrySet().iterator(); Iterator<Map.Entry<Integer, int[][]>> iterator = TopoStore.entrySet().iterator();
while (iterator.hasNext()){ while (iterator.hasNext()){
int[][] value = iterator.next().getValue(); int[][] value = iterator.next().getValue();
System.out.println(Arrays.deepToString(value)); /* System.out.println(Arrays.deepToString(value));
System.out.println("========================================="); System.out.println("=========================================");
System.out.println(count2); System.out.println(count2);*/
while (iterator.hasNext()){ while (iterator.hasNext()){
int[][] valueNext = iterator.next().getValue(); int[][] valueNext = iterator.next().getValue();
for (int i = 0;i<value.length;i++){ for (int i = 0;i<value.length;i++){
...@@ -64,9 +64,9 @@ public class CycleTopoUnit { ...@@ -64,9 +64,9 @@ public class CycleTopoUnit {
} }
if (count != 30){ if (count != 30){
System.out.println(Arrays.deepToString(valueNext)); /* System.out.println(Arrays.deepToString(valueNext));
System.out.println("========================================="); System.out.println("=========================================");
System.out.println(count2); System.out.println(count2);*/
count2++; count2++;
} }
count=0; count=0;
......
...@@ -73,7 +73,7 @@ public class TimeExpanGraph { ...@@ -73,7 +73,7 @@ public class TimeExpanGraph {
HashMap<Integer,int[][]> cycleTp = cycleTp(); HashMap<Integer,int[][]> cycleTp = cycleTp();
//获得第1个时隙的连接矩阵 0或1 //获得第1个时隙的连接矩阵 0或1
int[][] currentTp = cycleTp.get((slotKey)%300+1); int[][] currentTp = cycleTp.get((slotKey)%30+1);
int[][] slot1 = new int[num][num]; //10*10的矩阵图 int[][] slot1 = new int[num][num]; //10*10的矩阵图
for(int i = 0;i<slot1.length;i++){ for(int i = 0;i<slot1.length;i++){
for(int j = 0;j<slot1[0].length;j++){ for(int j = 0;j<slot1[0].length;j++){
...@@ -95,7 +95,7 @@ public class TimeExpanGraph { ...@@ -95,7 +95,7 @@ public class TimeExpanGraph {
}*/ }*/
//获得第2个时隙的连接矩阵 //获得第2个时隙的连接矩阵
currentTp = cycleTp.get((slotKey)%300+2); currentTp = cycleTp.get((slotKey)%30+2);
int[][] slot2 = new int[num][num]; int[][] slot2 = new int[num][num];
for(int i = 0;i<slot2.length;i++){ for(int i = 0;i<slot2.length;i++){
for(int j = 0;j<slot2.length;j++){ for(int j = 0;j<slot2.length;j++){
...@@ -111,7 +111,7 @@ public class TimeExpanGraph { ...@@ -111,7 +111,7 @@ public class TimeExpanGraph {
} }
//获得第3个时隙的连接矩阵 //获得第3个时隙的连接矩阵
currentTp = cycleTp.get((slotKey)%300+3); currentTp = cycleTp.get((slotKey)%30+3);
int[][] slot3 = new int[num][num]; int[][] slot3 = new int[num][num];
for(int i = 0;i<slot3.length;i++){ for(int i = 0;i<slot3.length;i++){
for(int j = 0;j<slot3.length;j++){ for(int j = 0;j<slot3.length;j++){
......
bishe.app.app-name=joliu bishe.app.app-name=joliu
#bishe.app.cloud-url=192.168.31.156:9090 #bishe.app.cloud-url=192.168.31.156:9090
bishe.app.cloud-url=192.168.81.1:9091 bishe.app.cloud-url=192.168.31.190:9091
spring.influx.url=http://192.168.0.108:8086 spring.influx.url=http://192.168.0.108:8086
spring.influx.user=admin spring.influx.user=admin
......
...@@ -39,7 +39,7 @@ public class TopoTests { ...@@ -39,7 +39,7 @@ public class TopoTests {
// TODO: 这个ID应该是从借口获取的 // TODO: 这个ID应该是从借口获取的
separatedClusterConfig.setEdgeNodeId("192.168.31.198:18088"); separatedClusterConfig.setEdgeNodeId("192.168.31.198:18088");
ClusterConfig clusterConfig = new ClusterConfig(); ClusterConfig clusterConfig = new ClusterConfig();
clusterConfig.setId(11111l); clusterConfig.setId(11112l);
clusterConfig.setOwner("joliu"); clusterConfig.setOwner("joliu");
//从文本中获取卫星的数据 //从文本中获取卫星的数据
...@@ -47,7 +47,7 @@ public class TopoTests { ...@@ -47,7 +47,7 @@ public class TopoTests {
ToponetImpl tp = new ToponetImpl(); ToponetImpl tp = new ToponetImpl();
SimData sd = new SimData(); SimData sd = new SimData();
//tp.delHistory(); //tp.delHistory();
File file = new File("D:\\LabratoryJavaPro\\codingDownload\\latestCoding\\topusim_1.txt"); File file = new File("F:\\ymwang\\topusim_1.txt");
// D:\LabratoryJavaPro\codingDownload\latestCoding\ // D:\LabratoryJavaPro\codingDownload\latestCoding\
List<WeiXingData> wxData = wx.iniTopo(file, sd.getZhouqi()); List<WeiXingData> wxData = wx.iniTopo(file, sd.getZhouqi());
int[][] toponet = tp.getTopology(wxData, sd); int[][] toponet = tp.getTopology(wxData, sd);
...@@ -61,7 +61,8 @@ public class TopoTests { ...@@ -61,7 +61,8 @@ public class TopoTests {
DockerContainer container0 = new DockerContainer(); DockerContainer container0 = new DockerContainer();
container0.setName(wxData.get(0).getName()); container0.setName(wxData.get(0).getName());
container0.setCommand("sh"); container0.setCommand("sh");
container0.setImage("joliu/networktest:schedule"); container0.setImage("dfs_client");
container0.setPorts("8099");//指定容器端口
containerDescription0.setDockerContainer(container0); containerDescription0.setDockerContainer(container0);
cds.add(containerDescription0); cds.add(containerDescription0);
...@@ -73,7 +74,7 @@ public class TopoTests { ...@@ -73,7 +74,7 @@ public class TopoTests {
DockerContainer container = new DockerContainer(); DockerContainer container = new DockerContainer();
container.setName(wxData.get(k).getName()); container.setName(wxData.get(k).getName());
container.setCommand("sh"); container.setCommand("sh");
container.setImage("joliu/networktest:server"); container.setImage("dfs_server");
containerDescription.setDockerContainer(container); containerDescription.setDockerContainer(container);
cds.add(containerDescription); cds.add(containerDescription);
...@@ -82,7 +83,7 @@ public class TopoTests { ...@@ -82,7 +83,7 @@ public class TopoTests {
clusterConfig.setDockers(cds); clusterConfig.setDockers(cds);
NetworkTopology topo = new NetworkTopology(); NetworkTopology topo = new NetworkTopology();
topo.setAppNames(tp.getAppNames(wxData)); topo.setAppNames(tp.getAppNames(wxData));
// 这个参数好像没啥用 // 这个参数好像没啥用
topo.setTopologyId(11); topo.setTopologyId(11);
topo.setTopology(toponet); topo.setTopology(toponet);
clusterConfig.setTopology(topo); clusterConfig.setTopology(topo);
...@@ -91,4 +92,73 @@ public class TopoTests { ...@@ -91,4 +92,73 @@ public class TopoTests {
clusterService.sendClusterConfigToEdgeNode(clusterConfigs); clusterService.sendClusterConfigToEdgeNode(clusterConfigs);
} }
//测试容器ip
@Test
public void getIpListByAppNameTest() {
//List<String> ipList = networkService.getIpListByAppName(11112L, "sate2");
//从文本中获取卫星的数据
WeixingImpl wx = new WeixingImpl();
ToponetImpl tp = new ToponetImpl();
SimData sd = new SimData();
//tp.delHistory();
File file = new File("F:\\ymwang\\topusim_1.txt");
List<WeiXingData> wxData = null;
try {
wxData = wx.iniTopo(file, sd.getZhouqi());
} catch (IllegalAccessException e) {
e.printStackTrace();
}
List<String> ipList = new ArrayList<>();
for (int k = 1; k < wxData.size(); k++){
String appName = wxData.get(k).getName();
ipList.add(networkService.getIpListByAppName(11112L, appName).toString()) ;
}
System.out.println("长度:"+ipList.size());
}
@Test
public void getIpList() {
//List<String> ipListS = networkService.getIpListByAppName(11112L, "dfs_server");
//从文本中获取卫星的数据
WeixingImpl wx = new WeixingImpl();
ToponetImpl tp = new ToponetImpl();
SimData sd = new SimData();
//tp.delHistory();
File file = new File("F:\\ymwang\\topusim_1.txt");
List<WeiXingData> wxData = null;
try {
wxData = wx.iniTopo(file, sd.getZhouqi());
} catch (IllegalAccessException e) {
e.printStackTrace();
}
List<String> ipListS = new ArrayList<>();
for (int k = 1; k < wxData.size(); k++){
String appName = wxData.get(k).getName();
ipListS.add(networkService.getIpListByAppName(11112L, appName).toString()) ;
}
String[] ipList = new String[ipListS.size()];
for (int i = 0; i < ipListS.size(); i++) {
if(!ipListS.isEmpty()){
String ip_tmp = ipListS.get(i);
String rep = ip_tmp.replaceAll("[\\[\\]]","");
String[] split_list = rep.split("/");
ipList[i] = split_list[0];
}
}
for (int j = 0; j < ipList.length; j++) {
System.out.println(ipList[j]);
}
}
@Test
public void removeClusterFromEdgeNodeTest() {
clusterService.removeClusterFromEdgeNode(11112L);
}
} }
...@@ -25,7 +25,7 @@ bs: ...@@ -25,7 +25,7 @@ bs:
edgenode: edgenode:
name: random name: random
#ip-prefix: 192.168.31 #ip-prefix: 192.168.31
ip-prefix: 192 ip-prefix: 192.168.31
ipservice: ipservice:
#ip: ipservice.cnf.org:23333 #ip: ipservice.cnf.org:23333
ip: 192.168.31.190:23333 ip: 192.168.31.190:23333
......
bishe.app.app-name=joliu bishe.app.app-name=joliu
#bishe.app.cloud-url=192.168.31.156:9090 #bishe.app.cloud-url=192.168.31.156:9090
bishe.app.cloud-url=192.168.81.1:9091 bishe.app.cloud-url=192.168.31.190:9091
spring.influx.url=http://192.168.0.108:8086 spring.influx.url=http://192.168.0.108:8086
spring.influx.user=admin spring.influx.user=admin
......
...@@ -33,7 +33,7 @@ public class YmwangDfsTests { ...@@ -33,7 +33,7 @@ public class YmwangDfsTests {
SeparatedClusterConfig separatedClusterConfig = new SeparatedClusterConfig(); SeparatedClusterConfig separatedClusterConfig = new SeparatedClusterConfig();
// TODO: 这个ID应该是从借口获取的 // TODO: 这个ID应该是从借口获取的
//separatedClusterConfig.setEdgeNodeId("192.168.31.198:8881"); //separatedClusterConfig.setEdgeNodeId("192.168.31.198:8881");
separatedClusterConfig.setEdgeNodeId("192.168.81.133:18088"); separatedClusterConfig.setEdgeNodeId("192.168.31.198:18088");
ClusterConfig clusterConfigStore = new ClusterConfig(); ClusterConfig clusterConfigStore = new ClusterConfig();
clusterConfigStore.setId(11112l); clusterConfigStore.setId(11112l);
clusterConfigStore.setOwner("joliu"); clusterConfigStore.setOwner("joliu");
......
...@@ -4,4 +4,19 @@ MAINTAINER Joliu<ljo0412@live.com> ...@@ -4,4 +4,19 @@ MAINTAINER Joliu<ljo0412@live.com>
RUN yum install -y http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm &&\ RUN yum install -y http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm &&\
yum install -y iperf iptables tc yum install -y iperf iptables tc
RUN yum install -y net-tools.x86_64 RUN yum install -y net-tools.x86_64
RUN mkdir -p /tmp/static
COPY jdk1.8.0_111 jdk1.8.0_111
ENV JAVA_HOME=/jdk1.8.0_111
ENV PATH=$JAVA_HOME/bin:$PATH
ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ADD dfs-transfer-server-1.0-SNAPSHOT.jar dfs-server.jar
RUN echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf RUN echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
ENTRYPOINT ["java","-jar","dbc_client.jar"]
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