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) {
......
......@@ -62,17 +62,17 @@ public class ServerService {
saveToFile(picture, in_file);
communicationToCloud("==========================");
System.out.println("=========1==========");
// System.out.println("==========================");
communicationToCloud("receive from sate"+sequence.get(0));
System.out.println("=========2==========");
// System.out.println("=========2==========");
cutProcess(eta);
Long l11 = System.currentTimeMillis();
double compCap = compCapacity.get(sequence.get(0)-1);
long length = picture.getData().length/1024;
System.out.println(length);
// System.out.println(length);
// communicationToCloud("picture size"+length);
System.out.println("=========3==========");
// System.out.println("=========3==========");
Long latency = Math.round(length/compCap);
// System.out.println(latency-(l11-fun1time));
try {
......@@ -86,7 +86,7 @@ public class ServerService {
long l111 = System.currentTimeMillis();
communicationToCloud("task 1 spend time: "+(l111- l1)+"ms");
communicationToCloud("--------------------------");
System.out.println("=========4==========");
// System.out.println("=========4==========");
System.out.println("task 1 spend time: "+(l111- l1)+"ms");
System.out.println("---------------------");
......@@ -107,18 +107,21 @@ public class ServerService {
String IP2 = ipService.getIpByAppName(app_name2);
send(dataPackage1, IP2, 2020, startime);
communicationToCloud("transfer next relay sate:"+nextHop);
System.out.println("transfer next relay sate:"+nextHop);
communicationToCloud("==========================");
System.out.println("==========================");
}else{
DataPackage dataPackage1 = combine(2,1, sequence, loc, out_file1, l111, finalFun1time, compCapacity,route,sequence.get(1), tranDelay);
String app_name2 = "sate" + sequence.get(1);
String IP2 = ipService.getIpByAppName(app_name2);
//communicationToCloud("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
// System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
send(dataPackage1, IP2, 2020, startime);
communicationToCloud("transfer next exec sate:"+sequence.get(1));
System.out.println("transfer next relay sate:"+sequence.get(1));
communicationToCloud("==========================");
System.out.println("=====================");
System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
System.out.println("==========================");
// System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
}
}
}).start();
......@@ -135,24 +138,27 @@ public class ServerService {
Integer nextHop = (Integer) route[2].pop();
DataPackage dataPackage2 = combine(3, 2,sequence, loc, out_file2, l111, finalFun1time1, compCapacity,route,nextHop, tranDelay);
String app_name3 = "sate" + nextHop;
System.out.println("transfer next sate:"+nextHop);
// System.out.println("transfer next sate:"+nextHop);
String IP3 = ipService.getIpByAppName(app_name3);
send(dataPackage2, IP3, 2020, startime);
communicationToCloud("transfer next relay sate:"+nextHop);
communicationToCloud("==========================");
System.out.println("transfer next relay sate:"+nextHop);
System.out.println("==========================");
}else{
DataPackage dataPackage2 = combine(3, 2,sequence, loc, out_file2, l111, finalFun1time1, compCapacity,route,sequence.get(2), tranDelay);
String app_name3 = "sate" + sequence.get(2);
String IP3 = ipService.getIpByAppName(app_name3);
//startime += 20*1000;
//communicationToCloud("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
// System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
send(dataPackage2, IP3, 2020, startime);
//communicationToCloud("transmission success!");
System.out.println("transmission success!");
// System.out.println("transmission success!");
communicationToCloud("transfer next exec sate:"+sequence.get(2));
communicationToCloud("==========================");
System.out.println("=====================");
System.out.println("transfer next exec sate:"+sequence.get(2));
System.out.println("==========================");
}
}
}).start();
......@@ -167,9 +173,9 @@ public class ServerService {
long l2t = System.currentTimeMillis();
System.out.println(tranDelay);
// System.out.println(tranDelay);
// System.out.println(tranDelay.get(0));
System.out.println(Currentime);
// System.out.println(Currentime);
transLatency(l2t,Currentime,tranDelay.get(0));
communicationToCloud("==========================");
communicationToCloud("receive from sate"+sequence.get(1));
......@@ -204,21 +210,25 @@ public class ServerService {
Integer nextHop = (Integer) route[3].pop();
DataPackage dataPackage = combine(4,3, sequence, loc, out_file, l21, fun1time, compCapacity, route,nextHop, tranDelay);
String app_name4 = "sate" + nextHop;
System.out.println("transfer next sate:"+nextHop);
// System.out.println("transfer next sate:"+nextHop);
String IP4 = ipService.getIpByAppName(app_name4);
send(dataPackage, IP4, 2020, startime);
communicationToCloud("transfer next relay sate:"+nextHop);
communicationToCloud("==========================");
System.out.println("transfer next relay sate:"+nextHop);
System.out.println("==========================");
}else{
DataPackage dataPackage = combine(4,3, sequence, loc, out_file, l21, fun1time, compCapacity, route,sequence.get(3), tranDelay);
String app_name4 = "sate" + sequence.get(3);
String IP4 = ipService.getIpByAppName(app_name4);
//communicationToCloud("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
// System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
send(dataPackage, IP4, 2020, startime);
System.out.println("transmission success!");
// System.out.println("transmission success!");
communicationToCloud("transfer next exec sate:"+sequence.get(3));
communicationToCloud("==========================");
System.out.println("transfer next exec sate:"+sequence.get(3));
System.out.println("==========================");
/*communicationToCloud("transmission success!");
communicationToCloud("==========================");*/
}
......@@ -241,6 +251,7 @@ public class ServerService {
}
}
communicationToCloud("route delay "+(System.currentTimeMillis()-currentime)+"ms");
System.out.println("route delay "+(System.currentTimeMillis()-currentime)+"ms");
}
public void func3(List<Integer> sequence, Picture picture, String loc, Double eta,
......@@ -285,19 +296,23 @@ public class ServerService {
send(dataPackage, IP5, 2020, startime);
communicationToCloud("transfer next relay sate:"+nextHop);
communicationToCloud("==========================");
System.out.println("transfer next relay sate:"+nextHop);
System.out.println("==========================");
}else{
DataPackage dataPackage = combine(5,4, sequence, loc, out_file, l22, fun1time, compCapacity, route,sequence.get(4), tranDelay);
String app_name5 = "sate" + sequence.get(4);
String IP5 = ipService.getIpByAppName(app_name5);
//communicationToCloud("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
// System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
send(dataPackage, IP5, 2020, startime);
communicationToCloud("transfer next exec sate:"+sequence.get(4));
communicationToCloud("==========================");
System.out.println("transfer next exec sate:"+sequence.get(4));
System.out.println("==========================");
}
sendToCloud(list);
System.out.println("transmission success!");
// System.out.println("transmission success!");
System.out.println("=====================");
}
......@@ -344,6 +359,8 @@ public class ServerService {
send(dataPackage, IP6, 2020, startime);
communicationToCloud("transfer next relay sate:"+nextHop);
communicationToCloud("==========================");
System.out.println("transfer next relay sate:"+nextHop);
System.out.println("==========================");
}else{
DataPackage dataPackage = combine(6,5, sequence, "top", out_file, l22, fun1time, compCapacity, route,sequence.get(5), tranDelay);
String app_name6 = "sate" + sequence.get(5);
......@@ -353,10 +370,12 @@ public class ServerService {
send(dataPackage, IP6, 2020, startime);
communicationToCloud("transfer next exec sate:"+sequence.get(5));
communicationToCloud("==========================");
System.out.println("transfer next exec sate:"+sequence.get(5));
System.out.println("==========================");
}
sendToCloud(list);
System.out.println("transmission success!");
// System.out.println("transmission success!");
System.out.println("=====================");
}
......@@ -403,19 +422,23 @@ public class ServerService {
send(dataPackage, IP6, 2020, startime);
communicationToCloud("transfer next relay sate:"+nextHop);
communicationToCloud("==========================");
System.out.println("transfer next relay sate:"+nextHop);
System.out.println("==========================");
}else{
DataPackage dataPackage = combine(6,6, sequence, "bottom", out_file, l22, fun1time, compCapacity, route,sequence.get(5), tranDelay);
String app_name6 = "sate" + sequence.get(5);
String IP6 = ipService.getIpByAppName(app_name6);
//communicationToCloud("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
// System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
send(dataPackage, IP6, 2020, startime);
communicationToCloud("transfer next exec sate:"+sequence.get(5));
communicationToCloud("==========================");
System.out.println("transfer next exec sate:"+sequence.get(5));
System.out.println("==========================");
}
sendToCloud(list);
System.out.println("transmission success!");
// System.out.println("transmission success!");
System.out.println("=====================");
}
......@@ -474,20 +497,24 @@ public class ServerService {
send(dataPackage, IP7, 2020, startime);
communicationToCloud("transfer next relay sate:"+nextHop);
communicationToCloud("==========================");
System.out.println("transfer next relay sate:"+nextHop);
System.out.println("==========================");
}else{
DataPackage dataPackage = combine(7,7, sequence, null, out_file, l22, fun1time, compCapacity, route,sequence.get(6), tranDelay);
String app_name7 = "sate" + sequence.get(6);
String IP7 = ipService.getIpByAppName(app_name7);
System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
// System.out.println("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
//communicationToCloud("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
send(dataPackage, IP7, 2020, startime);
communicationToCloud("transfer next exec sate:"+sequence.get(6));
communicationToCloud("==========================");
System.out.println("transfer next exec sate:"+sequence.get(6));
System.out.println("==========================");
}
sendToCloud(list);
System.out.println("transmission success!");
// System.out.println("transmission success!");
System.out.println("=====================");
file1.delete();
file2.delete();
......@@ -535,6 +562,7 @@ public class ServerService {
System.out.println("task total time: "+(l22-fun1time)+"ms");
communicationToCloud("task total time: "+(l22-fun1time)+"ms");
communicationToCloud("==========================");
System.out.println("==========================");
sendToCloud(list);
......@@ -586,7 +614,7 @@ public class ServerService {
}
private void sendToCloud(List<String> list) {
Socket ss = null;
/*Socket ss = null;
try {
//ip来自云地址
ss = new Socket(cldurl, cldport);
......@@ -603,7 +631,8 @@ public class ServerService {
} catch (IOException e) {
e.printStackTrace();
}
}
}*/
return;
}
......
......@@ -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