Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Distributed Computing and Network Fusion System
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
WirelessInformationCollaborate
Distributed Computing and Network Fusion System
Commits
b65532d4
Commit
b65532d4
authored
Mar 13, 2021
by
jthu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重新添加路径计算module群 更新
parent
c764f986
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
360 additions
and
97 deletions
+360
-97
apps/cnf-pathComp-app/app-docker-api/src/main/java/top/ninwoo/api/CnfData.java
.../app-docker-api/src/main/java/top/ninwoo/api/CnfData.java
+8
-0
apps/cnf-pathComp-app/app-docker-cloud/pom.xml
apps/cnf-pathComp-app/app-docker-cloud/pom.xml
+14
-2
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
+19
-0
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/config/RestConfig.java
...oud/src/main/java/top/ninwoo/cloud/config/RestConfig.java
+3
-5
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
+131
-32
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/IPService.java
...oud/src/main/java/top/ninwoo/cloud/service/IPService.java
+25
-0
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/TransService.java
.../src/main/java/top/ninwoo/cloud/service/TransService.java
+7
-4
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
+18
-6
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
+44
-17
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/csv/ReadFile.java
.../src/main/java/top/ninwoo/cloud/service/csv/ReadFile.java
+1
-1
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/dbctrans/DbcTrans.java
...main/java/top/ninwoo/cloud/service/dbctrans/DbcTrans.java
+55
-25
apps/cnf-pathComp-app/app-docker-cloud/src/main/resources/application.properties
...pp-docker-cloud/src/main/resources/application.properties
+8
-2
apps/cnf-pathComp-app/app-docker-cloud/src/main/resources/templates/cpcDownload.html
...ocker-cloud/src/main/resources/templates/cpcDownload.html
+17
-0
apps/cnf-pathComp-app/app-docker-cloud/src/main/resources/templates/cpcTrans.html
...p-docker-cloud/src/main/resources/templates/cpcTrans.html
+5
-1
apps/cnf-pathComp-app/app-docker-cloud/src/main/resources/templates/dbcTrans.html
...p-docker-cloud/src/main/resources/templates/dbcTrans.html
+4
-1
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/service/LogicTopoService.java
.../java/top/ninwoo/edgecenter/service/LogicTopoService.java
+1
-1
No files found.
apps/cnf-pathComp-app/app-docker-api/src/main/java/top/ninwoo/api/CnfData.java
View file @
b65532d4
...
...
@@ -36,4 +36,12 @@ public class CnfData implements Serializable {
private
String
endSateHop
;
//源节点
private
String
oriSateHop
;
//任务发起时刻
private
long
time
;
//时隙大小
private
long
gap
=
20000
;
//卫星数目
private
int
sataNum
=
10
;
//阈值设定
private
double
size
;
}
apps/cnf-pathComp-app/app-docker-cloud/pom.xml
View file @
b65532d4
...
...
@@ -18,11 +18,19 @@
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-thymeleaf
</artifactId>
<version>
2.1.1.RELEASE
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-autoconfigure
</artifactId>
<version>
2.3.7.RELEASE
</version>
<scope>
compile
</scope>
<version>
2.1.1.RELEASE
</version>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
...
...
@@ -34,6 +42,10 @@
<version>
1.3.2
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
top.ninwoo
</groupId>
<artifactId>
cnf-client-starter
</artifactId>
</dependency>
</dependencies>
...
...
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/config/BpsoConfig.java
0 → 100644
View file @
b65532d4
package
top.ninwoo.cloud.config
;
import
lombok.Data
;
import
lombok.ToString
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
@ConfigurationProperties
(
prefix
=
"bps"
)
@Component
@Data
@ToString
public
class
BpsoConfig
{
//
public
String
n
;
//
public
String
k
;
}
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/config/RestConfig.java
View file @
b65532d4
package
top.ninwoo.cloud.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
(
20000
);
...
...
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/controller/DataCtrl.java
View file @
b65532d4
...
...
@@ -2,6 +2,7 @@ package top.ninwoo.cloud.controller;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
@@ -15,6 +16,8 @@ import javax.annotation.Resource;
import
javax.imageio.ImageIO
;
import
java.io.*
;
import
java.text.ParseException
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -27,53 +30,84 @@ public class DataCtrl {
@Autowired
DbcTrans
dbcTrans
;
private
long
starTime
;
@Resource
private
RestTemplate
restTemplate
;
@RequestMapping
(
value
=
"/cpcTrans"
,
method
=
RequestMethod
.
GET
)
public
String
upload
()
{
public
String
Cpc
upload
()
{
return
"cpcTrans"
;
}
@RequestMapping
(
value
=
"/cpcTrans"
)
@ResponseBody
public
String
CpcTrans
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
"
fileId"
)
String
fileId
)
{
public
String
CpcTrans
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
"
path_1"
)
String
path_1
,
@RequestParam
(
"path_2"
)
String
path_2
,
@RequestParam
(
"func"
)
String
fun
)
{
if
(!
file
.
isEmpty
()){
try
{
//包装图片
Picture
picture
=
cpcTrans
.
packagePic
(
ImageIO
.
read
(
file
.
getInputStream
())
,
fileId
);
Picture
picture
=
cpcTrans
.
packagePic
(
ImageIO
.
read
(
file
.
getInputStream
()));
//包装数据包
LinkedList
<
CnfData
>
cnfData
=
cpcTrans
.
packageData
(
picture
);
//得到链路图
int
length
=
path_2
.
length
();
int
func_length
=
fun
.
length
();
int
[]
func
=
new
int
[
func_length
];
int
[][]
link
=
new
int
[
2
][
length
];
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
link
[
0
][
i
]
=
path_1
.
charAt
(
i
)
-
'0'
;
}
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
link
[
1
][
i
]
=
path_2
.
charAt
(
i
)
-
'0'
;
}
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
func
[
i
]
=
fun
.
charAt
(
i
)
-
'0'
;
}
LinkedList
<
CnfData
>
cnfData
=
cpcTrans
.
packageData
(
picture
,
link
,
func
);
//发送
for
(
CnfData
data
:
cnfData
)
{
cpcTrans
.
sendData
(
data
,
data
.
getNextIPHop
());
}
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
return
"上传失败,"
+
e
.
getMessage
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
"上传失败,"
+
e
.
getMessage
();
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
"上传成功!"
;
}
else
{
return
"上传失败,因为文件是空的."
;
}
}
@RequestMapping
(
value
=
"/dbcTrans"
,
method
=
RequestMethod
.
GET
)
public
String
Dbcupload
()
{
return
"dbcTrans"
;
}
@PostMapping
(
value
=
"/dbcTrans"
)
@ResponseBody
public
String
DbcTrans
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
"fileId"
)
String
fileId
)
{
public
String
DbcTrans
(
@RequestParam
(
"file"
)
MultipartFile
file
,
@RequestParam
(
"fileId"
)
String
fileId
,
@RequestParam
(
"size"
)
double
size
)
{
if
(!
file
.
isEmpty
()){
try
{
Date
time
=
new
Date
();
starTime
=
time
.
getTime
();
System
.
out
.
println
(
"开始分散计算: "
+
starTime
);
//包装图片
Picture
picture
=
dbcTrans
.
packagePic
(
ImageIO
.
read
(
file
.
getInputStream
())
,
fileId
);
Picture
picture
=
dbcTrans
.
packagePic
(
ImageIO
.
read
(
file
.
getInputStream
()));
//包装数据包
LinkedList
<
CnfData
>
cnfData
=
dbcTrans
.
packageData
(
picture
);
LinkedList
<
CnfData
>
cnfData
=
dbcTrans
.
packageData
(
picture
,
"sate1"
);
//发送
for
(
CnfData
data
:
cnfData
)
{
data
.
setTime
(
starTime
);
data
.
setSize
(
size
);
System
.
out
.
println
(
data
.
getGap
());
dbcTrans
.
sendData
(
data
,
data
.
getNextIPHop
());
}
}
catch
(
FileNotFoundException
e
)
{
...
...
@@ -91,9 +125,19 @@ public class DataCtrl {
}
}
@GetMapping
(
value
=
"/getImg"
)
@RequestMapping
(
value
=
"/cpcDownload"
,
method
=
RequestMethod
.
GET
)
public
String
Cpcdownload
(
Model
model
)
{
GetCpcImg
();
model
.
addAttribute
(
"fileName"
,
"cpc_images/sate11-0.jpg"
);
return
"cpcDownload"
;
}
@GetMapping
(
value
=
"/getcpcImg"
)
@ResponseBody
public
String
Get
All
Img
(){
public
String
Get
Cpc
Img
(){
FindServiceImpl
findService
=
new
FindServiceImpl
();
ConcurrentHashMap
<
String
,
String
>
ipool
=
findService
.
findIPool
();
for
(
int
i
=
1
;
i
<
ipool
.
size
()+
1
;
i
++)
{
...
...
@@ -101,12 +145,29 @@ public class DataCtrl {
System
.
out
.
println
(
str
);
String
ip
=
ipool
.
get
(
str
);
System
.
out
.
println
(
ip
);
GetImg
(
str
,
ip
);
String
path
=
"/var/www/html/cpc_images/"
;
GetImg
(
str
,
ip
,
path
);
}
return
"sucess"
;
}
public
void
GetImg
(
String
sataname
,
String
ip
){
@GetMapping
(
value
=
"/getdbcImg"
)
@ResponseBody
public
String
GetDbcImg
(){
FindServiceImpl
findService
=
new
FindServiceImpl
();
ConcurrentHashMap
<
String
,
String
>
ipool
=
findService
.
findIPool
();
for
(
int
i
=
1
;
i
<
ipool
.
size
()+
1
;
i
++)
{
String
str
=
"sate"
+
i
;
System
.
out
.
println
(
str
);
String
ip
=
ipool
.
get
(
str
);
System
.
out
.
println
(
ip
);
String
path
=
"/var/www/html/dbc_images/"
;
GetImg
(
str
,
ip
,
path
);
}
return
"sucess"
;
}
public
void
GetImg
(
String
sataname
,
String
ip
,
String
foldPath
){
String
IP
=
ip
+
":8083"
;
byte
[][]
res
=
restTemplate
.
getForObject
(
"http://"
+
IP
+
"/getImg"
,
byte
[][].
class
);
if
(
res
==
null
){
...
...
@@ -119,7 +180,7 @@ public class DataCtrl {
int
i
=
0
;
for
(
byte
[]
re
:
res
)
{
//得到新路径
String
path
=
"/home/dell/show/public/assets/cpc_images/"
+
sataname
+
"-"
+
i
+
".jpg"
;
String
path
=
foldPath
+
sataname
+
"-"
+
i
+
".jpg"
;
outputStream
=
new
FileOutputStream
(
path
);
//将图片输处到流中
outputStream
.
write
(
re
);
...
...
@@ -158,50 +219,88 @@ public class DataCtrl {
return
cpuCom
;
}
//
获取计算能力
@GetMapping
(
"/
download
"
)
//
卫星复位
@GetMapping
(
"/
reset
"
)
@ResponseBody
public
String
download
()
{
return
null
;
public
String
resetSate
(){
FindServiceImpl
findService
=
new
FindServiceImpl
();
ConcurrentHashMap
<
String
,
String
>
ipool
=
findService
.
findIPool
();
for
(
int
i
=
1
;
i
<
ipool
.
size
();
i
++)
{
String
str
=
"sate"
+
i
;
String
ip
=
ipool
.
get
(
str
);
String
res
=
dbcTrans
.
reset
(
ip
);
System
.
out
.
println
(
str
+
"复位:"
+
res
);
}
return
"sucess"
;
}
//收到图片时的时间
@PostMapping
(
value
=
"/getDate"
)
@ResponseBody
public
String
getDate
(
@RequestParam
(
"message"
)
String
message
)
{
System
.
out
.
println
(
"返回收到信息:"
+
message
);
Date
time
=
new
Date
();
System
.
out
.
println
(
"时间间隔:"
+
(
time
.
getTime
()
-
starTime
));
return
"backEarth sucess"
;
}
//收到图片时的时间
@PostMapping
(
value
=
"/getOverLoad"
)
@ResponseBody
public
boolean
getOverload
(
@RequestBody
HashMap
<
String
,
String
>
param
)
{
System
.
out
.
println
(
"================================"
);
System
.
out
.
println
(
param
.
get
(
"sName"
)+
" :"
+
param
.
get
(
"overLoad"
));
System
.
out
.
println
(
"================================"
);
return
true
;
}
@GetMapping
(
"/testCpc"
)
@ResponseBody
public
String
CpcTest
()
throws
ParseException
,
IOException
{
public
String
CpcTest
()
throws
IOException
{
File
file
=
new
File
(
"C:\\Users\\Elf\\Desktop\\test\\2.jpg"
);
Picture
picture
=
cpcTrans
.
packagePic
(
ImageIO
.
read
(
file
)
,
"123"
);
Picture
picture
=
cpcTrans
.
packagePic
(
ImageIO
.
read
(
file
));
//包装数据包
LinkedList
<
CnfData
>
cnfData
=
cpcTrans
.
packageData
(
picture
);
return
cpcTrans
.
sendData
(
cnfData
.
get
(
0
),
cnfData
.
get
(
0
).
getNextIPHop
());
//LinkedList<CnfData> cnfData = cpcTrans.packageData(picture,null);
//return cpcTrans.sendData(cnfData.get(0),cnfData.get(0).getNextIPHop());
return
null
;
}
@GetMapping
(
"/testDbc"
)
@ResponseBody
public
CnfData
DbcTest
()
throws
IOException
,
ParseException
{
File
file
=
new
File
(
"
C:\\Users\\Elf\\Desktop\\test\\2
.jpg"
);
Picture
picture
=
dbcTrans
.
packagePic
(
ImageIO
.
read
(
file
)
,
"123"
);
LinkedList
<
CnfData
>
cnfData
=
dbcTrans
.
packageData
(
picture
,
"sate
3
"
);
File
file
=
new
File
(
"
/home/elf/test3
.jpg"
);
Picture
picture
=
dbcTrans
.
packagePic
(
ImageIO
.
read
(
file
));
LinkedList
<
CnfData
>
cnfData
=
dbcTrans
.
packageData
(
picture
,
"sate
1
"
);
return
cnfData
.
get
(
0
);
}
@GetMapping
(
"/test"
)
@ResponseBody
public
CnfData
Test1
()
throws
ParseException
,
IOException
{
public
CnfData
Test1
()
throws
IOException
{
File
file
=
new
File
(
"C:\\Users\\Elf\\Desktop\\test\\1.jpg"
);
Picture
picture
=
cpcTrans
.
packagePic
(
ImageIO
.
read
(
file
)
,
"123"
);
Picture
picture
=
cpcTrans
.
packagePic
(
ImageIO
.
read
(
file
));
//包装数据包
LinkedList
<
CnfData
>
cnfData
=
cpcTrans
.
packageData
(
picture
);
//
LinkedList<CnfData> cnfData = cpcTrans.packageData(picture);
//String res = cpcTrans.sendData(cnfData.get(0),"127.0.0.1");
return
cnfData
.
get
(
0
);
//return cnfData.get(0);
return
null
;
}
@GetMapping
(
"/testlt"
)
@ResponseBody
public
String
[][]
LtTest
()
throws
IOException
,
ParseException
{
File
file
=
new
File
(
"C:\\Users\\Elf\\Desktop\\test\\2.jpg"
);
Picture
picture
=
dbcTrans
.
packagePic
(
ImageIO
.
read
(
file
),
"123"
);
Picture
picture
=
dbcTrans
.
packagePic
(
ImageIO
.
read
(
file
));
System
.
out
.
println
(
dbcTrans
.
getIt
().
length
);
return
dbcTrans
.
getIt
();
}
@GetMapping
(
"/testDbc2"
)
@ResponseBody
public
CnfData
DbcTest2
()
throws
IOException
,
ParseException
{
File
file
=
new
File
(
"C:\\Users\\Elf\\Desktop\\test\\2.jpg"
);
Picture
picture
=
dbcTrans
.
packagePic
(
ImageIO
.
read
(
file
));
LinkedList
<
CnfData
>
cnfData
=
dbcTrans
.
packageData
(
picture
,
"sate1"
);
return
cnfData
.
get
(
0
);
}
}
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/IPService.java
0 → 100644
View file @
b65532d4
package
top.ninwoo.cloud.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-cloud/src/main/java/top/ninwoo/cloud/service/TransService.java
View file @
b65532d4
...
...
@@ -12,11 +12,11 @@ public interface TransService {
* 打包picture
* @return picture列表
*/
Picture
packagePic
(
BufferedImage
bufferedImage
,
String
fileId
);
Picture
packagePic
(
BufferedImage
bufferedImage
);
/**
*打包成数据包
*/
LinkedList
<
CnfData
>
packageData
(
Picture
picture
)
throws
ParseException
;
LinkedList
<
CnfData
>
packageData
(
Picture
picture
,
int
[][]
link
,
int
[]
func
)
throws
ParseException
;
LinkedList
<
CnfData
>
packageData
(
Picture
picture
,
String
satename
)
throws
ParseException
;
/**
...
...
@@ -31,5 +31,8 @@ public interface TransService {
* 得到稳态图
*/
String
[][]
getIt
()
throws
ParseException
;
/**
* 卫星复位
*/
String
reset
(
String
url
);
}
\ No newline at end of file
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/bpso/Bpso.java
View file @
b65532d4
package
top.ninwoo.cloud.service.bpso
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
top.ninwoo.cloud.config.BpsoConfig
;
import
top.ninwoo.cloud.service.csv.Wteg
;
import
java.text.ParseException
;
...
...
@@ -13,7 +16,11 @@ import java.util.Stack;
* 目前只允许计算过程跨单时隙
* @jthu
*/
@Component
@Slf4j
public
class
Bpso
{
//最大权值
public
static
final
int
MAXWEIGHT
=
10000
*
1000
;
...
...
@@ -66,9 +73,9 @@ public class Bpso {
* BPSO参数
*/
//粒子群规模
static
int
n
=
1000
;
static
int
n
;
//种群迭代次数
static
int
k
=
500
;
static
int
k
;
//惯性权重,加速因子1,2
static
double
s
=
1.5
;
static
int
c1
=
1
;
static
int
c2
=
1
;
...
...
@@ -77,7 +84,8 @@ public class Bpso {
int
[][]
link
=
{{
0
,
1
,
1
,
2
,
3
,
4
,
5
,
6
},
{
1
,
2
,
3
,
4
,
5
,
6
,
6
,
7
}};
//task编号
int
[]
func
=
{
0
,
2
,
3
,
3
,
1
,
1
,
4
,
0
};
doMapApp
(
link
,
func
);
Bpso
doMap
=
new
Bpso
();
// doMap.doMapApp(link,func);
}
...
...
@@ -92,14 +100,16 @@ public class Bpso {
//路由表
public
static
int
[][]
lastHop
;
public
static
void
doMapApp
(
int
[][]
link1
,
int
[]
func1
)
throws
ParseException
{
public
void
doMapApp
(
int
[][]
link1
,
int
[]
func1
,
BpsoConfig
bpsoConfig
)
throws
ParseException
{
k
=
Integer
.
parseInt
(
bpsoConfig
.
getK
());
n
=
Integer
.
parseInt
(
bpsoConfig
.
getN
());
link
=
link1
;
func
=
func1
;
route
=
new
Stack
[
link
[
0
].
length
+
1
];
for
(
slotnum
=
2
;
slotnum
<=
3
;
slotnum
++){
for
(
slotnum
=
1
;
slotnum
<=
3
;
slotnum
++){
//slotnum = 3;
dev
=
num
*
slotnum
;
n2
=
dev
-
N_STABLE
*
slotnum
;
...
...
@@ -140,7 +150,8 @@ public class Bpso {
//执行粒子群算法,得路径计算结果
Bpso
doMap
=
new
Bpso
();
Par
best_par
=
doMap
.
main_bpso
(
k
,
c
,
dev
,
n1
,
n2
,
D
,
lt
,
nt
,
link
,
n
,
s
,
c1
,
c2
,
num
,
slot
,
mapdev
);
if
(
best_par
.
fit
!=
0
){
if
((
1
/
best_par
.
fit
)
!=
0
){
log
.
info
(
"规划最短时延:"
+(
1
/
best_par
.
fit
));
//赋值节点映射结果
int
itemp
=
0
;
for
(
int
a:
best_par
.
taskfinal
...
...
@@ -204,6 +215,7 @@ public class Bpso {
Par
best_par
=
new
Par
(
nn
,
c
);
Par
[]
par_array
=
new
Par
[
n
];
Par
[]
temp
=
new
Par
[
2
];
//存放返回值
for
(
int
i
=
0
;
i
<
par_array
.
length
;
i
++)
{
par_array
[
i
]
=
new
Par
(
nn
,
c
);
initialize
(
par_array
[
i
],
n1
,
n2
,
c
,
dev
,
num
,
mapdev
);
...
...
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/cpcTrans/CpcTrans.java
View file @
b65532d4
package
top.ninwoo.cloud.service.cpcTrans
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
top.ninwoo.api.CnfData
;
import
top.ninwoo.api.Picture
;
import
top.ninwoo.cloud.config.BpsoConfig
;
import
top.ninwoo.cloud.service.IPService
;
import
top.ninwoo.cloud.service.TransService
;
import
top.ninwoo.cloud.service.bpso.Bpso
;
import
top.ninwoo.cloud.service.findService.FindServiceImpl
;
...
...
@@ -23,18 +27,25 @@ import java.util.concurrent.ConcurrentHashMap;
import
static
top
.
ninwoo
.
cloud
.
service
.
bpso
.
Bpso
.
lastHop
;
@Slf4j
@Service
public
class
CpcTrans
implements
TransService
{
@Resource
private
RestTemplate
restTemplate
;
@Autowired
private
BpsoConfig
bpsoConfig
;
@Autowired
private
IPService
ipService
;
/**
* 打包picture
*
* @return picture列表
*/
@Override
public
Picture
packagePic
(
BufferedImage
bufferedImage
,
String
fileId
){
public
Picture
packagePic
(
BufferedImage
bufferedImage
){
Picture
picture
=
new
Picture
();
//转化为byte[]数组
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
...
...
@@ -47,7 +58,7 @@ public class CpcTrans implements TransService {
//设置图片数据
picture
.
setData
(
out
.
toByteArray
());
//设置文件名
picture
.
setPicId
(
fileId
);
picture
.
setPicId
(
"123"
);
return
picture
;
}
...
...
@@ -55,7 +66,7 @@ public class CpcTrans implements TransService {
* 打包成数据包
*/
@Override
public
LinkedList
<
CnfData
>
packageData
(
Picture
picture
)
throws
ParseException
{
public
LinkedList
<
CnfData
>
packageData
(
Picture
picture
,
int
[][]
link
,
int
[]
func
)
throws
ParseException
{
LinkedList
<
CnfData
>
cnfDatas
=
new
LinkedList
<>();
FindServiceImpl
findService
=
new
FindServiceImpl
();
//判断npe
...
...
@@ -66,17 +77,18 @@ public class CpcTrans implements TransService {
// 输入:
//子任务依赖关系 边
int
[][]
link
=
{{
0
,
1
,
1
,
2
,
3
,
4
,
5
,
6
},
{
1
,
2
,
3
,
4
,
5
,
6
,
6
,
7
}};
//
int[][] link = {{0, 1, 1, 2, 3, 4, 5, 6}, {1, 2, 3, 4, 5, 6, 6, 7}};
//task编号
int
[]
func
=
{
0
,
2
,
3
,
3
,
1
,
1
,
4
,
0
};
//
int[] func = {0, 2, 3, 3, 1, 1, 4, 0};
//任务表
String
[]
tasks
=
{
"start/end"
,
"binaryProcess"
,
"cutProcess"
,
"greyProcess"
,
"mergeProcess"
,
"
tailor
Process"
};
String
[]
tasks
=
{
"start/end"
,
"binaryProcess"
,
"cutProcess"
,
"greyProcess"
,
"mergeProcess"
,
"
distribute
Process"
};
Bpso
doMap
=
new
Bpso
();
doMap
.
doMapApp
(
link
,
func
);
doMap
.
doMapApp
(
link
,
func
,
bpsoConfig
);
//映射结果
int
[]
result
=
doMap
.
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
];
...
...
@@ -96,6 +108,7 @@ public class CpcTrans implements TransService {
//左为边起点,右为边终点
path
[
tm
]
=
startHop
+
"->"
+
endHop
;
}
log
.
info
(
"任务规划结果:"
+
Arrays
.
toString
(
path
));
//任务表
ConcurrentHashMap
<
String
,
String
>
taskTable
=
new
ConcurrentHashMap
();
...
...
@@ -113,6 +126,8 @@ public class CpcTrans implements TransService {
}
taskTable
.
put
(
hop
,
tasks
[
func
[
tm
]]);
}
log
.
info
(
"子任务功能执行卫星列表:"
+
taskTable
.
toString
());
//T3路由表
String
[][]
route
=
new
String
[
lastHop
.
length
][
lastHop
[
0
].
length
];
for
(
int
i
=
0
;
i
<
lastHop
.
length
;
i
++){
...
...
@@ -131,21 +146,24 @@ public class CpcTrans implements TransService {
}
}
}
boolean
flad
=
false
;
log
.
info
(
"跨时隙路由表:"
+
Arrays
.
deepToString
(
route
));
boolean
flag
=
false
;
// 防止形成自环,比如route[1][2] = sate1 那么发往sate2的数据包将永远在sate1自环
for
(
int
i
=
0
;
i
<
lastHop
.
length
;
i
++){
for
(
int
j
=
0
;
j
<
lastHop
[
0
].
length
;
j
++){
if
(
route
[
i
][
j
].
equals
(
"sate"
+(
i
))
&&
i
!=
j
){
fla
d
=
true
;
fla
g
=
true
;
}
}
}
if
(
fla
d
==
false
){
if
(
fla
g
==
false
){
System
.
out
.
println
(
"correct"
);
}
CnfData
dataPackage
=
new
CnfData
();
ConcurrentHashMap
<
String
,
String
>
ipool
=
findService
.
findIPool
();
dataPackage
.
setIpPool
(
ipool
);
//
ConcurrentHashMap<String,String> ipool = findService.findIPool();
//
dataPackage.setIpPool(ipool);
//路径表
dataPackage
.
setPathTable
(
path
);
...
...
@@ -156,7 +174,7 @@ public class CpcTrans implements TransService {
//图片
dataPackage
.
setPicture
(
picture
);
//ip池
dataPackage
.
setIpPool
(
findService
.
findIPool
());
//
dataPackage.setIpPool(findService.findIPool());
String
[]
routeself
=
findService
.
findRoute
(
dataPackage
.
getCurrentSataHop
(),
dataPackage
.
getRoute
());
ArrayList
<
String
>
destinSataHops
=
findService
.
findDestinSataHops
(
path
,
"D1"
);
for
(
String
des
:
destinSataHops
)
{
...
...
@@ -168,7 +186,9 @@ public class CpcTrans implements TransService {
//下一跳
transferPackage
.
setCurrentSataHop
(
transferPackage
.
getNextSataHop
());
//ip
transferPackage
.
setNextIPHop
(
findService
.
findIp
(
transferPackage
.
getNextSataHop
(),
transferPackage
.
getIpPool
()));
String
ip
=
ipService
.
getIpByAppName
(
transferPackage
.
getNextSataHop
());
transferPackage
.
setNextIPHop
(
ip
);
// transferPackage.setNextIPHop(findService.findIp(transferPackage.getNextSataHop(),transferPackage.getIpPool()));
//终止节点
transferPackage
.
setEndSateHop
(
"sate11"
);
//返回一个数据包
...
...
@@ -190,8 +210,6 @@ public class CpcTrans implements TransService {
*/
@Override
public
String
sendData
(
CnfData
cnfData
,
String
url
)
{
/*Map<String, Object> param = new HashMap<>();
param.put("cnfData ", cnfData);*/
String
IP
=
url
+
":8083"
;
ResponseEntity
<
String
>
res
=
restTemplate
.
postForEntity
(
"http://"
+
IP
+
"/transfer"
,
cnfData
,
String
.
class
);
if
(!
res
.
getStatusCode
().
is2xxSuccessful
())
{
...
...
@@ -228,5 +246,14 @@ public class CpcTrans implements TransService {
if
(
set
.
size
()==
result
.
length
)
return
false
;
else
return
true
;
}
}
@Override
public
String
reset
(
String
url
)
{
String
IP
=
url
+
":8083"
;
ResponseEntity
<
String
>
res
=
restTemplate
.
getForEntity
(
"http://"
+
IP
+
"/reset"
,
String
.
class
);
if
(!
res
.
getStatusCode
().
is2xxSuccessful
())
{
throw
new
RuntimeException
(
"send Error!"
);
}
return
"sucess"
;
}
}
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/csv/ReadFile.java
View file @
b65532d4
...
...
@@ -18,7 +18,7 @@ public class ReadFile {
public
static
NodeL
[][]
parse
(){
File
csv
=
new
File
(
"
C:\\Users\\Elf\\Desktop\\test\\
leo60.csv"
);
File
csv
=
new
File
(
"leo60.csv"
);
// D:\LabratoryJavaPro\
BufferedReader
br
=
null
;
try
{
...
...
apps/cnf-pathComp-app/app-docker-cloud/src/main/java/top/ninwoo/cloud/service/dbctrans/DbcTrans.java
View file @
b65532d4
...
...
@@ -33,7 +33,7 @@ public class DbcTrans implements TransService {
* @return picture列表
*/
@Override
public
Picture
packagePic
(
BufferedImage
bufferedImage
,
String
fileId
)
{
public
Picture
packagePic
(
BufferedImage
bufferedImage
)
{
Picture
picture
=
new
Picture
();
//转化为byte[]数组
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
...
...
@@ -45,7 +45,7 @@ public class DbcTrans implements TransService {
//设置图片数据
picture
.
setData
(
out
.
toByteArray
());
//设置文件名
picture
.
setPicId
(
fileId
);
picture
.
setPicId
(
"123"
);
return
picture
;
}
...
...
@@ -55,7 +55,7 @@ public class DbcTrans implements TransService {
* @param picture
*/
@Override
public
LinkedList
<
CnfData
>
packageData
(
Picture
picture
)
throws
ParseException
{
public
LinkedList
<
CnfData
>
packageData
(
Picture
picture
,
int
[][]
link
,
int
[]
func
)
throws
ParseException
{
return
null
;
}
...
...
@@ -88,6 +88,15 @@ public class DbcTrans implements TransService {
double
[][]
lt
=
pathRecord
.
getPathWeight
();
//最短路由矩阵
int
[][]
lastHop
=
pathRecord
.
getLastHop
();
for
(
int
j
=
0
;
j
<
lastHop
.
length
;
j
++){
for
(
int
i
=
0
;
i
<
lastHop
.
length
;
i
++){
int
tmp0
=
lastHop
[
j
][
i
];
while
(
tmp0
!=
0
){
lastHop
[
j
][
i
]
=
tmp0
;
tmp0
=
lastHop
[
j
][
tmp0
];
}
}
}
//路径表
String
[]
path
=
new
String
[
1
];
...
...
@@ -97,30 +106,33 @@ public class DbcTrans implements TransService {
ConcurrentHashMap
<
String
,
String
>
taskTable
=
new
ConcurrentHashMap
();
taskTable
.
put
(
satename
,
"distributeProcess"
);
cnfData
.
setTaskTable
(
taskTable
);
//T3路由表 todo
String
[][]
route
=
new
String
[
lastHop
.
length
][
lastHop
[
0
].
length
];
for
(
int
i
=
0
;
i
<
lastHop
.
length
;
i
++){
for
(
int
j
=
0
;
j
<
lastHop
[
0
].
length
;
j
++){
route
[
i
][
j
]
=
"sate"
+(
lastHop
[
i
][
j
]);
if
(
route
[
i
][
j
].
equals
(
"sate0"
)){
route
[
i
][
j
]=
"sate"
+(
j
);
//T3路由表
String
[][]
routetest
=
new
String
[
lastHop
.
length
][
lastHop
[
0
].
length
];
for
(
int
l
=
0
;
l
<
lastHop
.
length
/
num
;
l
++)
{
for
(
int
i
=
l
*
num
;
i
<
l
*
num
+
num
;
i
++)
{
for
(
int
j
=
l
*
num
;
j
<
lastHop
.
length
;
j
++)
{
routetest
[
i
][
j
]
=
"sate"
+
(
lastHop
[
i
][
j
]);
//到直联
if
((
routetest
[
i
][
j
].
equals
(
"sate0"
))){
routetest
[
i
][
j
]
=
"direct"
;
}
if
(
i
==
j
){
routetest
[
i
][
j
]
=
"self"
;
}
if
(
route
[
i
][
j
].
equals
(
"sate0"
)){
route
[
i
][
j
]=
"D1"
;
//表示不可达
if
((
j
%
num
)
==
0
){
routetest
[
i
][
j
]
=
null
;
}
//要修改
//todo
if
(
route
[
i
][
j
].
equals
(
"sate31"
)){
route
[
i
][
j
]=
"D2"
;
}
}
}
//不太正确
cnfData
.
setRoute
(
route
);
cnfData
.
setRoute
(
routetest
);
//图片
cnfData
.
setPicture
(
picture
);
//ip池
cnfData
.
setIpPool
(
findService
.
findIPool
());
//
cnfData
.
setOriSateHop
(
satename
);
String
[]
routeself
=
findService
.
findRoute
(
cnfData
.
getCurrentSataHop
(),
cnfData
.
getRoute
());
ArrayList
<
String
>
destinSataHops
=
findService
.
findDestinSataHops
(
path
,
"D1"
);
for
(
String
des
:
destinSataHops
)
{
...
...
@@ -156,7 +168,7 @@ public class DbcTrans implements TransService {
if
(!
res
.
getStatusCode
().
is2xxSuccessful
())
{
throw
new
RuntimeException
(
"send Error!"
);
}
return
"sucess"
;
return
res
.
getBody
()
;
}
/**
...
...
@@ -204,12 +216,15 @@ public class DbcTrans implements TransService {
for
(
int
i
=
l
*
num
;
i
<
l
*
num
+
num
;
i
++)
{
for
(
int
j
=
l
*
num
;
j
<
lastHop
.
length
;
j
++)
{
routetest
[
i
][
j
]
=
"sate"
+
(
lastHop
[
i
][
j
]);
//到自己
if
((
i
!=
0
||
i
!=
num
*
l
)&(
routetest
[
i
][
j
].
equals
(
"sate0"
))){
routetest
[
i
][
j
]
=
"sate"
+
i
;
//到直联
if
((
routetest
[
i
][
j
].
equals
(
"sate0"
))){
routetest
[
i
][
j
]
=
"direct"
;
}
if
(
i
==
j
){
routetest
[
i
][
j
]
=
"self"
;
}
//表示不可达
if
(
j
==
num
*
l
){
if
(
(
j
%
num
)
==
0
){
routetest
[
i
][
j
]
=
null
;
}
}
...
...
@@ -217,4 +232,19 @@ public class DbcTrans implements TransService {
}
return
routetest
;
}
/**
* 卫星复位
*
* @param url
*/
@Override
public
String
reset
(
String
url
)
{
String
IP
=
url
+
":8083"
;
ResponseEntity
<
String
>
res
=
restTemplate
.
getForEntity
(
"http://"
+
IP
+
"/reset"
,
String
.
class
);
if
(!
res
.
getStatusCode
().
is2xxSuccessful
())
{
throw
new
RuntimeException
(
"send Error!"
);
}
return
"sucess"
;
}
}
apps/cnf-pathComp-app/app-docker-cloud/src/main/resources/application.properties
View file @
b65532d4
...
...
@@ -9,6 +9,12 @@ spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type
=
text/html
spring.thymeleaf.cache
=
false
#
#
设置文件上传的大小
spring.servlet.multipart.max-file-size
=
1024000000000MB
spring.servlet.multipart.max-request-size
=
1024000000000MB
# 粒子群配置
# 迭代次数
bps.k
=
500
# 种群规模
bps.n
=
10
\ No newline at end of file
apps/cnf-pathComp-app/app-docker-cloud/src/main/resources/templates/cpcDownload.html
0 → 100644
View file @
b65532d4
<!DOCTYPE html>
<html
lang=
"en"
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:th=
"http://www.thymeleaf.org"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
文件显示
</title>
</head>
<body>
<hr/>
<!--<a href="jpg/1.jpg">预览图片</a>-->
<!--<a href="@{/getFile/(fileName=${fileName},fileId=${fileId})}">预览图片</a>-->
<img
th:src=
"file+'/'+${fileName}"
>
</body>
</html>
\ No newline at end of file
apps/cnf-pathComp-app/app-docker-cloud/src/main/resources/templates/cpcTrans.html
View file @
b65532d4
...
...
@@ -12,7 +12,11 @@
文件:
<input
type=
"file"
name=
"file"
/>
</p>
<p>
文件ID:
<input
type=
"text"
name=
"fileId"
palcegolder=
"请输入"
/>
路径表:
<input
type=
"text"
name=
"path_1"
palcegolder=
"请输入"
/>
<input
type=
"text"
name=
"path_2"
palcegolder=
"请输入"
/>
</p>
<p>
功能表:
<input
type=
"text"
name=
"func"
palcegolder=
"请输入"
/>
</p>
<p>
<input
type=
"submit"
value=
"上传"
/>
...
...
apps/cnf-pathComp-app/app-docker-cloud/src/main/resources/templates/dbcTrans.html
View file @
b65532d4
...
...
@@ -14,6 +14,9 @@
<p>
文件ID:
<input
type=
"text"
name=
"fileId"
palcegolder=
"请输入"
/>
</p>
<p>
size:
<input
type=
"number"
name=
"size"
palcegolder=
"请输入"
/>
</p>
<p>
<input
type=
"submit"
value=
"上传"
/>
</p>
...
...
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/service/LogicTopoService.java
View file @
b65532d4
package
top.ninwoo.edgecenter.service
;
import
com.sun.xml.internal.ws.spi.db.DatabindingException
;
import
top.ninwoo.common.entity.NetworkTopology
;
import
java.text.ParseException
;
...
...
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