Commit 8f16ab39 authored by Hu Jintao's avatar Hu Jintao

规划业务docker化

parent d97aae8f
......@@ -37,7 +37,7 @@ public class BisheTestMain implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
//解析注解
/*//解析注解
Class<BisheTestMain> bisheTestMainClass = BisheTestMain.class;
path annotation = bisheTestMainClass.getAnnotation(path.class);
String rmCmd = annotation.rmCmd();
......@@ -46,7 +46,7 @@ public class BisheTestMain implements ApplicationRunner {
String saveCmd3 = annotation.saveCmd3();
String saveCmd4 = annotation.saveCmd4();
String saveCmd5 = annotation.saveCmd5();
String savePath = annotation.savePath();
String savePath = annotation.savePath();*/
System.out.println("========================================");
......@@ -100,7 +100,7 @@ public class BisheTestMain implements ApplicationRunner {
}
DataPackage dataPackage = combine(number, routeNumber, sequence, loc, file_path, eta, currentime, fun1time, compCapacity,route,nextHop,tranDelay);
send(dataPackage, targetIp, 2020);
//接收卫星回传信息
/*//接收卫星回传信息
for(int i = 0;i<sequence.size();i++){
ServerSocket serverSocket = new ServerSocket(8900);
//获取数据流
......@@ -146,7 +146,7 @@ public class BisheTestMain implements ApplicationRunner {
e.printStackTrace();
}
System.out.println(saveCmd5);
System.out.println("========================================");
System.out.println("========================================");*/
// System.out.print("File size :");
// System.out.println(dataPackage.getPicture().getData().length / 1000+"k");
......
......@@ -17,7 +17,8 @@ public class CycleTopo {
ToponetImpl tp = new ToponetImpl();
SimData sd = new SimData();
//tp.delHistory();
File file = new File("D:\\LabratoryJavaPro\\codingDownload\\latestCoding\\topusim_1.txt");
File file = new File("topusim_1.txt");
//D:\LabratoryJavaPro\codingDownload\latestCoding\
List<WeiXingData> wxData = null;
try {
wxData = wx.iniTopo(file,sd.getZhouqi());
......@@ -47,7 +48,6 @@ public class CycleTopo {
System.out.println(" ");
}*/
//去掉ovs
//去掉ovs
double[][] topoNet = new double[30][30];
for (int p = 0;p<topoNet.length;p++){
......@@ -65,11 +65,10 @@ public class CycleTopo {
TopoStore.put(i,topoNet);
}
/*
* 对比全周期拓扑
/* 对比全周期拓扑
* count记录重复拓扑行数
* count2记录不同拓扑数目
* */
*/
int count = 0;
int count2 = 0;
Iterator<Map.Entry<Integer, double[][]>> iterator = TopoStore.entrySet().iterator();
......@@ -96,7 +95,7 @@ public class CycleTopo {
}
}
System.out.println("所有topo完成");
//System.out.println("所有topo完成");
return TopoStore;
}
......
......@@ -133,14 +133,6 @@ public class CycleTopoUnit {
//tp.delHistory();
File file = new File("D:\\LabratoryJavaPro\\codingDownload\\latestCoding\\topusim_1.txt");
List<WeiXingData> wxData = wx.iniTopo(file,sd.getZhouqi());
/*int[][] topoInit = tp.getTopology(wxData,sd);
//输出topo
for(int j = 0;j<topoInit.length;j++){
for(int k= 0;k<topoInit[0].length;k++){
System.out.print(topoInit[j][k] + " ");
}
System.out.println(" ");
} */
sd.setJiange(60);
sd.setC0(3e10);
......@@ -155,14 +147,6 @@ public class CycleTopoUnit {
int[][] topoChange = tp.getTopology(changetp,sd);
/*//输出topo
for(int m = 0;m<topoChange.length;m++){
for(int n= 0;n<topoChange[0].length;n++){
System.out.print(topoChange[m][n] + " ");
}
System.out.println(" ");
}*/
TopoStore.put(i,topoChange);
}
......@@ -197,7 +181,6 @@ public class CycleTopoUnit {
}
}
System.out.println("所有topo完成");
return TopoStore;
}
......
......@@ -23,7 +23,7 @@ public class DoMap {
* 业务参数
*/
//数据量MB?
static double D = 4;
static double[] D = {10, 1, 3, 0.8, 2.4, 0.7, 1.2};
//子任务数
static int c = 7; //8
......@@ -105,16 +105,17 @@ public class DoMap {
InterSlotDijstraV2.pathRecord pathRecord = dijs.dijstra(edgeWeight, testLatency);
//2最短路由矩阵
double[][] lt = pathRecord.pathWeight;
for(int i = 0;i<lt.length;i++){
/*for(int i = 0;i<lt.length;i++){
for(int j = 0;j<lt.length;j++){
lt[i][j] *= D;
}
lt[i][j];
}
}*/
System.out.println("最短路由");
System.out.println(Arrays.deepToString(lt));
for (int i = 0;i<nt.length;i++) {
nt[i] = (D * 1000) / nt[i];
}
//计算时延
/*for (int i = 0;i<nt.length;i++) {
nt[i] = (D[i] * 1000) / nt[i];
}*/
//执行粒子群算法,得路径计算结果
DoMap doMap = new DoMap();
Par best_par = doMap.main_bpso(k, c, dev, n1, n2, D, lt, nt, link, n, s, c1, c2, num, slot, mapdev);
......@@ -306,7 +307,7 @@ public class DoMap {
* 粒子群算法主方法
*/
private Par main_bpso(int k, int c, int dev, int n1, int n2,
double D, double[][] lt, double[] nt, int[][] link, int n,double s, int c1, int c2, int num, double slot, int mapdev) {
double[] D, double[][] lt, double[] nt, int[][] link, int n,double s, int c1, int c2, int num, double slot, int mapdev) {
//初始化粒子群数组
int nn = n1*n2; //粒子维度
Par best_par = new Par(nn, c);
......@@ -537,7 +538,7 @@ public class DoMap {
/**
* 计算适应度值
*/
private double compute_fit(Par par, double D, double[][] lt,
private double compute_fit(Par par, double[] D, double[][] lt,
double[] nt, int c, int dev, int n1, int n2, int nn, int[][] link, int num, double slot) {
//
double[] compu = new double[c];
......@@ -572,9 +573,9 @@ public class DoMap {
compu[0] = 0;
accu[0] = 0 + compu[0];
for (int i = 1; i < c; i++) {
/*for (int i = 1; i < c; i++) {
compu[i] = nt[par.taskfinal[i]%num];
}
}*/
//子任务终点
for (int i = 1; i < c; i++) {
......@@ -591,11 +592,12 @@ public class DoMap {
if (start/num == end/num){
transv = accu[link[0][j]] + lt[start][end];
}else{
transv = lt[start][end]+start/num*slot; //传输跨时隙的话,时延应该是跨时隙后的时刻
transv = (lt[start][end]*D[j])+start/num*slot; //传输跨时隙的话,时延应该是跨时隙后的时刻
}
max_trans = Math.max(max_trans, transv);
}
}
compu[i] = nt[par.taskfinal[i]%num]*D[i];
accu[i] = compu[i] + max_trans;
//modify
if(accu[i] > (par.taskfinal[i]/num + 1)*slot) {
......
......@@ -79,7 +79,7 @@ public class WxTests {
@Test
public void removeClusterFromEdgeNodeTest() {
clusterService.removeClusterFromEdgeNode(11111L);
clusterService.removeClusterFromEdgeNode(11111l);
}
@Test
......@@ -267,7 +267,7 @@ public class WxTests {
SeparatedClusterConfig separatedClusterConfig = new SeparatedClusterConfig();
List<ContainerDescription> cds = new ArrayList<>();
// TODO: 这个ID应该是从借口获取的
separatedClusterConfig.setEdgeNodeId("192.168.190.135:18088");
separatedClusterConfig.setEdgeNodeId("192.168.31.198:18088");
ClusterConfig clusterConfig = new ClusterConfig();
clusterConfig.setId(11111l);
clusterConfig.setOwner("joliu");
......@@ -277,13 +277,25 @@ public class WxTests {
ToponetImpl tp = new ToponetImpl();
SimData sd = new SimData();
//tp.delHistory();
File file = new File("C:\\WorkSpace\\test\\topusim_1.txt");
File file = new File("D:\\LabratoryJavaPro\\codingDownload\\latestCoding\\topusim_1.txt");
// D:\LabratoryJavaPro\codingDownload\latestCoding\
List<WeiXingData> wxData = wx.iniTopo(file,sd.getZhouqi());
int[][] toponet = tp.getTopology(wxData,sd);
//创建容器
for (int k = 0; k < wxData.size(); k++) {
ContainerDescription containerDescription0 = new ContainerDescription();
containerDescription0.setMode("normal");
containerDescription0.setReplicas(1);
DockerContainer container0 = new DockerContainer();
container0.setName(wxData.get(0).getName());
container0.setCommand("sh");
container0.setImage("joliu/networktest:schedule");
containerDescription0.setDockerContainer(container0);
cds.add(containerDescription0);
for (int k = 1; k < wxData.size(); k++) {
ContainerDescription containerDescription = new ContainerDescription();
containerDescription.setMode("normal");
containerDescription.setReplicas(1);
......@@ -291,7 +303,7 @@ public class WxTests {
DockerContainer container = new DockerContainer();
container.setName(wxData.get(k).getName());
container.setCommand("sh");
container.setImage("joliu/networktest");
container.setImage("joliu/networktest:server");
containerDescription.setDockerContainer(container);
cds.add(containerDescription);
......@@ -309,7 +321,7 @@ public class WxTests {
clusterService.sendClusterConfigToEdgeNode(clusterConfigs);
//下发逻辑拓扑
/* //下发逻辑拓扑
clusterService.sendLogicTopoToEdgeNode(clusterConfigs);
out:for (int i = 1; i<600; i++) {
......@@ -335,7 +347,7 @@ public class WxTests {
}
}
System.out.println("所有topo完成");
System.out.println("所有topo完成");*/
}
//测试历史功能,需要提前定义好输出文本地址
......
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