Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lucas Cavalcante
cloudsimplus
Commits
5c2b4f84
Commit
5c2b4f84
authored
Jul 18, 2018
by
Kaio Oliveira
Browse files
Finish VerticalVmIopsScaling example
Last efforts to implement a functional example of VerticalVmIopsScaling.
parent
c47e091b
Changes
4
Hide whitespace changes
Inline
Side-by-side
cloudsim-plus-examples/src/main/java/org/cloudbus/cloudsim/examples/autonomic/VerticalVmIopsScalingExample.java
View file @
5c2b4f84
...
...
@@ -75,7 +75,8 @@ public class VerticalVmIopsScalingExample {
// Cloudlets
private
static
final
int
CLOUDLETS
=
1
;
private
static
final
int
CLOUDLETS_INITIAL_LENGTH
=
100_000
;
private
static
final
int
CLOUDLETS_INITIAL_LENGTH
=
1
;
private
static
final
int
CLOUDLETS_INITIAL_LENGTH_IOPS
=
500_000
;
private
static
final
int
CLOUDLET_PES
=
1
;
private
final
CloudSim
simulation
;
...
...
@@ -84,7 +85,6 @@ public class VerticalVmIopsScalingExample {
private
List
<
Vm
>
vmList
;
private
List
<
Cloudlet
>
cloudletList
;
private
int
createdCloudlets
;
private
int
createdVms
;
public
static
void
main
(
String
[]
args
)
{
...
...
@@ -106,7 +106,7 @@ public class VerticalVmIopsScalingExample {
// cloudletList = new ArrayList<>(CLOUDLETS);
cloudletList
=
createCloudlets
();
simulation
=
new
CloudSim
();
simulation
=
new
CloudSim
(
SCHEDULING_INTERVAL
);
simulation
.
addOnClockTickListener
(
this
::
onClockTickListener
);
createDatacenter
();
...
...
@@ -133,9 +133,8 @@ public class VerticalVmIopsScalingExample {
*/
private
void
onClockTickListener
(
EventInfo
evt
)
{
vmList
.
forEach
(
vm
->
{
Log
.
printFormatted
(
"\t\tTime %6.1f: Vm %d
Disk Usage: %6.2f%%
(%2d IOPS. Running Cloudlets: #%d)\n"
,
Log
.
printFormatted
(
"\t\tTime %6.1f: Vm %d (%2d IOPS. Running Cloudlets: #%d)\n"
,
evt
.
getTime
(),
vm
.
getId
(),
vm
.
getIopsVerticalScaling
().
getResource
().
getPercentUtilization
()
*
100.0
,
vm
.
getIops
().
getCapacity
(),
vm
.
getCloudletScheduler
().
getCloudletExecList
().
size
());
});
}
...
...
@@ -154,7 +153,9 @@ public class VerticalVmIopsScalingExample {
*/
private
void
createDatacenter
()
{
for
(
int
i
=
0
;
i
<
HOSTS
;
i
++)
{
hostList
.
add
(
createHost
());
Host
host
=
createHost
();
host
.
setId
(
i
);
hostList
.
add
(
host
);
}
Datacenter
dc0
=
new
DatacenterSimple
(
simulation
,
hostList
,
new
VmAllocationPolicySimple
());
...
...
@@ -309,7 +310,7 @@ public class VerticalVmIopsScalingExample {
UtilizationModel
utilization
=
new
UtilizationModelFull
();
for
(
int
i
=
0
;
i
<
CLOUDLETS
;
i
++)
{
Cloudlet
cloudlet
=
new
CloudletSimple
(
i
,
CLOUDLETS_INITIAL_LENGTH
,
CLOUDLET_PES
).
setFileSize
(
1024
)
Cloudlet
cloudlet
=
new
CloudletSimple
(
i
,
CLOUDLETS_INITIAL_LENGTH
,
CLOUDLETS_INITIAL_LENGTH_IOPS
,
CLOUDLET_PES
).
setFileSize
(
1024
)
.
setOutputSize
(
1024
).
setUtilizationModel
(
utilization
).
setUtilizationModelIops
(
utilization
);
list
.
add
(
cloudlet
);
}
...
...
cloudsim-plus/src/main/java/org/cloudbus/cloudsim/allocationpolicies/VmAllocationPolicyAbstract.java
View file @
5c2b4f84
...
...
@@ -280,19 +280,24 @@ public abstract class VmAllocationPolicyAbstract implements VmAllocationPolicy {
final
ResourceProvisioner
provisioner
=
scaling
.
getVm
().
getHost
().
getProvisioner
(
resourceClass
);
final
ResourceManageable
vmResource
=
scaling
.
getVm
().
getResource
(
resourceClass
);
final
double
utilization
=
vmResource
.
getPercentUtilization
()*
100
;
final
double
newTotalVmResource
=
(
double
)
vmResource
.
getCapacity
()
+
extraAmountToAllocate
;
if
(!
provisioner
.
allocateResourceForVm
(
scaling
.
getVm
(),
newTotalVmResource
)){
showResourceIsUnavailable
(
scaling
);
return
false
;
}
scaling
.
getVm
().
setIops
((
long
)
newTotalVmResource
);
Log
.
printFormattedLine
(
"%.2f: %s: %.0f more %s allocated to Vm %d: new capacity is %d. Current resource usage is %.2f%%"
,
scaling
.
getVm
().
getSimulation
().
clock
(),
scaling
.
getClass
().
getSimpleName
(),
extraAmountToAllocate
,
resourceClass
.
getSimpleName
(),
scaling
.
getVm
().
getId
(),
vmResource
.
getCapacity
(),
vmResource
.
getPercentU
tilization
()*
100
);
u
tilization
);
return
true
;
}
...
...
cloudsim-plus/src/main/java/org/cloudbus/cloudsim/provisioners/ResourceProvisionerNull.java
View file @
5c2b4f84
...
...
@@ -13,8 +13,6 @@ import org.cloudbus.cloudsim.vms.Vm;
final
class
ResourceProvisionerNull
implements
ResourceProvisioner
{
public
ResourceProvisionerNull
()
{
// TODO Auto-generated constructor stub
System
.
out
.
println
(
"Null created"
);
}
@Override
public
boolean
allocateResourceForVm
(
Vm
vm
,
long
newTotalVmResourceCapacity
)
{
...
...
cloudsim-plus/src/main/java/org/cloudsimplus/autoscaling/VerticalVmScalingSimple.java
View file @
5c2b4f84
...
...
@@ -171,8 +171,6 @@ public class VerticalVmScalingSimple extends VmScalingAbstract implements Vertic
@Override
public
boolean
isVmUnderloaded
()
{
Vm
vm
=
getVm
();
Resource
r
=
getResource
();
return
getResource
().
getPercentUtilization
()
<
lowerUtilizationThresholdFunction
.
apply
(
getVm
());
}
...
...
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