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
Hide 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 {
coordinator
.
setDatacenter
(
this
);
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
);
setVmAllocationPolicy
(
vmAllocationPolicy
);
setLastProcessTime
(
0.0
);
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/core/CloudSim.java
View file @
ba4dac91
...
...
@@ -271,7 +271,7 @@ public class CloudSim {
private
static
boolean
paused
=
false
;
/** The pause at. */
private
static
long
pauseAt
=
Long
.
MAX_VALUE
;
private
static
long
pauseAt
=
-
1
;
/** The abrupt terminate. */
private
static
boolean
abruptTerminate
=
false
;
...
...
@@ -777,7 +777,7 @@ public class CloudSim {
paused
=
false
;
if
(
pauseAt
<=
clock
)
{
pauseAt
=
Long
.
MAX_VALUE
;
pauseAt
=
-
1
;
}
return
!
paused
;
...
...
@@ -798,7 +798,7 @@ public class CloudSim {
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
();
clock
=
pauseAt
;
}
...
...
@@ -849,7 +849,7 @@ public class CloudSim {
waitPredicates
=
null
;
paused
=
false
;
pauseAt
=
Long
.
MAX_VALUE
;
pauseAt
=
-
1
;
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 {
delay
=
0
;
}
if
(
Double
.
isInfinite
(
delay
))
{
throw
new
IllegalArgumentException
(
"The specified delay is infinite value"
);
}
if
(
entityId
<
0
)
{
Log
.
printLine
(
getName
()
+
".send(): Error - "
+
"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 {
vm
.
setInMigration
(
true
);
/** 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
for
(
PowerHost
host
:
this
.<
PowerHost
>
getHostList
())
{
if
(
host
.
isSuitableForVm
(
vm
))
{
double
maxUtilization
=
getMaxUtilizationAfterAllocation
(
host
,
vm
);
if
((!
vm
.
isRecentlyCreated
()
&&
maxUtilization
>
getUtilizationThreshold
())
||
(
vm
.
isRecentlyCreated
()
&&
maxUtilization
>
1.0
))
{
if
((!
vm
.
isRecentlyCreated
()
&&
maxUtilization
>
getUtilizationThreshold
())
||
(
vm
.
isRecentlyCreated
()
&&
maxUtilization
>
1.0
))
{
continue
;
}
try
{
...
...
@@ -107,22 +106,15 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
*/
@Override
public
boolean
allocateHostForVm
(
Vm
vm
)
{
boolean
result
=
false
;
PowerHost
allocatedHost
=
findHostForVm
(
vm
);
try
{
result
=
allocatedHost
.
vmCreate
(
vm
);
}
catch
(
Exception
e
)
{
result
=
false
;
}
if
(
result
)
{
//if vm has been succesfully created in the host
if
(
allocatedHost
!=
null
&&
allocatedHost
.
vmCreate
(
vm
))
{
//if vm has been succesfully created in the host
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
@Override
public
void
deallocateHostForVm
(
Vm
vm
)
{
if
(
getVmTable
().
containsKey
(
vm
.
getUid
()))
{
Host
host
=
getVmTable
().
remove
(
vm
.
getUid
());
PowerHost
host
=
(
PowerHost
)
getVmTable
().
remove
(
vm
.
getUid
());
if
(
host
!=
null
)
{
host
.
vmDestroy
(
vm
);
}
...
...
@@ -165,33 +157,31 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
vmTmpList
.
addAll
(
vmList
);
PowerVmList
.
sortByCpuUtilization
(
vmTmpList
);
for
(
PowerHost
host
:
this
.<
PowerHost
>
getHostList
())
{
host
.
reallocateMigratingVms
();
}
for
(
Vm
vm
:
vmTmpList
)
{
//Log.printLine("VM #" + vm.getId() + " utilization: " + String.format("%.2f;", vm.getTotalUtilization(CloudSim.clock()) * 100));
if
(
vm
.
isRecentlyCreated
())
{
if
(
vm
.
isRecentlyCreated
()
||
vm
.
isInMigration
())
{
continue
;
}
PowerHost
oldHost
=
(
PowerHost
)
getVmTable
().
get
(
vm
.
getUid
());
//PowerHost oldHost = vm.getHost();
PowerHost
allocatedHost
=
findHostForVm
(
vm
);
if
(
allocatedHost
!=
null
)
{
Log
.
printLine
(
"VM #"
+
vm
.
getId
()
+
" allocated to host #"
+
allocatedHost
.
getId
());
allocatedHost
.
vmCreate
(
vm
);
if
(
!
allocatedHost
.
equals
(
oldHost
))
{
if
(
allocatedHost
.
getId
()
!=
oldHost
.
getId
(
))
{
Map
<
String
,
Object
>
migrate
=
new
HashMap
<
String
,
Object
>();
migrate
.
put
(
"vm"
,
vm
);
migrate
.
put
(
"host"
,
allocatedHost
);
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
;
}
...
...
@@ -202,16 +192,12 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
* @param vmList the vm list
*/
protected
void
saveAllocation
(
List
<?
extends
Vm
>
vmList
)
{
getSavedAllocation
().
clear
();
for
(
Vm
vm
:
vmList
)
{
if
(
vm
!=
null
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
//Log.printLine("Trying to save VM #" + vm.getId());
map
.
put
(
"vm"
,
vm
);
map
.
put
(
"host"
,
vm
.
getHost
());
getSavedAllocation
().
add
(
map
);
vm
.
getHost
().
vmDestroy
(
vm
);
//getVmTable().remove(vm.getUid());
}
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"vm"
,
vm
);
map
.
put
(
"host"
,
vm
.
getHost
());
getSavedAllocation
().
add
(
map
);
}
}
...
...
@@ -220,34 +206,23 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
*
* @param vmsToRestore the vms to restore
*/
protected
void
restoreAllocation
(
List
<
Vm
>
vmsToRestore
)
{
for
(
Map
<
String
,
Object
>
map
:
getSavedAllocation
())
{
Vm
vm
=
(
Vm
)
map
.
get
(
"vm"
);
PowerHost
host
=
(
PowerHost
)
vm
.
getHost
();
if
(
host
!=
null
)
{
vm
.
getHost
().
vmDestroy
(
vm
);
}
//PowerHost host = (PowerHost) map.get("host");
//host.vmDestroy(vm);
//host.vmDestroyAll();
protected
void
restoreAllocation
(
List
<
Vm
>
vmsToRestore
,
List
<
Host
>
hostList
)
{
for
(
Host
host
:
hostList
)
{
host
.
vmDestroyAll
();
host
.
reallocateMigratingVms
();
}
for
(
Map
<
String
,
Object
>
map
:
getSavedAllocation
())
{
Vm
vm
=
(
Vm
)
map
.
get
(
"vm"
);
PowerHost
host
=
(
PowerHost
)
map
.
get
(
"host"
);
//Log.printLine("Trying to restore VM #" + vm.getVmId() + " on host #" + host.getMachineID());
if
(!
vmsToRestore
.
contains
(
vm
))
{
//Log.printLine("VM #" + vm.getVmId() + " skipped because it's not in the toRestore list");
continue
;
}
//host.vmDestroy(vm);
// if (!host.vmCreate(vm)) {
// host.vmCreateBestEffort(vm);
// }
//host.vmCreateBestEffort(vm);
host
.
vmCreate
(
vm
);
if
(!
host
.
vmCreate
(
vm
))
{
Log
.
printLine
(
"failed"
);
}
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