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
29d11138
Commit
29d11138
authored
Aug 17, 2020
by
ymwang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
动态网络拓扑下发
parent
71a72ef2
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
79 additions
and
51 deletions
+79
-51
apps/cnf-distributed-business-computing/cnf-distributed-business-topu/pom.xml
...-business-computing/cnf-distributed-business-topu/pom.xml
+0
-38
apps/cnf-distributed-business-computing/cnf-distributed-business-topu/target/cnf-distributed-business-topu-1.0-SNAPSHOT.jar
...opu/target/cnf-distributed-business-topu-1.0-SNAPSHOT.jar
+0
-0
apps/cnf-distributed-business-computing/cnf-distributed-business-topu/target/maven-archiver/pom.properties
...ibuted-business-topu/target/maven-archiver/pom.properties
+0
-5
apps/cnf-distributed-business-computing/pom.xml
apps/cnf-distributed-business-computing/pom.xml
+1
-1
apps/cnf-distributed-file-transfer/dfs-transfer-client/src/main/java/top/ninwoo/app/dfs/client/controller/TestController.java
.../top/ninwoo/app/dfs/client/controller/TestController.java
+1
-1
apps/cnf-distributed-file-transfer/dfs-transfer-client/src/main/java/top/ninwoo/app/dfs/client/service/FileService.java
...n/java/top/ninwoo/app/dfs/client/service/FileService.java
+76
-5
apps/cnf-distributed-file-transfer/dfs-transfer-client/src/main/resources/application.properties
...transfer-client/src/main/resources/application.properties
+1
-1
No files found.
apps/cnf-distributed-business-computing/cnf-distributed-business-topu/pom.xml
deleted
100644 → 0
View file @
71a72ef2
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
cnf-distributed-business-computing
</artifactId>
<groupId>
top.ninwoo
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
cnf-distributed-business-topu
</artifactId>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
top.ninwoo
</groupId>
<artifactId>
cnf-client-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
apps/cnf-distributed-business-computing/cnf-distributed-business-topu/target/cnf-distributed-business-topu-1.0-SNAPSHOT.jar
deleted
100644 → 0
View file @
71a72ef2
apps/cnf-distributed-business-computing/cnf-distributed-business-topu/target/maven-archiver/pom.properties
deleted
100644 → 0
View file @
71a72ef2
#Generated by Maven
#Sun Aug 16 17:08:54 CST 2020
version
=
1.0-SNAPSHOT
groupId
=
top.ninwoo
artifactId
=
cnf-distributed-business-topu
apps/cnf-distributed-business-computing/pom.xml
View file @
29d11138
...
...
@@ -20,7 +20,7 @@
<module>
dbc-business-utils
</module>
<module>
dbc-commom-api
</module>
<module>
cnf-distri-test
</module>
<module>
cnf-distributed-business-topu
</module>
<module>
distributed-business-cloudTest
</module>
</modules>
<artifactId>
cnf-distributed-business-computing
</artifactId>
...
...
apps/cnf-distributed-file-transfer/dfs-transfer-client/src/main/java/top/ninwoo/app/dfs/client/controller/TestController.java
View file @
29d11138
...
...
@@ -34,7 +34,7 @@ public class TestController {
return
result
;
}
/*
@GetMapping("sendFile")
/*
@GetMapping("sendFile")
public String sendFile(String name, Long fileId) {
byte[] bytes = fileService.readFile(name);
return fileService.sendFile(fileId, bytes);
...
...
apps/cnf-distributed-file-transfer/dfs-transfer-client/src/main/java/top/ninwoo/app/dfs/client/service/FileService.java
View file @
29d11138
...
...
@@ -14,7 +14,7 @@ import top.ninwoo.commonapi.po.SplitResult;
import
top.ninwoo.commonapi.service.TransferService
;
import
javax.annotation.PostConstruct
;
import
java.io.
FileOutputStream
;
import
java.io.
*
;
import
java.util.*
;
/**
...
...
@@ -23,6 +23,9 @@ import java.util.*;
@Service
public
class
FileService
{
@Value
(
"${dfs.directory.output}"
)
private
String
directoryPath
;
@Value
(
"${dfs.directory.output}"
)
private
String
directoryOutput
;
...
...
@@ -43,6 +46,7 @@ public class FileService {
private
String
[]
ipList
=
null
;
@PostConstruct
public
void
init
()
{
//ipList = getIpList(11112l,"dfs_server");
...
...
@@ -52,7 +56,6 @@ public class FileService {
}
public
String
[]
getIpList
(
Long
clusterId
,
String
appName
)
{
//List<String> ipListS = networkService.getIpListByAppName(clusterId, appName);//用于存储容器ip的list集合
...
...
@@ -73,6 +76,41 @@ public class FileService {
return
containerIp
;
}
// 从文件中读取数据
public
byte
[]
readFile
(
String
fileName
)
{
FileInputStream
fis
=
null
;
ByteArrayOutputStream
bos
=
null
;
try
{
File
file
=
new
File
(
fileName
);
fis
=
new
FileInputStream
(
file
);
bos
=
new
ByteArrayOutputStream
();
byte
[]
b
=
new
byte
[
1024
*
10
];
//存取读到的多个字节
int
len
;
//每次读取的有效字节的个数
while
((
len
=
fis
.
read
(
b
))
!=
-
1
)
{
bos
.
write
(
b
,
0
,
len
);
}
return
bos
.
toByteArray
();
}
catch
(
Exception
e
)
{
if
(
fis
!=
null
)
{
try
{
fis
.
close
();
}
catch
(
IOException
ioException
)
{
ioException
.
printStackTrace
();
}
}
if
(
bos
!=
null
)
{
try
{
bos
.
close
();
}
catch
(
IOException
ioException
)
{
ioException
.
printStackTrace
();
}
}
throw
new
RuntimeException
(
"文件读取错误"
+
e
.
getMessage
());
}
}
/**
* 发送文件到分布式节点
* @param fileId
...
...
@@ -83,13 +121,16 @@ public class FileService {
public
String
sendFile
(
Long
fileId
,
byte
[]
fileBytes
)
{
// 通过集群服务器接口获取当前集群的节点数量
//ipList = this.getIpList(clusterId,"dfs_server");
//读入图片数据
//byte[] fileBytes = readFile("1.jpg");
for
(
int
i
=
0
;
i
<
wxName_list
.
length
;
i
++){
ipList
=
getIpList
(
clusterId
,
wxName_list
[
i
]);
//通过卫星名字获取卫星ip
}
int
sliceNum
=
ipList
.
length
;
//int sliceNum = 30;
int
origNum
=
6
;
int
sliceNum
=
ipList
.
length
;
//根据卫星节点个数确定冗余后的数据碎片个数
int
origNum
=
6
;
//自己设定的一个图片被分割的原始数据的个数
// todo 这里需要制定文件的fileId
SplitResult
splitResult
=
transferService
.
fileSplit
(
fileBytes
,
sliceNum
,
origNum
);
...
...
@@ -118,6 +159,8 @@ public class FileService {
if
(!
response
.
getStatusCode
().
is2xxSuccessful
())
{
return
"failed!"
;
}
saveToFile
(
fileSlice
,
directoryOutput
);
return
response
.
getBody
();
}
...
...
@@ -186,4 +229,32 @@ public class FileService {
fos
.
write
(
fileByte
,
0
,
fileByte
.
length
);
fos
.
close
();
}
//在client将数据碎片传送至各个server上时,将数据包中的字节流存储在节点上
private
void
saveToFile
(
FileSlice
fileSlice
,
String
file_path
)
{
byte
[]
slice_data
=
fileSlice
.
getFileBytes
();
File
targetFile
=
new
File
(
file_path
);
if
(
targetFile
.
exists
())
{
targetFile
.
delete
();
}
//为什么创建父类
createParents
(
targetFile
);
try
{
targetFile
.
createNewFile
();
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
targetFile
);
fileOutputStream
.
write
(
slice_data
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
private
void
createParents
(
File
f
)
{
String
parentName
=
f
.
getParent
();
File
parent
=
new
File
(
parentName
);
if
(!
parent
.
exists
())
{
createParents
(
parent
);
parent
.
mkdir
();
}
}
}
\ No newline at end of file
apps/cnf-distributed-file-transfer/dfs-transfer-client/src/main/resources/application.properties
View file @
29d11138
...
...
@@ -4,7 +4,7 @@ bishe.app.app-name=joliu
#bishe.app.cloud-url=192.168.31.156:9090
bishe.app.cloud-url
=
192.168.31.198:9091
dfs.directory.output
=
/tmp/static/
dfs.directory.output
=
/tmp/static/
images/
#thymeleaf
spring.thymeleaf.prefix
=
classpath:/templates/
...
...
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