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
7cd86d1d
Commit
7cd86d1d
authored
Aug 24, 2020
by
Hu Jintao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整参数
parent
aa06df5e
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
265 additions
and
33 deletions
+265
-33
apps/cnf-path-computing/businessInCloud/src/main/java/top/ninwoo/test/BisheTestMain.java
...sInCloud/src/main/java/top/ninwoo/test/BisheTestMain.java
+23
-13
apps/cnf-path-computing/businessInCloud/src/main/java/top/ninwoo/test/doMap/CycleTopo.java
...nCloud/src/main/java/top/ninwoo/test/doMap/CycleTopo.java
+1
-1
apps/cnf-path-computing/businessInCloud/src/main/java/top/ninwoo/test/doMap/DoMap.java
...essInCloud/src/main/java/top/ninwoo/test/doMap/DoMap.java
+15
-4
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/IPicProcess.java
...rc/main/java/com/pitong/business/service/IPicProcess.java
+15
-0
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/ServerService.java
.../main/java/com/pitong/business/service/ServerService.java
+20
-15
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/picImpl/binaryProcess.java
...va/com/pitong/business/service/picImpl/binaryProcess.java
+28
-0
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/picImpl/cutProcess.java
.../java/com/pitong/business/service/picImpl/cutProcess.java
+29
-0
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/picImpl/greyProcess.java
...java/com/pitong/business/service/picImpl/greyProcess.java
+28
-0
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/picImpl/mergePorcess.java
...ava/com/pitong/business/service/picImpl/mergePorcess.java
+27
-0
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/picImpl/tailorProcess.java
...va/com/pitong/business/service/picImpl/tailorProcess.java
+28
-0
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/saveFile/Save.java
.../main/java/com/pitong/business/service/saveFile/Save.java
+51
-0
No files found.
apps/cnf-path-computing/businessInCloud/src/main/java/top/ninwoo/test/BisheTestMain.java
View file @
7cd86d1d
...
...
@@ -14,7 +14,6 @@ import top.ninwoo.test.doMap.DoMap;
import
top.ninwoo.test.doMap.path
;
import
java.io.*
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.util.*
;
...
...
@@ -49,15 +48,19 @@ public class BisheTestMain implements ApplicationRunner {
int
[][]
link
=
{{
0
,
0
,
1
,
2
,
3
,
4
,
5
},
{
1
,
2
,
3
,
4
,
5
,
5
,
6
}};
//task编号
int
[]
func
=
{
1
,
3
,
3
,
3
,
2
,
2
,
4
};
//功能分支表
int
[][]
branch
=
{{
1
,
1
},{
1
,
2
},{
1
,
1
},{
2
,
1
},{
1
,
1
}};
DoMap
doMap
=
new
DoMap
();
doMap
.
doMapApp
();
doMap
.
doMapApp
(
link
,
func
);
//将节点映射结果保存为List
int
[]
result
=
doMap
.
result
;
while
(
result
[
0
]
==
0
){
boolean
flag
=
repetition
(
result
);
while
(
result
[
0
]
==
0
||
flag
){
System
.
out
.
println
(
"failure mapping :"
+
Arrays
.
toString
(
result
));
doMap
.
doMapApp
();
doMap
.
doMapApp
(
link
,
func
);
result
=
doMap
.
result
;
flag
=
repetition
(
result
);
}
List
<
Integer
>
sequence
=
new
ArrayList
<>();
for
(
int
a:
result
...
...
@@ -94,23 +97,31 @@ public class BisheTestMain implements ApplicationRunner {
String
loc
=
null
;
//
String loc = null;
String
file_path
=
"passport.jpg"
;
int
number
=
1
;
double
eta
=
ETA
;
/* int number = 1;
Long currentime = System.currentTimeMillis();
Long fun1time = Long.valueOf(0);
List<Double> compCapacity = Arrays.asList(1.112341341313, 0.5196272109574349, 0.675827555541419, 0.7637869915859579, 0.7998320296858645,
0.638652700648973, 0.6396760676518485, 0.5615337810185533, 0.6356797503522186, 0.8266103444996542, 0.6924037701405794,
0.9371892689614395, 0.6949256728585527, 0.6212614126622614, 0.6318393608430264, 0.7494680794385384, 0.9983949989039682,
0.5610722256465777, 0.6415780028672076, 0.9371892689, 0.5269659075274151, 0.8219152161388867, 0.5815463889106197, 0.8431429542046349,
0.31386253514456774
,
0.6045132365410817
,
0.8102279249524735
,
0.47057296148341216
,
0.8529743685059654
,
0.8177711194660409
);
//取值范围0.2到1,首尾固定为1M/s
LinkedList
<
Double
>
tranDelay
=
doMap
.
list
;
0.31386253514456774, 0.6045132365410817, 0.8102279249524735, 0.47057296148341216, 0.8529743685059654, 0.8177711194660409);//取值范围0.2到1,首尾固定为1M/s
*/
/*
LinkedList<Double> tranDelay = doMap.list;
for (int i = 0;i<tranDelay.size();i++){
tranDelay.set(i,tranDelay.get(i)/(i+2)+(Math.random()*10+1));
}*/
// DataPackage dataPackage = combine(file_path, lastHop, edgeMaps, nodeMaps);
// send(dataPackage, targetIp, 2020);
}
DataPackage
dataPackage
=
combine
(
number
,
sequence
,
loc
,
file_path
,
eta
,
currentime
,
fun1time
,
compCapacity
,
tranDelay
);
send
(
dataPackage
,
targetIp
,
2020
);
private
boolean
repetition
(
int
[]
result
)
{
HashSet
<
Integer
>
set
=
new
HashSet
<>();
for
(
int
a
:
result
){
set
.
add
(
a
);
}
if
(
set
.
size
()==
result
.
length
)
return
false
;
else
return
true
;
}
private
void
creatParent
(
File
dirpath
)
{
...
...
@@ -122,13 +133,12 @@ public class BisheTestMain implements ApplicationRunner {
}
private
static
DataPackage
combine
(
int
number
,
List
<
Integer
>
sequence
,
String
loc
,
String
file_path
,
double
eta
,
Long
Currentime
,
Long
fun1time
,
List
<
Double
>
compCapacity
,
Long
Currentime
,
Long
fun1time
,
List
<
Double
>
compCapacity
,
LinkedList
<
Double
>
tranDelay
)
{
DataPackage
dataPackage
=
new
DataPackage
();
dataPackage
.
setNumber
(
number
);
dataPackage
.
setPicture
(
loadPicture
(
file_path
));
dataPackage
.
setSequence
(
sequence
);
dataPackage
.
setEta
(
eta
);
dataPackage
.
setCurrentime
(
Currentime
);
dataPackage
.
setFun1time
(
fun1time
);
dataPackage
.
setCompCapacity
(
compCapacity
);
...
...
apps/cnf-path-computing/businessInCloud/src/main/java/top/ninwoo/test/doMap/CycleTopo.java
View file @
7cd86d1d
...
...
@@ -17,7 +17,7 @@ public class CycleTopo {
ToponetImpl
tp
=
new
ToponetImpl
();
SimData
sd
=
new
SimData
();
//tp.delHistory();
File
file
=
new
File
(
"topusim_1.txt"
);
File
file
=
new
File
(
"
D:\\LabratoryJavaPro\\codingDownload\\latestCoding\\
topusim_1.txt"
);
//D:\LabratoryJavaPro\codingDownload\latestCoding\
List
<
WeiXingData
>
wxData
=
null
;
try
{
...
...
apps/cnf-path-computing/businessInCloud/src/main/java/top/ninwoo/test/doMap/DoMap.java
View file @
7cd86d1d
...
...
@@ -29,7 +29,10 @@ public class DoMap {
static
int
c
=
7
;
//8
//子任务依赖关系 边
static
int
[][]
link
=
{{
0
,
0
,
1
,
2
,
3
,
4
,
5
},
{
1
,
2
,
3
,
4
,
5
,
5
,
6
}};
//
static
int
[][]
link
;
//
//task编号
static
int
[]
func
;
//固定映射任务数==起始任务+终止任务
static
final
int
C_STABLE
=
2
;
...
...
@@ -75,14 +78,18 @@ public class DoMap {
static
double
s
=
1.5
;
static
int
c1
=
1
;
static
int
c2
=
1
;
public
static
void
main
(
String
[]
args
)
{
doMapApp
();
//子任务依赖关系 边
int
[][]
link
=
{{
0
,
0
,
1
,
2
,
3
,
4
,
5
},
{
1
,
2
,
3
,
4
,
5
,
5
,
6
}};
//task编号
int
[]
func
=
{
1
,
3
,
3
,
3
,
2
,
2
,
4
};
doMapApp
(
link
,
func
);
}
//节点最终分配结果
public
static
int
[]
result
=
new
int
[
c
];
//节点间最短路由
public
static
Stack
[]
route
=
new
Stack
[
link
[
0
].
length
+
1
]
;
public
static
Stack
[]
route
;
//业务发起时刻
public
static
long
startT
;
//传输时延约束
...
...
@@ -90,7 +97,11 @@ public class DoMap {
//路由表
public
static
int
[][]
lastHop
;
public
static
void
doMapApp
()
{
public
static
void
doMapApp
(
int
[][]
link1
,
int
[]
func1
)
{
link
=
link1
;
func
=
func1
;
route
=
new
Stack
[
link
[
0
].
length
+
1
];
for
(
slotnum
=
1
;
slotnum
<=
3
;
slotnum
++){
...
...
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/IPicProcess.java
0 → 100644
View file @
7cd86d1d
package
com.pitong.business.service
;
import
com.pitong.business.item.Picture
;
public
interface
IPicProcess
{
String
in_file
=
"/pic/in.jpg"
;
String
out_file
=
"/pic/out.jpg"
;
String
in_file1
=
"/pic/in1.jpg"
;
String
in_file2
=
"/pic/in2.jpg"
;
String
out_file1
=
"/pic/out1.jpg"
;
String
out_file2
=
"/pic/out2.jpg"
;
public
void
picProcess
(
Picture
...
pictures
);
}
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/ServerService.java
View file @
7cd86d1d
...
...
@@ -65,7 +65,7 @@ public class ServerService {
// System.out.println("==========================");
communicationToCloud
(
"receive from sate"
+
sequence
.
get
(
0
));
// System.out.println("=========2==========");
cutProcess
(
eta
);
cutProcess
();
Long
l11
=
System
.
currentTimeMillis
();
double
compCap
=
compCapacity
.
get
(
sequence
.
get
(
0
)-
1
);
...
...
@@ -111,7 +111,7 @@ public class ServerService {
communicationToCloud
(
"=========================="
);
System
.
out
.
println
(
"=========================="
);
}
else
{
DataPackage
dataPackage1
=
combine
(
2
,
1
,
sequence
,
loc
,
out_file
1
,
l111
,
finalFun1time
,
compCapacity
,
route
,
sequence
.
get
(
1
),
tranDelay
);
DataPackage
dataPackage1
=
combine
(
2
,
1
,
sequence
,
loc
,
out_file
2
,
l111
,
finalFun1time
,
compCapacity
,
route
,
sequence
.
get
(
1
),
tranDelay
);
String
app_name2
=
"sate"
+
sequence
.
get
(
1
);
String
IP2
=
ipService
.
getIpByAppName
(
app_name2
);
//communicationToCloud("current slot: " + ((System.currentTimeMillis()-startime)/slot + 1));
...
...
@@ -539,7 +539,7 @@ public class ServerService {
long
length
=
picture
.
getData
().
length
/
1024
;
long
l2
=
System
.
currentTimeMillis
();
tailorProcess
(
coe
);
tailorProcess
();
long
l20
=
System
.
currentTimeMillis
();
Long
latency
=
Math
.
round
(
length
/
compCap
);
...
...
@@ -670,9 +670,21 @@ public class ServerService {
}
}
private
void
tailorProcess
(
double
coe
)
{
private
void
createParents
(
File
f
)
{
String
parentName
=
f
.
getParent
();
File
parent
=
new
File
(
parentName
);
if
(!
parent
.
exists
())
{
createParents
(
parent
);
parent
.
mkdir
();
}
}
private
void
tailorProcess
()
{
try
{
String
command
=
"python tailor-pro.py "
+
in_file
+
" "
+
out_file
+
" "
+
coe
;
String
command
=
"python tailor-pro.py "
+
in_file
+
" "
+
out_file
+
" "
+
0.5
;
Process
process
=
Runtime
.
getRuntime
().
exec
(
command
);
process
.
waitFor
();
}
catch
(
IOException
|
InterruptedException
e
)
{
...
...
@@ -711,9 +723,9 @@ public class ServerService {
}
}
private
void
cutProcess
(
double
eta
)
{
private
void
cutProcess
()
{
try
{
String
command
=
"python cut-pro.py "
+
in_file
+
" "
+
out_file1
+
" "
+
out_file2
+
" "
+
eta
;
String
command
=
"python cut-pro.py "
+
in_file
+
" "
+
out_file1
+
" "
+
out_file2
+
" "
+
0.5
;
Process
process
=
Runtime
.
getRuntime
().
exec
(
command
);
process
.
waitFor
();
}
catch
(
IOException
|
InterruptedException
e
)
{
...
...
@@ -721,14 +733,7 @@ public class ServerService {
}
}
private
void
createParents
(
File
f
)
{
String
parentName
=
f
.
getParent
();
File
parent
=
new
File
(
parentName
);
if
(!
parent
.
exists
())
{
createParents
(
parent
);
parent
.
mkdir
();
}
}
private
Picture
loadPicture
(
String
pic_url
)
{
try
{
...
...
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/picImpl/binaryProcess.java
0 → 100644
View file @
7cd86d1d
package
com.pitong.business.service.picImpl
;
import
com.pitong.business.item.Picture
;
import
com.pitong.business.service.IPicProcess
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
static
com
.
pitong
.
business
.
service
.
saveFile
.
Save
.
loadPicture
;
import
static
com
.
pitong
.
business
.
service
.
saveFile
.
Save
.
saveToFile
;
public
class
binaryProcess
implements
IPicProcess
{
public
static
ArrayList
<
Picture
>
picPara
=
new
ArrayList
<>();
@Override
public
void
picProcess
(
Picture
...
pictures
)
{
for
(
Picture
picture:
pictures
){
saveToFile
(
picture
,
in_file
);
}
try
{
String
command
=
"python binary-pro.py "
+
in_file
+
" "
+
out_file
;
Process
process
=
Runtime
.
getRuntime
().
exec
(
command
);
process
.
waitFor
();
}
catch
(
IOException
|
InterruptedException
e
)
{
e
.
printStackTrace
();
}
picPara
.
add
(
loadPicture
(
out_file
));
}
}
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/picImpl/cutProcess.java
0 → 100644
View file @
7cd86d1d
package
com.pitong.business.service.picImpl
;
import
com.pitong.business.item.Picture
;
import
com.pitong.business.service.IPicProcess
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
static
com
.
pitong
.
business
.
service
.
saveFile
.
Save
.*;
public
class
cutProcess
implements
IPicProcess
{
public
static
ArrayList
<
Picture
>
picPara
=
new
ArrayList
<>();
@Override
public
void
picProcess
(
Picture
...
pictures
)
{
for
(
Picture
picture:
pictures
){
saveToFile
(
picture
,
in_file
);
}
try
{
String
command
=
"python cut-pro.py "
+
in_file
+
" "
+
out_file1
+
" "
+
out_file2
+
" "
+
0.5
;
Process
process
=
Runtime
.
getRuntime
().
exec
(
command
);
process
.
waitFor
();
}
catch
(
IOException
|
InterruptedException
e
)
{
e
.
printStackTrace
();
}
picPara
.
add
(
loadPicture
(
out_file1
));
picPara
.
add
(
loadPicture
(
out_file2
));
}
}
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/picImpl/greyProcess.java
0 → 100644
View file @
7cd86d1d
package
com.pitong.business.service.picImpl
;
import
com.pitong.business.item.Picture
;
import
com.pitong.business.service.IPicProcess
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
static
com
.
pitong
.
business
.
service
.
saveFile
.
Save
.
loadPicture
;
import
static
com
.
pitong
.
business
.
service
.
saveFile
.
Save
.
saveToFile
;
public
class
greyProcess
implements
IPicProcess
{
public
static
ArrayList
<
Picture
>
picPara
=
new
ArrayList
<>();
@Override
public
void
picProcess
(
Picture
...
pictures
)
{
for
(
Picture
picture:
pictures
){
saveToFile
(
picture
,
in_file
);
}
try
{
String
command
=
"python grey-pro.py "
+
in_file
+
" "
+
out_file
;
Process
process
=
Runtime
.
getRuntime
().
exec
(
command
);
process
.
waitFor
();
}
catch
(
IOException
|
InterruptedException
e
)
{
e
.
printStackTrace
();
}
picPara
.
add
(
loadPicture
(
out_file
));
}
}
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/picImpl/mergePorcess.java
0 → 100644
View file @
7cd86d1d
package
com.pitong.business.service.picImpl
;
import
com.pitong.business.item.Picture
;
import
com.pitong.business.service.IPicProcess
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
static
com
.
pitong
.
business
.
service
.
saveFile
.
Save
.
loadPicture
;
import
static
com
.
pitong
.
business
.
service
.
saveFile
.
Save
.
saveToFile
;
public
class
mergePorcess
implements
IPicProcess
{
public
static
ArrayList
<
Picture
>
picPara
=
new
ArrayList
<>();
@Override
public
void
picProcess
(
Picture
...
pictures
)
{
saveToFile
(
pictures
[
0
],
in_file1
);
saveToFile
(
pictures
[
1
],
in_file2
);
try
{
String
command
=
"python merge-pro.py "
+
in_file1
+
" "
+
in_file2
+
" "
+
out_file
;
Process
process
=
Runtime
.
getRuntime
().
exec
(
command
);
process
.
waitFor
();
}
catch
(
IOException
|
InterruptedException
e
)
{
e
.
printStackTrace
();
}
picPara
.
add
(
loadPicture
(
out_file
));
}
}
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/picImpl/tailorProcess.java
0 → 100644
View file @
7cd86d1d
package
com.pitong.business.service.picImpl
;
import
com.pitong.business.item.Picture
;
import
com.pitong.business.service.IPicProcess
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
static
com
.
pitong
.
business
.
service
.
saveFile
.
Save
.
loadPicture
;
import
static
com
.
pitong
.
business
.
service
.
saveFile
.
Save
.
saveToFile
;
public
class
tailorProcess
implements
IPicProcess
{
public
static
ArrayList
<
Picture
>
picPara
=
new
ArrayList
<>();
@Override
public
void
picProcess
(
Picture
...
pictures
)
{
for
(
Picture
picture:
pictures
){
saveToFile
(
picture
,
in_file
);
}
try
{
String
command
=
"python tailor-pro.py "
+
in_file
+
" "
+
out_file
+
" "
+
0.8
;
Process
process
=
Runtime
.
getRuntime
().
exec
(
command
);
process
.
waitFor
();
}
catch
(
IOException
|
InterruptedException
e
)
{
e
.
printStackTrace
();
}
picPara
.
add
(
loadPicture
(
out_file
));
}
}
apps/cnf-path-computing/businessInDocker/src/main/java/com/pitong/business/service/saveFile/Save.java
0 → 100644
View file @
7cd86d1d
package
com.pitong.business.service.saveFile
;
import
com.pitong.business.item.Picture
;
import
java.io.*
;
public
class
Save
{
public
static
void
saveToFile
(
Picture
picture
,
String
file_path
)
{
byte
[]
pic_data
=
picture
.
getData
();
File
targetFile
=
new
File
(
file_path
);
if
(
targetFile
.
exists
())
{
targetFile
.
delete
();
}
//为什么创建父类
createParents
(
targetFile
);
try
{
targetFile
.
createNewFile
();
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
targetFile
);
fileOutputStream
.
write
(
pic_data
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
public
static
void
createParents
(
File
f
)
{
String
parentName
=
f
.
getParent
();
File
parent
=
new
File
(
parentName
);
if
(!
parent
.
exists
())
{
createParents
(
parent
);
parent
.
mkdir
();
}
}
public
static
Picture
loadPicture
(
String
pic_url
)
{
try
{
File
f
=
new
File
(
pic_url
);
InputStream
is
=
new
FileInputStream
(
f
);
byte
[]
b
=
new
byte
[(
int
)
f
.
length
()];
is
.
read
(
b
);
is
.
close
();
Picture
picture
=
new
Picture
();
picture
.
setData
(
b
);
return
picture
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
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