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
712d0b5a
Commit
712d0b5a
authored
Mar 19, 2020
by
wutu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'pretty-log' of gitee.com:prowo_admin/bishe into pretty-log
parents
44daf7ef
fc5639ea
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
115 additions
and
12 deletions
+115
-12
bishe-edge-center/pom.xml
bishe-edge-center/pom.xml
+5
-0
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/controller/IndexController.java
...ava/top/ninwoo/edgecenter/controller/IndexController.java
+28
-8
bishe-edge-center/src/main/resources/application.yaml
bishe-edge-center/src/main/resources/application.yaml
+4
-1
bishe-test/pom.xml
bishe-test/pom.xml
+5
-0
bishe-test/src/main/resources/application.properties
bishe-test/src/main/resources/application.properties
+5
-1
bishe-test/src/test/java/top/ninwoo/BisheMultiNodeTests.java
bishe-test/src/test/java/top/ninwoo/BisheMultiNodeTests.java
+67
-1
bishe-utils/src/main/java/top/ninwoo/utils/service/impl/TcServiceImpl.java
...ain/java/top/ninwoo/utils/service/impl/TcServiceImpl.java
+1
-1
No files found.
bishe-edge-center/pom.xml
View file @
712d0b5a
...
...
@@ -23,6 +23,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.influxdb
</groupId>
<artifactId>
influxdb-java
</artifactId>
<version>
2.9
</version>
</dependency>
<!--日志模块-->
<dependency>
...
...
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/controller/IndexController.java
View file @
712d0b5a
package
top.ninwoo.edgecenter.controller
;
import
org.influxdb.InfluxDB
;
import
org.influxdb.dto.Point
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
top.ninwoo.common.entity.ClusterConfig
;
...
...
@@ -22,13 +24,16 @@ public class IndexController {
ScheduledExecutorService
scheduledExecutorService
=
new
ScheduledThreadPoolExecutor
(
8
);
@Autowired
ClusterService
clusterService
;
private
ClusterService
clusterService
;
@Autowired
TopologyService
topologyService
;
private
TopologyService
topologyService
;
@Autowired
IpService
ipService
;
private
IpService
ipService
;
@Autowired
private
InfluxDB
influxDB
;
@RequestMapping
(
value
=
"/index"
)
public
List
<
DockerContainer
>
index
(
int
flag
)
{
...
...
@@ -88,7 +93,7 @@ public class IndexController {
// 为每一个cid容器创建一个定时任务
if
(!
scheduledFutureMap
.
containsKey
(
cid
))
{
containerInfoMap
.
put
(
cid
,
new
ContainerInfo
());
NetworkMonitorThread
networkMonitorThread
=
new
NetworkMonitorThread
(
cid
,
containerInfoMap
,
clusterService
);
NetworkMonitorThread
networkMonitorThread
=
new
NetworkMonitorThread
(
cid
,
containerInfoMap
,
clusterService
,
influxDB
,
containerName
);
// 放入线程池执行任务
ScheduledFuture
<?>
future
=
scheduledExecutorService
.
scheduleAtFixedRate
(
networkMonitorThread
,
0
,
1
,
TimeUnit
.
SECONDS
);
// 保存任务,以方便进行定时任务的关闭
...
...
@@ -119,7 +124,6 @@ public class IndexController {
containerInfoMap
.
remove
(
cid
);
}
});
return
true
;
}
...
...
@@ -143,11 +147,15 @@ public class IndexController {
private
String
containerId
;
private
ConcurrentHashMap
<
String
,
ContainerInfo
>
map
;
private
ClusterService
clusterService
;
private
InfluxDB
influxDB
;
private
String
cName
;
public
NetworkMonitorThread
(
String
containerId
,
ConcurrentHashMap
<
String
,
ContainerInfo
>
map
,
ClusterService
clusterService
)
{
public
NetworkMonitorThread
(
String
containerId
,
ConcurrentHashMap
<
String
,
ContainerInfo
>
map
,
ClusterService
clusterService
,
InfluxDB
influxDB
,
String
cName
)
{
this
.
containerId
=
containerId
;
this
.
map
=
map
;
this
.
clusterService
=
clusterService
;
this
.
influxDB
=
influxDB
;
this
.
cName
=
cName
;
}
@Override
...
...
@@ -163,9 +171,20 @@ public class IndexController {
if
(
map
.
containsKey
(
containerId
))
{
map
.
put
(
containerId
,
containerInfo
);
// TODO: 这里有又重新把容器id注册回去了
}
System
.
out
.
println
(
"监控运行中"
+
containerId
);
savePoint
(
networkInfo
);
}
private
void
savePoint
(
NetworkInfo
networkInfo
)
{
Point
.
Builder
builder
=
Point
.
measurement
(
"monitor"
);
Point
point
=
builder
.
addField
(
"rate"
,
networkInfo
.
getCurRate
())
.
addField
(
"error"
,
networkInfo
.
getErrorRate
())
.
addField
(
"drop"
,
networkInfo
.
getDropRate
())
.
tag
(
"cid"
,
containerId
)
.
tag
(
"cName"
,
cName
).
build
();
influxDB
.
setDatabase
(
"test"
).
write
(
point
);
}
public
void
setContainerId
(
String
containerId
)
{
this
.
containerId
=
containerId
;
}
...
...
@@ -227,7 +246,8 @@ public class IndexController {
return
"没有设置clusterid"
;
}
String
res
=
clusterService
.
adjustCluster
(
clusterConfig
);
return
res
;
String
res1
=
topologyService
.
modifyTopology
(
clusterConfig
.
getId
(),
clusterConfig
.
getTopology
());
return
res
+
"|"
+
res1
;
}
@RequestMapping
(
value
=
"/adjustClusterTopo"
)
...
...
bishe-edge-center/src/main/resources/application.yaml
View file @
712d0b5a
...
...
@@ -5,7 +5,10 @@ spring:
url
:
jdbc:mysql://opengn.org:32306/bishe?useSSL=false
username
:
root
password
:
Vudo3423ljo
influx
:
url
:
http://192.168.61.131:8086
user
:
admin
password
:
admin
mybatis
:
configuration
:
map-underscore-to-camel-case
:
true
...
...
bishe-test/pom.xml
View file @
712d0b5a
...
...
@@ -30,5 +30,10 @@
<version>
2.1.2.RELEASE
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.influxdb
</groupId>
<artifactId>
influxdb-java
</artifactId>
<version>
2.9
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
bishe-test/src/main/resources/application.properties
View file @
712d0b5a
bishe.app.app-name
=
joliu
bishe.app.cloud-url
=
127.0.0.1:9091
\ No newline at end of file
bishe.app.cloud-url
=
127.0.0.1:9091
spring.influx.url
=
http://192.168.61.131:8086
spring.influx.user
=
admin
spring.influx.password
=
admin
\ No newline at end of file
bishe-test/src/test/java/top/ninwoo/BisheMultiNodeTests.java
View file @
712d0b5a
package
top.ninwoo
;
import
org.influxdb.InfluxDB
;
import
org.influxdb.dto.Point
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -14,6 +16,7 @@ import top.ninwoo.test.BisheTestMain;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
BisheTestMain
.
class
)
...
...
@@ -25,6 +28,21 @@ public class BisheMultiNodeTests {
@Resource
private
NetworkService
networkService
;
@Autowired
private
InfluxDB
influxDB
;
@Test
public
void
testInFluxDB
()
{
Point
.
Builder
builder
=
Point
.
measurement
(
"monitor"
);
System
.
out
.
println
(
System
.
currentTimeMillis
());
builder
.
addField
(
"rate"
,
1221
f
)
.
addField
(
"error"
,
0.01f
)
.
tag
(
"cid"
,
"APP1"
);
Point
point
=
builder
.
build
();
influxDB
.
setDatabase
(
"test"
).
write
(
point
);
}
@Test
public
void
testNetworkChange
()
{
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
...
...
@@ -108,7 +126,7 @@ public class BisheMultiNodeTests {
clusterConfigs
.
add
(
separatedClusterConfig1
);
clusterService
.
sendClusterConfigToEdgeNode
(
clusterConfigs
);
topo1
.
getTopology
()[
5
][
3
]
=
1
;
//topo1.getTopology()[6
][3] = 1;
adjustCluster
(
clusterConfigs
);
}
...
...
@@ -118,6 +136,54 @@ public class BisheMultiNodeTests {
return
b
;
}
@Test
public
void
testNewService
()
{
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.61.130:8081"
);
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
clusterConfig
.
setId
(
11112
l
);
clusterConfig
.
setOwner
(
"joliu"
);
ContainerDescription
containerDescription
=
new
ContainerDescription
();
containerDescription
.
setMode
(
"normal"
);
containerDescription
.
setReplicas
(
1
);
DockerContainer
container
=
new
DockerContainer
();
container
.
setName
(
"APP4"
);
container
.
setCommand
(
"sh"
);
container
.
setImage
(
"joliu/networktest"
);
containerDescription
.
setDockerContainer
(
container
);
ClusterConfig
clusterConfig1
=
new
ClusterConfig
();
clusterConfig1
.
setId
(
11112
l
);
clusterConfig1
.
setOwner
(
"joliu"
);
ContainerDescription
containerDescription1
=
new
ContainerDescription
();
containerDescription1
.
setMode
(
"normal"
);
containerDescription1
.
setReplicas
(
1
);
DockerContainer
container1
=
new
DockerContainer
();
container1
.
setName
(
"APP5"
);
container1
.
setCommand
(
"sh"
);
container1
.
setImage
(
"joliu/networktest"
);
containerDescription1
.
setDockerContainer
(
container1
);
List
<
ContainerDescription
>
cds
=
new
ArrayList
<>();
cds
.
add
(
containerDescription
);
cds
.
add
(
containerDescription1
);
clusterConfig
.
setDockers
(
cds
);
NetworkTopology
topo
=
new
NetworkTopology
();
topo
.
setAppNames
(
new
String
[]{
"APP4"
,
"APP5"
,
"br:ovs9"
,
"br:ovs10"
});
// 这个参数好像没啥用
topo
.
setTopologyId
(
11
);
topo
.
setTopology
(
new
int
[][]{
{
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
},
{
1
,
0
,
0
,
0
},
{
0
,
1
,
1
,
0
}});
clusterConfig
.
setTopology
(
topo
);
separatedClusterConfig
.
setClusterConfig
(
clusterConfig
);
clusterConfigs
.
add
(
separatedClusterConfig
);
clusterService
.
sendClusterConfigToEdgeNode
(
clusterConfigs
);
}
@Test
public
void
testSendSeparateConfig
()
{
...
...
bishe-utils/src/main/java/top/ninwoo/utils/service/impl/TcServiceImpl.java
View file @
712d0b5a
...
...
@@ -116,7 +116,7 @@ public class TcServiceImpl implements TcService {
if
(
qosMap
.
containsKey
(
containerId
))
{
maxRate
=
qosMap
.
get
(
containerId
);
}
netUsage
=
curRate
/
maxRate
;
netUsage
=
curRate
/
(
1024
*
8
f
)
;
if
(
netUsage
>
1.0
)
{
netUsage
=
1.0f
;
}
...
...
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