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
9d293a90
Commit
9d293a90
authored
Jul 09, 2020
by
Elf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决端口错误的问题
parent
ce5d2893
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
134 additions
and
8 deletions
+134
-8
apps/cnf-weixingsim/src/main/resources/application.properties
.../cnf-weixingsim/src/main/resources/application.properties
+2
-0
apps/cnf-weixingsim/src/test/java/top/ninwoo/WxTests.java
apps/cnf-weixingsim/src/test/java/top/ninwoo/WxTests.java
+98
-4
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/controller/TransferTopoController.java
.../ninwoo/edgecenter/controller/TransferTopoController.java
+7
-0
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/service/LogicTopoService.java
.../java/top/ninwoo/edgecenter/service/LogicTopoService.java
+4
-0
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/service/impl/LogicTopoServiceImpl.java
.../ninwoo/edgecenter/service/impl/LogicTopoServiceImpl.java
+23
-4
No files found.
apps/cnf-weixingsim/src/main/resources/application.properties
0 → 100644
View file @
9d293a90
bishe.app.app-name
=
joliu
bishe.app.cloud-url
=
127.0.0.1:9091
\ No newline at end of file
apps/cnf-weixingsim/src/test/java/top/ninwoo/WxTests.java
View file @
9d293a90
...
...
@@ -258,13 +258,14 @@ public class WxTests {
}
//测试连续传输
//测试生成所有的逻辑topo
@Test
public
void
test3
()
throws
IllegalAccessException
,
InterruptedException
{
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
List
<
ContainerDescription
>
cds
=
new
ArrayList
<>();
// TODO: 这个ID应该是从借口获取的
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.190.135:
8081
"
);
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.190.135:
18088
"
);
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
clusterConfig
.
setId
(
11111
l
);
clusterConfig
.
setOwner
(
"joliu"
);
...
...
@@ -309,7 +310,7 @@ public class WxTests {
//下发逻辑拓扑
clusterService
.
sendLogicTopoToEdgeNode
(
clusterConfigs
);
for
(
int
i
=
1
;
;
i
++)
{
out:
for
(
int
i
=
1
;
;
i
++)
{
Thread
.
sleep
(
2000
);
int
time
=
i
*
sd
.
getJiange
();
List
<
WeiXingData
>
changetp
=
wx
.
changeTopo
(
wxData
,
time
);
...
...
@@ -318,10 +319,23 @@ public class WxTests {
//下发修改后逻辑拓扑
clusterService
.
adjustLogicTopoToEdgeNode
(
clusterConfigs
);
Boolean
tag
=
false
;
for
(
int
k
=
1
;
k
<
toponet
[
0
].
length
;
k
++){
for
(
int
j
=
0
;
j
<
k
;
j
++){
if
(
toponet
[
k
][
j
]
==
tp
.
getTopology
(
changetp
,
sd
)[
k
][
j
]){
tag
=
true
;
}
}
}
if
(
tag
){
break
out
;
}
}
System
.
out
.
println
(
"所有topo完成"
);
}
//测试历史功能,需要提前定义好输出文本地址
@Test
public
void
test4
()
throws
IllegalAccessException
,
InterruptedException
{
...
...
@@ -394,7 +408,7 @@ public class WxTests {
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
//需修改为下发的IP地址
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.190.135:
8081
"
);
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.190.135:
18088
"
);
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
clusterConfig
.
setId
(
11111
l
);
...
...
@@ -468,4 +482,84 @@ public class WxTests {
*/
}
@Test
public
void
test6
()
{
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
//需修改为下发的IP地址
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.190.135:18088"
);
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
clusterConfig
.
setId
(
11111
l
);
clusterConfig
.
setOwner
(
"joliu"
);
ContainerDescription
containerDescription
=
new
ContainerDescription
();
containerDescription
.
setMode
(
"normal"
);
containerDescription
.
setReplicas
(
1
);
DockerContainer
container
=
new
DockerContainer
();
container
.
setName
(
"D1"
);
container
.
setCommand
(
"sh"
);
container
.
setImage
(
"test2"
);
containerDescription
.
setDockerContainer
(
container
);
List
<
ContainerDescription
>
cds
=
new
ArrayList
<>();
cds
.
add
(
containerDescription
);
ContainerDescription
dis
=
new
ContainerDescription
();
dis
.
setMode
(
"normal"
);
dis
.
setReplicas
(
1
);
DockerContainer
disContainer
=
new
DockerContainer
();
disContainer
.
setName
(
"D2"
);
disContainer
.
setCommand
(
"sh"
);
disContainer
.
setImage
(
"test2"
);
dis
.
setDockerContainer
(
disContainer
);
cds
.
add
(
dis
);
ContainerDescription
dis2
=
new
ContainerDescription
();
dis2
.
setMode
(
"normal"
);
dis2
.
setReplicas
(
1
);
DockerContainer
disContainer2
=
new
DockerContainer
();
disContainer2
.
setName
(
"D3"
);
disContainer2
.
setCommand
(
"sh"
);
disContainer2
.
setImage
(
"test2"
);
dis2
.
setDockerContainer
(
disContainer2
);
cds
.
add
(
dis2
);
String
[]
appnames
=
new
String
[]{
"D1"
,
"D2"
,
"D3"
,
"br:ovs"
};
int
[][]
topology
=
new
int
[][]{
{
0
,
0
,
0
,
0
},
{
1
,
0
,
0
,
0
},
{
0
,
1
,
0
,
0
},
{
1
,
1
,
1
,
0
}};
clusterConfig
.
setDockers
(
cds
);
NetworkTopology
topo
=
new
NetworkTopology
();
topo
.
setAppNames
(
appnames
);
// 这个参数好像没啥用
topo
.
setTopologyId
(
11
);
topo
.
setTopology
(
topology
);
clusterConfig
.
setTopology
(
topo
);
separatedClusterConfig
.
setClusterConfig
(
clusterConfig
);
clusterConfigs
.
add
(
separatedClusterConfig
);
clusterService
.
sendClusterConfigToEdgeNode
(
clusterConfigs
);
//下发逻辑拓扑
clusterService
.
sendLogicTopoToEdgeNode
(
clusterConfigs
);
/*
//改变逻辑拓扑
int[][] newtopology = new int[][]{
{0, 0, 0, 0 },
{1, 0, 0, 0 },
{1, 1, 0, 0 },
{1, 1, 1, 0 }};
topo.setTopology(newtopology);
//下发修改后的逻辑拓扑
clusterService.adjustLogicTopoToEdgeNode(clusterConfigs);
*/
}
}
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/controller/TransferTopoController.java
View file @
9d293a90
...
...
@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RestController;
import
top.ninwoo.edgecenter.service.LogicTopoService
;
import
java.util.List
;
import
java.util.concurrent.ConcurrentHashMap
;
@RestController
@RequestMapping
(
"/dockerData"
)
...
...
@@ -29,4 +30,10 @@ public class TransferTopoController {
return
logicTopoService
.
getTopo
(
clusterId
);
}
@GetMapping
(
"/getTopoAll"
)
public
ConcurrentHashMap
<
Long
,
int
[][]>
getTopoList
()
{
//System.out.println("已返回topo");
return
logicTopoService
.
getTopoAll
();
}
}
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/service/LogicTopoService.java
View file @
9d293a90
...
...
@@ -3,6 +3,7 @@ package top.ninwoo.edgecenter.service;
import
top.ninwoo.common.entity.NetworkTopology
;
import
java.util.List
;
import
java.util.concurrent.ConcurrentHashMap
;
//逻辑网络
public
interface
LogicTopoService
{
...
...
@@ -16,5 +17,8 @@ public interface LogicTopoService {
int
[][]
getTopo
(
long
clusterId
);
//返回IPlist到docker容器端
List
<
String
>
getIPlist
(
long
clusterId
);
//返回所有topo
ConcurrentHashMap
<
Long
,
int
[][]>
getTopoAll
();
}
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/service/impl/LogicTopoServiceImpl.java
View file @
9d293a90
...
...
@@ -3,7 +3,6 @@ package top.ninwoo.edgecenter.service.impl;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
top.ninwoo.common.entity.NetworkTopology
;
import
top.ninwoo.edgecenter.service.ClusterService
;
...
...
@@ -12,6 +11,7 @@ import top.ninwoo.edgecenter.service.LogicTopoService;
import
top.ninwoo.utils.service.IptablesService
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -23,6 +23,10 @@ public class LogicTopoServiceImpl implements LogicTopoService {
private
ConcurrentHashMap
<
Long
,
NetworkTopology
>
clustersTopo
=
new
ConcurrentHashMap
<>();
//根据appnames来存储IP
private
ConcurrentHashMap
<
Long
,
List
<
String
>>
clustersIPlist
=
new
ConcurrentHashMap
<>();
//全部的topo网络
private
ConcurrentHashMap
<
Long
,
int
[][]>
topoAll
=
new
ConcurrentHashMap
<>();
//
private
long
time
;
@Autowired
private
ClusterService
clusterService
;
...
...
@@ -45,7 +49,6 @@ public class LogicTopoServiceImpl implements LogicTopoService {
// 校验信息
String
[]
cNames
=
logictopo
.
getAppNames
();
int
[][]
topo
=
logictopo
.
getTopology
();
if
(
cNames
==
null
||
cNames
.
length
<=
1
)
{
return
"集群创建失败"
;
}
...
...
@@ -67,6 +70,10 @@ public class LogicTopoServiceImpl implements LogicTopoService {
}
clustersTopo
.
put
(
clusterId
,
logictopo
);
clustersIPlist
.
put
(
clusterId
,
IPlist
);
Date
date
=
new
Date
();
time
=
date
.
getTime
();
topoAll
.
put
(
time
,
logictopo
.
getTopology
());
return
"success"
;
}
...
...
@@ -81,7 +88,7 @@ public class LogicTopoServiceImpl implements LogicTopoService {
// 获取clusterId的网络拓扑
if
(!
clustersTopo
.
containsKey
(
clusterId
))
{
System
.
out
.
println
(
"该集群没有设置topo"
);
LOG
.
error
(
"该集群没有设置topo"
);
return
"该集群没有设置topo"
;
}
...
...
@@ -110,6 +117,11 @@ public class LogicTopoServiceImpl implements LogicTopoService {
}
clustersTopo
.
put
(
clusterId
,
logictopo
);
//这里修改间隔
time
=
time
+
10
;
topoAll
.
put
(
time
,
logictopo
.
getTopology
());
return
"success"
;
}
...
...
@@ -119,7 +131,7 @@ public class LogicTopoServiceImpl implements LogicTopoService {
int
flag
=
0
;
//获取appnames
for
(
int
i
=
0
;
i
<
oritopo
.
getAppNames
().
length
-
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
oritopo
.
getAppNames
().
length
;
i
++)
{
if
(
oritopo
.
getAppNames
()[
i
].
startsWith
(
"br:"
))
{
break
;
}
...
...
@@ -187,4 +199,11 @@ public class LogicTopoServiceImpl implements LogicTopoService {
}
return
clustersIPlist
.
get
(
clusterId
);
}
//todo,后续要加上集群ID并且防止NPE
@Override
public
ConcurrentHashMap
<
Long
,
int
[][]>
getTopoAll
()
{
return
topoAll
;
}
}
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