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
0d6fdfb2
Commit
0d6fdfb2
authored
Jul 20, 2018
by
Rafael Vieira Falcão
Browse files
Adding modification that check if a vm should be counted as a vm with credit
parent
7c0cab28
Changes
6
Hide whitespace changes
Inline
Side-by-side
cloudsim-plus/src/main/java/org/cloudbus/cloudsim/allocationpolicies/migration/VmAllocationPolicyMigrationSla.java
View file @
0d6fdfb2
...
...
@@ -316,6 +316,8 @@ public class VmAllocationPolicyMigrationSla extends VmAllocationPolicyAbstract {
for
(
Host
h
:
looseSlaHosts
)
{
for
(
Vm
vm
:
h
.
getVmList
())
{
// TODO (IF) Create method with code bellow
if
(
vm
.
isInMigration
()
&&
!
isLooseHost
(
vm
.
gethostInMigration
()))
continue
;
if
(
vm
.
getMonitor
().
getCumulativeCredit
(
clock
)
-
MIGRATION_TIME
>=
0
)
{
candidateVmsToMigrate
.
add
(
vm
);
}
...
...
@@ -393,6 +395,10 @@ public class VmAllocationPolicyMigrationSla extends VmAllocationPolicyAbstract {
}
return
hosts
;
}
private
boolean
isLooseHost
(
Host
host
)
{
return
host
.
getIopsProvisioner
()
instanceof
ResourceProvisionerSimple
;
}
@Override
public
Optional
<
Host
>
findHostForVm
(
Vm
vm
)
{
...
...
cloudsim-plus/src/main/java/org/cloudbus/cloudsim/allocationpolicies/migration/VmAllocationPolicyMigrationSlaFixedTightHost.java
View file @
0d6fdfb2
...
...
@@ -101,34 +101,15 @@ public class VmAllocationPolicyMigrationSlaFixedTightHost extends VmAllocationPo
private
Map
<
Vm
,
Host
>
optimisticConsolidation
(
Map
<
Vm
,
Host
>
actualMigrationMap
)
{
List
<
Host
>
sortedLooseHosts
=
getLooseHostsSortedAscendingByFragmentation
();
for
(
int
j
=
sortedLooseHosts
.
size
()
-
1
;
j
>=
0
;
j
--)
{
for
(
int
i
=
0
;
i
<
sortedLooseHosts
.
size
();
i
++)
{
if
(
i
==
j
||
sortedLooseHosts
.
get
(
i
).
getVmList
().
isEmpty
())
continue
;
for
(
Vm
vm
:
sortedLooseHosts
.
get
(
i
).
getVmList
())
{
if
(
sortedLooseHosts
.
get
(
j
).
isSuitableForVm
(
vm
)
&&
sortedLooseHosts
.
get
(
j
).
addMigratingInVm
(
vm
))
{
actualMigrationMap
.
put
(
vm
,
sortedLooseHosts
.
get
(
j
));
}
}
}
}
return
actualMigrationMap
;
}
private
Map
<
Vm
,
Host
>
optimisticConsolidation2
(
Map
<
Vm
,
Host
>
actualMigrationMap
)
{
List
<
Host
>
orderedLooseHosts
=
getLooseHostsSortedAscendingByFragmentation
();
List
<
Host
>
sortedLooseHosts
=
getLooseHostsSortedAscendingByFragmentation
();
Iterator
<
Host
>
hostIt
=
sortedLooseHosts
.
listIterator
();
for
(
int
j
=
sortedLooseHosts
.
size
()
-
1
;
j
>=
0
;
j
--)
{
for
(
int
i
=
0
;
i
<
sortedLooseHosts
.
size
();
i
++)
{
if
(
i
==
j
||
sortedLooseHosts
.
get
(
i
).
getVmList
().
isEmpty
())
continue
;
for
(
Vm
vm
:
sortedLooseHosts
.
get
(
i
).
getVmList
())
{
if
(
sortedLooseHosts
.
get
(
j
).
isSuitableForVm
(
vm
)
&&
sortedLooseHosts
.
get
(
j
).
addMigratingInVm
(
vm
))
{
actualMigrationMap
.
put
(
vm
,
sortedLooseHosts
.
get
(
j
));
for
(
int
i
=
0
;
i
<
orderedLooseHosts
.
size
();
i
++)
{
for
(
int
j
=
orderedLooseHosts
.
size
()
-
1
;
j
>=
0
;
j
--)
{
if
(
i
==
j
||
orderedLooseHosts
.
get
(
i
).
getVmList
().
isEmpty
())
break
;
for
(
Vm
vm
:
orderedLooseHosts
.
get
(
i
).
getVmList
())
{
if
(
orderedLooseHosts
.
get
(
j
).
isSuitableForVm
(
vm
)
&&
orderedLooseHosts
.
get
(
j
).
addMigratingInVm
(
vm
))
{
actualMigrationMap
.
put
(
vm
,
orderedLooseHosts
.
get
(
j
));
}
}
}
...
...
@@ -136,6 +117,26 @@ public class VmAllocationPolicyMigrationSlaFixedTightHost extends VmAllocationPo
return
actualMigrationMap
;
}
// private Map<Vm, Host> optimisticConsolidation2(Map<Vm, Host> actualMigrationMap) {
//
// List<Host> sortedLooseHosts = getLooseHostsSortedAscendingByFragmentation();
// Iterator<Host> hostIt = sortedLooseHosts.listIterator();
//
// for (int j = sortedLooseHosts.size() - 1; j >= 0; j--) {
// for (int i = 0; i < sortedLooseHosts.size(); i++) {
// if(i == j || sortedLooseHosts.get(i).getVmList().isEmpty())
// continue;
// for (Vm vm : sortedLooseHosts.get(i).getVmList()) {
// if(sortedLooseHosts.get(j).isSuitableForVm(vm) && sortedLooseHosts.get(j).addMigratingInVm(vm)) {
// actualMigrationMap.put(vm, sortedLooseHosts.get(j));
// }
// }
// }
// }
//
// return actualMigrationMap;
// }
// Returns the list of loose hosts ordered (increase order) by the number of Vm
private
List
<
Host
>
getLooseHostsSortedAscendingByFragmentation
()
{
...
...
cloudsim-plus/src/main/java/org/cloudbus/cloudsim/hosts/HostSimple.java
View file @
0d6fdfb2
...
...
@@ -342,6 +342,10 @@ public class HostSimple implements Host {
}
vm
.
setInMigration
(
inMigration
);
if
(
inMigration
)
vm
.
setHostInMigration
(
this
);
storage
.
allocateResource
(
vm
.
getStorage
());
ramProvisioner
.
allocateResourceForVm
(
vm
,
vm
.
getCurrentRequestedRam
());
bwProvisioner
.
allocateResourceForVm
(
vm
,
vm
.
getCurrentRequestedBw
());
...
...
cloudsim-plus/src/main/java/org/cloudbus/cloudsim/vms/Vm.java
View file @
0d6fdfb2
...
...
@@ -413,6 +413,16 @@ public interface Vm extends Machine, UniquelyIdentificable, Comparable<Vm>, Cust
* @return
*/
boolean
isInMigration
();
/**
* Sets host that the Vm is migrating into
*/
void
setHostInMigration
(
Host
host
);
/**
* Gets host that the Vm is migrating into
*/
Host
gethostInMigration
();
/**
* Defines if the VM is in migration process or not.
...
...
cloudsim-plus/src/main/java/org/cloudbus/cloudsim/vms/VmNull.java
View file @
0d6fdfb2
...
...
@@ -258,4 +258,14 @@ final class VmNull implements Vm {
public
void
setIOPSUtilization
(
double
time
,
double
value
)
{
return
;
}
@Override
public
void
setHostInMigration
(
Host
host
)
{
// TODO Auto-generated method stub
}
@Override
public
Host
gethostInMigration
()
{
// TODO Auto-generated method stub
return
null
;
}
}
cloudsim-plus/src/main/java/org/cloudbus/cloudsim/vms/VmSimple.java
View file @
0d6fdfb2
...
...
@@ -123,6 +123,8 @@ public class VmSimple implements Vm {
*/
private
Iops
iops
;
private
Host
hostMigratingIn
;
/**
* The SLA regarding this VM.
*/
...
...
@@ -934,4 +936,17 @@ public class VmSimple implements Vm {
public
UtilizationHistory
getUtilizationHistory
()
{
return
utilizationHistory
;
}
@Override
public
void
setHostInMigration
(
Host
host
)
{
this
.
hostMigratingIn
=
host
;
}
@Override
public
Host
gethostInMigration
()
{
return
this
.
hostMigratingIn
;
}
}
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