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
d80238b2
Commit
d80238b2
authored
Jun 04, 2020
by
Elf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试修改逻辑成功,增加修改逻辑的例子
parent
320ef351
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
7 deletions
+42
-7
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/controller/IndexController.java
...ava/top/ninwoo/edgecenter/controller/IndexController.java
+3
-0
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/service/impl/LogicTopoServiceImpl.java
.../ninwoo/edgecenter/service/impl/LogicTopoServiceImpl.java
+14
-3
bishe-test/src/test/java/top/ninwoo/BisheTests.java
bishe-test/src/test/java/top/ninwoo/BisheTests.java
+25
-4
No files found.
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/controller/IndexController.java
View file @
d80238b2
...
@@ -320,6 +320,8 @@ public class IndexController {
...
@@ -320,6 +320,8 @@ public class IndexController {
// 创建网络
// 创建网络
// 使用topo创建工具
// 使用topo创建工具
logicTopoService
.
creatLogicTopo
(
clusterConfig
.
getId
(),
clusterConfig
.
getTopology
());
logicTopoService
.
creatLogicTopo
(
clusterConfig
.
getId
(),
clusterConfig
.
getTopology
());
//System.out.println("ok");
//return "sucess";
}
}
//修改逻辑拓扑
//修改逻辑拓扑
@RequestMapping
(
value
=
"/adjustLogicTopo"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/adjustLogicTopo"
,
method
=
RequestMethod
.
POST
)
...
@@ -329,6 +331,7 @@ public class IndexController {
...
@@ -329,6 +331,7 @@ public class IndexController {
return
"没有设置clusterid"
;
return
"没有设置clusterid"
;
}
}
String
res1
=
logicTopoService
.
modifyLogicTopology
(
clusterConfig
.
getId
(),
clusterConfig
.
getTopology
());
String
res1
=
logicTopoService
.
modifyLogicTopology
(
clusterConfig
.
getId
(),
clusterConfig
.
getTopology
());
//System.out.println("ok?");
return
res1
;
return
res1
;
}
}
}
}
\ No newline at end of file
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/service/impl/LogicTopoServiceImpl.java
View file @
d80238b2
...
@@ -65,48 +65,59 @@ public class LogicTopoServiceImpl implements LogicTopoService {
...
@@ -65,48 +65,59 @@ public class LogicTopoServiceImpl implements LogicTopoService {
@Override
@Override
public
String
modifyLogicTopology
(
long
clusterId
,
NetworkTopology
oldtopo
)
{
public
String
modifyLogicTopology
(
long
clusterId
,
NetworkTopology
oldtopo
)
{
//System.out.println("我运行了么?");
NetworkTopology
logictopo
=
this
.
getLogictopo
(
oldtopo
);
NetworkTopology
logictopo
=
this
.
getLogictopo
(
oldtopo
);
// 先进行校验
// 先进行校验
if
(
logictopo
==
null
)
{
if
(
logictopo
==
null
)
{
System
.
out
.
println
(
"topoloy不能为空"
);
return
"topoloy不能为空"
;
return
"topoloy不能为空"
;
}
}
// 获取clusterId的网络拓扑
// 获取clusterId的网络拓扑
if
(!
clustersTopo
.
containsKey
(
clusterId
))
{
if
(!
clustersTopo
.
containsKey
(
clusterId
))
{
System
.
out
.
println
(
"该集群没有设置topo"
);
return
"该集群没有设置topo"
;
return
"该集群没有设置topo"
;
}
}
NetworkTopology
origTopo
=
this
.
getLogictopo
(
clustersTopo
.
get
(
clusterId
)
);
NetworkTopology
origTopo
=
clustersTopo
.
get
(
clusterId
);
// 校验topoId是否一致
// 校验topoId是否一致
if
(
origTopo
.
getTopologyId
()
!=
logictopo
.
getTopologyId
())
{
if
(
origTopo
.
getTopologyId
()
!=
logictopo
.
getTopologyId
())
{
System
.
out
.
println
(
"不是相同的网络拓扑,无法更改"
);
return
"不是相同的网络拓扑,无法更改"
;
return
"不是相同的网络拓扑,无法更改"
;
}
}
// 校验成员名称是否相同
// 校验成员名称是否相同
for
(
int
i
=
0
;
i
<
origTopo
.
getAppNames
().
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
origTopo
.
getAppNames
().
length
;
i
++)
{
if
(!
origTopo
.
getAppNames
()[
i
].
equals
(
logictopo
.
getAppNames
()[
i
]))
{
if
(!
origTopo
.
getAppNames
()[
i
].
equals
(
logictopo
.
getAppNames
()[
i
]))
{
System
.
out
.
println
(
"App名称必须一致"
);
return
"App名称必须一致"
;
return
"App名称必须一致"
;
}
}
}
}
int
[][]
origTopoArr
=
origTopo
.
getTopology
();
int
[][]
origTopoArr
=
origTopo
.
getTopology
();
int
[][]
newTopoArr
=
logictopo
.
getTopology
();
int
[][]
newTopoArr
=
logictopo
.
getTopology
();
//System.out.println("康康我的新拓扑怎样呢");
//System.out.println(newTopoArr[2][1]);
// 校验topo是否一致
// 校验topo是否一致
if
((
origTopoArr
.
length
!=
newTopoArr
.
length
)
if
((
origTopoArr
.
length
!=
newTopoArr
.
length
)
||
(
origTopoArr
[
0
].
length
!=
newTopoArr
[
0
].
length
))
{
||
(
origTopoArr
[
0
].
length
!=
newTopoArr
[
0
].
length
))
{
System
.
out
.
println
(
"拓扑大小不一致"
);
return
"拓扑大小不一致"
;
return
"拓扑大小不一致"
;
}
}
//System.out.println("终于要更新网络了啦");
// 更新网络拓扑
// 更新网络拓扑
for
(
int
i
=
1
;
i
<
newTopoArr
.
length
;
i
++)
{
for
(
int
i
=
1
;
i
<
newTopoArr
.
length
;
i
++)
{
for
(
int
j
=
0
;
j
<
i
;
j
++)
{
for
(
int
j
=
0
;
j
<
i
;
j
++)
{
//增加新的 dropIPtable
//增加新的 dropIPtable
if
(
origTopoArr
[
i
][
j
]
==
1
&&
newTopoArr
[
i
][
j
]
==
0
)
{
if
(
origTopoArr
[
i
][
j
]
==
1
&&
newTopoArr
[
i
][
j
]
==
0
)
{
// 创建新的连接
// 创建新的连接
addDropIPtable
(
clusterId
,
origTopo
.
getAppNames
()[
i
],
origTopo
.
getAppNames
()[
j
]);
this
.
addDropIPtable
(
clusterId
,
origTopo
.
getAppNames
()[
i
],
origTopo
.
getAppNames
()[
j
]);
//System.out.println("改了一次");
}
else
if
(
origTopoArr
[
i
][
j
]
==
0
&&
newTopoArr
[
i
][
j
]
==
1
)
{
}
else
if
(
origTopoArr
[
i
][
j
]
==
0
&&
newTopoArr
[
i
][
j
]
==
1
)
{
// 删除旧的连接
// 删除旧的连接
addDelDropIPtable
(
clusterId
,
origTopo
.
getAppNames
()[
i
],
origTopo
.
getAppNames
()[
j
]);
this
.
addDelDropIPtable
(
clusterId
,
origTopo
.
getAppNames
()[
i
],
origTopo
.
getAppNames
()[
j
]);
//System.out.println("gaile");
}
}
}
}
}
}
...
...
bishe-test/src/test/java/top/ninwoo/BisheTests.java
View file @
d80238b2
...
@@ -145,11 +145,22 @@ public class BisheTests {
...
@@ -145,11 +145,22 @@ public class BisheTests {
dis
.
setDockerContainer
(
disContainer
);
dis
.
setDockerContainer
(
disContainer
);
cds
.
add
(
dis
);
cds
.
add
(
dis
);
String
[]
appnames
=
new
String
[]{
"D1"
,
"D2"
,
"br:ovs"
};
ContainerDescription
dis2
=
new
ContainerDescription
();
dis2
.
setMode
(
"normal"
);
dis2
.
setReplicas
(
1
);
DockerContainer
disContainer2
=
new
DockerContainer
();
disContainer2
.
setName
(
"D3"
);
disContainer2
.
setCommand
(
"sh"
);
disContainer2
.
setImage
(
"joliu/networktest"
);
dis2
.
setDockerContainer
(
disContainer2
);
cds
.
add
(
dis2
);
String
[]
appnames
=
new
String
[]{
"D1"
,
"D2"
,
"D3"
,
"br:ovs"
};
int
[][]
topology
=
new
int
[][]{
int
[][]
topology
=
new
int
[][]{
{
0
,
0
,
0
},
{
0
,
0
,
0
,
0
},
{
0
,
0
,
0
},
{
0
,
0
,
0
,
0
},
{
1
,
1
,
0
}};
{
0
,
0
,
0
,
0
},
{
1
,
1
,
1
,
0
}};
clusterConfig
.
setDockers
(
cds
);
clusterConfig
.
setDockers
(
cds
);
NetworkTopology
topo
=
new
NetworkTopology
();
NetworkTopology
topo
=
new
NetworkTopology
();
...
@@ -165,6 +176,16 @@ public class BisheTests {
...
@@ -165,6 +176,16 @@ public class BisheTests {
clusterService
.
sendLogicTopoToEdgeNode
(
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
);
}
}
//改变集群拓扑配置
//改变集群拓扑配置
...
...
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