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
c2aac233
Commit
c2aac233
authored
Feb 02, 2021
by
ymwangya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new
parent
47651670
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
27 deletions
+30
-27
apps/cnf-hadoop-computing/cnf-hadoop-client/src/main/java/top/ninwoo/hadoop/client/service/FileService.java
...in/java/top/ninwoo/hadoop/client/service/FileService.java
+29
-26
apps/cnf-hadoop-computing/cnf-hadoop-test/src/test/java/top/ninwoo/hadoop/tests/HadoopTest.java
...est/src/test/java/top/ninwoo/hadoop/tests/HadoopTest.java
+1
-1
No files found.
apps/cnf-hadoop-computing/cnf-hadoop-client/src/main/java/top/ninwoo/hadoop/client/service/FileService.java
View file @
c2aac233
...
...
@@ -50,23 +50,6 @@ public class FileService{
private
String
[]
ipList
=
new
String
[
29
];
private
List
<
Integer
>
index
=
new
ArrayList
<
Integer
>()
{}
;
long
startTime
=
System
.
currentTimeMillis
();
// 获取开始时间
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
//设置日期格式
/*获取容器ip*/
public
String
[]
getIpList
(
Long
clusterId
,
String
appName
)
{
List
<
String
>
ipListS
=
networkService
.
getIpListByAppName
(
clusterId
,
appName
);
//用于存储容器ip的list集合
String
[]
containerIp
=
new
String
[
ipListS
.
size
()];
//将集合中的元素存在数组里,因为下边用的是数组
for
(
int
i
=
0
;
i
<
ipListS
.
size
();
i
++)
{
if
(!
ipListS
.
isEmpty
()){
String
ip_tmp
=
ipListS
.
get
(
i
);
String
rep
=
ip_tmp
.
replaceAll
(
"[\\[\\]]"
,
""
);
String
[]
split_list
=
rep
.
split
(
"/"
);
containerIp
[
i
]
=
split_list
[
0
]+
":8082"
;
}
}
return
containerIp
;
}
public
String
getIpByAppName
(
Long
clusterId
,
String
appName
)
{
List
<
String
>
ipList
=
networkService
.
getIpListByAppName
(
clusterId
,
appName
);
...
...
@@ -84,12 +67,16 @@ public class FileService{
* @param bufferedImage
* @return
*/
long
startTime
=
System
.
currentTimeMillis
()/
1000
;
// 获取开始时间
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
//设置日期格式
@Async
(
"taskExecutor"
)
public
String
sendFile
(
Long
fileId
,
BufferedImage
bufferedImage
)
{
//long startTime = System.currentTimeMillis(); // 获取开始时间
System
.
out
.
println
(
"The current system time at the beginning of the program:"
+
df
.
format
(
new
Date
()));
// new Date()为获取当前系统时间
System
.
out
.
println
(
"The execution time at the beginning of the program:"
+
startTime
);
// System.out.println("-----------------------------The time of sending file--------------------------------");
// long startTime = System.currentTimeMillis()/1000; // 获取开始时间
System
.
out
.
println
(
"The current system time at the beginning of the program:"
+
df
.
format
(
new
Date
()));
// new Date()为获取当前系统时间
for
(
int
i
=
0
;
i
<
wxName_list
.
length
;
i
++){
ipList
[
i
]
=
getIpByAppName
(
clusterId
,
wxName_list
[
i
]);
//通过卫星名字获取卫星ip
...
...
@@ -118,7 +105,14 @@ public class FileService{
}
}
}
/* long endTime = System.currentTimeMillis()/1000; //获取程序结束时间
System.out.println("The current system time at the end of the program:"+ df.format(new Date()));// new Date()为获取当前系统时间
System.out.println("The total running time of the program:" + (endTime - startTime) + "s");
System.out.println("=====================================================================================");*/
return
"success"
;
}
// 发送文件切片到目标地址
...
...
@@ -139,6 +133,11 @@ public class FileService{
}
public
String
getFile
(
String
fileName
,
Long
fileId
)
{
/* System.out.println("--------------------The time of geting file------------------------------------------");
long startTime1 = System.currentTimeMillis()/1000; // 获取开始时间
System.out.println("The current system time at the beginning of the program:" +df.format(new Date()));*/
for
(
int
i
=
0
;
i
<
wxName_list
.
length
;
i
++){
ipList
[
i
]
=
getIpByAppName
(
clusterId
,
wxName_list
[
i
]);
//通过卫星名字获取卫星ip
}
...
...
@@ -147,10 +146,10 @@ public class FileService{
//异常处理
for
(
int
k
=
0
;
k
<
5
;
k
++)
{
try
{
//
Set<FileSlice> fileSliceSet = getFileSlice(ipList[index.get(k)], fileId);
//
System.out.println("recive "+wxName_list[index.get(k)]+" success");
Set
<
FileSlice
>
fileSliceSet
=
getFileSlice
(
ipList
[
k
],
fileId
);
System
.
out
.
println
(
"recive "
+
wxName_list
[
k
]+
" success"
);
Set
<
FileSlice
>
fileSliceSet
=
getFileSlice
(
ipList
[
index
.
get
(
k
)],
fileId
);
System
.
out
.
println
(
"recive "
+
wxName_list
[
index
.
get
(
k
)]+
" success"
);
//
Set<FileSlice> fileSliceSet = getFileSlice(ipList[k], fileId);
//
System.out.println("recive "+wxName_list[k]+" success");
result
.
addAll
(
fileSliceSet
);
}
catch
(
Exception
e
){
System
.
out
.
println
(
"recive fileslice fail"
);
...
...
@@ -159,12 +158,16 @@ public class FileService{
List
<
FileSlice
>
list
=
new
ArrayList
<>(
result
);
SplitResult
splitResult
=
new
SplitResult
();
splitResult
.
setFileSliceList
(
sortList
(
list
));
//merge
ComputingResult
computingResult
=
hadoopComService
.
sliceComputing
(
splitResult
);
MergeResult
mergeResult
=
hadoopComService
.
sliceMerge
(
computingResult
,
sliceNum
);
//save
try
{
saveFile
(
fileName
,
mergeResult
);
long
endTime
=
System
.
currentTimeMillis
()/
1000
;
//获取程序结束时间
System
.
out
.
println
(
"The current system time at the end of the program:"
+
df
.
format
(
new
Date
()));
// new Date()为获取当前系统时间
System
.
out
.
println
(
"The total running time of the program:"
+
(
endTime
-
startTime
)
+
"s"
);
return
"success"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -197,10 +200,10 @@ public class FileService{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
long
endTime
=
System
.
currentTimeMillis
();
//获取程序结束时间
/*
long endTime = System.currentTimeMillis(); //获取程序结束时间
System.out.println("The current system time at the end of the program:"+ df.format(new Date()));// new Date()为获取当前系统时间
System.out.println("The execution time at the end of the program:"+ endTime);
System
.
out
.
println
(
"The total running time of the program:"
+
(
endTime
-
startTime
)
+
"ms"
);
System.out.println("The total running time of the program:" + (endTime - startTime) + "ms");
*/
}
public
List
<
Integer
>
getIndex
(
int
num
){
...
...
apps/cnf-hadoop-computing/cnf-hadoop-test/src/test/java/top/ninwoo/hadoop/tests/HadoopTest.java
View file @
c2aac233
...
...
@@ -85,7 +85,7 @@ public class HadoopTest {
DockerContainer
container0
=
new
DockerContainer
();
container0
.
setName
(
wxData
.
get
(
wxData
.
size
()-
1
).
getName
());
container0
.
setCommand
(
"sh"
);
container0
.
setImage
(
"hadoop
_client
"
);
container0
.
setImage
(
"hadoop"
);
container0
.
setPorts
(
"8999"
);
//指定容器端口
containerDescription0
.
setDockerContainer
(
container0
);
...
...
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