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
5e506afb
Commit
5e506afb
authored
Aug 18, 2020
by
ymwang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
单时隙业务
parent
ecbbca86
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
29 deletions
+71
-29
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
+1
-29
apps/cnf-distributed-file-transfer/dfs-transfer-topology/src/main/java/top/ninwoo/weixingsim/dynamicNet/SingleSlotTopology.java
.../top/ninwoo/weixingsim/dynamicNet/SingleSlotTopology.java
+70
-0
No files found.
apps/cnf-distributed-file-transfer/dfs-transfer-client/src/main/java/top/ninwoo/app/dfs/client/service/FileService.java
View file @
5e506afb
...
...
@@ -160,7 +160,6 @@ public class FileService {
return
"failed!"
;
}
saveToFile
(
fileSlice
,
directoryOutput
);
return
response
.
getBody
();
}
...
...
@@ -230,31 +229,4 @@ public class FileService {
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-topology/src/main/java/top/ninwoo/weixingsim/dynamicNet/SingleSlotTopology.java
0 → 100644
View file @
5e506afb
package
top.ninwoo.weixingsim.dynamicNet
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.HashMap
;
import
static
top
.
ninwoo
.
weixingsim
.
dynamicNet
.
CycleTopoUnit
.
cycleTp
;
public
class
SingleSlotTopology
{
/*
* 网络参数
*/
//设备数
static
int
num
=
30
;
//时隙大小
static
double
slot
=
20
*
1000
;
//时隙数目
static
int
slotnum
;
//网络节点数
static
int
dev
;
public
static
void
main
(
String
[]
args
)
{
int
[][]
matrixGraph
=
SingleMatrixGraph
();
for
(
int
i
=
0
;
i
<
matrixGraph
.
length
;
i
++)
{
for
(
int
j
=
0
;
j
<
matrixGraph
[
0
].
length
;
j
++)
{
System
.
out
.
print
(
matrixGraph
[
i
][
j
]+
" "
);
}
System
.
out
.
println
();
}
}
//业务发起时刻
public
static
long
startT
;
private
static
int
[][]
SingleMatrixGraph
()
{
//获取当前3时隙拓扑
/**
* 先用SimpleDateFormat.parse() 方法将日期字符串转化为Date格式
* 通过Date.getTime()方法,将其转化为毫秒数
*/
String
date
=
"2019-01-01 00-00-00"
;
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH-mm-ss"
);
//24小时制
long
time
=
0
;
try
{
time
=
simpleDateFormat
.
parse
(
date
).
getTime
();
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
int
slotKey
=
(
int
)
((((
System
.
currentTimeMillis
()-
time
)/
20
/
1000
)-
1
)%
300
+
1
);
startT
=
((
System
.
currentTimeMillis
()-
time
)/
20000
+
1
)*
20000
;
HashMap
<
Integer
,
int
[][]>
cycleTp
=
cycleTp
();
//获得第1个时隙的连接矩阵 0或1
int
[][]
currentTp
=
cycleTp
.
get
((
slotKey
)%
30
+
1
);
int
[][]
slot1
=
new
int
[
num
][
num
];
//10*10的矩阵图
for
(
int
i
=
0
;
i
<
slot1
.
length
;
i
++){
for
(
int
j
=
0
;
j
<
slot1
[
0
].
length
;
j
++){
slot1
[
i
][
j
]
=
currentTp
[
i
][
j
];
}
}
return
slot1
;
}
}
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