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
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
alex037yang
openXG-WIC-Cnf
Commits
f6bd61a8
Commit
f6bd61a8
authored
Sep 05, 2020
by
Elf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
扩散算法(伪)
parent
60aee3cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
10 deletions
+32
-10
apps/cnf-distributed-business-computing/dbc-business-client/src/main/java/top/ninwoo/dbc/client/service/FileService.java
.../main/java/top/ninwoo/dbc/client/service/FileService.java
+32
-10
No files found.
apps/cnf-distributed-business-computing/dbc-business-client/src/main/java/top/ninwoo/dbc/client/service/FileService.java
View file @
f6bd61a8
...
@@ -48,6 +48,8 @@ public class FileService{
...
@@ -48,6 +48,8 @@ public class FileService{
"sate22"
,
"sate23"
,
"sate24"
,
"sate25"
,
"sate26"
,
"sate27"
,
"sate28"
,
"sate29"
};
//获取卫星名字
"sate22"
,
"sate23"
,
"sate24"
,
"sate25"
,
"sate26"
,
"sate27"
,
"sate28"
,
"sate29"
};
//获取卫星名字
private
String
[]
ipList
=
new
String
[
29
];
private
String
[]
ipList
=
new
String
[
29
];
private
List
<
Integer
>
index
=
new
ArrayList
<
Integer
>()
{}
;
/* @PostConstruct
/* @PostConstruct
public void init() {
public void init() {
*//* ipList = getIpList(11113l,"dbc_server");
*//* ipList = getIpList(11113l,"dbc_server");
...
@@ -103,25 +105,29 @@ public class FileService{
...
@@ -103,25 +105,29 @@ public class FileService{
System
.
out
.
println
(
ipList
.
length
);
System
.
out
.
println
(
ipList
.
length
);
System
.
out
.
println
(
Arrays
.
toString
(
ipList
));
System
.
out
.
println
(
Arrays
.
toString
(
ipList
));
int
sliceNum
=
10
;
index
=
this
.
getIndex
(
ipList
.
length
);
int
sliceNum
=
5
;
// todo 这里需要制定文件的fileId
// todo 这里需要制定文件的fileId
SplitResult
splitResult
=
distributedComService
.
fileSplit
(
bufferedImage
,
sliceNum
);
SplitResult
splitResult
=
distributedComService
.
fileSplit
(
bufferedImage
,
sliceNum
);
int
ipIndex
=
0
;
//int ipIndex = 0;
int
i
=
0
;
for
(
FileSlice
slice
:
splitResult
.
getFileSliceList
())
{
for
(
FileSlice
slice
:
splitResult
.
getFileSliceList
())
{
slice
.
setFileId
(
fileId
);
slice
.
setFileId
(
fileId
);
//异常处理
//异常处理
while
(
true
){
while
(
true
){
try
{
try
{
sendFileSlice
(
ipList
[
i
pIndex
],
slice
);
sendFileSlice
(
ipList
[
i
ndex
.
get
(
i
)
],
slice
);
//
//
System
.
out
.
println
(
"send "
+
ipList
[
ipIndex
]+
"success"
);
System
.
out
.
println
(
"send "
+
wxName_list
[
index
.
get
(
i
)]+
" success"
);
ipIndex
=
(
ipIndex
+
1
)
%
ipList
.
length
;
i
=
i
+
1
;
//ipIndex = (ipIndex + 1) % ipList.length;
break
;
break
;
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
ipIndex
=
(
ipIndex
+
1
)
%
ipList
.
length
;
//
ipIndex = (ipIndex + 1) % ipList.length;
//
//
System
.
out
.
println
(
"send "
+
ipList
[
ipIndex
]+
"
failed"
);
System
.
out
.
println
(
"send "
+
wxName_list
[
index
.
get
(
i
)]+
"
failed"
);
}
}
}
}
}
}
...
@@ -160,7 +166,7 @@ public class FileService{
...
@@ -160,7 +166,7 @@ public class FileService{
for
(
int
i
=
0
;
i
<
wxName_list
.
length
;
i
++){
for
(
int
i
=
0
;
i
<
wxName_list
.
length
;
i
++){
ipList
[
i
]
=
getIpByAppName
(
clusterId
,
wxName_list
[
i
]);
//通过卫星名字获取卫星ip
ipList
[
i
]
=
getIpByAppName
(
clusterId
,
wxName_list
[
i
]);
//通过卫星名字获取卫星ip
}
}
int
sliceNum
=
10
;
int
sliceNum
=
5
;
//int sliceNum = ipList.length;
//int sliceNum = ipList.length;
Set
<
FileSlice
>
result
=
new
HashSet
<>();
Set
<
FileSlice
>
result
=
new
HashSet
<>();
/* for (String ip : ipList) {
/* for (String ip : ipList) {
...
@@ -169,9 +175,10 @@ public class FileService{
...
@@ -169,9 +175,10 @@ public class FileService{
}*/
}*/
//异常处理
//异常处理
for
(
int
index
=
0
;
index
<
10
;
index
++)
{
for
(
int
k
=
0
;
k
<
5
;
k
++)
{
try
{
try
{
Set
<
FileSlice
>
fileSliceSet
=
getFileSlice
(
ipList
[
index
],
fileId
);
Set
<
FileSlice
>
fileSliceSet
=
getFileSlice
(
ipList
[
index
.
get
(
k
)],
fileId
);
System
.
out
.
println
(
"recive "
+
wxName_list
[
index
.
get
(
k
)]+
" success"
);
result
.
addAll
(
fileSliceSet
);
result
.
addAll
(
fileSliceSet
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
...
@@ -222,6 +229,21 @@ public class FileService{
...
@@ -222,6 +229,21 @@ public class FileService{
}
}
public
List
<
Integer
>
getIndex
(
int
num
){
Random
r
=
new
Random
();
List
<
Integer
>
v
=
new
ArrayList
<
Integer
>()
{}
;
int
count
=
0
;
while
(
count
<
5
){
int
number
=
r
.
nextInt
(
num
)
+
1
;
if
(!
v
.
contains
(
number
)){
//不在集合中,就添加
v
.
add
(
number
);
count
++;
}
}
return
v
;
}
...
...
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