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
462fc42f
Commit
462fc42f
authored
Jul 21, 2020
by
Elf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加起始时间
打jar包
parent
8ba09f7e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
211 additions
and
10 deletions
+211
-10
apps/cnf-weixingsim/src/main/java/top/ninwoo/weixingsim/entity/SimData.java
...m/src/main/java/top/ninwoo/weixingsim/entity/SimData.java
+3
-1
apps/cnf-weixingsim/src/main/java/top/ninwoo/weixingsim/init/Initapp.java
...sim/src/main/java/top/ninwoo/weixingsim/init/Initapp.java
+107
-0
apps/cnf-weixingsim/src/test/java/top/ninwoo/WxTests.java
apps/cnf-weixingsim/src/test/java/top/ninwoo/WxTests.java
+87
-1
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/controller/IndexController.java
...ava/top/ninwoo/edgecenter/controller/IndexController.java
+3
-2
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/service/LogicTopoService.java
.../java/top/ninwoo/edgecenter/service/LogicTopoService.java
+4
-1
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/service/impl/LogicTopoServiceImpl.java
.../ninwoo/edgecenter/service/impl/LogicTopoServiceImpl.java
+3
-2
cnf-test/src/test/java/top/ninwoo/BisheTests.java
cnf-test/src/test/java/top/ninwoo/BisheTests.java
+4
-3
No files found.
apps/cnf-weixingsim/src/main/java/top/ninwoo/weixingsim/entity/SimData.java
View file @
462fc42f
...
@@ -7,9 +7,11 @@ import lombok.Data;
...
@@ -7,9 +7,11 @@ import lombok.Data;
*/
*/
@Data
@Data
public
class
SimData
{
public
class
SimData
{
//设置时间,默认为 2020-01-01 00-00-00
//24小时制
private
String
defaultDate
=
"2020-01-01 00-00-00"
;
//时间间隔,默认值为10
//时间间隔,默认值为10
private
int
jiange
=
10
;
private
int
jiange
=
10
;
//周期值,默认值为100分钟,即为6000秒
//周期值,默认值为100分钟,即为6000秒
private
int
zhouqi
=
6000
;
private
int
zhouqi
=
6000
;
//todo:这里因该预设默认值
//todo:这里因该预设默认值
...
...
apps/cnf-weixingsim/src/main/java/top/ninwoo/weixingsim/init/Initapp.java
0 → 100644
View file @
462fc42f
package
top.ninwoo.weixingsim.init
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.stereotype.Component
;
import
top.ninwoo.bishe.starter.service.ClusterService
;
import
top.ninwoo.common.entity.*
;
import
top.ninwoo.weixingsim.entity.SimData
;
import
top.ninwoo.weixingsim.entity.WeiXingData
;
import
top.ninwoo.weixingsim.service.impl.ToponetImpl
;
import
top.ninwoo.weixingsim.service.impl.WeixingImpl
;
import
java.io.File
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.List
;
@Component
public
class
Initapp
implements
CommandLineRunner
{
@Autowired
private
ClusterService
clusterService
;
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
List
<
ContainerDescription
>
cds
=
new
ArrayList
<>();
// TODO: 这个ID应该是从借口获取的
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.190.135:18088"
);
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
clusterConfig
.
setId
(
11111
l
);
clusterConfig
.
setOwner
(
"joliu"
);
//从文本中获取卫星的数据
WeixingImpl
wx
=
new
WeixingImpl
();
ToponetImpl
tp
=
new
ToponetImpl
();
SimData
sd
=
new
SimData
();
//tp.delHistory();
File
file
=
new
File
(
"C:\\WorkSpace\\test\\topusim_1.txt"
);
List
<
WeiXingData
>
wxData
=
wx
.
iniTopo
(
file
,
sd
.
getZhouqi
());
int
[][]
toponet
=
tp
.
getTopology
(
wxData
,
sd
);
//创建容器
for
(
int
k
=
0
;
k
<
wxData
.
size
();
k
++)
{
ContainerDescription
containerDescription
=
new
ContainerDescription
();
containerDescription
.
setMode
(
"normal"
);
containerDescription
.
setReplicas
(
1
);
DockerContainer
container
=
new
DockerContainer
();
container
.
setName
(
wxData
.
get
(
k
).
getName
());
container
.
setCommand
(
"sh"
);
container
.
setImage
(
"joliu/networktest"
);
containerDescription
.
setDockerContainer
(
container
);
cds
.
add
(
containerDescription
);
}
//设置创建时间
//自己设计的时间
//sd.setDefaultDate("2020-07-16 20-38-56");
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH-mm-ss"
);
//24小时制
clusterConfig
.
setCreateTime
(
sdf
.
parse
(
sd
.
getDefaultDate
()));
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
clusterConfig
.
setDockers
(
cds
);
NetworkTopology
topo
=
new
NetworkTopology
();
topo
.
setAppNames
(
tp
.
getAppNames
(
wxData
));
// 这个参数好像没啥用
topo
.
setTopologyId
(
11
);
topo
.
setTopology
(
toponet
);
clusterConfig
.
setTopology
(
topo
);
separatedClusterConfig
.
setClusterConfig
(
clusterConfig
);
clusterConfigs
.
add
(
separatedClusterConfig
);
clusterService
.
sendClusterConfigToEdgeNode
(
clusterConfigs
);
//下发逻辑拓扑
clusterService
.
sendLogicTopoToEdgeNode
(
clusterConfigs
);
out:
for
(
int
i
=
1
;
i
<
600
;
i
++)
{
Thread
.
sleep
(
2000
);
int
time
=
i
*
sd
.
getJiange
();
List
<
WeiXingData
>
changetp
=
wx
.
changeTopo
(
wxData
,
time
);
topo
.
setTopology
(
tp
.
getTopology
(
changetp
,
sd
));
//下发修改后逻辑拓扑
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完成"
);
}
}
apps/cnf-weixingsim/src/test/java/top/ninwoo/WxTests.java
View file @
462fc42f
...
@@ -17,6 +17,8 @@ import top.ninwoo.weixingsim.service.impl.WeixingImpl;
...
@@ -17,6 +17,8 @@ import top.ninwoo.weixingsim.service.impl.WeixingImpl;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.io.File
;
import
java.io.File
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -310,7 +312,7 @@ public class WxTests {
...
@@ -310,7 +312,7 @@ public class WxTests {
//下发逻辑拓扑
//下发逻辑拓扑
clusterService
.
sendLogicTopoToEdgeNode
(
clusterConfigs
);
clusterService
.
sendLogicTopoToEdgeNode
(
clusterConfigs
);
out:
for
(
int
i
=
1
;
;
i
++)
{
out:
for
(
int
i
=
1
;
i
<
600
;
i
++)
{
Thread
.
sleep
(
2000
);
Thread
.
sleep
(
2000
);
int
time
=
i
*
sd
.
getJiange
();
int
time
=
i
*
sd
.
getJiange
();
List
<
WeiXingData
>
changetp
=
wx
.
changeTopo
(
wxData
,
time
);
List
<
WeiXingData
>
changetp
=
wx
.
changeTopo
(
wxData
,
time
);
...
@@ -562,4 +564,88 @@ public class WxTests {
...
@@ -562,4 +564,88 @@ public class WxTests {
*/
*/
}
}
//测试设置时间
@Test
public
void
test7
()
throws
IllegalAccessException
,
InterruptedException
,
ParseException
{
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
List
<
ContainerDescription
>
cds
=
new
ArrayList
<>();
// TODO: 这个ID应该是从借口获取的
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.190.135:18088"
);
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
clusterConfig
.
setId
(
11111
l
);
clusterConfig
.
setOwner
(
"joliu"
);
//从文本中获取卫星的数据
WeixingImpl
wx
=
new
WeixingImpl
();
ToponetImpl
tp
=
new
ToponetImpl
();
SimData
sd
=
new
SimData
();
//tp.delHistory();
File
file
=
new
File
(
"C:\\WorkSpace\\test\\topusim_1.txt"
);
List
<
WeiXingData
>
wxData
=
wx
.
iniTopo
(
file
,
sd
.
getZhouqi
());
int
[][]
toponet
=
tp
.
getTopology
(
wxData
,
sd
);
//创建容器
for
(
int
k
=
0
;
k
<
wxData
.
size
();
k
++)
{
ContainerDescription
containerDescription
=
new
ContainerDescription
();
containerDescription
.
setMode
(
"normal"
);
containerDescription
.
setReplicas
(
1
);
DockerContainer
container
=
new
DockerContainer
();
container
.
setName
(
wxData
.
get
(
k
).
getName
());
container
.
setCommand
(
"sh"
);
container
.
setImage
(
"joliu/networktest"
);
containerDescription
.
setDockerContainer
(
container
);
cds
.
add
(
containerDescription
);
}
//设置创建时间
//自己设计的时间
//sd.setDefaultDate("2020-07-16 20-38-56");
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH-mm-ss"
);
//24小时制
clusterConfig
.
setCreateTime
(
sdf
.
parse
(
sd
.
getDefaultDate
()));
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
clusterConfig
.
setDockers
(
cds
);
NetworkTopology
topo
=
new
NetworkTopology
();
topo
.
setAppNames
(
tp
.
getAppNames
(
wxData
));
// 这个参数好像没啥用
topo
.
setTopologyId
(
11
);
topo
.
setTopology
(
toponet
);
clusterConfig
.
setTopology
(
topo
);
separatedClusterConfig
.
setClusterConfig
(
clusterConfig
);
clusterConfigs
.
add
(
separatedClusterConfig
);
clusterService
.
sendClusterConfigToEdgeNode
(
clusterConfigs
);
//下发逻辑拓扑
clusterService
.
sendLogicTopoToEdgeNode
(
clusterConfigs
);
out:
for
(
int
i
=
1
;
i
<
600
;
i
++)
{
Thread
.
sleep
(
2000
);
int
time
=
i
*
sd
.
getJiange
();
List
<
WeiXingData
>
changetp
=
wx
.
changeTopo
(
wxData
,
time
);
topo
.
setTopology
(
tp
.
getTopology
(
changetp
,
sd
));
//下发修改后逻辑拓扑
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完成"
);
}
}
}
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/controller/IndexController.java
View file @
462fc42f
...
@@ -18,6 +18,7 @@ import top.ninwoo.utils.entity.NetworkInfo;
...
@@ -18,6 +18,7 @@ import top.ninwoo.utils.entity.NetworkInfo;
import
top.ninwoo.utils.entity.OvsBridge
;
import
top.ninwoo.utils.entity.OvsBridge
;
import
top.ninwoo.utils.service.TcService
;
import
top.ninwoo.utils.service.TcService
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.*
;
import
java.util.concurrent.*
;
...
@@ -316,12 +317,12 @@ public class IndexController {
...
@@ -316,12 +317,12 @@ public class IndexController {
}
}
//下发逻辑拓扑
//下发逻辑拓扑
@RequestMapping
(
value
=
"/sendLogicTopo"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/sendLogicTopo"
,
method
=
RequestMethod
.
POST
)
public
String
sendLogicTopo
(
@RequestBody
ClusterConfig
clusterConfig
)
{
public
String
sendLogicTopo
(
@RequestBody
ClusterConfig
clusterConfig
)
throws
ParseException
{
if
(
clusterConfig
==
null
){
if
(
clusterConfig
==
null
){
return
"请传入正确的集群设置"
;
return
"请传入正确的集群设置"
;
}
}
// 使用topo创建工具
// 使用topo创建工具
String
res
=
logicTopoService
.
creatLogicTopo
(
clusterConfig
.
getId
(),
clusterConfig
.
getTopology
());
String
res
=
logicTopoService
.
creatLogicTopo
(
clusterConfig
.
getId
(),
clusterConfig
.
getTopology
()
,
clusterConfig
.
getCreateTime
()
);
//System.out.println("ok");
//System.out.println("ok");
return
res
;
return
res
;
}
}
...
...
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/service/LogicTopoService.java
View file @
462fc42f
package
top.ninwoo.edgecenter.service
;
package
top.ninwoo.edgecenter.service
;
import
com.sun.xml.internal.ws.spi.db.DatabindingException
;
import
top.ninwoo.common.entity.NetworkTopology
;
import
top.ninwoo.common.entity.NetworkTopology
;
import
java.text.ParseException
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
//逻辑网络
//逻辑网络
public
interface
LogicTopoService
{
public
interface
LogicTopoService
{
//通过逻辑拓扑创造逻辑网络
//通过逻辑拓扑创造逻辑网络
String
creatLogicTopo
(
long
clusterId
,
NetworkTopology
logictopo
)
;
String
creatLogicTopo
(
long
clusterId
,
NetworkTopology
logictopo
,
Date
date
)
throws
ParseException
;
//调整逻辑网络
//调整逻辑网络
String
modifyLogicTopology
(
long
clusterId
,
NetworkTopology
logictopo
);
String
modifyLogicTopology
(
long
clusterId
,
NetworkTopology
logictopo
);
//得到逻辑拓扑
//得到逻辑拓扑
...
...
cnf-edge-center/src/main/java/top/ninwoo/edgecenter/service/impl/LogicTopoServiceImpl.java
View file @
462fc42f
...
@@ -10,6 +10,8 @@ import top.ninwoo.edgecenter.service.IpService;
...
@@ -10,6 +10,8 @@ import top.ninwoo.edgecenter.service.IpService;
import
top.ninwoo.edgecenter.service.LogicTopoService
;
import
top.ninwoo.edgecenter.service.LogicTopoService
;
import
top.ninwoo.utils.service.IptablesService
;
import
top.ninwoo.utils.service.IptablesService
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
...
@@ -38,7 +40,7 @@ public class LogicTopoServiceImpl implements LogicTopoService {
...
@@ -38,7 +40,7 @@ public class LogicTopoServiceImpl implements LogicTopoService {
private
IptablesService
iptablesService
;
private
IptablesService
iptablesService
;
@Override
@Override
public
String
creatLogicTopo
(
long
clusterId
,
NetworkTopology
oldtopo
)
{
public
String
creatLogicTopo
(
long
clusterId
,
NetworkTopology
oldtopo
,
Date
date
)
throws
ParseException
{
List
<
String
>
IPlist
=
new
ArrayList
<
String
>();
List
<
String
>
IPlist
=
new
ArrayList
<
String
>();
NetworkTopology
logictopo
=
this
.
getLogictopo
(
oldtopo
);
NetworkTopology
logictopo
=
this
.
getLogictopo
(
oldtopo
);
...
@@ -71,7 +73,6 @@ public class LogicTopoServiceImpl implements LogicTopoService {
...
@@ -71,7 +73,6 @@ public class LogicTopoServiceImpl implements LogicTopoService {
clustersTopo
.
put
(
clusterId
,
logictopo
);
clustersTopo
.
put
(
clusterId
,
logictopo
);
clustersIPlist
.
put
(
clusterId
,
IPlist
);
clustersIPlist
.
put
(
clusterId
,
IPlist
);
Date
date
=
new
Date
();
time
=
date
.
getTime
();
time
=
date
.
getTime
();
topoAll
.
put
(
time
,
logictopo
.
getTopology
());
topoAll
.
put
(
time
,
logictopo
.
getTopology
());
return
"success"
;
return
"success"
;
...
...
cnf-test/src/test/java/top/ninwoo/BisheTests.java
View file @
462fc42f
...
@@ -12,6 +12,7 @@ import top.ninwoo.common.entity.*;
...
@@ -12,6 +12,7 @@ import top.ninwoo.common.entity.*;
import
top.ninwoo.client.BisheTestMain
;
import
top.ninwoo.client.BisheTestMain
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -30,7 +31,7 @@ public class BisheTests {
...
@@ -30,7 +31,7 @@ public class BisheTests {
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
// TODO: 这个ID应该是从借口获取的
// TODO: 这个ID应该是从借口获取的
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.190.135:
8081
"
);
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.190.135:
18088
"
);
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
clusterConfig
.
setId
(
11111
l
);
clusterConfig
.
setId
(
11111
l
);
clusterConfig
.
setOwner
(
"joliu"
);
clusterConfig
.
setOwner
(
"joliu"
);
...
@@ -124,7 +125,7 @@ public class BisheTests {
...
@@ -124,7 +125,7 @@ public class BisheTests {
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
//需修改为下发的IP地址
//需修改为下发的IP地址
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.190.135:
8081
"
);
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.190.135:
18088
"
);
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
clusterConfig
.
setId
(
11111
l
);
clusterConfig
.
setId
(
11111
l
);
...
@@ -205,7 +206,7 @@ public class BisheTests {
...
@@ -205,7 +206,7 @@ public class BisheTests {
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
//需修改为下发的IP地址
//需修改为下发的IP地址
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.190.135:
8081
"
);
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.190.135:
18088
"
);
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
clusterConfig
.
setId
(
11111
l
);
clusterConfig
.
setId
(
11111
l
);
...
...
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