Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
gpucloudsim
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LPDS
gpucloudsim
Commits
b463216f
Commit
b463216f
authored
Jan 09, 2012
by
rodrigo.calheiros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates in documentation and tests.
parent
d2495835
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
12 deletions
+81
-12
VmSchedulerTimeSharedOverSubscription.java
...udbus/cloudsim/VmSchedulerTimeSharedOverSubscription.java
+42
-12
VmSchedulerTimeSharedOverSubscriptionTest.java
...s/cloudsim/VmSchedulerTimeSharedOverSubscriptionTest.java
+39
-0
No files found.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/VmSchedulerTimeSharedOverSubscription.java
View file @
b463216f
...
@@ -8,11 +8,12 @@
...
@@ -8,11 +8,12 @@
package
org
.
cloudbus
.
cloudsim
;
package
org
.
cloudbus
.
cloudsim
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
org.cloudbus.cloudsim.lists.PeList
;
import
org.cloudbus.cloudsim.lists.PeList
;
import
org.cloudbus.cloudsim.util.MathUtil
;
/**
/**
* This is a Time-Shared VM Scheduler, which allows over-subscription. In other words, the scheduler
* This is a Time-Shared VM Scheduler, which allows over-subscription. In other words, the scheduler
...
@@ -47,9 +48,20 @@ public class VmSchedulerTimeSharedOverSubscription extends VmSchedulerTimeShared
...
@@ -47,9 +48,20 @@ public class VmSchedulerTimeSharedOverSubscription extends VmSchedulerTimeShared
@Override
@Override
protected
boolean
allocatePesForVm
(
String
vmUid
,
List
<
Double
>
mipsShareRequested
)
{
protected
boolean
allocatePesForVm
(
String
vmUid
,
List
<
Double
>
mipsShareRequested
)
{
double
totalRequestedMips
=
0
;
double
totalRequestedMips
=
0
;
//if the requested mips is bigger than the capacity of a single PE, we cap
//the request to the PE's capacity
List
<
Double
>
mipsShareRequestedCapped
=
new
ArrayList
<
Double
>();
double
peMips
=
getPeCapacity
();
for
(
Double
mips
:
mipsShareRequested
)
{
for
(
Double
mips
:
mipsShareRequested
)
{
if
(
mips
>
peMips
)
{
mipsShareRequestedCapped
.
add
(
peMips
);
totalRequestedMips
+=
peMips
;
}
else
{
mipsShareRequestedCapped
.
add
(
mips
);
totalRequestedMips
+=
mips
;
totalRequestedMips
+=
mips
;
}
}
}
getMipsMapRequested
().
put
(
vmUid
,
mipsShareRequested
);
getMipsMapRequested
().
put
(
vmUid
,
mipsShareRequested
);
setPesInUse
(
getPesInUse
()
+
mipsShareRequested
.
size
());
setPesInUse
(
getPesInUse
()
+
mipsShareRequested
.
size
());
...
@@ -61,7 +73,7 @@ public class VmSchedulerTimeSharedOverSubscription extends VmSchedulerTimeShared
...
@@ -61,7 +73,7 @@ public class VmSchedulerTimeSharedOverSubscription extends VmSchedulerTimeShared
if
(
getAvailableMips
()
>=
totalRequestedMips
)
{
if
(
getAvailableMips
()
>=
totalRequestedMips
)
{
List
<
Double
>
mipsShareAllocated
=
new
ArrayList
<
Double
>();
List
<
Double
>
mipsShareAllocated
=
new
ArrayList
<
Double
>();
for
(
Double
mipsRequested
:
mipsShareRequested
)
{
for
(
Double
mipsRequested
:
mipsShareRequested
Capped
)
{
if
(
getVmsMigratingOut
().
contains
(
vmUid
))
{
if
(
getVmsMigratingOut
().
contains
(
vmUid
))
{
// performance degradation due to migration = 10% MIPS
// performance degradation due to migration = 10% MIPS
mipsRequested
*=
0.9
;
mipsRequested
*=
0.9
;
...
@@ -90,8 +102,26 @@ public class VmSchedulerTimeSharedOverSubscription extends VmSchedulerTimeShared
...
@@ -90,8 +102,26 @@ public class VmSchedulerTimeSharedOverSubscription extends VmSchedulerTimeShared
// proportionally
// proportionally
double
totalRequiredMipsByAllVms
=
0
;
double
totalRequiredMipsByAllVms
=
0
;
Map
<
String
,
List
<
Double
>>
mipsMapCapped
=
new
HashMap
<
String
,
List
<
Double
>>();
for
(
Entry
<
String
,
List
<
Double
>>
entry
:
getMipsMapRequested
().
entrySet
())
{
for
(
Entry
<
String
,
List
<
Double
>>
entry
:
getMipsMapRequested
().
entrySet
())
{
double
requiredMipsByThisVm
=
MathUtil
.
sum
(
entry
.
getValue
());
double
requiredMipsByThisVm
=
0.0
;
String
vmId
=
entry
.
getKey
();
List
<
Double
>
mipsShareRequested
=
entry
.
getValue
();
List
<
Double
>
mipsShareRequestedCapped
=
new
ArrayList
<
Double
>();
double
peMips
=
getPeCapacity
();
for
(
Double
mips
:
mipsShareRequested
)
{
if
(
mips
>
peMips
)
{
mipsShareRequestedCapped
.
add
(
peMips
);
requiredMipsByThisVm
+=
peMips
;
}
else
{
mipsShareRequestedCapped
.
add
(
mips
);
requiredMipsByThisVm
+=
mips
;
}
}
mipsMapCapped
.
put
(
vmId
,
mipsShareRequestedCapped
);
if
(
getVmsMigratingIn
().
contains
(
entry
.
getKey
()))
{
if
(
getVmsMigratingIn
().
contains
(
entry
.
getKey
()))
{
// the destination host only experience 10% of the migrating VM's MIPS
// the destination host only experience 10% of the migrating VM's MIPS
requiredMipsByThisVm
*=
0.1
;
requiredMipsByThisVm
*=
0.1
;
...
@@ -106,7 +136,7 @@ public class VmSchedulerTimeSharedOverSubscription extends VmSchedulerTimeShared
...
@@ -106,7 +136,7 @@ public class VmSchedulerTimeSharedOverSubscription extends VmSchedulerTimeShared
getMipsMap
().
clear
();
getMipsMap
().
clear
();
// Update the actual MIPS allocated to the VMs
// Update the actual MIPS allocated to the VMs
for
(
Entry
<
String
,
List
<
Double
>>
entry
:
getMipsMapRequested
()
.
entrySet
())
{
for
(
Entry
<
String
,
List
<
Double
>>
entry
:
mipsMapCapped
.
entrySet
())
{
String
vmUid
=
entry
.
getKey
();
String
vmUid
=
entry
.
getKey
();
List
<
Double
>
requestedMips
=
entry
.
getValue
();
List
<
Double
>
requestedMips
=
entry
.
getValue
();
...
@@ -138,11 +168,11 @@ public class VmSchedulerTimeSharedOverSubscription extends VmSchedulerTimeShared
...
@@ -138,11 +168,11 @@ public class VmSchedulerTimeSharedOverSubscription extends VmSchedulerTimeShared
setAvailableMips
(
0
);
setAvailableMips
(
0
);
}
}
/**
//
/**
* Update allocation of VMs on PEs.
//
* Update allocation of VMs on PEs.
*/
//
*/
@Override
//
@Override
protected
void
updatePeProvisioning
()
{
//
protected void updatePeProvisioning() {
// getPeMap().clear();
// getPeMap().clear();
// for (Pe pe : getPeList()) {
// for (Pe pe : getPeList()) {
// pe.getPeProvisioner().deallocateMipsForAllVms();
// pe.getPeProvisioner().deallocateMipsForAllVms();
...
@@ -182,6 +212,6 @@ public class VmSchedulerTimeSharedOverSubscription extends VmSchedulerTimeShared
...
@@ -182,6 +212,6 @@ public class VmSchedulerTimeSharedOverSubscription extends VmSchedulerTimeShared
// }
// }
// }
// }
// }
// }
}
//
}
}
}
modules/cloudsim/src/test/java/org/cloudbus/cloudsim/VmSchedulerTimeSharedOverSubscriptionTest.java
View file @
b463216f
...
@@ -203,4 +203,43 @@ public class VmSchedulerTimeSharedOverSubscriptionTest {
...
@@ -203,4 +203,43 @@ public class VmSchedulerTimeSharedOverSubscriptionTest {
assertEquals
(
3500
,
vmScheduler
.
getMaxAvailableMips
(),
0
);
assertEquals
(
3500
,
vmScheduler
.
getMaxAvailableMips
(),
0
);
}
}
@Test
public
void
testAllocatePesForSameSizedVmsOversubscribed
()
{
List
<
Pe
>
peList
=
new
ArrayList
<
Pe
>();
peList
.
add
(
new
Pe
(
0
,
new
PeProvisionerSimple
(
1000
)));
VmScheduler
vmScheduler
=
new
VmSchedulerTimeSharedOverSubscription
(
peList
);
Vm
vm1
=
new
Vm
(
0
,
0
,
1500
,
1
,
0
,
0
,
0
,
""
,
null
);
Vm
vm2
=
new
Vm
(
1
,
0
,
1000
,
1
,
0
,
0
,
0
,
""
,
null
);
Vm
vm3
=
new
Vm
(
2
,
0
,
1000
,
1
,
0
,
0
,
0
,
""
,
null
);
List
<
Double
>
mipsShare1
=
new
ArrayList
<
Double
>();
mipsShare1
.
add
(
1500.0
);
List
<
Double
>
mipsShare2
=
new
ArrayList
<
Double
>();
mipsShare2
.
add
(
1000.0
);
List
<
Double
>
mipsShare3
=
new
ArrayList
<
Double
>();
mipsShare3
.
add
(
1000.0
);
assertTrue
(
vmScheduler
.
allocatePesForVm
(
vm1
,
mipsShare1
));
assertEquals
(
0
,
vmScheduler
.
getAvailableMips
(),
0
);
assertEquals
(
1000
,
vmScheduler
.
getTotalAllocatedMipsForVm
(
vm1
),
0
);
assertTrue
(
vmScheduler
.
allocatePesForVm
(
vm2
,
mipsShare2
));
assertEquals
(
0
,
vmScheduler
.
getAvailableMips
(),
0
);
assertEquals
(
500
,
vmScheduler
.
getTotalAllocatedMipsForVm
(
vm1
),
0
);
assertEquals
(
500
,
vmScheduler
.
getTotalAllocatedMipsForVm
(
vm2
),
0
);
assertTrue
(
vmScheduler
.
allocatePesForVm
(
vm3
,
mipsShare3
));
assertEquals
(
0
,
vmScheduler
.
getAvailableMips
(),
0
);
assertEquals
(
333
,
vmScheduler
.
getTotalAllocatedMipsForVm
(
vm1
),
0
);
assertEquals
(
333
,
vmScheduler
.
getTotalAllocatedMipsForVm
(
vm2
),
0
);
assertEquals
(
333
,
vmScheduler
.
getTotalAllocatedMipsForVm
(
vm3
),
0
);
vmScheduler
.
deallocatePesForAllVms
();
assertEquals
(
1000
,
vmScheduler
.
getAvailableMips
(),
0
);
assertEquals
(
1000
,
vmScheduler
.
getMaxAvailableMips
(),
0
);
}
}
}
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