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
82c0d7f0
Commit
82c0d7f0
authored
Jul 17, 2020
by
ymwang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加云计算模块
parent
862dea04
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
178 additions
and
4 deletions
+178
-4
apps/cnf-distributed-business-computing/cnf-distri-test/src/main/resources/application.properties
...cnf-distri-test/src/main/resources/application.properties
+7
-0
apps/cnf-distributed-business-computing/cnf-distri-test/src/test/java/top/ninwoo/distri/tests/WymDisCloudTests.java
...c/test/java/top/ninwoo/distri/tests/WymDisCloudTests.java
+141
-0
apps/cnf-distributed-business-computing/dbc-business-cloud-cli/src/main/java/top/ninwoo/dbc/cloud/client/service/FileCloService.java
...a/top/ninwoo/dbc/cloud/client/service/FileCloService.java
+28
-2
apps/cnf-distributed-business-computing/dbc-business-cloud-cli/src/main/resources/application.properties
...iness-cloud-cli/src/main/resources/application.properties
+2
-2
No files found.
apps/cnf-distributed-business-computing/cnf-distri-test/src/main/resources/application.properties
0 → 100644
View file @
82c0d7f0
bishe.app.app-name
=
joliu
#bishe.app.cloud-url=192.168.31.156:9090
bishe.app.cloud-url
=
192.168.81.1:9091
spring.influx.url
=
http://192.168.0.108:8086
spring.influx.user
=
admin
spring.influx.password
=
admin
\ No newline at end of file
apps/cnf-distributed-business-computing/cnf-distri-test/src/test/java/top/ninwoo/distri/tests/WymDisCloudTests.java
0 → 100644
View file @
82c0d7f0
package
top.ninwoo.distri.tests
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
top.ninwoo.bishe.starter.entity.ContainerMonitor
;
import
top.ninwoo.bishe.starter.service.ClusterService
;
import
top.ninwoo.bishe.starter.service.NetworkService
;
import
top.ninwoo.common.entity.*
;
import
top.ninwoo.distri.test.DistriTestMain
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
DistriTestMain
.
class
)
public
class
WymDisCloudTests
{
/*分散计算业务的测试*/
@Autowired
private
ClusterService
clusterService
;
@Resource
private
NetworkService
networkService
;
@Test
public
void
testSendSeparateConfig
()
{
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
// TODO: 这个ID应该是从借口获取的
//separatedClusterConfig.setEdgeNodeId("192.168.31.198:8881"); //边缘节点IP+端口号
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.81.133:18088"
);
ClusterConfig
clusterConfigCom
=
new
ClusterConfig
();
clusterConfigCom
.
setId
(
11114
l
);
clusterConfigCom
.
setOwner
(
"joliu"
);
List
<
ContainerDescription
>
cds
=
new
ArrayList
<>();
/*通过镜像"ymwang/dfs_transfer_client"启动一个名为client的容器,来作为文件的收发端(图片的切割、合并)*/
ContainerDescription
containerDescriptionClient
=
new
ContainerDescription
();
containerDescriptionClient
.
setMode
(
"normal"
);
containerDescriptionClient
.
setReplicas
(
1
);
DockerContainer
container
=
new
DockerContainer
();
container
.
setName
(
"dbc_cloud_client"
);
//创建一个client容器
container
.
setCommand
(
"sh"
);
container
.
setImage
(
"dbc_cloud_client"
);
container
.
setPorts
(
"8000"
);
//指定容器端口
containerDescriptionClient
.
setDockerContainer
(
container
);
cds
.
add
(
containerDescriptionClient
);
//将client容器添加到list集合中
/*通过镜像"ymwang/dfs_transfer_server"启动一个名为server1的容器,用于存储图片切片*/
ContainerDescription
containerDescriptionServer1
=
new
ContainerDescription
();
containerDescriptionServer1
.
setMode
(
"normal"
);
containerDescriptionServer1
.
setReplicas
(
1
);
DockerContainer
containerServer1
=
new
DockerContainer
();
containerServer1
.
setName
(
"dbc_cloud_server"
);
//创建一个server1容器
containerServer1
.
setCommand
(
"sh"
);
containerServer1
.
setImage
(
"dbc_cloud_server"
);
containerDescriptionServer1
.
setDockerContainer
(
containerServer1
);
cds
.
add
(
containerDescriptionServer1
);
//将server1容器添加到list集合中
clusterConfigCom
.
setDockers
(
cds
);
NetworkTopology
topo
=
new
NetworkTopology
();
//topo.setAppNames(new String[]{"Run", "APP", "br:ovs1"});
topo
.
setAppNames
(
new
String
[]{
"dbc_cloud_client"
,
"dbc_cloud_server"
,
"br:ovs1"
});
// 这个参数好像没啥用
topo
.
setTopologyId
(
11
);
topo
.
setTopology
(
new
int
[][]{{
0
,
0
,
0
},{
0
,
0
,
0
},{
1
,
1
,
0
}});
clusterConfigCom
.
setTopology
(
topo
);
separatedClusterConfig
.
setClusterConfig
(
clusterConfigCom
);
clusterConfigs
.
add
(
separatedClusterConfig
);
clusterService
.
sendClusterConfigToEdgeNode
(
clusterConfigs
);
}
//测试容器ip
@Test
public
void
getIpListByAppNameTest
()
{
List
<
String
>
ipList
=
networkService
.
getIpListByAppName
(
11114L
,
"dbc_cloud_server"
);
System
.
out
.
println
(
ipList
);
}
@Test
public
void
getIpList
()
{
List
<
String
>
ipListS
=
networkService
.
getIpListByAppName
(
11114L
,
"dbc_cloud_server"
);
String
[]
ipList
=
new
String
[
ipListS
.
size
()];
for
(
int
i
=
0
;
i
<
ipListS
.
size
();
i
++)
{
if
(!
ipListS
.
isEmpty
()){
String
ip_tmp
=
ipListS
.
get
(
i
);
String
[]
split_list
=
ip_tmp
.
split
(
"/"
);
ipList
[
i
]
=
split_list
[
0
]+
":8888"
;
}
}
for
(
int
j
=
0
;
j
<
ipList
.
length
;
j
++)
{
System
.
out
.
println
(
ipList
[
j
]);
}
}
@Test
public
void
removeClusterFromEdgeNodeTest
()
{
clusterService
.
removeClusterFromEdgeNode
(
11114L
);
}
@Test
public
void
getLogicalNetworkTopologyTest
()
{
NetworkTopology
logicalNetworkTopology
=
networkService
.
getLogicalNetworkTopology
(
11114L
);
System
.
out
.
println
(
logicalNetworkTopology
);
}
@Test
public
void
enableNetworkMonitorTest
()
throws
InterruptedException
{
String
res
=
networkService
.
enableNetworkMonitor
(
11114L
,
"server"
);
System
.
out
.
println
(
res
);
}
@Test
public
void
cancelNetworkMonitorTest
()
{
String
run
=
networkService
.
cancelNetworkMonitor
(
11112L
,
"server"
);
System
.
out
.
println
(
run
);
}
@Test
public
void
getNetworkMonitorTest
()
throws
InterruptedException
{
List
<
ContainerMonitor
>
run
=
networkService
.
getContainerMonitors
(
11112L
,
"Run"
);
int
i
=
0
;
while
(
i
<
10
)
{
run
.
forEach
(
c
->
{
System
.
out
.
println
(
c
.
getContainerInfo
());
});
Thread
.
sleep
(
500
);
i
++;
}
}
}
apps/cnf-distributed-business-computing/dbc-business-cloud-cli/src/main/java/top/ninwoo/dbc/cloud/client/service/FileCloService.java
View file @
82c0d7f0
package
top.ninwoo.dbc.cloud.client.service
;
package
top.ninwoo.dbc.cloud.client.service
;
import
top.ninwoo.bishe.starter.service.NetworkService
;
import
top.ninwoo.dbc.api.po.*
;
import
top.ninwoo.dbc.api.po.*
;
import
top.ninwoo.dbc.api.service.DistributedComService
;
import
top.ninwoo.dbc.api.service.DistributedComService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -10,6 +11,7 @@ import org.springframework.scheduling.annotation.Async;
...
@@ -10,6 +11,7 @@ import org.springframework.scheduling.annotation.Async;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.PostConstruct
;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
...
@@ -27,11 +29,32 @@ public class FileCloService {
...
@@ -27,11 +29,32 @@ public class FileCloService {
@Autowired
@Autowired
private
RestTemplate
restTemplate
;
private
RestTemplate
restTemplate
;
@Autowired
private
NetworkService
networkService
;
@Autowired
@Autowired
private
DistributedComService
distributedComService
;
private
DistributedComService
distributedComService
;
String
cloudIp
=
"127.0.0.1:8888"
;
//String cloudIp = "127.0.0.1:8888";
//String cloudIp = "172.17.0.4:8888";
private
String
cloudIp
=
null
;
@PostConstruct
public
void
init
()
{
cloudIp
=
getIpList
(
11114
l
,
"dbc_cloud_server"
);
System
.
out
.
println
(
cloudIp
);
}
public
String
getIpList
(
Long
clusterId
,
String
appName
)
{
List
<
String
>
ipList
=
networkService
.
getIpListByAppName
(
clusterId
,
appName
);
if
(!
ipList
.
isEmpty
()){
String
ip_tmp
=
ipList
.
get
(
0
);
String
[]
split_list
=
ip_tmp
.
split
(
"/"
);
String
containerIp
=
split_list
[
0
]+
":8888"
;
return
containerIp
;
}
return
null
;
}
/**
/**
...
@@ -44,8 +67,9 @@ public class FileCloService {
...
@@ -44,8 +67,9 @@ public class FileCloService {
public
String
sendFile
(
Long
fileId
,
byte
[]
fileBytes
)
{
public
String
sendFile
(
Long
fileId
,
byte
[]
fileBytes
)
{
// 通过集群服务器接口获取当前集群的节点数量
// 通过集群服务器接口获取当前集群的节点数量
// todo 这里需要制定文件的fileId
cloudIp
=
getIpList
(
11114
l
,
"dbc_cloud_server"
);
// todo 这里需要制定文件的fileId
FileCloudSlice
fileCloudSlice
=
new
FileCloudSlice
();
FileCloudSlice
fileCloudSlice
=
new
FileCloudSlice
();
fileCloudSlice
.
setFileCloudId
(
fileId
);
fileCloudSlice
.
setFileCloudId
(
fileId
);
fileCloudSlice
.
setFileByte
(
fileBytes
);
fileCloudSlice
.
setFileByte
(
fileBytes
);
...
@@ -76,6 +100,8 @@ public class FileCloService {
...
@@ -76,6 +100,8 @@ public class FileCloService {
}
}
public
String
getFile
(
String
fileName
,
Long
fileId
)
{
public
String
getFile
(
String
fileName
,
Long
fileId
)
{
cloudIp
=
getIpList
(
11114
l
,
"dbc_cloud_server"
);
Set
<
FileCloudSlice
>
result
=
new
HashSet
<>();
Set
<
FileCloudSlice
>
result
=
new
HashSet
<>();
Set
<
FileCloudSlice
>
fileCloudComSet
=
getFileSlice
(
cloudIp
,
fileId
);
Set
<
FileCloudSlice
>
fileCloudComSet
=
getFileSlice
(
cloudIp
,
fileId
);
...
...
apps/cnf-distributed-business-computing/dbc-business-cloud-cli/src/main/resources/application.properties
View file @
82c0d7f0
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
server.port
=
8000
server.port
=
8000
#接入云端的端口设置
#接入云端的端口设置
#
bishe.app.app-name=joliu
bishe.app.app-name
=
joliu
#bishe.app.cloud-url=192.168.31.156:9090
bishe.app.cloud-url
=
192.168.81.1:9091
#容器里的挂载目录
#容器里的挂载目录
dbc.directory.output
=
/tmp/static/
dbc.directory.output
=
/tmp/static/
...
...
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