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
4848a97f
Commit
4848a97f
authored
Mar 19, 2020
by
wutu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加集群扩容扩缩容功能模块
parent
945046d1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
4 deletions
+55
-4
bishe-client-starter/src/main/java/top/ninwoo/bishe/starter/service/ClusterService.java
...java/top/ninwoo/bishe/starter/service/ClusterService.java
+2
-0
bishe-client-starter/src/main/java/top/ninwoo/bishe/starter/service/ClusterServiceImpl.java
.../top/ninwoo/bishe/starter/service/ClusterServiceImpl.java
+14
-0
bishe-cloud-center/src/main/java/top/ninwoo/cloudcenter/controller/ClusterController.java
.../top/ninwoo/cloudcenter/controller/ClusterController.java
+5
-0
bishe-cloud-center/src/main/java/top/ninwoo/cloudcenter/service/CloudService.java
...ain/java/top/ninwoo/cloudcenter/service/CloudService.java
+1
-0
bishe-cloud-center/src/main/java/top/ninwoo/cloudcenter/service/impl/CloudServiceImpl.java
...top/ninwoo/cloudcenter/service/impl/CloudServiceImpl.java
+21
-0
bishe-test/src/test/java/top/ninwoo/BisheMultiNodeTests.java
bishe-test/src/test/java/top/ninwoo/BisheMultiNodeTests.java
+12
-4
No files found.
bishe-client-starter/src/main/java/top/ninwoo/bishe/starter/service/ClusterService.java
View file @
4848a97f
...
@@ -14,4 +14,6 @@ public interface ClusterService {
...
@@ -14,4 +14,6 @@ public interface ClusterService {
String
removeClusterFromEdgeNode
(
Long
clusterId
);
String
removeClusterFromEdgeNode
(
Long
clusterId
);
List
<
String
>
getAllEdgeNodeIds
();
List
<
String
>
getAllEdgeNodeIds
();
boolean
adjustClusterToEdgeNode
(
List
<
SeparatedClusterConfig
>
configs
);
}
}
bishe-client-starter/src/main/java/top/ninwoo/bishe/starter/service/ClusterServiceImpl.java
View file @
4848a97f
package
top.ninwoo.bishe.starter.service
;
package
top.ninwoo.bishe.starter.service
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
top.ninwoo.bishe.starter.config.ClientProperties
;
import
top.ninwoo.bishe.starter.config.ClientProperties
;
...
@@ -21,6 +22,8 @@ public class ClusterServiceImpl implements ClusterService {
...
@@ -21,6 +22,8 @@ public class ClusterServiceImpl implements ClusterService {
=
"/cluster/removeClusterFromEdgeNode?clusterId="
;
=
"/cluster/removeClusterFromEdgeNode?clusterId="
;
private
final
static
String
GET_ALL_EDGE_NODE_IDS
private
final
static
String
GET_ALL_EDGE_NODE_IDS
=
"/cluster/getEdgeNodeIds"
;
=
"/cluster/getEdgeNodeIds"
;
private
final
static
String
ADJUST_CLUSTER_TO_EDGE_NODE
=
"/cluster/adjustCluster"
;
@Resource
@Resource
private
RestTemplate
restTemplate
;
private
RestTemplate
restTemplate
;
...
@@ -50,4 +53,15 @@ public class ClusterServiceImpl implements ClusterService {
...
@@ -50,4 +53,15 @@ public class ClusterServiceImpl implements ClusterService {
return
restTemplate
.
getForObject
(
"http://"
+
clientProperties
.
getCloudUrl
()
+
return
restTemplate
.
getForObject
(
"http://"
+
clientProperties
.
getCloudUrl
()
+
GET_ALL_EDGE_NODE_IDS
,
List
.
class
);
GET_ALL_EDGE_NODE_IDS
,
List
.
class
);
}
}
@Override
public
boolean
adjustClusterToEdgeNode
(
List
<
SeparatedClusterConfig
>
configs
)
{
Map
<
String
,
Object
>
param
=
new
HashMap
<>();
param
.
put
(
"configs"
,
configs
.
toArray
());
ResponseEntity
<
Boolean
>
result
=
restTemplate
.
postForEntity
(
"http://"
+
clientProperties
.
getCloudUrl
()
+
ADJUST_CLUSTER_TO_EDGE_NODE
,
configs
,
Boolean
.
class
);
return
result
.
getStatusCode
().
is2xxSuccessful
();
}
}
}
bishe-cloud-center/src/main/java/top/ninwoo/cloudcenter/controller/ClusterController.java
View file @
4848a97f
...
@@ -34,4 +34,9 @@ public class ClusterController {
...
@@ -34,4 +34,9 @@ public class ClusterController {
public
List
<
String
>
getEdgeNodeIds
()
{
public
List
<
String
>
getEdgeNodeIds
()
{
return
cloudService
.
getEdgeNodeIds
();
return
cloudService
.
getEdgeNodeIds
();
}
}
@RequestMapping
(
value
=
"/adjustCluster"
,
method
=
RequestMethod
.
POST
)
public
Boolean
adjustClusterToEdgeNode
(
@RequestBody
List
<
SeparatedClusterConfig
>
clusterConfigs
)
{
return
cloudService
.
adjustCluster
(
clusterConfigs
);
}
}
}
bishe-cloud-center/src/main/java/top/ninwoo/cloudcenter/service/CloudService.java
View file @
4848a97f
...
@@ -34,4 +34,5 @@ public interface CloudService {
...
@@ -34,4 +34,5 @@ public interface CloudService {
List
<
String
>
getEdgeNodeIds
();
List
<
String
>
getEdgeNodeIds
();
boolean
adjustCluster
(
List
<
SeparatedClusterConfig
>
clusterConfigs
);
}
}
bishe-cloud-center/src/main/java/top/ninwoo/cloudcenter/service/impl/CloudServiceImpl.java
View file @
4848a97f
...
@@ -20,6 +20,7 @@ public class CloudServiceImpl implements CloudService {
...
@@ -20,6 +20,7 @@ public class CloudServiceImpl implements CloudService {
private
static
final
Random
randomInt
=
new
Random
(
14
);
private
static
final
Random
randomInt
=
new
Random
(
14
);
private
static
final
String
CREATE_CLUSTER
=
"/createCluster"
;
private
static
final
String
CREATE_CLUSTER
=
"/createCluster"
;
private
static
final
String
DELETE_CLUSTER
=
"/delCluster"
;
private
static
final
String
DELETE_CLUSTER
=
"/delCluster"
;
private
static
final
String
ADJUST_CLUSTER
=
"/adjustCluster"
;
private
static
final
String
DROP_DOCKER_NETWORK
=
"/dropDockerNetwork?clusterId={clusterId}&appName={appName}&ipList={ipList}"
;
private
static
final
String
DROP_DOCKER_NETWORK
=
"/dropDockerNetwork?clusterId={clusterId}&appName={appName}&ipList={ipList}"
;
private
static
final
String
CANCEL_DROP_DOCKER_NETWORK
=
"/cancelDropDockerNetwork?clusterId={clusterId}&appName={appName}&ipList={ipList}"
;
private
static
final
String
CANCEL_DROP_DOCKER_NETWORK
=
"/cancelDropDockerNetwork?clusterId={clusterId}&appName={appName}&ipList={ipList}"
;
private
static
final
String
REMOTE_IP_LIST_BY_APPNAME
=
"/getIpListByAppName?clusterId={clusterId}&appName={appName}"
;
private
static
final
String
REMOTE_IP_LIST_BY_APPNAME
=
"/getIpListByAppName?clusterId={clusterId}&appName={appName}"
;
...
@@ -49,6 +50,26 @@ public class CloudServiceImpl implements CloudService {
...
@@ -49,6 +50,26 @@ public class CloudServiceImpl implements CloudService {
private
RestTemplate
restTemplate
;
private
RestTemplate
restTemplate
;
@Override
public
boolean
adjustCluster
(
List
<
SeparatedClusterConfig
>
clusterConfigs
)
{
if
(
clusterConfigs
==
null
)
{
throw
new
RuntimeException
(
"clusterConfig cannot be null."
);
}
try
{
clusterConfigs
.
forEach
(
c
->
{
ResponseEntity
<
String
>
response
=
restTemplate
.
postForEntity
(
"http://"
+
c
.
getEdgeNodeId
()
+
ADJUST_CLUSTER
,
c
.
getClusterConfig
(),
String
.
class
);
if
(!
response
.
getStatusCode
().
is2xxSuccessful
())
{
throw
new
RuntimeException
(
"send Error!"
);
}
LOG
.
info
(
"{} update success!"
,
c
.
getEdgeNodeId
());
});
}
catch
(
Exception
e
)
{
return
false
;
}
return
true
;
}
/**
/**
* 这里的拓扑必须限定为逻辑拓扑
* 这里的拓扑必须限定为逻辑拓扑
* @param clusterConfig
* @param clusterConfig
...
...
bishe-test/src/test/java/top/ninwoo/BisheMultiNodeTests.java
View file @
4848a97f
...
@@ -78,7 +78,7 @@ public class BisheMultiNodeTests {
...
@@ -78,7 +78,7 @@ public class BisheMultiNodeTests {
List
<
ContainerDescription
>
cds1
=
new
ArrayList
<>();
List
<
ContainerDescription
>
cds1
=
new
ArrayList
<>();
cds1
.
add
(
containerDescription11
);
cds1
.
add
(
containerDescription11
);
ContainerDescription
containerDescription12
=
new
ContainerDescription
();
/*
ContainerDescription containerDescription12 = new ContainerDescription();
containerDescription12.setMode("normal");
containerDescription12.setMode("normal");
containerDescription12.setReplicas(1);
containerDescription12.setReplicas(1);
DockerContainer container12 = new DockerContainer();
DockerContainer container12 = new DockerContainer();
...
@@ -87,11 +87,11 @@ public class BisheMultiNodeTests {
...
@@ -87,11 +87,11 @@ public class BisheMultiNodeTests {
container12.setImage("joliu/networktest");
container12.setImage("joliu/networktest");
containerDescription12.setDockerContainer(container12);
containerDescription12.setDockerContainer(container12);
cds1
.
add
(
containerDescription12
);
cds1.add(containerDescription12);
*/
clusterConfig1
.
setDockers
(
cds1
);
clusterConfig1
.
setDockers
(
cds1
);
NetworkTopology
topo1
=
new
NetworkTopology
();
NetworkTopology
topo1
=
new
NetworkTopology
();
topo1
.
setAppNames
(
new
String
[]{
"APP
2
"
,
"br:ovs3"
,
"br:ovs4"
,
"br:ovs5"
,
"br:ovs6"
,
"br:ovs7"
,
"br:ovs8"
,
"br:remote:ovs2:192.168.61.130"
});
topo1
.
setAppNames
(
new
String
[]{
"APP
3
"
,
"br:ovs3"
,
"br:ovs4"
,
"br:ovs5"
,
"br:ovs6"
,
"br:ovs7"
,
"br:ovs8"
,
"br:remote:ovs2:192.168.61.130"
});
// 这个参数好像没啥用
// 这个参数好像没啥用
topo1
.
setTopologyId
(
11
);
topo1
.
setTopologyId
(
11
);
...
@@ -99,7 +99,7 @@ public class BisheMultiNodeTests {
...
@@ -99,7 +99,7 @@ public class BisheMultiNodeTests {
,{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
,{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
,{
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
}
,{
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
}
,{
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
}
,{
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
}
,{
0
,
0
,
1
,
1
,
0
,
0
,
0
,
0
}
,{
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
}
,{
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
}
,{
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
}
,{
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
}
,{
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
}
,{
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
}});
,{
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
}});
...
@@ -108,6 +108,14 @@ public class BisheMultiNodeTests {
...
@@ -108,6 +108,14 @@ public class BisheMultiNodeTests {
clusterConfigs
.
add
(
separatedClusterConfig1
);
clusterConfigs
.
add
(
separatedClusterConfig1
);
clusterService
.
sendClusterConfigToEdgeNode
(
clusterConfigs
);
clusterService
.
sendClusterConfigToEdgeNode
(
clusterConfigs
);
topo1
.
getTopology
()[
5
][
3
]
=
1
;
adjustCluster
(
clusterConfigs
);
}
private
boolean
adjustCluster
(
List
<
SeparatedClusterConfig
>
configs
)
{
boolean
b
=
clusterService
.
adjustClusterToEdgeNode
(
configs
);
return
b
;
}
}
...
...
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