Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-WIC-Cnf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
CommunityXG
OpenXG-WIC-Cnf
Commits
6e3cac7c
Commit
6e3cac7c
authored
Mar 14, 2021
by
jthu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重新添加路径计算module群 更新 正式测通版本
parent
b65532d4
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
736 additions
and
68 deletions
+736
-68
apps/cnf-pathComp-app/app-docker-cloud/pom.xml
apps/cnf-pathComp-app/app-docker-cloud/pom.xml
+16
-0
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/config/BpsoConfig.java
...oud/src/main/java/top/ninwoo/cloud/config/BpsoConfig.java
+6
-0
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/controller/DataCtrl.java
...d/src/main/java/top/ninwoo/cloud/controller/DataCtrl.java
+14
-10
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/bpso/Bpso.java
...oud/src/main/java/top/ninwoo/cloud/service/bpso/Bpso.java
+49
-16
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/cpcTrans/CpcTrans.java
...main/java/top/ninwoo/cloud/service/cpcTrans/CpcTrans.java
+20
-11
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/findService/FindServiceImpl.java
...top/ninwoo/cloud/service/findService/FindServiceImpl.java
+2
-1
apps/cnf-pathComp-app/app-docker-cloud/src/main/resources/application.properties
...pp-docker-cloud/src/main/resources/application.properties
+10
-2
apps/cnf-pathComp-app/app-docker-edge/pom.xml
apps/cnf-pathComp-app/app-docker-edge/pom.xml
+4
-0
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/config/RestConfig.java
...edge/src/main/java/top/ninwoo/edge/config/RestConfig.java
+3
-5
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/controller/DataController.java
.../main/java/top/ninwoo/edge/controller/DataController.java
+10
-3
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/IPService.java
...edge/src/main/java/top/ninwoo/edge/service/IPService.java
+25
-0
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/PicServiceImpl.java
...ain/java/top/ninwoo/edge/service/impl/PicServiceImpl.java
+7
-4
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/picService/CutServiceImpl.java
...p/ninwoo/edge/service/impl/picService/CutServiceImpl.java
+1
-1
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/picService/GreyServiceImpl.java
.../ninwoo/edge/service/impl/picService/GreyServiceImpl.java
+1
-1
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/picService/MergeServiceImpl.java
...ninwoo/edge/service/impl/picService/MergeServiceImpl.java
+1
-1
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/transferService/DistributeServiceImpl.java
...e/service/impl/transferService/DistributeServiceImpl.java
+2
-2
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/transferService/FindServiceImpl.java
...oo/edge/service/impl/transferService/FindServiceImpl.java
+1
-0
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/transferService/TransServiceImpl.java
...o/edge/service/impl/transferService/TransServiceImpl.java
+19
-8
cnf-client-starter/src/main/java/top/ninwoo/bishe/starter/config/ClientProperties.java
...ava/top/ninwoo/bishe/starter/config/ClientProperties.java
+5
-3
cnf-test/src/test/java/top/ninwoo/StaticSateDeploy.java
cnf-test/src/test/java/top/ninwoo/StaticSateDeploy.java
+105
-0
leo60.csv
leo60.csv
+435
-0
No files found.
apps/cnf-pathComp-app/app-docker-cloud/pom.xml
View file @
6e3cac7c
...
...
@@ -48,5 +48,21 @@
</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
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/config/BpsoConfig.java
View file @
6e3cac7c
...
...
@@ -15,5 +15,11 @@ public class BpsoConfig {
//
public
String
k
;
public
String
D
;
public
String
c
;
public
String
dev
;
public
String
nt
;
}
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/controller/DataCtrl.java
View file @
6e3cac7c
...
...
@@ -49,21 +49,25 @@ public class DataCtrl {
//包装图片
Picture
picture
=
cpcTrans
.
packagePic
(
ImageIO
.
read
(
file
.
getInputStream
()));
//包装数据包
//倘若数据不只是0-9之内,应用,隔开
String
[]
path_1s
=
path_1
.
split
(
","
);
String
[]
path_2s
=
path_2
.
split
(
","
);
String
[]
funs
=
fun
.
split
(
","
);
//得到链路图
int
length
=
path_2
.
length
();
int
func_length
=
fun
.
length
();
int
[]
func
=
new
int
[
fun
c_
length
];
int
[][]
link
=
new
int
[
2
][
length
];
/*
int length = path_2.length();
int func_length = fun.length();
*/
int
[]
func
=
new
int
[
fun
s
.
length
];
int
[][]
link
=
new
int
[
2
][
path_1s
.
length
];
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
link
[
0
][
i
]
=
path_1
.
charAt
(
i
)
-
'0'
;
for
(
int
i
=
0
;
i
<
path_1s
.
length
;
i
++)
{
link
[
0
][
i
]
=
Integer
.
parseInt
(
path_1s
[
i
])
;
}
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
link
[
1
][
i
]
=
path_2
.
charAt
(
i
)
-
'0'
;
for
(
int
i
=
0
;
i
<
path_1s
.
length
;
i
++)
{
link
[
1
][
i
]
=
Integer
.
parseInt
(
path_2s
[
i
])
;
}
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
func
[
i
]
=
fun
.
charAt
(
i
)
-
'0'
;
for
(
int
i
=
0
;
i
<
funs
.
length
;
i
++)
{
func
[
i
]
=
Integer
.
parseInt
(
funs
[
i
])
;
}
...
...
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/bpso/Bpso.java
View file @
6e3cac7c
...
...
@@ -28,11 +28,11 @@ public class Bpso {
* 业务参数
*/
//数据量MB?
static
double
[]
D
=
{
10
,
10
,
1
,
3
,
0.8
,
2.4
,
0.7
,
1.2
};
//
static double[] D = {10, 10, 1, 3, 0.8, 2.4, 0.7, 1.2};
static
double
[]
D
;
//子任务数
static
int
c
=
8
;
//8
//
static int c = 8; //8
static
int
c
;
//子任务依赖关系 边
static
int
[][]
link
;
//
//task编号
...
...
@@ -42,17 +42,20 @@ public class Bpso {
//固定映射任务数==起始任务+终止任务
static
final
int
C_STABLE
=
2
;
//实际需映射任务数
static
int
n1
=
c
-
C_STABLE
;
/*
//实际需映射任务数
static int n1 = c - C_STABLE;
*/
/*
* 网络参数
*/
//设备数
public
static
int
num
=
12
;
// public static int num = 12;
public
static
int
num
;
//设备计算能力参数s GB/s
static
double
[]
nt
=
{
1.112341341313
,
0.5196272109574349
,
0.675827555541419
,
0.7637869915859579
,
0.7998320296858645
,
0.638652700648973
,
0.6396760676518485
,
0.5615337810185533
,
0.6356797503522186
,
0.8266103444996542
,
0.8102279249524735
,
1.17057296148341216
};
//32节点
// static double[] nt = {1.112341341313, 0.5196272109574349, 0.675827555541419, 0.7637869915859579, 0.7998320296858645,
// 0.638652700648973, 0.6396760676518485, 0.5615337810185533, 0.6356797503522186, 0.8266103444996542,0.8102279249524735, 1.17057296148341216}; //32节点
static
double
[]
nt
;
//时隙大小
public
static
double
slot
=
100
*
1000
;
//时隙数目
...
...
@@ -67,8 +70,8 @@ public class Bpso {
static
final
int
N_STABLE
=
2
;
//实际可映射设备数
static
int
n2
;
//单时隙可映射设备数
static
int
mapdev
=
num
-
N_STABLE
;
/*
//单时隙可映射设备数
static int mapdev = num - N_STABLE ;
*/
/*
* BPSO参数
*/
...
...
@@ -90,7 +93,7 @@ public class Bpso {
//节点最终分配结果
public
static
int
[]
result
=
new
int
[
c
]
;
public
static
int
[]
result
;
//节点间最短路由
public
static
Stack
[]
route
;
//业务发起时刻
...
...
@@ -102,8 +105,14 @@ public class Bpso {
public
void
doMapApp
(
int
[][]
link1
,
int
[]
func1
,
BpsoConfig
bpsoConfig
)
throws
ParseException
{
k
=
Integer
.
parseInt
(
bpsoConfig
.
getK
());
n
=
Integer
.
parseInt
(
bpsoConfig
.
getN
());
// 加载粒子群配置项 种群 迭代 任务 设备等参数
parseConfig
(
bpsoConfig
);
//实际需映射任务数
int
n1
=
c
-
C_STABLE
;
//单时隙可映射设备数
int
mapdev
=
num
-
N_STABLE
;
//节点最终分配结果
result
=
new
int
[
c
];
link
=
link1
;
func
=
func1
;
route
=
new
Stack
[
link
[
0
].
length
+
1
];
...
...
@@ -113,12 +122,12 @@ public class Bpso {
//slotnum = 3;
dev
=
num
*
slotnum
;
n2
=
dev
-
N_STABLE
*
slotnum
;
//1组装最短路矩阵
//1组装最短路矩阵
加权时间扩展图
double
[][]
edgeWeight
=
Wteg
.
getWteg
(
num
*
slotnum
);
InterSlotDijstraV2
dijs
=
new
InterSlotDijstraV2
(
num
,
slot
);
InterSlotDijstraV2
.
pathRecord
pathRecord
=
dijs
.
dijstra
(
edgeWeight
,
testLatency
);
//2最短路由矩阵
//2最短路由矩阵
时间扩展图最短路由时延矩阵
double
[][]
lt
=
pathRecord
.
pathWeight
;
lastHop
=
pathRecord
.
lastHop
;
for
(
int
j
=
0
;
j
<
lastHop
.
length
;
j
++){
...
...
@@ -130,6 +139,7 @@ public class Bpso {
}
}
}
// 一跳路由转发表
String
[][]
routetest
=
new
String
[
lastHop
.
length
][
lastHop
[
0
].
length
];
for
(
int
l
=
0
;
l
<
lastHop
.
length
/
num
;
l
++)
{
for
(
int
i
=
l
*
num
;
i
<
num
+
l
*
num
;
i
++)
{
...
...
@@ -205,6 +215,26 @@ public class Bpso {
}
}
private
void
parseConfig
(
BpsoConfig
bpsoConfig
)
{
k
=
Integer
.
parseInt
(
bpsoConfig
.
getK
());
n
=
Integer
.
parseInt
(
bpsoConfig
.
getN
());
c
=
Integer
.
parseInt
(
bpsoConfig
.
getC
());
num
=
Integer
.
parseInt
(
bpsoConfig
.
getDev
());
String
bpsoConfigD
=
bpsoConfig
.
getD
();
String
[]
bpsoConfigDs
=
bpsoConfigD
.
split
(
","
);
double
[]
Dc
=
new
double
[
c
];
for
(
int
i
=
0
;
i
<
c
;
i
++){
Dc
[
i
]
=
Double
.
parseDouble
(
bpsoConfigDs
[
i
]);
}
D
=
Dc
;
String
[]
bpsoConfigDevs
=
bpsoConfig
.
getNt
().
split
(
","
);
double
[]
ntdev
=
new
double
[
num
];
for
(
int
i
=
0
;
i
<
num
;
i
++){
ntdev
[
i
]
=
Double
.
parseDouble
(
bpsoConfigDevs
[
i
]);
}
nt
=
ntdev
;
}
/*
* 粒子群算法主方法
*/
...
...
@@ -247,6 +277,9 @@ public class Bpso {
par_array
[
j
]
=
temp
[
0
];
best_par
=
temp
[
1
];
}
log
.
info
(
"当前迭代次数:"
+
i
);
log
.
info
(
"最佳粒子时延:"
+(
1
/
best_par
.
fit
));
}
return
best_par
;
}
...
...
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/cpcTrans/CpcTrans.java
View file @
6e3cac7c
...
...
@@ -81,17 +81,19 @@ public class CpcTrans implements TransService {
//task编号
//int[] func = {0, 2, 3, 3, 1, 1, 4, 0};
//任务表
String
[]
tasks
=
{
"start/end"
,
"binaryProcess"
,
"cutProcess"
,
"greyProcess"
,
"mergeProcess"
,
"distributeProcess"
};
String
[]
tasks
=
{
"start/end"
,
"binaryProcess"
,
"cutProcess"
,
"greyProcess"
,
"mergeProcess"
,
"tailorProcess"
,
"distributeProcess"
};
Bpso
doMap
=
new
Bpso
();
doMap
.
doMapApp
(
link
,
func
,
bpsoConfig
);
//映射结果
int
[]
result
=
doMap
.
result
;
System
.
out
.
println
(
"optimal mapping scheme"
+
Arrays
.
toString
(
result
));
//
System.out.println("optimal mapping scheme"+ Arrays.toString(result));
log
.
info
(
"optimal mapping scheme"
+
Arrays
.
toString
(
result
));
//路径表
String
[]
path
=
new
String
[
link
[
0
].
length
];
/* int sateEndNum = result[result.length - 1];
int sateStartNum = result[0];*/
for
(
int
tm
=
0
;
tm
<
link
[
0
].
length
;
tm
++){
String
startHop
=
"sate"
+
result
[
link
[
0
][
tm
]];
String
endHop
=
"sate"
+
result
[
link
[
1
][
tm
]];
...
...
@@ -101,10 +103,10 @@ public class CpcTrans implements TransService {
}
//要修改
//todo
if
(
endHop
.
equals
(
"sate31"
)){
/* if(endHop.equals("sate"+sateEndNum
)){
path[tm] = startHop +"->"+ "D2";
continue;
}
}
*/
//左为边起点,右为边终点
path
[
tm
]
=
startHop
+
"->"
+
endHop
;
}
...
...
@@ -120,10 +122,10 @@ public class CpcTrans implements TransService {
}
//要修改
//todo
if
(
hop
.
equals
(
"sate31"
)){
/* if(hop.equals("sate"+sateEndNum
)){
taskTable.put("D2",tasks[func[tm]]);
continue;
}
}
*/
taskTable
.
put
(
hop
,
tasks
[
func
[
tm
]]);
}
...
...
@@ -141,9 +143,9 @@ public class CpcTrans implements TransService {
}
//要修改
//todo
if
(
route
[
i
][
j
].
equals
(
"sate31"
)){
/* if (route[i][j].equals("sate"+(sateEndNum-1)
)){
route[i][j]="D2";
}
}
*/
}
}
log
.
info
(
"跨时隙路由表:"
+
Arrays
.
deepToString
(
route
));
...
...
@@ -176,7 +178,9 @@ public class CpcTrans implements TransService {
//ip池
// dataPackage.setIpPool(findService.findIPool());
String
[]
routeself
=
findService
.
findRoute
(
dataPackage
.
getCurrentSataHop
(),
dataPackage
.
getRoute
());
log
.
info
(
"该节点转发路由表:"
+
Arrays
.
toString
(
routeself
));
ArrayList
<
String
>
destinSataHops
=
findService
.
findDestinSataHops
(
path
,
"D1"
);
log
.
info
(
"该子任务边终止卫星:"
+
destinSataHops
);
for
(
String
des
:
destinSataHops
)
{
CnfData
transferPackage
=
dataPackage
;
//目的
...
...
@@ -187,10 +191,12 @@ public class CpcTrans implements TransService {
transferPackage
.
setCurrentSataHop
(
transferPackage
.
getNextSataHop
());
//ip
String
ip
=
ipService
.
getIpByAppName
(
transferPackage
.
getNextSataHop
());
// log.info("下一跳ip地址:"+ip);
transferPackage
.
setNextIPHop
(
ip
);
// transferPackage.setNextIPHop(findService.findIp(transferPackage.getNextSataHop(),transferPackage.getIpPool()));
//终止节点
transferPackage
.
setEndSateHop
(
"sate11"
);
int
SerialsNum
=
Bpso
.
num
-
1
;
transferPackage
.
setEndSateHop
(
"sate"
+
SerialsNum
);
//返回一个数据包
cnfDatas
.
add
(
transferPackage
);
}
...
...
@@ -210,12 +216,15 @@ public class CpcTrans implements TransService {
*/
@Override
public
String
sendData
(
CnfData
cnfData
,
String
url
)
{
String
IP
=
url
+
":8083"
;
String
IP
=
"172.17.0.2:8083"
;
// String IP =url+":8083";
log
.
info
(
"目标地址:"
+
IP
);
ResponseEntity
<
String
>
res
=
restTemplate
.
postForEntity
(
"http://"
+
IP
+
"/transfer"
,
cnfData
,
String
.
class
);
if
(!
res
.
getStatusCode
().
is2xxSuccessful
())
{
throw
new
RuntimeException
(
"send Error!"
);
}
return
"sucess"
;
return
"suc
c
ess"
;
}
/**
...
...
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/findService/FindServiceImpl.java
View file @
6e3cac7c
...
...
@@ -82,7 +82,8 @@ public class FindServiceImpl implements FindService {
@Override
public
String
findNextHop
(
String
destinSataHop
,
String
[]
route
)
{
int
index
=
Integer
.
parseInt
(
destinSataHop
.
split
(
"sate"
)[
1
]);
return
route
[
index
-
1
];
// return route[index-1];
return
"sate1"
;
}
@Override
...
...
apps/cnf-pathComp-app/app-docker-cloud/src/main/resources/application.properties
View file @
6e3cac7c
...
...
@@ -15,6 +15,14 @@ spring.servlet.multipart.max-request-size=1024000000000MB
# 粒子群配置
# 迭代次数
bps.k
=
50
0
bps.k
=
50
# 种群规模
bps.n
=
10
\ No newline at end of file
bps.n
=
10
# 任务总数
bps.c
=
10
# 子任务数据量 与任务总数一致
bps.D
=
10,10,1,3,0.8,2.4,0.7,1.2,0.4,1.2
# 设备总数
bps.dev
=
12
# 设备计算能力 与设备数量一致
bps.nt
=
1,1.112341341313,0.5196272109574349,0.675827555541419,0.7637869915859579,0.7998320296858645,0.638652700648973,0.6396760676518485,0.5615337810185533,0.6356797503522186,0.8266103444996542,0.8102279249524735,1.17057296148341216,1
\ No newline at end of file
apps/cnf-pathComp-app/app-docker-edge/pom.xml
View file @
6e3cac7c
...
...
@@ -25,6 +25,10 @@
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</dependency>
<dependency>
<groupId>
top.ninwoo
</groupId>
<artifactId>
cnf-client-starter
</artifactId>
</dependency>
</dependencies>
<build>
...
...
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/config/RestConfig.java
View file @
6e3cac7c
package
top.ninwoo.edge.config
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.client.ClientHttpRequestFactory
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
import
org.springframework.web.client.RestTemplate
;
@Configuration
//
@Configuration
public
class
RestConfig
{
private
ApplicationContext
applicationContext
=
null
;
@Bean
//
@Bean
public
RestTemplate
restTemplate
(
ClientHttpRequestFactory
factory
)
{
return
new
RestTemplate
(
factory
);
}
@Bean
//
@Bean
ClientHttpRequestFactory
simpleClientHttpRequestFactory
()
{
SimpleClientHttpRequestFactory
factory
=
new
SimpleClientHttpRequestFactory
();
factory
.
setReadTimeout
(
1000000
);
...
...
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/controller/DataController.java
View file @
6e3cac7c
...
...
@@ -56,6 +56,7 @@ public class DataController {
* pass 当前节点仅转发数据包
* */
String
res
=
transService
.
parseData
(
cnfData
);
log
.
info
(
"current task status:"
+
res
);
FindServiceImpl
findService
=
new
FindServiceImpl
();
switch
(
res
)
{
...
...
@@ -66,9 +67,12 @@ public class DataController {
//装包 get0很奇怪
CnfData
newtransData
=
transService
.
packageData
(
cnfData
).
get
(
0
);
System
.
out
.
println
(
"nextsataHop: "
+
newtransData
.
getNextSataHop
());
log
.
info
(
"next sate name: "
+
newtransData
.
getNextSataHop
());
// System.out.println("nextsataHop: "+newtransData.getNextSataHop());
//发包
log
.
info
(
"next sate ip: "
+
newtransData
.
getNextIPHop
());
transService
.
sendData
(
newtransData
,
newtransData
.
getNextIPHop
());
log
.
info
(
"transfer success!"
);
System
.
out
.
println
(
"transfer sucess"
);
return
"transfer sucess"
;
...
...
@@ -82,6 +86,7 @@ public class DataController {
//储存图片节点
saveToFile
(
cnfData
.
getPicture
(),
"/pic/out-"
+
cnfData
.
getPicture
().
getSliceId
()+
".jpg"
);
String
message
=
cnfData
.
getCurrentSataHop
();
log
.
info
(
"current node is the end node:"
+
message
);
transService
.
backEarth
(
message
);
System
.
out
.
println
(
"end hop"
);
return
"end"
;
...
...
@@ -93,18 +98,20 @@ public class DataController {
//完成路径计算
case
"pathComputing"
:
System
.
out
.
println
(
"pathComputing task
sucess
"
);
System
.
out
.
println
(
"pathComputing task
process...
"
);
//完成图像处理功能
picService
.
PicTask
();
//得到图像
LinkedList
<
Picture
>
pictures
=
picService
.
getPicPara
();
//装包
for
(
CnfData
newData:
transService
.
packageData
(
cnfData
,
pictures
))
{
log
.
info
(
"next sate name:"
+
newData
.
getNextSataHop
());
System
.
out
.
println
(
"nextSate: "
+
newData
.
getNextSataHop
());
//发包
transService
.
sendData
(
newData
,
newData
.
getNextIPHop
());
}
System
.
out
.
println
(
"cpc transfer sucess"
);
System
.
out
.
println
(
"cpc transfer success"
);
log
.
info
(
"cpc & transfer success"
);
return
"cpc task&transfer success"
;
case
"distributeProcess"
:
...
...
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/IPService.java
0 → 100644
View file @
6e3cac7c
package
top.ninwoo.edge.service
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
top.ninwoo.bishe.starter.service.NetworkService
;
import
java.util.List
;
@Service
public
class
IPService
{
@Autowired
private
NetworkService
networkService
;
public
String
getIpByAppName
(
String
appName
)
{
List
<
String
>
ipList
=
networkService
.
getIpListByAppName
(
11111
l
,
appName
);
if
(!
ipList
.
isEmpty
()){
String
ip_tmp
=
ipList
.
get
(
0
);
String
[]
split_list
=
ip_tmp
.
split
(
"/"
);
return
split_list
[
0
];
}
return
null
;
}
}
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/PicServiceImpl.java
View file @
6e3cac7c
package
top.ninwoo.edge.service.impl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
top.ninwoo.api.Picture
;
...
...
@@ -8,7 +9,7 @@ import java.lang.reflect.Constructor;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.util.LinkedList
;
@Slf4j
@Service
public
class
PicServiceImpl
{
...
...
@@ -25,7 +26,8 @@ public class PicServiceImpl {
//清空图像
delPicPara
();
// 创建图像处理功能对象
picRes
=
getPicService
(
taskName
,
1
,
picOrigin
);
log
.
info
(
"prepare to invoke "
+
taskName
);
picRes
=
getPicService
(
taskName
,
1
,
picOrigin
);
//sliceNum 参数没用到
picOrigin
.
clear
();
}
...
...
@@ -34,7 +36,8 @@ public class PicServiceImpl {
private
LinkedList
<
Picture
>
getPicService
(
String
taskName
,
int
SliceNum
,
LinkedList
<
Picture
>
picOrigin
)
{
String
in
=
(
taskName
.
substring
(
0
,
1
).
toUpperCase
()
+
taskName
.
substring
(
1
)+
"Impl"
)
.
replace
(
"Process"
,
"Service"
);
String
packagePath
=
"org.elf.cnf.sate.service.impl.picService."
;
String
packagePath
=
"top.ninwoo.edge.service.impl.picService."
;
log
.
info
(
"subtask class name:"
+(
packagePath
+
in
));
LinkedList
<
Picture
>
result
=
null
;
try
{
Class
<?>
name
=
Class
.
forName
(
packagePath
+
in
);
...
...
@@ -79,7 +82,7 @@ public class PicServiceImpl {
taskName
=
task
;
//单图片情况及多图片并且全都收到
if
(
picture
.
getSliceNum
()
==
picOrigin
.
size
()
||
!
taskName
.
equals
(
"mergeProcess"
)){
return
"sucess"
;
return
"suc
c
ess"
;
}
//多图片未完全收到
else
{
...
...
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/picService/
Spli
tServiceImpl.java
→
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/picService/
Cu
tServiceImpl.java
View file @
6e3cac7c
...
...
@@ -9,7 +9,7 @@ import java.util.LinkedList;
import
static
top
.
ninwoo
.
edge
.
service
.
impl
.
fileService
.
SaveFile
.
loadPicture
;
import
static
top
.
ninwoo
.
edge
.
service
.
impl
.
fileService
.
SaveFile
.
saveToFile
;
public
class
Spli
tServiceImpl
implements
PicService
{
public
class
Cu
tServiceImpl
implements
PicService
{
public
static
LinkedList
<
Picture
>
picPara
=
new
LinkedList
<>();
@Override
public
LinkedList
<
Picture
>
picProcess
(
int
num
,
LinkedList
<
Picture
>
pictures
)
{
...
...
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/picService/Gr
a
yServiceImpl.java
→
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/picService/Gr
e
yServiceImpl.java
View file @
6e3cac7c
...
...
@@ -9,7 +9,7 @@ import java.util.LinkedList;
import
static
top
.
ninwoo
.
edge
.
service
.
impl
.
fileService
.
SaveFile
.
loadPicture
;
import
static
top
.
ninwoo
.
edge
.
service
.
impl
.
fileService
.
SaveFile
.
saveToFile
;
public
class
Gr
a
yServiceImpl
implements
PicService
{
public
class
Gr
e
yServiceImpl
implements
PicService
{
public
static
LinkedList
<
Picture
>
picPara
=
new
LinkedList
<>();
@Override
public
LinkedList
<
Picture
>
picProcess
(
int
num
,
LinkedList
<
Picture
>
pictures
)
{
...
...
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/picService/Mer
a
geServiceImpl.java
→
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/picService/MergeServiceImpl.java
View file @
6e3cac7c
...
...
@@ -9,7 +9,7 @@ import java.util.LinkedList;
import
static
top
.
ninwoo
.
edge
.
service
.
impl
.
fileService
.
SaveFile
.
loadPicture
;
import
static
top
.
ninwoo
.
edge
.
service
.
impl
.
fileService
.
SaveFile
.
saveToFile
;
public
class
Mer
a
geServiceImpl
implements
PicService
{
public
class
MergeServiceImpl
implements
PicService
{
public
static
LinkedList
<
Picture
>
picPara
=
new
LinkedList
<>();
@Override
public
LinkedList
<
Picture
>
picProcess
(
int
num
,
LinkedList
<
Picture
>
pictures
)
{
...
...
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/transferService/DistributeServiceImpl.java
View file @
6e3cac7c
...
...
@@ -9,7 +9,7 @@ import top.ninwoo.api.CnfData;
import
top.ninwoo.api.Picture
;
import
top.ninwoo.api.TacticsCtl
;
import
top.ninwoo.edge.service.DistributeService
;
import
top.ninwoo.edge.service.impl.picService.Gr
a
yServiceImpl
;
import
top.ninwoo.edge.service.impl.picService.Gr
e
yServiceImpl
;
import
javax.annotation.Resource
;
import
javax.imageio.ImageIO
;
...
...
@@ -148,7 +148,7 @@ public class DistributeServiceImpl implements DistributeService {
@Override
public
String
packageHasCut
(
CnfData
cnfData
,
Picture
picture
)
{
System
.
out
.
println
(
"=====packageHasCut start"
);
Gr
ayServiceImpl
picService
=
new
Gra
yServiceImpl
();
Gr
eyServiceImpl
picService
=
new
Gre
yServiceImpl
();
LinkedList
<
Picture
>
pic
=
new
LinkedList
<>();
pic
.
add
(
picture
);
...
...
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/transferService/FindServiceImpl.java
View file @
6e3cac7c
...
...
@@ -143,6 +143,7 @@ public class FindServiceImpl implements FindService {
//找到本卫星的路由
private
String
[]
findCurrentRoute
(
String
sataname
,
String
[][]
routeTable
){
// 这里减1是为了将卫星真实编号与索引值对应
int
index
=
Integer
.
parseInt
(
sataname
.
split
(
"sate"
)[
1
]);
// System.out.println(index);
return
routeTable
[
index
];
...
...
apps/cnf-pathComp-app/app-docker-edge/src/main/java/top/ninwoo/edge/service/impl/transferService/TransServiceImpl.java
View file @
6e3cac7c
package
top.ninwoo.edge.service.impl.transferService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
...
...
@@ -9,14 +10,17 @@ import top.ninwoo.api.CnfData;
import
top.ninwoo.api.Picture
;
import
top.ninwoo.api.TacticsCtl
;
import
top.ninwoo.edge.service.FindService
;
import
top.ninwoo.edge.service.IPService
;
import
top.ninwoo.edge.service.TransferService
;
import
top.ninwoo.edge.service.impl.PicServiceImpl
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.LinkedList
;
@Service
@Slf4j
public
class
TransServiceImpl
implements
TransferService
{
@Resource
...
...
@@ -28,6 +32,9 @@ public class TransServiceImpl implements TransferService {
@Autowired
private
PicServiceImpl
picService
;
@Autowired
private
IPService
ipService
;
@Override
public
String
sendData
(
CnfData
cnfData
,
String
url
){
...
...
@@ -37,7 +44,7 @@ public class TransServiceImpl implements TransferService {
throw
new
RuntimeException
(
"send Error!"
);
}
System
.
out
.
println
(
"send picRes sucess"
);
return
"sucess"
;
return
"suc
c
ess"
;
}
/**
...
...
@@ -79,6 +86,9 @@ public class TransServiceImpl implements TransferService {
}
//是否为该边节点
log
.
info
(
"current sate: "
+
cnfData
.
getCurrentSataHop
());
log
.
info
(
"Destination sate: "
+
cnfData
.
getDestinSataHop
());
if
(
cnfData
.
getCurrentSataHop
().
equals
(
cnfData
.
getDestinSataHop
())){
// 通过任务分配表和当前卫星名寻找当前任务
String
task
=
findService
.
findTask
(
cnfData
.
getCurrentSataHop
(),
cnfData
.
getTaskTable
());
...
...
@@ -97,7 +107,7 @@ public class TransServiceImpl implements TransferService {
// 传输当前任务名及待处理图片,返回节点执行状态
String
status
=
picService
.
setPicOrigin
(
task
,
cnfData
.
getPicture
());
switch
(
status
)
{
case
"sucess"
:
case
"suc
c
ess"
:
//正义执行
return
"pathComputing"
;
case
"wait"
:
...
...
@@ -124,15 +134,15 @@ public class TransServiceImpl implements TransferService {
LinkedList
<
CnfData
>
newData
=
new
LinkedList
<>();
//找到路由
String
[]
route
=
findService
.
findRoute
(
cnfData
.
getCurrentSataHop
(),
cnfData
.
getRoute
());
log
.
info
(
"current sate route: "
+
Arrays
.
toString
(
route
));
CnfData
newDataPackage
=
cnfData
;
//设置下一跳地址
newDataPackage
.
setNextSataHop
(
findService
.
findNextHop
(
newDataPackage
.
getDestinSataHop
(),
route
));
//设置本机地址
newDataPackage
.
setCurrentSataHop
(
newDataPackage
.
getNextSataHop
());
//设置下一跳ip地址
String
nextIP
=
findService
.
findIp
(
newDataPackage
.
getNextSataHop
(),
newDataPackage
.
getIpPool
());
String
nextIP
=
ipService
.
getIpByAppName
(
newDataPackage
.
getNextSataHop
());
//
String nextIP = findService.findIp(newDataPackage.getNextSataHop(),newDataPackage.getIpPool());
newDataPackage
.
setNextIPHop
(
nextIP
);
newData
.
add
(
newDataPackage
);
return
newData
;
...
...
@@ -152,7 +162,7 @@ public class TransServiceImpl implements TransferService {
newDataPackage
.
setTaskTable
(
cnfData
.
getTaskTable
());
newDataPackage
.
setRoute
(
cnfData
.
getRoute
());
newDataPackage
.
setPathTable
(
cnfData
.
getPathTable
());
newDataPackage
.
setIpPool
(
cnfData
.
getIpPool
()
);
//
newDataPackage.setIpPool(cnfData.getIpPool() );
//设置目的地址
newDataPackage
.
setDestinSataHop
(
destinSataHop
);
//设置下一跳地址
...
...
@@ -160,7 +170,8 @@ public class TransServiceImpl implements TransferService {
//设置本机地址
newDataPackage
.
setCurrentSataHop
(
newDataPackage
.
getNextSataHop
());
//设置下一跳ip地址
String
nextIP
=
findService
.
findIp
(
newDataPackage
.
getNextSataHop
(),
newDataPackage
.
getIpPool
());
String
nextIP
=
ipService
.
getIpByAppName
(
newDataPackage
.
getNextSataHop
());
// String nextIP = findService.findIp(newDataPackage.getNextSataHop(),newDataPackage.getIpPool());
newDataPackage
.
setNextIPHop
(
nextIP
);
//放入图片
newDataPackage
.
setPicture
(
pictures
.
removeFirst
());
...
...
@@ -171,7 +182,7 @@ public class TransServiceImpl implements TransferService {
@Override
public
void
backEarth
(
String
message
){
String
IP
=
"192.168.
31.213
"
+
":8082"
;
String
IP
=
"192.168.
253.130
"
+
":8082"
;
String
res
=
restTemplate
.
postForObject
(
"http://"
+
IP
+
"/getDate?message="
,
message
,
String
.
class
);
System
.
out
.
println
(
res
);
}
...
...
cnf-client-starter/src/main/java/top/ninwoo/bishe/starter/config/ClientProperties.java
View file @
6e3cac7c
...
...
@@ -6,9 +6,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@Data
@ConfigurationProperties
(
prefix
=
"bishe.app"
)
public
class
ClientProperties
{
private
String
zookeeperUrl
=
"zookeeper://127.0.0.1:2181"
;
private
String
cloudUrl
=
"127.0.0.1:9300"
;
//"192.168.47.130:9091";
// private String zookeeperUrl = "zookeeper://127.0.0.1:2181";
private
String
zookeeperUrl
=
"zookeeper://192.168.253.1:2181"
;
// private String cloudUrl = "127.0.0.1:9300";//"192.168.47.130:9091";
// private String cloudUrl = "127.0.0.1:9091";
private
String
cloudUrl
=
"192.168.253.1:9091"
;
private
String
appName
=
"default"
;
}
cnf-test/src/test/java/top/ninwoo/StaticSateDeploy.java
0 → 100644
View file @
6e3cac7c
package
top.ninwoo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
top.ninwoo.bishe.starter.service.ClusterService
;
import
top.ninwoo.bishe.starter.service.NetworkService
;
import
top.ninwoo.client.BisheTestMain
;
import
top.ninwoo.common.entity.*
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
@Slf4j
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
BisheTestMain
.
class
)
public
class
StaticSateDeploy
{
@Autowired
private
ClusterService
clusterService
;
@Resource
private
NetworkService
networkService
;
@Test
public
void
testSendSeparateConfig
()
{
int
sateNum
=
12
;
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
// TODO: 这个ID应该是从借口获取的
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.253.130:18088"
);
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
clusterConfig
.
setId
(
11111
l
);
clusterConfig
.
setOwner
(
"joliu"
);
List
<
ContainerDescription
>
cds
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<=
sateNum
;
i
++)
{
ContainerDescription
containerDescription
=
new
ContainerDescription
();
containerDescription
.
setMode
(
"normal"
);
containerDescription
.
setReplicas
(
1
);
DockerContainer
container
=
new
DockerContainer
();
container
.
setName
(
"sate"
+
i
);
container
.
setCommand
(
"sh"
);
container
.
setImage
(
"jthu/pathcomp"
);
containerDescription
.
setDockerContainer
(
container
);
cds
.
add
(
containerDescription
);
}
/* ContainerDescription containerDescription1 = new ContainerDescription();
containerDescription1.setMode("normal");
containerDescription1.setReplicas(1);
DockerContainer container1 = new DockerContainer();
container1.setName("APP");
container1.setCommand("sh");
container1.setImage("jthu/pathcomp");
containerDescription1.setDockerContainer(container1);
cds.add(containerDescription1);*/
clusterConfig
.
setDockers
(
cds
);
NetworkTopology
topo
=
new
NetworkTopology
();
String
[]
devices
=
new
String
[
sateNum
+
1
];
for
(
int
i
=
1
;
i
<=
sateNum
;
i
++)
{
devices
[
i
-
1
]
=
"sate"
+
i
;
}
devices
[
sateNum
]
=
"br:ovs1"
;
log
.
info
(
"设备列表:"
+
Arrays
.
toString
(
devices
));
topo
.
setAppNames
(
devices
);
// 这个参数好像没啥用
topo
.
setTopologyId
(
11
);
int
[][]
devicesTopo
=
new
int
[
sateNum
+
1
][
sateNum
+
1
];
for
(
int
i
=
0
;
i
<=
sateNum
;
i
++)
{
for
(
int
j
=
0
;
j
<=
sateNum
;
j
++)
{
if
(
i
<
sateNum
){
devicesTopo
[
i
][
j
]
=
0
;
}
else
if
(
j
!=
sateNum
){
devicesTopo
[
i
][
j
]
=
1
;
}
else
devicesTopo
[
i
][
j
]
=
0
;
}
}
log
.
info
(
"网络拓扑:"
+
Arrays
.
deepToString
(
devicesTopo
));
topo
.
setTopology
(
devicesTopo
);
// topo.setTopology(new int[][]{{0,0,0},{0,0,0},{1,1,0}});
clusterConfig
.
setTopology
(
topo
);
separatedClusterConfig
.
setClusterConfig
(
clusterConfig
);
clusterConfigs
.
add
(
separatedClusterConfig
);
clusterService
.
sendClusterConfigToEdgeNode
(
clusterConfigs
);
}
@Test
public
void
removeClusterFromEdgeNodeTest
()
{
clusterService
.
removeClusterFromEdgeNode
(
11111L
);
}
}
leo60.csv
0 → 100644
View file @
6e3cac7c
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment