Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
vagabond
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jon Shahen
vagabond
Commits
34e9b1cc
Commit
34e9b1cc
authored
May 05, 2020
by
Jonathan Shahen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding 2 more ILP reductions to try and fix the additional security flaw
parent
1b266778
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
459 additions
and
132 deletions
+459
-132
data/ilp_sum_v3.mod
data/ilp_sum_v3.mod
+59
-0
data/ilp_sum_v4.mod
data/ilp_sum_v4.mod
+60
-0
logs/vagabond.stats.csv
logs/vagabond.stats.csv
+5
-0
src/vagabond/VagabondCUI.java
src/vagabond/VagabondCUI.java
+4
-0
src/vagabond/VagabondInstance.java
src/vagabond/VagabondInstance.java
+6
-0
src/vagabond/VagabondOptionString.java
src/vagabond/VagabondOptionString.java
+2
-0
src/vagabond/pieces/Client.java
src/vagabond/pieces/Client.java
+5
-0
src/vagabond/pieces/Machine.java
src/vagabond/pieces/Machine.java
+29
-24
src/vagabond/pieces/PlacementMap.java
src/vagabond/pieces/PlacementMap.java
+88
-83
src/vagabond/pieces/SumOfClientVMsPerMachine.java
src/vagabond/pieces/SumOfClientVMsPerMachine.java
+31
-25
src/vagabond/reduction/ilp/ReduceToILPv3.java
src/vagabond/reduction/ilp/ReduceToILPv3.java
+1
-0
src/vagabond/reduction/ilp/ReduceToILPv4.java
src/vagabond/reduction/ilp/ReduceToILPv4.java
+95
-0
src/vagabond/singleton/VagabondSettings.java
src/vagabond/singleton/VagabondSettings.java
+10
-0
tests/figures/max-client/ILP_v3-SubOptimal-window10.properties
.../figures/max-client/ILP_v3-SubOptimal-window10.properties
+16
-0
tests/figures/max-client/ILP_v3-SubOptimal-window5.properties
...s/figures/max-client/ILP_v3-SubOptimal-window5.properties
+16
-0
tests/figures/max-client/ILP_v4-SubOptimal-window10.properties
.../figures/max-client/ILP_v4-SubOptimal-window10.properties
+16
-0
tests/figures/max-client/ILP_v4-SubOptimal-window5.properties
...s/figures/max-client/ILP_v4-SubOptimal-window5.properties
+16
-0
No files found.
data/ilp_sum_v3.mod
0 → 100644
View file @
34e9b1cc
/*********************************************
* OPL 12.6.1.0 Model
* Author: jonathan
* Creation Date: May 17, 2016 at 12:26:31 PM
*********************************************/
int numMachines=...;
range Machines=1..numMachines;
int numClients=...;
range Clients=1..numClients;
//int numVMs=...;
int migrationBudget=...;
int vmsPerClient[Clients]=...;
int machineCapacity[Machines]=...;
// Sum of previous Information Leakage ClientToClient
int L[Clients,Clients]=...;
// Sum of Client VMs per Machine
int p0[Machines,Clients]=...;
int r=...;
int t=ftoi(ceil(lg(r+1)));
int dMaxVal=ftoi(pow(2,2*t-1)-1);
range tRange=0..t;
range zRange=0..t-1;
// NEW Placement of the Sum of Client VMs per Machine
dvar int p1[Machines,Clients] in 0..r;
// Variables to fix the quadratic variable from old reduction
dvar int p[Machines,Clients,tRange] in 0..1;
dvar int e[Clients,Clients,Machines,tRange,tRange] in 0..1;
dvar int d[Clients,Clients,Machines,zRange] in 0..dMaxVal;
minimize
sum(c0, c1 in Clients: c0 != c1) (L[c0,c1] + sum(k in Machines, z in zRange) (d[c0,c1,k,z]) ) +
max(c0, c1 in Clients: c0 != c1) (L[c0,c1] + sum(k in Machines, z in zRange) (d[c0,c1,k,z]) );
subject to {
// p1 represented as a value from p's bit form
forall(i in Clients, k in Machines)
p1[k,i] == sum(l in tRange) (pow(2,l) * p[k,i,l]);
// Bitwise AND for all pairs in p1
forall(k in Machines, c0 in Clients, c1 in Clients, u in tRange, v in tRange)
0 <= p[k,c0,u] + p[k,c1,v] - (2 * e[c0,c1,k,u,v]) <= 1;
// Setting up values for d
forall(k in Machines, c0 in Clients, c1 in Clients, z in zRange)
d[c0,c1,k,z] == sum(l in zRange) (pow(2,z+l) *e[c0,c1,k,l,z]);
// Capacity of servers respected
forall(k in Machines)
machineCapacity[k] >= sum(i in Clients) (p1[k,i]);
// Sum of clients in p1 should equal the number of vms of that client
forall(i in Clients)
vmsPerClient[i] == sum(k in Machines) (p1[k,i]);
// Migration budget
2 * migrationBudget >= sum(i in Clients, k in Machines) ( abs(p1[k,i] - p0[k,i]) );
};
\ No newline at end of file
data/ilp_sum_v4.mod
0 → 100644
View file @
34e9b1cc
/*********************************************
* OPL 12.6.1.0 Model
* Author: jonathan
* Creation Date: May 17, 2016 at 12:26:31 PM
*********************************************/
int numMachines=...;
range Machines=1..numMachines;
int numClients=...;
range Clients=1..numClients;
//int numVMs=...;
int migrationBudget=...;
int vmsPerClient[Clients]=...;
int machineCapacity[Machines]=...;
// Sum of previous Information Leakage ClientToClient
int L[Clients,Clients]=...;
// Sum of Client VMs per Machine
int p0[Machines,Clients]=...;
int r=...;
int t=ftoi(ceil(lg(r+1)));
int dMaxVal=ftoi(pow(2,2*t-1)-1);
range tRange=0..t;
range zRange=0..t-1;
// NEW Placement of the Sum of Client VMs per Machine
dvar int p1[Machines,Clients] in 0..r;
// Variables to fix the quadratic variable from old reduction
dvar int p[Machines,Clients,tRange] in 0..1;
dvar int e[Clients,Clients,Machines,tRange,tRange] in 0..1;
dvar int d[Clients,Clients,Machines,zRange] in 0..dMaxVal;
// MIN: Total info leak for only this placement + max info leak for the window
minimize
((1/numClients) * sum(c0, c1 in Clients: c0 != c1) (L[c0,c1] + sum(k in Machines, z in zRange) (d[c0,c1,k,z]) )) +
max(c0, c1 in Clients: c0 != c1) (L[c0,c1] + sum(k in Machines, z in zRange) (d[c0,c1,k,z]) );
subject to {
// p1 represented as a value from p's bit form
forall(i in Clients, k in Machines)
p1[k,i] == sum(l in tRange) (pow(2,l) * p[k,i,l]);
// Bitwise AND for all pairs in p1
forall(k in Machines, c0 in Clients, c1 in Clients, u in tRange, v in tRange)
0 <= p[k,c0,u] + p[k,c1,v] - (2 * e[c0,c1,k,u,v]) <= 1;
// Setting up values for d
forall(k in Machines, c0 in Clients, c1 in Clients, z in zRange)
d[c0,c1,k,z] == sum(l in zRange) (pow(2,z+l) *e[c0,c1,k,l,z]);
// Capacity of servers respected
forall(k in Machines)
machineCapacity[k] >= sum(i in Clients) (p1[k,i]);
// Sum of clients in p1 should equal the number of vms of that client
forall(i in Clients)
vmsPerClient[i] == sum(k in Machines) (p1[k,i]);
// Migration budget
2 * migrationBudget >= sum(i in Clients, k in Machines) ( abs(p1[k,i] - p0[k,i]) );
};
\ No newline at end of file
logs/vagabond.stats.csv
View file @
34e9b1cc
...
...
@@ -320,3 +320,8 @@ Date Time,Test Name,Machines,Clients,Slots,Max VMs/Client,Min VMs/Client,Placeme
2020/04/15 02:03:47.404-0400,SubOptimal_Window10,3,4,3,3,2,File_none,9,3,1.0,9,10,1586930631304,31,ilp_v1,Sum CCIL,29,12,8,2,2,4,0,2,0,117;44;27;23;23;23;23;22;23;23;21;23;23;22;22;23;22;21;22;22;22;24;23;30;44;53;21;23;24;45;23,0=6;1=0;2=6,0=8;1=0;2=4,12;12;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8,2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2,2;3;2;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0,3,924,
2020/04/15 02:03:54.539-0400,SubOptimal_Window5,3,4,3,3,2,File_none,9,3,1.0,9,5,1586930638330,31,ilp_v2,Sum CCIL,29,12,8,2,2,4,0,31,6,141;67;36;13;30;13;26;30;26;34;25;23;23;25;12;27;25;26;24;23;28;23;30;24;27;21;29;21;25;20;22,0=6;1=0;2=6,0=8;1=0;2=4,12;16;14;12;16;14;12;8;8;12;8;8;8;8;8;12;8;12;8;8;12;8;12;8;12;8;12;8;12;8;12;8,2;2;3;2;2;3;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2,2;3;2;3;3;3;3;2;3;3;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2,31,941,
2020/04/15 02:04:00.706-0400,SubOptimal_Window10,3,4,3,3,2,File_none,9,3,1.0,9,10,1586930646023,31,ilp_v2,Sum CCIL,29,12,16,2,2,-4,0,31,17,134;67;40;13;29;13;29;24;32;34;24;25;35;33;24;28;25;32;24;28;15;37;13;26;23;13;33;13;25;24;12,0=6;1=0;2=6,0=4;1=0;2=8,12;16;14;12;16;14;12;12;12;12;12;12;16;12;8;12;14;12;12;12;12;16;12;16;12;12;16;12;16;12;12;16,2;2;3;2;2;3;2;2;2;2;2;2;2;2;2;2;3;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2,2;3;2;3;3;3;2;2;2;2;2;2;3;2;2;2;3;2;0;2;2;3;3;2;2;2;3;3;2;2;2,31,947,
2020/05/05 06:41:40.979-0400,SubOptimal_Window5,3,4,3,3,2,File_none,9,3,1.0,9,5,1588718506255,31,ilp_v3,Sum CCIL,49,12,8,2,2,4,0,2,0,467;63;39;44;56;58;34;73;68;33;30;28;31;26;31;27;25;27;30;28;30;25;26;33;35;29;29;25;25;25;25,0=6;1=0;2=6,0=8;1=0;2=4,12;12;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8,2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2,2;2;2;2;0;2;2;2;2;0;0;0;2;2;2;0;0;2;2;2;2;0;0;2;2;2;2;0;0;2;2,31,1648,
2020/05/05 06:42:12.146-0400,SubOptimal_Window10,3,4,3,3,2,File_none,9,3,1.0,9,10,1588718533792,31,ilp_v3,Sum CCIL,36,12,8,2,2,4,0,2,0,142;58;37;38;52;60;37;31;29;28;28;27;27;37;45;35;32;32;26;27;27;25;25;38;28;32;30;24;28;25;24,0=6;1=0;2=6,0=8;1=0;2=4,12;12;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8,2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2,2;2;2;2;0;2;2;0;0;0;0;0;2;2;0;2;2;2;0;0;0;0;0;0;0;2;2;2;2;0;0,29,1154,
2020/05/05 07:00:35.595-0400,SubOptimal_Window5,3,4,3,3,2,File_none,9,3,1.0,9,5,1588719637921,31,ilp_v4,Sum CCIL,39,12,8,2,2,4,0,2,0,147;127;35;38;29;30;28;27;27;28;27;29;30;38;54;32;30;28;31;29;32;27;26;71;39;38;36;27;28;27;31,0=6;1=0;2=6,0=8;1=0;2=4,12;12;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8,2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2,2;2;2;2;0;2;2;2;2;0;0;0;2;2;2;0;0;2;2;2;2;0;0;2;2;2;2;0;0;2;2,31,1245,
2020/05/05 07:00:42.144-0400,SubOptimal_Window10,3,4,3,3,2,File_none,9,3,1.0,9,10,1588719646131,31,ilp_v4,Sum CCIL,37,12,8,2,2,4,0,2,0,146;58;35;36;29;28;27;30;28;30;27;28;26;29;36;34;41;33;30;30;26;28;40;27;26;76;41;55;33;25;25,0=6;1=0;2=6,0=8;1=0;2=4,12;12;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8,2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2,2;2;2;2;0;2;2;0;0;0;0;0;2;2;0;2;2;2;0;0;0;0;0;0;0;2;2;2;2;0;0,29,1184,
2020/05/05 07:11:22.650-0400,SubOptimal_Window5,3,4,3,3,2,File_none,9,3,1.0,9,5,1588720286220,31,ilp_v4,Sum CCIL,31,12,8,2,2,4,0,3,0,148;49;45;35;36;34;29;28;30;28;31;32;31;26;25;24;25;25;24;24;23;24;21;23;21;24;23;20;27;23;21,0=6;1=0;2=6,0=8;1=0;2=4,12;12;12;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8;8,2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2,2;2;2;0;0;2;0;2;0;2;2;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0,11,1003,
src/vagabond/VagabondCUI.java
View file @
34e9b1cc
...
...
@@ -151,6 +151,10 @@ public class VagabondCUI {
System
.
out
.
println
(
a
+
"-settings \"tests/figures/max-client/ILP_v1-SubOptimal-window10.properties\" !e"
);
System
.
out
.
println
(
a
+
"-settings \"tests/figures/max-client/ILP_v2-SubOptimal-window5.properties\" !e"
);
System
.
out
.
println
(
a
+
"-settings \"tests/figures/max-client/ILP_v2-SubOptimal-window10.properties\" !e"
);
System
.
out
.
println
(
a
+
"-settings \"tests/figures/max-client/ILP_v3-SubOptimal-window5.properties\" !e"
);
System
.
out
.
println
(
a
+
"-settings \"tests/figures/max-client/ILP_v3-SubOptimal-window10.properties\" !e"
);
System
.
out
.
println
(
a
+
"-settings \"tests/figures/max-client/ILP_v4-SubOptimal-window5.properties\" !e"
);
System
.
out
.
println
(
a
+
"-settings \"tests/figures/max-client/ILP_v4-SubOptimal-window10.properties\" !e"
);
System
.
out
.
println
(
""
);
try
{
BufferedReader
bfr
=
new
BufferedReader
(
new
FileReader
(
previousCommandFilename
));
...
...
src/vagabond/VagabondInstance.java
View file @
34e9b1cc
...
...
@@ -188,6 +188,10 @@ public class VagabondInstance {
reduction
=
new
ReduceToILPv3
();
runSolver
=
new
RunSolverILP
();
break
;
case
REDUCTION_ILP_V4
:
reduction
=
new
ReduceToILPv4
();
runSolver
=
new
RunSolverILP
();
break
;
case
REDUCTION_NOMAD
:
reduction
=
new
ReduceToNomad
();
runSolver
=
new
RunSolverNomad
();
...
...
@@ -566,6 +570,8 @@ public class VagabondInstance {
settings
.
reductionAlgorithm
=
VagabondOptionString
.
REDUCTION_ILP_V2
;
}
else
if
(
value
.
equals
(
VagabondOptionString
.
REDUCTION_ILP_V3
.
toString
()))
{
settings
.
reductionAlgorithm
=
VagabondOptionString
.
REDUCTION_ILP_V3
;
}
else
if
(
value
.
equals
(
VagabondOptionString
.
REDUCTION_ILP_V4
.
toString
()))
{
settings
.
reductionAlgorithm
=
VagabondOptionString
.
REDUCTION_ILP_V4
;
}
else
if
(
value
.
equals
(
VagabondOptionString
.
REDUCTION_NOMAD
.
toString
()))
{
settings
.
reductionAlgorithm
=
VagabondOptionString
.
REDUCTION_NOMAD
;
}
else
{
...
...
src/vagabond/VagabondOptionString.java
View file @
34e9b1cc
...
...
@@ -266,6 +266,8 @@ public enum VagabondOptionString {
REDUCTION_ILP_V2
(
"ilp_v2"
),
/** */
REDUCTION_ILP_V3
(
"ilp_v3"
),
/** */
REDUCTION_ILP_V4
(
"ilp_v4"
),
/**
* [Reduction Algorithms] Sends a PlacementMap to NOMAD and runs it
* @vagabond.category Reduction Algorithms
...
...
src/vagabond/pieces/Client.java
View file @
34e9b1cc
...
...
@@ -74,4 +74,9 @@ public class Client {
return
true
;
}
@Override
public
int
hashCode
()
{
return
_clientID
.
hashCode
()
+
_nextVMID
.
hashCode
();
}
}
src/vagabond/pieces/Machine.java
View file @
34e9b1cc
...
...
@@ -58,30 +58,6 @@ public class Machine {
return
Boolean
.
TRUE
;
}
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"Machine "
).
append
(
_machineID
).
append
(
" {"
);
if
(
_vms
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
_vms
.
size
();
i
++)
{
if
(
i
!=
0
)
{
sb
.
append
(
", "
);
}
sb
.
append
(
_vms
.
get
(
i
).
toString
());
if
(
i
==
TOSTRING_MAXVMS
)
{
sb
.
append
(
" ... Skipping "
+
(
_vms
.
size
()
-
TOSTRING_MAXVMS
)
+
" VMs"
);
break
;
}
}
}
else
{
sb
.
append
(
"[EMPTY]"
);
}
sb
.
append
(
"}"
);
return
sb
.
toString
();
}
public
String
getFormatString
(
PlacementMapDisplayStyle
displayStyle
)
{
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -158,6 +134,30 @@ public class Machine {
return
"]\n}"
;
}
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"Machine "
).
append
(
_machineID
).
append
(
" {"
);
if
(
_vms
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
_vms
.
size
();
i
++)
{
if
(
i
!=
0
)
{
sb
.
append
(
", "
);
}
sb
.
append
(
_vms
.
get
(
i
).
toString
());
if
(
i
==
TOSTRING_MAXVMS
)
{
sb
.
append
(
" ... Skipping "
+
(
_vms
.
size
()
-
TOSTRING_MAXVMS
)
+
" VMs"
);
break
;
}
}
}
else
{
sb
.
append
(
"[EMPTY]"
);
}
sb
.
append
(
"}"
);
return
sb
.
toString
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(!(
obj
instanceof
Machine
))
{
...
...
@@ -191,4 +191,9 @@ public class Machine {
return
true
;
}
@Override
public
int
hashCode
()
{
return
_machineID
.
hashCode
()
+
_maxSpots
.
hashCode
();
}
}
src/vagabond/pieces/PlacementMap.java
View file @
34e9b1cc
...
...
@@ -147,31 +147,6 @@ public class PlacementMap {
return
result
;
}
/**
* Display a readable Placement Map, runs in O(1) time as it is limited to the number of machines
* @return A constant time string that is small enough to be included in the log file without affecting performance
*/
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"PlacementMap("
).
append
(
getNumberOfMachines
()).
append
(
" Machines; "
).
append
(
getNumberOfClients
())
.
append
(
" Clients; "
).
append
(
getNumberOfVMs
()).
append
(
" Total VMS)\n"
);
int
i
=
0
;
for
(
Machine
m
:
_machines
)
{
sb
.
append
(
m
.
toString
()).
append
(
"\n"
);
i
++;
if
(
i
==
TOSTRING_MAXMACHINES
)
{
sb
.
append
(
"... Not Displaying "
+
(
getNumberOfMachines
()
-
TOSTRING_MAXMACHINES
)
+
" Machines"
);
break
;
}
}
return
sb
.
toString
();
}
/**
* Adds a newly create VM to a machine in the system
* @param vm the newly created VM; should have all of its values already set
...
...
@@ -385,64 +360,6 @@ public class PlacementMap {
return
place
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(!(
obj
instanceof
PlacementMap
))
{
System
.
out
.
println
(
"Not the proper PlacementMap object class"
);
return
false
;
}
PlacementMap
p
=
(
PlacementMap
)
obj
;
if
(
p
.
_clients
.
size
()
!=
getNumberOfClients
())
{
System
.
out
.
println
(
"Number of Clients are not the same"
);
return
false
;
}
if
(
p
.
_machines
.
size
()
!=
getNumberOfMachines
())
{
System
.
out
.
println
(
"Number of Machines are not the same"
);
return
false
;
}
if
(
p
.
_vms
.
size
()
!=
getNumberOfVMs
())
{
System
.
out
.
println
(
"Number of VMs are not the same"
);
return
false
;
}
for
(
int
m
=
0
;
m
<
getNumberOfMachines
();
m
++)
{
if
(!
_machines
.
get
(
m
).
equals
(
p
.
_machines
.
get
(
m
)))
{
System
.
out
.
println
(
"Machine ID "
+
m
+
" is not equal!"
);
System
.
out
.
println
(
"Our Machine: "
+
_machines
.
get
(
m
));
System
.
out
.
println
(
"Their Machine: "
+
p
.
_machines
.
get
(
m
));
return
false
;
}
}
for
(
Integer
cID
:
_clients
.
keySet
())
{
if
(!
p
.
_clients
.
containsKey
(
cID
))
{
System
.
out
.
println
(
"obj Does not have the Client ID: "
+
cID
);
return
false
;
}
if
(!
_clients
.
get
(
cID
).
equals
(
p
.
_clients
.
get
(
cID
)))
{
System
.
out
.
println
(
"Client ID "
+
cID
+
" is not equal"
);
return
false
;
}
}
for
(
Integer
vmID
:
_vms
.
keySet
())
{
if
(!
p
.
_vms
.
containsKey
(
vmID
))
{
System
.
out
.
println
(
"obj Does not contain the VM ID: "
+
vmID
);
return
false
;
}
if
(!
_vms
.
get
(
vmID
).
equals
(
p
.
_vms
.
get
(
vmID
)))
{
System
.
out
.
println
(
"VM ID "
+
vmID
+
" is not equal"
);
return
false
;
}
}
return
true
;
}
/**
* Counts the number of moves that occur between this placement map to get to the placement map provided
* @param placementMap the end placement map to calculate the number of moves made
...
...
@@ -503,4 +420,92 @@ public class PlacementMap {
return
sum
;
}
/**
* Display a readable Placement Map, runs in O(1) time as it is limited to the number of machines
* @return A constant time string that is small enough to be included in the log file without affecting performance
*/
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"PlacementMap("
).
append
(
getNumberOfMachines
()).
append
(
" Machines; "
).
append
(
getNumberOfClients
())
.
append
(
" Clients; "
).
append
(
getNumberOfVMs
()).
append
(
" Total VMS)\n"
);
int
i
=
0
;
for
(
Machine
m
:
_machines
)
{
sb
.
append
(
m
.
toString
()).
append
(
"\n"
);
i
++;
if
(
i
==
TOSTRING_MAXMACHINES
)
{
sb
.
append
(
"... Not Displaying "
+
(
getNumberOfMachines
()
-
TOSTRING_MAXMACHINES
)
+
" Machines"
);
break
;
}
}
return
sb
.
toString
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(!(
obj
instanceof
PlacementMap
))
{
System
.
out
.
println
(
"Not the proper PlacementMap object class"
);
return
false
;
}
PlacementMap
p
=
(
PlacementMap
)
obj
;
if
(
p
.
_clients
.
size
()
!=
getNumberOfClients
())
{
System
.
out
.
println
(
"Number of Clients are not the same"
);
return
false
;
}
if
(
p
.
_machines
.
size
()
!=
getNumberOfMachines
())
{
System
.
out
.
println
(
"Number of Machines are not the same"
);
return
false
;
}
if
(
p
.
_vms
.
size
()
!=
getNumberOfVMs
())
{
System
.
out
.
println
(
"Number of VMs are not the same"
);
return
false
;
}
for
(
int
m
=
0
;
m
<
getNumberOfMachines
();
m
++)
{
if
(!
_machines
.
get
(
m
).
equals
(
p
.
_machines
.
get
(
m
)))
{
System
.
out
.
println
(
"Machine ID "
+
m
+
" is not equal!"
);
System
.
out
.
println
(
"Our Machine: "
+
_machines
.
get
(
m
));
System
.
out
.
println
(
"Their Machine: "
+
p
.
_machines
.
get
(
m
));
return
false
;
}
}
for
(
Integer
cID
:
_clients
.
keySet
())
{
if
(!
p
.
_clients
.
containsKey
(
cID
))
{
System
.
out
.
println
(
"obj Does not have the Client ID: "
+
cID
);
return
false
;
}
if
(!
_clients
.
get
(
cID
).
equals
(
p
.
_clients
.
get
(
cID
)))
{
System
.
out
.
println
(
"Client ID "
+
cID
+
" is not equal"
);
return
false
;
}
}
for
(
Integer
vmID
:
_vms
.
keySet
())
{
if
(!
p
.
_vms
.
containsKey
(
vmID
))
{
System
.
out
.
println
(
"obj Does not contain the VM ID: "
+
vmID
);
return
false
;
}
if
(!
_vms
.
get
(
vmID
).
equals
(
p
.
_vms
.
get
(
vmID
)))
{
System
.
out
.
println
(
"VM ID "
+
vmID
+
" is not equal"
);
return
false
;
}
}
return
true
;
}
@Override
public
int
hashCode
()
{
return
toString
().
hashCode
();
}
}
src/vagabond/pieces/SumOfClientVMsPerMachine.java
View file @
34e9b1cc
...
...
@@ -65,8 +65,9 @@ public class SumOfClientVMsPerMachine {
/* Timing */
timing
.
startTimer
(
"SumOfClientVMsPerMachine::constructor(IloIntVarMap,ArrayList<Integer>)"
);
if
(
sortedClientIDs
.
size
()
!=
cplexP1
.
getSub
(
1
).
getSize
())
{
throw
new
IllegalArgumentException
(
"Sorted Client IDs must be the same size as the CPLEX P1 variable!"
);
}
if
(
sortedClientIDs
.
size
()
!=
cplexP1
.
getSub
(
1
).
getSize
())
{
throw
new
IllegalArgumentException
(
"Sorted Client IDs must be the same size as the CPLEX P1 variable!"
);
}
_numberOfClients
=
sortedClientIDs
.
size
();
_numberOfMachines
=
cplexP1
.
getSize
();
...
...
@@ -106,8 +107,9 @@ public class SumOfClientVMsPerMachine {
* @return number of VMs owned by clientID on Machine machineID; default is 0
*/
public
Integer
get
(
Integer
machineID
,
Integer
clientID
)
{
if
(
machineID
==
null
||
clientID
==
null
)
{
throw
new
IllegalArgumentException
(
"Machine ID and Client Id cannot be null"
);
}
if
(
machineID
==
null
||
clientID
==
null
)
{
throw
new
IllegalArgumentException
(
"Machine ID and Client Id cannot be null"
);
}
return
_matrix
.
getOrDefault
(
new
MachineAndClientKey
(
machineID
,
clientID
),
0
);
}
...
...
@@ -119,25 +121,13 @@ public class SumOfClientVMsPerMachine {
}
public
Integer
put
(
Integer
machineID
,
Integer
clientID
,
Integer
value
)
{
if
(
machineID
==
null
||
clientID
==
null
||
value
==
null
)
{
throw
new
IllegalArgumentException
(
"MAchine ID and Client Id cannot be null"
);
}
if
(
machineID
==
null
||
clientID
==
null
||
value
==
null
)
{
throw
new
IllegalArgumentException
(
"MAchine ID and Client Id cannot be null"
);
}
return
_matrix
.
put
(
new
MachineAndClientKey
(
machineID
,
clientID
),
value
);
}
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"VM Sum PlacementMap("
).
append
(
_numberOfMachines
).
append
(
" Machines; "
)
.
append
(
_numberOfClients
)
.
append
(
" Clients; "
).
append
(
_numberOfVMs
).
append
(
" Total VMS)\n"
);
sb
.
append
(
getFormatString
(
PlacementMapDisplayStyle
.
VAGABOND
,
TOSTRING_LIMIT
));
return
sb
.
toString
();
}
public
String
getFormatString
(
PlacementMapDisplayStyle
displayStyle
,
int
limit
)
{
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -213,8 +203,7 @@ public class SumOfClientVMsPerMachine {
return
sb
.
toString
();
}
protected
SumOfClientVMsPerMachine
()
{
}
protected
SumOfClientVMsPerMachine
()
{}
public
static
SumOfClientVMsPerMachine
empty
(
Integer
numberOfMachines
,
Integer
numberOfClients
)
{
SumOfClientVMsPerMachine
sum
=
new
SumOfClientVMsPerMachine
();
...
...
@@ -229,6 +218,18 @@ public class SumOfClientVMsPerMachine {
return
sum
;
}
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"VM Sum PlacementMap("
).
append
(
_numberOfMachines
).
append
(
" Machines; "
).
append
(
_numberOfClients
)
.
append
(
" Clients; "
).
append
(
_numberOfVMs
).
append
(
" Total VMS)\n"
);
sb
.
append
(
getFormatString
(
PlacementMapDisplayStyle
.
VAGABOND
,
TOSTRING_LIMIT
));
return
sb
.
toString
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(!(
obj
instanceof
SumOfClientVMsPerMachine
))
{
...
...
@@ -253,20 +254,25 @@ public class SumOfClientVMsPerMachine {
for
(
Entry
<
MachineAndClientKey
,
Integer
>
sEntry
:
s
.
_matrix
.
entrySet
())
{
if
(!
sEntry
.
getValue
().
equals
(
get
(
sEntry
.
getKey
())))
{
System
.
out
.
println
(
"[s to this] "
+
sEntry
.
getKey
()
+
": "
+
sEntry
.
getValue
()
+
" != "
+
get
(
sEntry
.
getKey
()));
System
.
out
.
println
(
"[s to this] "
+
sEntry
.
getKey
()
+
": "
+
sEntry
.
getValue
()
+
" != "
+
get
(
sEntry
.
getKey
()));
return
false
;
}
}
for
(
Entry
<
MachineAndClientKey
,
Integer
>
sEntry
:
_matrix
.
entrySet
())
{
if
(!
sEntry
.
getValue
().
equals
(
s
.
get
(
sEntry
.
getKey
())))
{
System
.
out
.
println
(
"[this to s] "
+
sEntry
.
getKey
()
+
": "
+
sEntry
.
getValue
()
+
" != "
+
s
.
get
(
sEntry
.
getKey
()));
System
.
out
.
println
(
"[this to s] "
+
sEntry
.
getKey
()
+
": "
+
sEntry
.
getValue
()
+
" != "
+
s
.
get
(
sEntry
.
getKey
()));
return
false
;
}
}
return
true
;
}
@Override
public
int
hashCode
()
{
return
toString
().
hashCode
();
}
}
src/vagabond/reduction/ilp/ReduceToILPv3.java
View file @
34e9b1cc
...
...
@@ -11,6 +11,7 @@ import vagabond.pieces.SumOfClientVMsPerMachine;
import
vagabond.reduction.ReduceToI
;
public
class
ReduceToILPv3
extends
ReduceToILPBase
implements
ReduceToI
{
public
ReduceToILPv3
()
{
super
();
}
...
...
src/vagabond/reduction/ilp/ReduceToILPv4.java
0 → 100644
View file @
34e9b1cc
package
vagabond.reduction.ilp
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.logging.Level
;
import
ilog.concert.IloException
;
import
ilog.opl.*
;
import
vagabond.pieces.EpochHistory
;
import
vagabond.pieces.SumOfClientVMsPerMachine
;
import
vagabond.reduction.ReduceToI
;
public
class
ReduceToILPv4
extends
ReduceToILPBase
implements
ReduceToI
{
public
ReduceToILPv4
()
{
super
();
}
@Override
public
String
getName
()
{
return
"ReduceToILPv4"
;
}
@Override
public
boolean
reduce
(
EpochHistory
eh
)
throws
IloException
{
/*TIMING*/
timing
.
startTimer
(
tp
+
"ReduceToILP::reduce"
);
_history
=
eh
;
_currentPlacement
=
_history
.
_latestPlacementMap
;
_sumPlacement
=
new
SumOfClientVMsPerMachine
(
_currentPlacement
);
try
{
if
(
logger
.
isLoggable
(
Level
.
FINE
))
{
FileWriter
writeOutILP
=
new
FileWriter
(
settings
.
getIlpFile
());
String
ilpString
=
WriteILPFile
.
toILPString
(
eh
,
_sumPlacement
);
writeOutILP
.
write
(
ilpString
);
writeOutILP
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
// Changes between production mode and debugging mode
if
(
logger
.
isLoggable
(
Level
.
FINE
))
{
IloOplFactory
.
setDebugMode
(
true
);
}
else
{
IloOplFactory
.
setDebugMode
(
false
);
IloOplFactory
.
setDebugModeWarning
(
false
);
}
oplF
=
new
IloOplFactory
();
IloOplErrorHandler
errHandler
=
oplF
.
createOplErrorHandler
(
null
);
/*TIMING*/
timing
.
startTimer
(
tp
+
"ReduceToILP::reduce::readOPL"
);
IloOplModelSource
modelSource
;
if
(
settings
.
migrationBudget
!=
-
1
)
{
logger
.
info
(
"Using the OPL Model: "
+
settings
.
getIlpOplFile_v4
().
getAbsolutePath
());
modelSource
=
oplF
.
createOplModelSource
(
settings
.
getIlpOplFile_v4
().
getAbsolutePath
());
}
else
{
logger
.
info
(
"Using the OPL Model: "
+
settings
.
getIlpOplNoMigrationFile
().
getAbsolutePath
());
modelSource
=
oplF
.
createOplModelSource
(
settings
.
getIlpOplNoMigrationFile
().
getAbsolutePath
());
}
/*TIMING*/
timing
.
stopTimer
(
tp
+
"ReduceToILP::reduce::readOPL"
);