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
ba4dac91
Commit
ba4dac91
authored
Jul 26, 2010
by
Anton Beloglazov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Fixed PowerVmAllocationPolicySingleThreshold
- Fixed sngle threshold example
parent
a0226d94
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
68 deletions
+37
-68
FederatedDatacenter.java
.../main/java/org/cloudbus/cloudsim/FederatedDatacenter.java
+0
-10
CloudSim.java
...im/src/main/java/org/cloudbus/cloudsim/core/CloudSim.java
+4
-4
SimEntity.java
...m/src/main/java/org/cloudbus/cloudsim/core/SimEntity.java
+4
-0
PowerDatacenter.java
...ain/java/org/cloudbus/cloudsim/power/PowerDatacenter.java
+1
-1
PowerVmAllocationPolicySingleThreshold.java
...loudsim/power/PowerVmAllocationPolicySingleThreshold.java
+28
-53
No files found.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/FederatedDatacenter.java
View file @
ba4dac91
...
@@ -95,16 +95,6 @@ public class FederatedDatacenter extends SimEntity {
...
@@ -95,16 +95,6 @@ public class FederatedDatacenter extends SimEntity {
coordinator
.
setDatacenter
(
this
);
coordinator
.
setDatacenter
(
this
);
this
.
sensorsList
=
new
LinkedList
<
Sensor
<
Double
>>();
this
.
sensorsList
=
new
LinkedList
<
Sensor
<
Double
>>();
//HostList2<Host> test = this.<Host>getHosts();
// LinkedList<Host> test = getHosts();
// test.add(new Host(0, null, null, null, 0, null));
// getHostsWildcard();
//
//
//
// getHosts().add(new Host(0, null, null, null, 0, null));
// getHosts().add(new cloudsim.power.Host(0, null, null, null, 0, null));
setCharacteristics
(
characteristics
);
setCharacteristics
(
characteristics
);
setVmAllocationPolicy
(
vmAllocationPolicy
);
setVmAllocationPolicy
(
vmAllocationPolicy
);
setLastProcessTime
(
0.0
);
setLastProcessTime
(
0.0
);
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/core/CloudSim.java
View file @
ba4dac91
...
@@ -271,7 +271,7 @@ public class CloudSim {
...
@@ -271,7 +271,7 @@ public class CloudSim {
private
static
boolean
paused
=
false
;
private
static
boolean
paused
=
false
;
/** The pause at. */
/** The pause at. */
private
static
long
pauseAt
=
Long
.
MAX_VALUE
;
private
static
long
pauseAt
=
-
1
;
/** The abrupt terminate. */
/** The abrupt terminate. */
private
static
boolean
abruptTerminate
=
false
;
private
static
boolean
abruptTerminate
=
false
;
...
@@ -777,7 +777,7 @@ public class CloudSim {
...
@@ -777,7 +777,7 @@ public class CloudSim {
paused
=
false
;
paused
=
false
;
if
(
pauseAt
<=
clock
)
{
if
(
pauseAt
<=
clock
)
{
pauseAt
=
Long
.
MAX_VALUE
;
pauseAt
=
-
1
;
}
}
return
!
paused
;
return
!
paused
;
...
@@ -798,7 +798,7 @@ public class CloudSim {
...
@@ -798,7 +798,7 @@ public class CloudSim {
break
;
break
;
}
}
if
(
(
future
.
size
()
>
0
&&
clock
<=
pauseAt
&&
pauseAt
<=
future
.
iterator
().
next
().
eventTime
())
||
future
.
size
()
==
0
&&
pauseAt
<=
clock
)
{
if
(
pauseAt
!=
-
1
&&
((
future
.
size
()
>
0
&&
clock
<=
pauseAt
&&
pauseAt
<=
future
.
iterator
().
next
().
eventTime
())
||
future
.
size
()
==
0
&&
pauseAt
<=
clock
)
)
{
pauseSimulation
();
pauseSimulation
();
clock
=
pauseAt
;
clock
=
pauseAt
;
}
}
...
@@ -849,7 +849,7 @@ public class CloudSim {
...
@@ -849,7 +849,7 @@ public class CloudSim {
waitPredicates
=
null
;
waitPredicates
=
null
;
paused
=
false
;
paused
=
false
;
pauseAt
=
Long
.
MAX_VALUE
;
pauseAt
=
-
1
;
abruptTerminate
=
false
;
abruptTerminate
=
false
;
}
}
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/core/SimEntity.java
View file @
ba4dac91
...
@@ -453,6 +453,10 @@ public abstract class SimEntity implements Cloneable {
...
@@ -453,6 +453,10 @@ public abstract class SimEntity implements Cloneable {
delay
=
0
;
delay
=
0
;
}
}
if
(
Double
.
isInfinite
(
delay
))
{
throw
new
IllegalArgumentException
(
"The specified delay is infinite value"
);
}
if
(
entityId
<
0
)
{
if
(
entityId
<
0
)
{
Log
.
printLine
(
getName
()
+
".send(): Error - "
+
Log
.
printLine
(
getName
()
+
".send(): Error - "
+
"invalid entity id "
+
entityId
);
"invalid entity id "
+
entityId
);
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java
View file @
ba4dac91
...
@@ -174,7 +174,7 @@ public class PowerDatacenter extends Datacenter {
...
@@ -174,7 +174,7 @@ public class PowerDatacenter extends Datacenter {
vm
.
setInMigration
(
true
);
vm
.
setInMigration
(
true
);
/** VM migration delay = RAM / bandwidth + C (C = 10 sec) **/
/** VM migration delay = RAM / bandwidth + C (C = 10 sec) **/
send
(
getId
(),
(
double
)
vm
.
getRam
()
/
(
vm
.
getBw
()
/
8000
)
+
0
,
CloudSimTags
.
VM_MIGRATE
,
migrate
);
send
(
getId
(),
vm
.
getRam
()
/
((
double
)
vm
.
getBw
()
/
8000
)
+
0
,
CloudSimTags
.
VM_MIGRATE
,
migrate
);
}
}
}
}
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerVmAllocationPolicySingleThreshold.java
View file @
ba4dac91
...
@@ -74,8 +74,7 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
...
@@ -74,8 +74,7 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
for
(
PowerHost
host
:
this
.<
PowerHost
>
getHostList
())
{
for
(
PowerHost
host
:
this
.<
PowerHost
>
getHostList
())
{
if
(
host
.
isSuitableForVm
(
vm
))
{
if
(
host
.
isSuitableForVm
(
vm
))
{
double
maxUtilization
=
getMaxUtilizationAfterAllocation
(
host
,
vm
);
double
maxUtilization
=
getMaxUtilizationAfterAllocation
(
host
,
vm
);
if
((!
vm
.
isRecentlyCreated
()
&&
maxUtilization
>
getUtilizationThreshold
())
||
if
((!
vm
.
isRecentlyCreated
()
&&
maxUtilization
>
getUtilizationThreshold
())
||
(
vm
.
isRecentlyCreated
()
&&
maxUtilization
>
1.0
))
{
(
vm
.
isRecentlyCreated
()
&&
maxUtilization
>
1.0
))
{
continue
;
continue
;
}
}
try
{
try
{
...
@@ -107,22 +106,15 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
...
@@ -107,22 +106,15 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
*/
*/
@Override
@Override
public
boolean
allocateHostForVm
(
Vm
vm
)
{
public
boolean
allocateHostForVm
(
Vm
vm
)
{
boolean
result
=
false
;
PowerHost
allocatedHost
=
findHostForVm
(
vm
);
PowerHost
allocatedHost
=
findHostForVm
(
vm
);
if
(
allocatedHost
!=
null
&&
allocatedHost
.
vmCreate
(
vm
))
{
//if vm has been succesfully created in the host
try
{
result
=
allocatedHost
.
vmCreate
(
vm
);
}
catch
(
Exception
e
)
{
result
=
false
;
}
if
(
result
)
{
//if vm has been succesfully created in the host
getVmTable
().
put
(
vm
.
getUid
(),
allocatedHost
);
getVmTable
().
put
(
vm
.
getUid
(),
allocatedHost
);
Log
.
formatLine
(
"%.2f: VM #"
+
vm
.
getId
()
+
" has been sent to the host #"
+
allocatedHost
.
getId
(),
CloudSim
.
clock
());
if
(!
Log
.
isDisabled
())
{
Log
.
print
(
String
.
format
(
"%.2f: VM #"
+
vm
.
getId
()
+
" has been allocated to the host #"
+
allocatedHost
.
getId
()
+
"\n"
,
CloudSim
.
clock
()));
}
}
return
true
;
return
result
;
}
return
false
;
}
}
/**
/**
...
@@ -136,7 +128,7 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
...
@@ -136,7 +128,7 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
@Override
@Override
public
void
deallocateHostForVm
(
Vm
vm
)
{
public
void
deallocateHostForVm
(
Vm
vm
)
{
if
(
getVmTable
().
containsKey
(
vm
.
getUid
()))
{
if
(
getVmTable
().
containsKey
(
vm
.
getUid
()))
{
Host
host
=
getVmTable
().
remove
(
vm
.
getUid
());
PowerHost
host
=
(
PowerHost
)
getVmTable
().
remove
(
vm
.
getUid
());
if
(
host
!=
null
)
{
if
(
host
!=
null
)
{
host
.
vmDestroy
(
vm
);
host
.
vmDestroy
(
vm
);
}
}
...
@@ -165,33 +157,31 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
...
@@ -165,33 +157,31 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
vmTmpList
.
addAll
(
vmList
);
vmTmpList
.
addAll
(
vmList
);
PowerVmList
.
sortByCpuUtilization
(
vmTmpList
);
PowerVmList
.
sortByCpuUtilization
(
vmTmpList
);
for
(
PowerHost
host
:
this
.<
PowerHost
>
getHostList
())
{
host
.
reallocateMigratingVms
();
}
for
(
Vm
vm
:
vmTmpList
)
{
for
(
Vm
vm
:
vmTmpList
)
{
//Log.printLine("VM #" + vm.getId() + " utilization: " + String.format("%.2f;", vm.getTotalUtilization(CloudSim.clock()) * 100));
if
(
vm
.
isRecentlyCreated
()
||
vm
.
isInMigration
())
{
if
(
vm
.
isRecentlyCreated
())
{
continue
;
continue
;
}
}
PowerHost
oldHost
=
(
PowerHost
)
getVmTable
().
get
(
vm
.
getUid
());
PowerHost
oldHost
=
(
PowerHost
)
getVmTable
().
get
(
vm
.
getUid
());
//PowerHost oldHost = vm.getHost();
PowerHost
allocatedHost
=
findHostForVm
(
vm
);
PowerHost
allocatedHost
=
findHostForVm
(
vm
);
if
(
allocatedHost
!=
null
)
{
if
(
allocatedHost
!=
null
)
{
Log
.
printLine
(
"VM #"
+
vm
.
getId
()
+
" allocated to host #"
+
allocatedHost
.
getId
());
Log
.
printLine
(
"VM #"
+
vm
.
getId
()
+
" allocated to host #"
+
allocatedHost
.
getId
());
allocatedHost
.
vmCreate
(
vm
);
allocatedHost
.
vmCreate
(
vm
);
if
(
!
allocatedHost
.
equals
(
oldHost
))
{
if
(
allocatedHost
.
getId
()
!=
oldHost
.
getId
(
))
{
Map
<
String
,
Object
>
migrate
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
migrate
=
new
HashMap
<
String
,
Object
>();
migrate
.
put
(
"vm"
,
vm
);
migrate
.
put
(
"vm"
,
vm
);
migrate
.
put
(
"host"
,
allocatedHost
);
migrate
.
put
(
"host"
,
allocatedHost
);
migrationMap
.
add
(
migrate
);
migrationMap
.
add
(
migrate
);
getVmTable
().
put
(
vm
.
getUid
(),
allocatedHost
);
vmsToRestore
.
remove
(
vm
);
//Log.printLine("Skip restore of VM #" + vm.getVmId());
}
}
}
}
}
}
restoreAllocation
(
vmsToRestore
);
restoreAllocation
(
vmsToRestore
,
getHostList
()
);
return
migrationMap
;
return
migrationMap
;
}
}
...
@@ -202,16 +192,12 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
...
@@ -202,16 +192,12 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
* @param vmList the vm list
* @param vmList the vm list
*/
*/
protected
void
saveAllocation
(
List
<?
extends
Vm
>
vmList
)
{
protected
void
saveAllocation
(
List
<?
extends
Vm
>
vmList
)
{
getSavedAllocation
().
clear
();
for
(
Vm
vm
:
vmList
)
{
for
(
Vm
vm
:
vmList
)
{
if
(
vm
!=
null
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
//Log.printLine("Trying to save VM #" + vm.getId());
map
.
put
(
"vm"
,
vm
);
map
.
put
(
"vm"
,
vm
);
map
.
put
(
"host"
,
vm
.
getHost
());
map
.
put
(
"host"
,
vm
.
getHost
());
getSavedAllocation
().
add
(
map
);
getSavedAllocation
().
add
(
map
);
vm
.
getHost
().
vmDestroy
(
vm
);
//getVmTable().remove(vm.getUid());
}
}
}
}
}
...
@@ -220,34 +206,23 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
...
@@ -220,34 +206,23 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
*
*
* @param vmsToRestore the vms to restore
* @param vmsToRestore the vms to restore
*/
*/
protected
void
restoreAllocation
(
List
<
Vm
>
vmsToRestore
)
{
protected
void
restoreAllocation
(
List
<
Vm
>
vmsToRestore
,
List
<
Host
>
hostList
)
{
for
(
Map
<
String
,
Object
>
map
:
getSavedAllocation
())
{
for
(
Host
host
:
hostList
)
{
Vm
vm
=
(
Vm
)
map
.
get
(
"vm"
);
host
.
vmDestroyAll
();
PowerHost
host
=
(
PowerHost
)
vm
.
getHost
();
host
.
reallocateMigratingVms
();
if
(
host
!=
null
)
{
vm
.
getHost
().
vmDestroy
(
vm
);
}
//PowerHost host = (PowerHost) map.get("host");
//host.vmDestroy(vm);
//host.vmDestroyAll();
}
}
for
(
Map
<
String
,
Object
>
map
:
getSavedAllocation
())
{
for
(
Map
<
String
,
Object
>
map
:
getSavedAllocation
())
{
Vm
vm
=
(
Vm
)
map
.
get
(
"vm"
);
Vm
vm
=
(
Vm
)
map
.
get
(
"vm"
);
PowerHost
host
=
(
PowerHost
)
map
.
get
(
"host"
);
PowerHost
host
=
(
PowerHost
)
map
.
get
(
"host"
);
//Log.printLine("Trying to restore VM #" + vm.getVmId() + " on host #" + host.getMachineID());
if
(!
vmsToRestore
.
contains
(
vm
))
{
if
(!
vmsToRestore
.
contains
(
vm
))
{
//Log.printLine("VM #" + vm.getVmId() + " skipped because it's not in the toRestore list");
continue
;
continue
;
}
}
//host.vmDestroy(vm);
if
(!
host
.
vmCreate
(
vm
))
{
// if (!host.vmCreate(vm)) {
Log
.
printLine
(
"failed"
);
// host.vmCreateBestEffort(vm);
}
// }
//host.vmCreateBestEffort(vm);
host
.
vmCreate
(
vm
);
getVmTable
().
put
(
vm
.
getUid
(),
host
);
getVmTable
().
put
(
vm
.
getUid
(),
host
);
Log
.
printLine
(
"Restored VM #"
+
vm
.
getId
()
+
" on host #"
+
host
.
getId
());
}
}
setSavedAllocation
(
new
ArrayList
<
Map
<
String
,
Object
>>());
}
}
/**
/**
...
...
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