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
86a5047d
Commit
86a5047d
authored
Nov 11, 2019
by
wutu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除容器id出现bug,已修复
parent
544e2ce3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
5 deletions
+34
-5
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/controller/IndexController.java
...ava/top/ninwoo/edgecenter/controller/IndexController.java
+13
-1
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/service/TopologyService.java
...n/java/top/ninwoo/edgecenter/service/TopologyService.java
+3
-0
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/service/impl/ClusterServiceImpl.java
...op/ninwoo/edgecenter/service/impl/ClusterServiceImpl.java
+8
-1
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/service/impl/TopologyServiceImpl.java
...p/ninwoo/edgecenter/service/impl/TopologyServiceImpl.java
+9
-3
bishe-utils/src/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
...rc/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
+1
-0
No files found.
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/controller/IndexController.java
View file @
86a5047d
...
@@ -6,6 +6,7 @@ import top.ninwoo.edgecenter.entity.ClusterConfig;
...
@@ -6,6 +6,7 @@ import top.ninwoo.edgecenter.entity.ClusterConfig;
import
top.ninwoo.edgecenter.entity.ContainerInfo
;
import
top.ninwoo.edgecenter.entity.ContainerInfo
;
import
top.ninwoo.edgecenter.entity.NetworkTopology
;
import
top.ninwoo.edgecenter.entity.NetworkTopology
;
import
top.ninwoo.edgecenter.service.ClusterService
;
import
top.ninwoo.edgecenter.service.ClusterService
;
import
top.ninwoo.edgecenter.service.TopologyService
;
import
top.ninwoo.utils.entity.DockerContainer
;
import
top.ninwoo.utils.entity.DockerContainer
;
import
top.ninwoo.utils.entity.NetworkInfo
;
import
top.ninwoo.utils.entity.NetworkInfo
;
import
top.ninwoo.utils.entity.OvsBridge
;
import
top.ninwoo.utils.entity.OvsBridge
;
...
@@ -22,6 +23,9 @@ public class IndexController {
...
@@ -22,6 +23,9 @@ public class IndexController {
@Autowired
@Autowired
ClusterService
clusterService
;
ClusterService
clusterService
;
@Autowired
TopologyService
topologyService
;
@RequestMapping
(
"/index"
)
@RequestMapping
(
"/index"
)
public
List
<
DockerContainer
>
index
(
int
flag
)
{
public
List
<
DockerContainer
>
index
(
int
flag
)
{
...
@@ -155,15 +159,23 @@ public class IndexController {
...
@@ -155,15 +159,23 @@ public class IndexController {
}
}
@RequestMapping
(
value
=
"/createTopo"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/createTopo"
,
method
=
RequestMethod
.
POST
)
public
NetworkTopology
createTopo
(
long
topologyId
,
String
[]
appNames
,
String
topology
)
{
public
NetworkTopology
createTopo
(
long
clusterId
,
long
topologyId
,
String
[]
appNames
,
String
topology
)
{
// 二维数组作为一个字符串传递进来,需要进行一个解析
// 二维数组作为一个字符串传递进来,需要进行一个解析
NetworkTopology
topo
=
new
NetworkTopology
();
NetworkTopology
topo
=
new
NetworkTopology
();
topo
.
setAppNames
(
appNames
);
topo
.
setAppNames
(
appNames
);
topo
.
setTopologyId
(
111
);
topo
.
setTopologyId
(
111
);
topo
.
setTopology
(
parseString
(
topology
));
topo
.
setTopology
(
parseString
(
topology
));
// 使用topo创建工具
topologyService
.
createTopo
(
clusterId
,
topo
);
return
topo
;
return
topo
;
}
}
@RequestMapping
(
value
=
"/delCluster"
,
method
=
RequestMethod
.
GET
)
public
String
delCluster
(
long
clusterId
)
{
clusterService
.
removeContainersByClusterId
(
clusterId
);
return
"success"
;
}
private
int
[][]
parseString
(
String
topology
)
{
private
int
[][]
parseString
(
String
topology
)
{
String
[]
lines
=
topology
.
split
(
";"
);
String
[]
lines
=
topology
.
split
(
";"
);
int
x
=
lines
.
length
;
int
x
=
lines
.
length
;
...
...
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/service/TopologyService.java
View file @
86a5047d
package
top.ninwoo.edgecenter.service
;
package
top.ninwoo.edgecenter.service
;
import
top.ninwoo.edgecenter.entity.ClusterConfig
;
import
top.ninwoo.edgecenter.entity.ClusterConfig
;
import
top.ninwoo.edgecenter.entity.NetworkTopology
;
/**
/**
* @Author joliu
* @Author joliu
...
@@ -15,4 +16,6 @@ public interface TopologyService {
...
@@ -15,4 +16,6 @@ public interface TopologyService {
* @param clusterConfig
* @param clusterConfig
*/
*/
void
initTopo
(
ClusterConfig
clusterConfig
);
void
initTopo
(
ClusterConfig
clusterConfig
);
void
createTopo
(
long
clusterId
,
NetworkTopology
topology
);
}
}
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/service/impl/ClusterServiceImpl.java
View file @
86a5047d
...
@@ -165,7 +165,14 @@ public class ClusterServiceImpl implements ClusterService {
...
@@ -165,7 +165,14 @@ public class ClusterServiceImpl implements ClusterService {
return
;
return
;
}
}
clustersInfo
.
get
(
clusterId
).
keySet
().
forEach
(
clustersInfo
.
get
(
clusterId
).
keySet
().
forEach
(
c
->
removeContainersByClusterIdAndContainerName
(
clusterId
,
c
)
//c -> removeContainersByClusterIdAndContainerName(clusterId, c)
// bug: 遍历过程中,不能进行删除,会导致并发错误,不能直接调用removeContainersByCo...接口
cName
->
{
LOG
.
debug
(
"删除应用["
+
cName
+
"]"
);
// 获取全部的容器id
clustersInfo
.
get
(
clusterId
).
get
(
cName
).
forEach
(
c
->
dockerService
.
deleteDockerById
(
c
));
}
);
);
clustersInfo
.
remove
(
clusterId
);
clustersInfo
.
remove
(
clusterId
);
}
}
...
...
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/service/impl/TopologyServiceImpl.java
View file @
86a5047d
...
@@ -3,6 +3,7 @@ package top.ninwoo.edgecenter.service.impl;
...
@@ -3,6 +3,7 @@ package top.ninwoo.edgecenter.service.impl;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
top.ninwoo.edgecenter.entity.ClusterConfig
;
import
top.ninwoo.edgecenter.entity.ClusterConfig
;
import
top.ninwoo.edgecenter.entity.NetworkTopology
;
import
top.ninwoo.edgecenter.entity.NetworkTopology
;
import
top.ninwoo.edgecenter.service.ClusterService
;
import
top.ninwoo.edgecenter.service.ClusterService
;
...
@@ -18,6 +19,7 @@ import java.util.Set;
...
@@ -18,6 +19,7 @@ import java.util.Set;
* @Description 这里描述的物理连接的拓扑关系
* @Description 这里描述的物理连接的拓扑关系
* @Date Create in 上午11:16 2019/11/7
* @Date Create in 上午11:16 2019/11/7
*/
*/
@Service
public
class
TopologyServiceImpl
implements
TopologyService
{
public
class
TopologyServiceImpl
implements
TopologyService
{
private
final
static
Logger
LOG
=
LoggerFactory
.
getLogger
(
TopologyServiceImpl
.
class
);
private
final
static
Logger
LOG
=
LoggerFactory
.
getLogger
(
TopologyServiceImpl
.
class
);
...
@@ -37,9 +39,13 @@ public class TopologyServiceImpl implements TopologyService {
...
@@ -37,9 +39,13 @@ public class TopologyServiceImpl implements TopologyService {
@Override
@Override
public
void
initTopo
(
ClusterConfig
clusterConfig
)
{
public
void
initTopo
(
ClusterConfig
clusterConfig
)
{
// 获取topology
// 获取topology
NetworkTopology
topology
=
clusterConfig
.
getTopology
();
createTopo
(
clusterConfig
.
getId
(),
clusterConfig
.
getTopology
());
}
@Override
public
void
createTopo
(
long
clusterId
,
NetworkTopology
topology
)
{
if
(
topology
==
null
)
{
if
(
topology
==
null
)
{
LOG
.
warn
(
"集群["
+
cluster
Config
.
getId
()
+
"]未设置网络"
);
LOG
.
warn
(
"集群["
+
cluster
Id
+
"]未设置网络"
);
return
;
return
;
}
}
...
@@ -56,7 +62,7 @@ public class TopologyServiceImpl implements TopologyService {
...
@@ -56,7 +62,7 @@ public class TopologyServiceImpl implements TopologyService {
// 判断每一个节点的连接状态
// 判断每一个节点的连接状态
if
(
topo
[
i
][
j
]
==
1
)
{
if
(
topo
[
i
][
j
]
==
1
)
{
// 如果存在连接,则创建连接
// 如果存在连接,则创建连接
addLink
(
cluster
Config
.
getId
()
,
cNames
[
i
],
cNames
[
j
]);
addLink
(
cluster
Id
,
cNames
[
i
],
cNames
[
j
]);
}
}
}
}
}
}
...
...
bishe-utils/src/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
View file @
86a5047d
...
@@ -249,6 +249,7 @@ public class OvsUtilsImpl implements OvsUtils {
...
@@ -249,6 +249,7 @@ public class OvsUtilsImpl implements OvsUtils {
*/
*/
@Override
@Override
public
boolean
setVxlan
(
String
bridgeName
,
String
remoteIp
)
{
public
boolean
setVxlan
(
String
bridgeName
,
String
remoteIp
)
{
// TODO: bug
String
cmd
=
"echo 'Vudo3423' | sudo -S ovs-vsctl add-port "
+
bridgeName
String
cmd
=
"echo 'Vudo3423' | sudo -S ovs-vsctl add-port "
+
bridgeName
+
" vxlan0 -- set interface vxlan0 type=vxlan options:remote_ip="
+
remoteIp
;
+
" vxlan0 -- set interface vxlan0 type=vxlan options:remote_ip="
+
remoteIp
;
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
...
...
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