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
4f25a01a
Commit
4f25a01a
authored
Jan 09, 2012
by
rodrigo.calheiros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed warnings from Network package
parent
b463216f
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
601 additions
and
592 deletions
+601
-592
TestExample.java
...bus/cloudsim/examples/network/datacenter/TestExample.java
+76
-101
EdgeSwitch.java
.../org/cloudbus/cloudsim/network/datacenter/EdgeSwitch.java
+55
-60
NetDatacenterBroker.java
...dbus/cloudsim/network/datacenter/NetDatacenterBroker.java
+24
-34
NetworkCloudlet.java
...cloudbus/cloudsim/network/datacenter/NetworkCloudlet.java
+31
-23
NetworkCloudletSpaceSharedScheduler.java
...twork/datacenter/NetworkCloudletSpaceSharedScheduler.java
+95
-65
NetworkConstants.java
...loudbus/cloudsim/network/datacenter/NetworkConstants.java
+33
-44
NetworkDatacenter.java
...oudbus/cloudsim/network/datacenter/NetworkDatacenter.java
+74
-81
NetworkHost.java
...org/cloudbus/cloudsim/network/datacenter/NetworkHost.java
+59
-52
NetworkVm.java
...a/org/cloudbus/cloudsim/network/datacenter/NetworkVm.java
+21
-13
Switch.java
...java/org/cloudbus/cloudsim/network/datacenter/Switch.java
+31
-62
WorkflowApp.java
...org/cloudbus/cloudsim/network/datacenter/WorkflowApp.java
+102
-57
No files found.
modules/cloudsim-examples/src/main/java/org/cloudbus/cloudsim/examples/network/datacenter/TestExample.java
View file @
4f25a01a
package
org
.
cloudbus
.
cloudsim
.
examples
.
network
.
datacenter
;
package
org
.
cloudbus
.
cloudsim
.
examples
.
network
.
datacenter
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -10,20 +8,13 @@ import java.util.LinkedList;
...
@@ -10,20 +8,13 @@ import java.util.LinkedList;
import
java.util.List
;
import
java.util.List
;
import
org.cloudbus.cloudsim.Cloudlet
;
import
org.cloudbus.cloudsim.Cloudlet
;
import
org.cloudbus.cloudsim.CloudletSchedulerSpaceShared
;
import
org.cloudbus.cloudsim.DatacenterCharacteristics
;
import
org.cloudbus.cloudsim.DatacenterCharacteristics
;
import
org.cloudbus.cloudsim.Host
;
import
org.cloudbus.cloudsim.Host
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Pe
;
import
org.cloudbus.cloudsim.Pe
;
import
org.cloudbus.cloudsim.Storage
;
import
org.cloudbus.cloudsim.Storage
;
import
org.cloudbus.cloudsim.UtilizationModel
;
import
org.cloudbus.cloudsim.UtilizationModelFull
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.VmAllocationPolicySimple
;
import
org.cloudbus.cloudsim.VmSchedulerTimeShared
;
import
org.cloudbus.cloudsim.VmSchedulerTimeShared
;
import
org.cloudbus.cloudsim.core.CloudSim
;
import
org.cloudbus.cloudsim.core.CloudSim
;
import
org.cloudbus.cloudsim.distributions.UniformDistr
;
import
org.cloudbus.cloudsim.network.datacenter.AppCloudlet
;
import
org.cloudbus.cloudsim.network.datacenter.EdgeSwitch
;
import
org.cloudbus.cloudsim.network.datacenter.EdgeSwitch
;
import
org.cloudbus.cloudsim.network.datacenter.NetDatacenterBroker
;
import
org.cloudbus.cloudsim.network.datacenter.NetDatacenterBroker
;
import
org.cloudbus.cloudsim.network.datacenter.NetworkConstants
;
import
org.cloudbus.cloudsim.network.datacenter.NetworkConstants
;
...
@@ -37,13 +28,6 @@ import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
...
@@ -37,13 +28,6 @@ import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
public
class
TestExample
{
public
class
TestExample
{
/**
* @param args
*/
/** The cloudlet list. */
private
static
List
<
AppCloudlet
>
cloudletList
;
/** The vmlist. */
/** The vmlist. */
private
static
List
<
NetworkVm
>
vmlist
;
private
static
List
<
NetworkVm
>
vmlist
;
...
@@ -72,11 +56,9 @@ public class TestExample {
...
@@ -72,11 +56,9 @@ public class TestExample {
// Third step: Create Broker
// Third step: Create Broker
NetDatacenterBroker
broker
=
createBroker
();
NetDatacenterBroker
broker
=
createBroker
();
int
brokerId
=
broker
.
getId
();
broker
.
setLinkDC
(
datacenter0
);
broker
.
setLinkDC
(
datacenter0
);
// broker.setLinkDC(datacenter0);
// broker.setLinkDC(datacenter0);
// Fifth step: Create one Cloudlet
// Fifth step: Create one Cloudlet
cloudletList
=
new
ArrayList
<
AppCloudlet
>();
vmlist
=
new
ArrayList
<
NetworkVm
>();
vmlist
=
new
ArrayList
<
NetworkVm
>();
...
@@ -92,9 +74,9 @@ public class TestExample {
...
@@ -92,9 +74,9 @@ public class TestExample {
// Final step: Print results when simulation is over
// Final step: Print results when simulation is over
List
<
Cloudlet
>
newList
=
broker
.
getCloudletReceivedList
();
List
<
Cloudlet
>
newList
=
broker
.
getCloudletReceivedList
();
printCloudletList
(
newList
);
printCloudletList
(
newList
);
System
.
out
.
println
(
"numberofcloudlet "
+
newList
.
size
()
System
.
out
.
println
(
"numberofcloudlet "
+
newList
.
size
()
+
" Cached "
+
" Cached "
+
NetDatacenterBroker
.
cachedcloudlet
+
NetDatacenterBroker
.
cachedcloudlet
+
" Data transfered "
+
" Data transfered "
+
NetworkConstants
.
totaldatatransfer
);
+
NetworkConstants
.
totaldatatransfer
);
// Print the debt of each user to each datacenter
// Print the debt of each user to each datacenter
datacenter0
.
printDebts
();
datacenter0
.
printDebts
();
...
@@ -133,12 +115,10 @@ public class TestExample {
...
@@ -133,12 +115,10 @@ public class TestExample {
// 4. Create Host with its id and list of PEs and add them to the list
// 4. Create Host with its id and list of PEs and add them to the list
// of machines
// of machines
int
hostId
=
0
;
int
ram
=
2048
;
// host memory (MB)
int
ram
=
2048
;
// host memory (MB)
long
storage
=
1000000
;
// host storage
long
storage
=
1000000
;
// host storage
int
bw
=
10000
;
int
bw
=
10000
;
for
(
int
i
=
0
;
i
<
NetworkConstants
.
EdgeSwitchPort
for
(
int
i
=
0
;
i
<
NetworkConstants
.
EdgeSwitchPort
*
NetworkConstants
.
AggSwitchPort
*
NetworkConstants
.
AggSwitchPort
*
NetworkConstants
.
RootSwitchPort
;
i
++)
{
*
NetworkConstants
.
RootSwitchPort
;
i
++)
{
// 2. A Machine contains one or more PEs or CPUs/Cores.
// 2. A Machine contains one or more PEs or CPUs/Cores.
// In this example, it will have only one core.
// In this example, it will have only one core.
...
@@ -195,8 +175,12 @@ public class TestExample {
...
@@ -195,8 +175,12 @@ public class TestExample {
// 4. Create PowerHost with its id and list of PEs and add them to
// 4. Create PowerHost with its id and list of PEs and add them to
// the list of machines
// the list of machines
hostList
.
add
(
new
NetworkHost
(
i
,
new
RamProvisionerSimple
(
ram
),
hostList
.
add
(
new
NetworkHost
(
new
BwProvisionerSimple
(
bw
),
storage
,
peList
,
i
,
new
RamProvisionerSimple
(
ram
),
new
BwProvisionerSimple
(
bw
),
storage
,
peList
,
new
VmSchedulerTimeShared
(
peList
)));
// This is our machine
new
VmSchedulerTimeShared
(
peList
)));
// This is our machine
}
}
...
@@ -220,14 +204,25 @@ public class TestExample {
...
@@ -220,14 +204,25 @@ public class TestExample {
// devices by now
// devices by now
DatacenterCharacteristics
characteristics
=
new
DatacenterCharacteristics
(
DatacenterCharacteristics
characteristics
=
new
DatacenterCharacteristics
(
arch
,
os
,
vmm
,
hostList
,
time_zone
,
cost
,
costPerMem
,
arch
,
costPerStorage
,
costPerBw
);
os
,
vmm
,
hostList
,
time_zone
,
cost
,
costPerMem
,
costPerStorage
,
costPerBw
);
// 6. Finally, we need to create a NetworkDatacenter object.
// 6. Finally, we need to create a NetworkDatacenter object.
NetworkDatacenter
datacenter
=
null
;
NetworkDatacenter
datacenter
=
null
;
try
{
try
{
datacenter
=
new
NetworkDatacenter
(
name
,
characteristics
,
datacenter
=
new
NetworkDatacenter
(
new
NetworkVmAllocationPolicy
(
hostList
),
storageList
,
0
);
name
,
characteristics
,
new
NetworkVmAllocationPolicy
(
hostList
),
storageList
,
0
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -263,17 +258,14 @@ public class TestExample {
...
@@ -263,17 +258,14 @@ public class TestExample {
* list of Cloudlets
* list of Cloudlets
* @throws IOException
* @throws IOException
*/
*/
private
static
void
printCloudletList
(
List
<
Cloudlet
>
list
)
private
static
void
printCloudletList
(
List
<
Cloudlet
>
list
)
throws
IOException
{
throws
IOException
{
int
size
=
list
.
size
();
int
size
=
list
.
size
();
Cloudlet
cloudlet
;
Cloudlet
cloudlet
;
double
fintime
=
0
;
String
indent
=
" "
;
String
indent
=
" "
;
Log
.
printLine
();
Log
.
printLine
();
Log
.
printLine
(
"========== OUTPUT =========="
);
Log
.
printLine
(
"========== OUTPUT =========="
);
Log
.
printLine
(
"Cloudlet ID"
+
indent
+
"STATUS"
+
indent
Log
.
printLine
(
"Cloudlet ID"
+
indent
+
"STATUS"
+
indent
+
"Data center ID"
+
indent
+
"VM ID"
+
"Data center ID"
+
indent
+
"VM ID"
+
indent
+
"Time"
+
indent
+
"Time"
+
indent
+
"Start Time"
+
indent
+
"Finish Time"
);
+
indent
+
"Start Time"
+
indent
+
"Finish Time"
);
DecimalFormat
dft
=
new
DecimalFormat
(
"###.##"
);
DecimalFormat
dft
=
new
DecimalFormat
(
"###.##"
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
...
@@ -282,13 +274,9 @@ public class TestExample {
...
@@ -282,13 +274,9 @@ public class TestExample {
if
(
cloudlet
.
getCloudletStatus
()
==
Cloudlet
.
SUCCESS
)
{
if
(
cloudlet
.
getCloudletStatus
()
==
Cloudlet
.
SUCCESS
)
{
Log
.
print
(
"SUCCESS"
);
Log
.
print
(
"SUCCESS"
);
fintime
=
cloudlet
.
getFinishTime
();
Log
.
printLine
(
indent
+
indent
+
cloudlet
.
getResourceId
()
+
indent
+
indent
+
indent
Log
.
printLine
(
indent
+
indent
+
cloudlet
.
getResourceId
()
+
cloudlet
.
getVmId
()
+
indent
+
indent
+
dft
.
format
(
cloudlet
.
getActualCPUTime
())
+
indent
+
indent
+
indent
+
cloudlet
.
getVmId
()
+
indent
+
indent
+
dft
.
format
(
cloudlet
.
getExecStartTime
())
+
indent
+
indent
+
indent
+
indent
+
dft
.
format
(
cloudlet
.
getActualCPUTime
())
+
indent
+
indent
+
dft
.
format
(
cloudlet
.
getExecStartTime
())
+
indent
+
indent
+
dft
.
format
(
cloudlet
.
getFinishTime
()));
+
dft
.
format
(
cloudlet
.
getFinishTime
()));
}
}
}
}
...
@@ -297,24 +285,11 @@ public class TestExample {
...
@@ -297,24 +285,11 @@ public class TestExample {
static
void
CreateNetwork
(
int
numhost
,
NetworkDatacenter
dc
)
{
static
void
CreateNetwork
(
int
numhost
,
NetworkDatacenter
dc
)
{
// //Root Switch
// Switch swroot=new Switch("Root", Constants.ROOT_LEVEL, dc);
// dc.Switchlist.put(swroot.getId(), swroot);
// //Agg Switch
// Switch aggswitch[]=new Switch[(int) Constants.RootSwitchPort];
// for(int j=0;j<Constants.RootSwitchPort;j++)
// {
// aggswitch[j]=new Switch("Agg"+j, Constants.Agg_LEVEL, dc);
// swroot.downlinkswitches.add(aggswitch[j]);
// aggswitch[j].uplinkswitches.add(swroot);
// dc.Switchlist.put(aggswitch[j].getId(), aggswitch[j]);
// }
// Edge Switch
// Edge Switch
EdgeSwitch
edgeswitch
[]
=
new
EdgeSwitch
[
1
];
EdgeSwitch
edgeswitch
[]
=
new
EdgeSwitch
[
1
];
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
edgeswitch
[
i
]
=
new
EdgeSwitch
(
"Edge"
+
i
,
edgeswitch
[
i
]
=
new
EdgeSwitch
(
"Edge"
+
i
,
NetworkConstants
.
EDGE_LEVEL
,
dc
);
NetworkConstants
.
EDGE_LEVEL
,
dc
);
// edgeswitch[i].uplinkswitches.add(null);
// edgeswitch[i].uplinkswitches.add(null);
dc
.
Switchlist
.
put
(
edgeswitch
[
i
].
getId
(),
edgeswitch
[
i
]);
dc
.
Switchlist
.
put
(
edgeswitch
[
i
].
getId
(),
edgeswitch
[
i
]);
// aggswitch[(int)
// aggswitch[(int)
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/EdgeSwitch.java
View file @
4f25a01a
...
@@ -49,7 +49,6 @@ public class EdgeSwitch extends Switch{
...
@@ -49,7 +49,6 @@ public class EdgeSwitch extends Switch{
this
.
switching_delay
=
NetworkConstants
.
SwitchingDelayEdge
;
this
.
switching_delay
=
NetworkConstants
.
SwitchingDelayEdge
;
numport
=
NetworkConstants
.
EdgeSwitchPort
;
numport
=
NetworkConstants
.
EdgeSwitchPort
;
uplinkswitches
=
new
ArrayList
<
Switch
>();
uplinkswitches
=
new
ArrayList
<
Switch
>();
// TODO Auto-generated constructor stub
}
}
/**
/**
* Send Packet to switch connected through a uplink port
* Send Packet to switch connected through a uplink port
...
@@ -58,7 +57,6 @@ public class EdgeSwitch extends Switch{
...
@@ -58,7 +57,6 @@ public class EdgeSwitch extends Switch{
*/
*/
@Override
@Override
protected
void
processpacket_up
(
SimEvent
ev
)
{
protected
void
processpacket_up
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
//packet coming from down level router/host.
//packet coming from down level router/host.
//has to send up
//has to send up
//check which switch to forward to
//check which switch to forward to
...
@@ -114,7 +112,6 @@ public class EdgeSwitch extends Switch{
...
@@ -114,7 +112,6 @@ public class EdgeSwitch extends Switch{
@Override
@Override
protected
void
processpacketforward
(
SimEvent
ev
)
{
protected
void
processpacketforward
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
//search for the host and packets..send to them
//search for the host and packets..send to them
...
@@ -143,8 +140,6 @@ public class EdgeSwitch extends Switch{
...
@@ -143,8 +140,6 @@ public class EdgeSwitch extends Switch{
{
{
for
(
Entry
<
Integer
,
List
<
NetworkPacket
>>
es:
packetTohost
.
entrySet
())
for
(
Entry
<
Integer
,
List
<
NetworkPacket
>>
es:
packetTohost
.
entrySet
())
{
{
int
tosend
=
es
.
getKey
();
NetworkHost
hs
=
this
.
hostlist
.
get
(
tosend
);
List
<
NetworkPacket
>
hspktlist
=
es
.
getValue
();
List
<
NetworkPacket
>
hspktlist
=
es
.
getValue
();
if
(!
hspktlist
.
isEmpty
()){
if
(!
hspktlist
.
isEmpty
()){
double
avband
=
this
.
downlinkbandwidth
/
hspktlist
.
size
();
double
avband
=
this
.
downlinkbandwidth
/
hspktlist
.
size
();
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/NetDatacenterBroker.java
View file @
4f25a01a
...
@@ -13,14 +13,8 @@ import java.util.HashMap;
...
@@ -13,14 +13,8 @@ import java.util.HashMap;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Random
;
import
java.util.SortedMap
;
import
java.util.TreeMap
;
import
java.util.UUID
;
import
org.cloudbus.cloudsim.Cloudlet
;
import
org.cloudbus.cloudsim.Cloudlet
;
import
org.cloudbus.cloudsim.CloudletSchedulerSpaceShared
;
import
org.cloudbus.cloudsim.DatacenterCharacteristics
;
import
org.cloudbus.cloudsim.DatacenterCharacteristics
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.Vm
;
...
@@ -29,7 +23,6 @@ import org.cloudbus.cloudsim.core.CloudSimTags;
...
@@ -29,7 +23,6 @@ import org.cloudbus.cloudsim.core.CloudSimTags;
import
org.cloudbus.cloudsim.core.SimEntity
;
import
org.cloudbus.cloudsim.core.SimEntity
;
import
org.cloudbus.cloudsim.core.SimEvent
;
import
org.cloudbus.cloudsim.core.SimEvent
;
import
org.cloudbus.cloudsim.distributions.UniformDistr
;
import
org.cloudbus.cloudsim.distributions.UniformDistr
;
import
org.cloudbus.cloudsim.lists.CloudletList
;
import
org.cloudbus.cloudsim.lists.VmList
;
import
org.cloudbus.cloudsim.lists.VmList
;
/**
/**
...
@@ -56,7 +49,7 @@ public class NetDatacenterBroker extends SimEntity {
...
@@ -56,7 +49,7 @@ public class NetDatacenterBroker extends SimEntity {
private
List
<?
extends
AppCloudlet
>
appCloudletList
;
private
List
<?
extends
AppCloudlet
>
appCloudletList
;
/** The Appcloudlet submitted list. */
/** The Appcloudlet submitted list. */
private
Map
<
Integer
,
Integer
>
appCloudletRecieved
;
private
final
Map
<
Integer
,
Integer
>
appCloudletRecieved
;
private
List
<?
extends
Cloudlet
>
cloudletSubmittedList
;
private
List
<?
extends
Cloudlet
>
cloudletSubmittedList
;
...
@@ -170,8 +163,8 @@ public class NetDatacenterBroker extends SimEntity {
...
@@ -170,8 +163,8 @@ public class NetDatacenterBroker extends SimEntity {
// public void bindCloudletToVm(int cloudletId, int vmId){
// public void bindCloudletToVm(int cloudletId, int vmId){
// CloudletList.getById(getCloudletList(), cloudletId).setVmId(vmId);
// CloudletList.getById(getCloudletList(), cloudletId).setVmId(vmId);
// }
// }
public
void
setLinkDC
(
NetworkDatacenter
linkDC
)
{
public
void
setLinkDC
(
NetworkDatacenter
a
linkDC
)
{
this
.
linkDC
=
linkDC
;
linkDC
=
a
linkDC
;
}
}
/**
/**
...
@@ -206,8 +199,9 @@ public class NetDatacenterBroker extends SimEntity {
...
@@ -206,8 +199,9 @@ public class NetDatacenterBroker extends SimEntity {
shutdownEntity
();
shutdownEntity
();
break
;
break
;
case
CloudSimTags
.
NextCycle
:
case
CloudSimTags
.
NextCycle
:
if
(
NetworkConstants
.
BASE
)
if
(
NetworkConstants
.
BASE
)
{
this
.
createVmsInDatacenterBase
(
this
.
linkDC
.
getId
());
this
.
createVmsInDatacenterBase
(
linkDC
.
getId
());
}
break
;
break
;
// other unknown tags are processed by this method
// other unknown tags are processed by this method
...
@@ -341,8 +335,6 @@ public class NetDatacenterBroker extends SimEntity {
...
@@ -341,8 +335,6 @@ public class NetDatacenterBroker extends SimEntity {
// send as much vms as possible for this datacenter before trying the
// send as much vms as possible for this datacenter before trying the
// next one
// next one
int
requestedVms
=
0
;
int
requestedVms
=
0
;
String
datacenterName
=
CloudSim
.
getEntityName
(
datacenterId
);
int
j
=
0
;
// All host will have two VMs (assumption) VM is the minimum unit
// All host will have two VMs (assumption) VM is the minimum unit
...
@@ -360,16 +352,14 @@ public class NetDatacenterBroker extends SimEntity {
...
@@ -360,16 +352,14 @@ public class NetDatacenterBroker extends SimEntity {
NetworkConstants
.
currentAppId
++;
NetworkConstants
.
currentAppId
++;
}
}
int
seed
=
5
;
int
k
=
0
;
int
k
=
0
;
int
totalvm
=
this
.
vmsCreatedList
.
size
();
int
currentvmid
=
0
;
int
currentvmid
=
0
;
//schedule the application on VMs
//schedule the application on VMs
for
(
AppCloudlet
app
:
this
.
getAppCloudletList
())
{
for
(
AppCloudlet
app
:
this
.
getAppCloudletList
())
{
List
<
Integer
>
vmids
=
new
ArrayList
<
Integer
>();
List
<
Integer
>
vmids
=
new
ArrayList
<
Integer
>();
int
numVms
=
this
.
linkDC
.
getVmList
().
size
();
int
numVms
=
linkDC
.
getVmList
().
size
();
UniformDistr
ufrnd
=
new
UniformDistr
(
0
,
numVms
,
5
);
UniformDistr
ufrnd
=
new
UniformDistr
(
0
,
numVms
,
5
);
for
(
int
i
=
0
;
i
<
app
.
numbervm
;
i
++)
{
for
(
int
i
=
0
;
i
<
app
.
numbervm
;
i
++)
{
...
@@ -416,8 +406,7 @@ public class NetDatacenterBroker extends SimEntity {
...
@@ -416,8 +406,7 @@ public class NetDatacenterBroker extends SimEntity {
}
}
private
void
CreateVMs
(
int
datacenterId
)
{
private
void
CreateVMs
(
int
datacenterId
)
{
// TODO Auto-generated method stub
int
numVM
=
linkDC
.
getHostList
().
size
()
*
NetworkConstants
.
maxhostVM
;
// two
int
numVM
=
this
.
linkDC
.
getHostList
().
size
()
*
NetworkConstants
.
maxhostVM
;
// two
// VMs
// VMs
// per
// per
// host
// host
...
@@ -436,7 +425,7 @@ public class NetDatacenterBroker extends SimEntity {
...
@@ -436,7 +425,7 @@ public class NetDatacenterBroker extends SimEntity {
// create VM
// create VM
NetworkVm
vm
=
new
NetworkVm
(
vmid
,
this
.
getId
(),
mips
,
pesNumber
,
NetworkVm
vm
=
new
NetworkVm
(
vmid
,
this
.
getId
(),
mips
,
pesNumber
,
ram
,
bw
,
size
,
vmm
,
new
NetworkCloudletSpaceSharedScheduler
());
ram
,
bw
,
size
,
vmm
,
new
NetworkCloudletSpaceSharedScheduler
());
this
.
linkDC
.
processVmCreateNetwork
(
vm
);
linkDC
.
processVmCreateNetwork
(
vm
);
// add the VM to the vmList
// add the VM to the vmList
getVmList
().
add
(
vm
);
getVmList
().
add
(
vm
);
requestedVms
++;
requestedVms
++;
...
@@ -545,6 +534,7 @@ public class NetDatacenterBroker extends SimEntity {
...
@@ -545,6 +534,7 @@ public class NetDatacenterBroker extends SimEntity {
this
.
cloudletList
=
cloudletList
;
this
.
cloudletList
=
cloudletList
;
}
}
@SuppressWarnings
(
"unchecked"
)
public
<
T
extends
AppCloudlet
>
List
<
T
>
getAppCloudletList
()
{
public
<
T
extends
AppCloudlet
>
List
<
T
>
getAppCloudletList
()
{
return
(
List
<
T
>)
appCloudletList
;
return
(
List
<
T
>)
appCloudletList
;
}
}
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/NetworkCloudlet.java
View file @
4f25a01a
...
@@ -5,10 +5,11 @@ import java.util.Map;
...
@@ -5,10 +5,11 @@ import java.util.Map;
import
org.cloudbus.cloudsim.Cloudlet
;
import
org.cloudbus.cloudsim.Cloudlet
;
import
org.cloudbus.cloudsim.UtilizationModel
;
import
org.cloudbus.cloudsim.UtilizationModel
;
/**
/**
* NetworkCloudlet class extends Cloudlet to support simulation of complex
applications.
* NetworkCloudlet class extends Cloudlet to support simulation of complex
*
Each such network Cloudlet represents a task of the application. Each task consists of several
*
applications. Each such network Cloudlet represents a task of the
*
stages.
*
application. Each task consists of several stages.
*
*
* Please refer to following publication for more details:
* Please refer to following publication for more details:
*
*
...
@@ -21,49 +22,56 @@ import org.cloudbus.cloudsim.UtilizationModel;
...
@@ -21,49 +22,56 @@ import org.cloudbus.cloudsim.UtilizationModel;
* @author Saurabh Kumar Garg
* @author Saurabh Kumar Garg
* @since CloudSim Toolkit 1.0
* @since CloudSim Toolkit 1.0
*/
*/
public
class
NetworkCloudlet
extends
Cloudlet
implements
Comparable
{
public
class
NetworkCloudlet
extends
Cloudlet
implements
Comparable
<
Object
>
{
long
memory
;
long
memory
;
public
NetworkCloudlet
(
int
cloudletId
,
long
cloudletLength
,
int
pesNumber
,
public
NetworkCloudlet
(
long
cloudletFileSize
,
long
cloudletOutputSize
,
long
memory
,
int
cloudletId
,
long
cloudletLength
,
int
pesNumber
,
long
cloudletFileSize
,
long
cloudletOutputSize
,
long
memory
,
UtilizationModel
utilizationModelCpu
,
UtilizationModel
utilizationModelCpu
,
UtilizationModel
utilizationModelRam
,
UtilizationModel
utilizationModelRam
,
UtilizationModel
utilizationModelBw
)
{
UtilizationModel
utilizationModelBw
)
{
super
(
cloudletId
,
cloudletLength
,
pesNumber
,
cloudletFileSize
,
super
(
cloudletOutputSize
,
utilizationModelCpu
,
utilizationModelRam
,
cloudletId
,
cloudletLength
,
pesNumber
,
cloudletFileSize
,
cloudletOutputSize
,
utilizationModelCpu
,
utilizationModelRam
,
utilizationModelBw
);
utilizationModelBw
);
// TODO Auto-generated constructor stub
currStagenum
=
-
1
;
currStagenum
=
-
1
;
this
.
memory
=
memory
;
this
.
memory
=
memory
;
stages
=
new
ArrayList
<
TaskStage
>();
stages
=
new
ArrayList
<
TaskStage
>();
}
}
public
double
submittime
;
//time when cloudlet will be submitted
public
double
submittime
;
//
time when cloudlet will be submitted
public
double
finishtime
;
//time when cloudlet finish execution
public
double
finishtime
;
//
time when cloudlet finish execution
public
double
exetime
;
//execution time for cloudlet
public
double
exetime
;
//
execution time for cloudlet
public
double
numStage
;
//number of stages in cloudlet
public
double
numStage
;
//
number of stages in cloudlet
public
int
currStagenum
;
//current stage of cloudlet execution
public
int
currStagenum
;
//
current stage of cloudlet execution
public
double
timetostartStage
;
public
double
timetostartStage
;
public
double
timespentInStage
;
//how much time spent in particular stage
public
double
timespentInStage
;
//
how much time spent in particular stage
public
Map
<
Double
,
HostPacket
>
timeCommunicate
;
public
Map
<
Double
,
HostPacket
>
timeCommunicate
;
public
ArrayList
<
TaskStage
>
stages
;
//all stages which cloudlet execution consists of.
public
ArrayList
<
TaskStage
>
stages
;
// all stages which cloudlet execution
// consists of.
public
double
starttime
;
public
double
starttime
;
@Override
@Override
public
int
compareTo
(
Object
arg0
)
{
public
int
compareTo
(
Object
arg0
)
{
// TODO Auto-generated method stub
NetworkCloudlet
s1
=
(
NetworkCloudlet
)
arg0
;
int
alpha
=
0
;
return
0
;
return
0
;
}
}
public
double
getSubmittime
()
{
public
double
getSubmittime
()
{
// TODO Auto-generated method stub
return
submittime
;
return
submittime
;
}
;
}
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/NetworkCloudletSpaceSharedScheduler.java
View file @
4f25a01a
...
@@ -15,17 +15,19 @@ import org.cloudbus.cloudsim.core.CloudSimTags;
...
@@ -15,17 +15,19 @@ import org.cloudbus.cloudsim.core.CloudSimTags;
public
class
NetworkCloudletSpaceSharedScheduler
extends
CloudletScheduler
{
public
class
NetworkCloudletSpaceSharedScheduler
extends
CloudletScheduler
{
/*
/*
* Title: CloudSim Toolkit Description: CloudSim (Cloud Simulation) Toolkit for Modeling and
* Title: CloudSim Toolkit Description: CloudSim (Cloud Simulation) Toolkit
* Simulation of Clouds Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* for Modeling and Simulation of Clouds Licence: GPL -
* http://www.gnu.org/copyleft/gpl.html
*
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
*/
/**
/**
* CloudletSchedulerSpaceShared implements a policy of scheduling performed by a virtual
* CloudletSchedulerSpaceShared implements a policy of scheduling performed
* machine. It consider that there will be only one cloudlet per VM. Other cloudlets will be in
* by a virtual machine. It consider that there will be only one cloudlet
* a waiting list. We consider that file transfer from cloudlets waiting happens before cloudlet
* per VM. Other cloudlets will be in a waiting list. We consider that file
* execution. I.e., even though cloudlets must wait for CPU, data transfer happens as soon as
* transfer from cloudlets waiting happens before cloudlet execution. I.e.,
* even though cloudlets must wait for CPU, data transfer happens as soon as
* cloudlets are submitted.
* cloudlets are submitted.
*
*
* @author Saurabh Kumar Garg
* @author Saurabh Kumar Garg
...
@@ -58,8 +60,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -58,8 +60,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
public
Map
<
Integer
,
List
<
HostPacket
>>
pktrecv
;
public
Map
<
Integer
,
List
<
HostPacket
>>
pktrecv
;
/**
/**
* Creates a new CloudletSchedulerSpaceShared object. This method must be
invoked before
* Creates a new CloudletSchedulerSpaceShared object. This method must be
* starting the actual simulation.
*
invoked before
starting the actual simulation.
*
*
* @pre $none
* @pre $none
* @post $none
* @post $none
...
@@ -77,13 +79,17 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -77,13 +79,17 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
}
}
/**
/**
* Updates the processing of cloudlets running under management of this scheduler.
* Updates the processing of cloudlets running under management of this
* scheduler.
*
*
* @param currentTime current simulation time
* @param currentTime
* @param mipsShare array with MIPS share of each processor available to the scheduler
* current simulation time
* @param mipsShare
* array with MIPS share of each processor available to the
* scheduler
*
*
* @return time predicted completion time of the earliest finishing
cloudlet, or 0 if there is
* @return time predicted completion time of the earliest finishing
* no next events
*
cloudlet, or 0 if there is
no next events
*
*
* @pre currentTime >= 0
* @pre currentTime >= 0
* @post $none
* @post $none
...
@@ -91,7 +97,6 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -91,7 +97,6 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
@Override
@Override
public
double
updateVmProcessing
(
double
currentTime
,
List
<
Double
>
mipsShare
)
{
public
double
updateVmProcessing
(
double
currentTime
,
List
<
Double
>
mipsShare
)
{
setCurrentMipsShare
(
mipsShare
);
setCurrentMipsShare
(
mipsShare
);
double
timeSpam
=
currentTime
-
getPreviousTime
();
// time since last
// update
// update
double
capacity
=
0.0
;
double
capacity
=
0.0
;
int
cpus
=
0
;
int
cpus
=
0
;
...
@@ -139,10 +144,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -139,10 +144,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
List
<
HostPacket
>
pktlist
=
pktrecv
.
get
(
st
.
peer
);
List
<
HostPacket
>
pktlist
=
pktrecv
.
get
(
st
.
peer
);
List
<
HostPacket
>
pkttoremove
=
new
ArrayList
<
HostPacket
>();
List
<
HostPacket
>
pkttoremove
=
new
ArrayList
<
HostPacket
>();
if
(
pktlist
!=
null
)
{
if
(
pktlist
!=
null
)
{
Iterator
it
=
pktlist
.
iterator
();
Iterator
<
HostPacket
>
it
=
pktlist
.
iterator
();
HostPacket
pkt
=
null
;
HostPacket
pkt
=
null
;
if
(
it
.
hasNext
())
{
if
(
it
.
hasNext
())
{
pkt
=
(
HostPacket
)
it
.
next
();
pkt
=
it
.
next
();
if
(
pkt
.
reciever
==
cl
.
getVmId
())
// Asumption packet
if
(
pkt
.
reciever
==
cl
.
getVmId
())
// Asumption packet
// will not
// will not
// arrive in the
// arrive in the
...
@@ -180,7 +185,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -180,7 +185,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
}
}
if
(
getCloudletExecList
().
size
()
==
0
&&
getCloudletWaitingList
().
size
()
==
0
)
{
// no more
if
(
getCloudletExecList
().
size
()
==
0
&&
getCloudletWaitingList
().
size
()
==
0
)
{
// no
// more
// cloudlets
// cloudlets
// in
// in
// this
// this
...
@@ -247,7 +253,6 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -247,7 +253,6 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
}
}
private
void
changetonextstage
(
NetworkCloudlet
cl
,
TaskStage
st
)
{
private
void
changetonextstage
(
NetworkCloudlet
cl
,
TaskStage
st
)
{
// TODO Auto-generated method stub
cl
.
timespentInStage
=
0
;
cl
.
timespentInStage
=
0
;
cl
.
timetostartStage
=
CloudSim
.
clock
();
cl
.
timetostartStage
=
CloudSim
.
clock
();
int
currstage
=
cl
.
currStagenum
;
int
currstage
=
cl
.
currStagenum
;
...
@@ -255,7 +260,6 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -255,7 +260,6 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
cl
.
currStagenum
=
NetworkConstants
.
FINISH
;
cl
.
currStagenum
=
NetworkConstants
.
FINISH
;
}
else
{
}
else
{
cl
.
currStagenum
=
currstage
+
1
;
cl
.
currStagenum
=
currstage
+
1
;
TaskStage
st1
=
cl
.
stages
.
get
(
cl
.
currStagenum
);
int
i
=
0
;
int
i
=
0
;
for
(
i
=
cl
.
currStagenum
;
i
<
cl
.
stages
.
size
();
i
++)
{
for
(
i
=
cl
.
currStagenum
;
i
<
cl
.
stages
.
size
();
i
++)
{
if
(
cl
.
stages
.
get
(
i
).
type
==
NetworkConstants
.
WAIT_SEND
)
{
if
(
cl
.
stages
.
get
(
i
).
type
==
NetworkConstants
.
WAIT_SEND
)
{
...
@@ -302,7 +306,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -302,7 +306,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Cancels execution of a cloudlet.
* Cancels execution of a cloudlet.
*
*
* @param cloudletId ID of the cloudlet being cancealed
* @param cloudletId
* ID of the cloudlet being cancealed
*
*
* @return the canceled cloudlet, $null if not found
* @return the canceled cloudlet, $null if not found
*
*
...
@@ -356,7 +361,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -356,7 +361,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Pauses execution of a cloudlet.
* Pauses execution of a cloudlet.
*
*
* @param cloudletId ID of the cloudlet being paused
* @param cloudletId
* ID of the cloudlet being paused
*
*
* @return $true if cloudlet paused, $false otherwise
* @return $true if cloudlet paused, $false otherwise
*
*
...
@@ -420,7 +426,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -420,7 +426,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Processes a finished cloudlet.
* Processes a finished cloudlet.
*
*
* @param rcl finished cloudlet
* @param rcl
* finished cloudlet
*
*
* @pre rgl != $null
* @pre rgl != $null
* @post $none
* @post $none
...
@@ -436,7 +443,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -436,7 +443,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Resumes execution of a paused cloudlet.
* Resumes execution of a paused cloudlet.
*
*
* @param cloudletId ID of the cloudlet being resumed
* @param cloudletId
* ID of the cloudlet being resumed
*
*
* @return $true if the cloudlet was resumed, $false otherwise
* @return $true if the cloudlet was resumed, $false otherwise
*
*
...
@@ -460,7 +468,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -460,7 +468,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
if
(
found
)
{
if
(
found
)
{
ResCloudlet
rcl
=
getCloudletPausedList
().
remove
(
position
);
ResCloudlet
rcl
=
getCloudletPausedList
().
remove
(
position
);
if
((
currentCpus
-
usedPes
)
>=
rcl
.
getNumberOfPes
())
{
// it can go to
if
((
currentCpus
-
usedPes
)
>=
rcl
.
getNumberOfPes
())
{
// it can go
// to
// the exec list
// the exec list
rcl
.
setCloudletStatus
(
Cloudlet
.
INEXEC
);
rcl
.
setCloudletStatus
(
Cloudlet
.
INEXEC
);
for
(
int
i
=
0
;
i
<
rcl
.
getNumberOfPes
();
i
++)
{
for
(
int
i
=
0
;
i
<
rcl
.
getNumberOfPes
();
i
++)
{
...
@@ -513,17 +522,22 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -513,17 +522,22 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Receives an cloudlet to be executed in the VM managed by this scheduler.
* Receives an cloudlet to be executed in the VM managed by this scheduler.
*
*
* @param cloudlet the submited cloudlet
* @param cloudlet
* @param fileTransferTime time required to move the required files from the SAN to the VM
* the submited cloudlet
* @param fileTransferTime
* time required to move the required files from the SAN to the
* VM
*
*
* @return expected finish time of this cloudlet, or 0 if it is in the waiting queue
* @return expected finish time of this cloudlet, or 0 if it is in the
* waiting queue
*
*
* @pre gl != null
* @pre gl != null
* @post $none
* @post $none
*/
*/
@Override
@Override
public
double
cloudletSubmit
(
Cloudlet
cloudlet
,
double
fileTransferTime
)
{
public
double
cloudletSubmit
(
Cloudlet
cloudlet
,
double
fileTransferTime
)
{
if
((
currentCpus
-
usedPes
)
>=
cloudlet
.
getNumberOfPes
())
{
// it can go to
if
((
currentCpus
-
usedPes
)
>=
cloudlet
.
getNumberOfPes
())
{
// it can go
// to
// the exec
// the exec
// list
// list
ResCloudlet
rcl
=
new
ResCloudlet
(
cloudlet
);
ResCloudlet
rcl
=
new
ResCloudlet
(
cloudlet
);
...
@@ -577,7 +591,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -577,7 +591,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Gets the status of a cloudlet.
* Gets the status of a cloudlet.
*
*
* @param cloudletId ID of the cloudlet
* @param cloudletId
* ID of the cloudlet
*
*
* @return status of the cloudlet, -1 if cloudlet not found
* @return status of the cloudlet, -1 if cloudlet not found
*
*
...
@@ -610,7 +625,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -610,7 +625,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Get utilization created by all cloudlets.
* Get utilization created by all cloudlets.
*
*
* @param time the time
* @param time
* the time
*
*
* @return total utilization
* @return total utilization
*/
*/
...
@@ -624,9 +640,11 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -624,9 +640,11 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
}
}
/**
/**
* Informs about completion of some cloudlet in the VM managed by this scheduler.
* Informs about completion of some cloudlet in the VM managed by this
* scheduler.
*
*
* @return $true if there is at least one finished cloudlet; $false otherwise
* @return $true if there is at least one finished cloudlet; $false
* otherwise
*
*
* @pre $none
* @pre $none
* @post $none
* @post $none
...
@@ -637,7 +655,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -637,7 +655,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
}
}
/**
/**
* Returns the next cloudlet in the finished list, $null if this list is empty.
* Returns the next cloudlet in the finished list, $null if this list is
* empty.
*
*
* @return a finished cloudlet
* @return a finished cloudlet
*
*
...
@@ -685,7 +704,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -685,7 +704,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Gets the cloudlet waiting list.
* Gets the cloudlet waiting list.
*
*
* @param <T> the generic type
* @param <T>
* the generic type
* @return the cloudlet waiting list
* @return the cloudlet waiting list
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
@@ -696,8 +716,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -696,8 +716,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Cloudlet waiting list.
* Cloudlet waiting list.
*
*
* @param <T> the generic type
* @param <T>
* @param cloudletWaitingList the cloudlet waiting list
* the generic type
* @param cloudletWaitingList
* the cloudlet waiting list
*/
*/
protected
<
T
extends
ResCloudlet
>
void
cloudletWaitingList
(
List
<
T
>
cloudletWaitingList
)
{
protected
<
T
extends
ResCloudlet
>
void
cloudletWaitingList
(
List
<
T
>
cloudletWaitingList
)
{
this
.
cloudletWaitingList
=
cloudletWaitingList
;
this
.
cloudletWaitingList
=
cloudletWaitingList
;
...
@@ -706,7 +728,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -706,7 +728,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Gets the cloudlet exec list.
* Gets the cloudlet exec list.
*
*
* @param <T> the generic type
* @param <T>
* the generic type
* @return the cloudlet exec list
* @return the cloudlet exec list
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
@@ -717,8 +740,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -717,8 +740,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Sets the cloudlet exec list.
* Sets the cloudlet exec list.
*
*
* @param <T> the generic type
* @param <T>
* @param cloudletExecList the new cloudlet exec list
* the generic type
* @param cloudletExecList
* the new cloudlet exec list
*/
*/
protected
<
T
extends
ResCloudlet
>
void
setCloudletExecList
(
List
<
T
>
cloudletExecList
)
{
protected
<
T
extends
ResCloudlet
>
void
setCloudletExecList
(
List
<
T
>
cloudletExecList
)
{
this
.
cloudletExecList
=
cloudletExecList
;
this
.
cloudletExecList
=
cloudletExecList
;
...
@@ -727,7 +752,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -727,7 +752,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Gets the cloudlet paused list.
* Gets the cloudlet paused list.
*
*
* @param <T> the generic type
* @param <T>
* the generic type
* @return the cloudlet paused list
* @return the cloudlet paused list
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
@@ -738,8 +764,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -738,8 +764,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Sets the cloudlet paused list.
* Sets the cloudlet paused list.
*
*
* @param <T> the generic type
* @param <T>
* @param cloudletPausedList the new cloudlet paused list
* the generic type
* @param cloudletPausedList
* the new cloudlet paused list
*/
*/
protected
<
T
extends
ResCloudlet
>
void
setCloudletPausedList
(
List
<
T
>
cloudletPausedList
)
{
protected
<
T
extends
ResCloudlet
>
void
setCloudletPausedList
(
List
<
T
>
cloudletPausedList
)
{
this
.
cloudletPausedList
=
cloudletPausedList
;
this
.
cloudletPausedList
=
cloudletPausedList
;
...
@@ -748,7 +776,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -748,7 +776,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Gets the cloudlet finished list.
* Gets the cloudlet finished list.
*
*
* @param <T> the generic type
* @param <T>
* the generic type
* @return the cloudlet finished list
* @return the cloudlet finished list
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
@@ -759,8 +788,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -759,8 +788,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
/**
* Sets the cloudlet finished list.
* Sets the cloudlet finished list.
*
*
* @param <T> the generic type
* @param <T>
* @param cloudletFinishedList the new cloudlet finished list
* the generic type
* @param cloudletFinishedList
* the new cloudlet finished list
*/
*/
protected
<
T
extends
ResCloudlet
>
void
setCloudletFinishedList
(
List
<
T
>
cloudletFinishedList
)
{
protected
<
T
extends
ResCloudlet
>
void
setCloudletFinishedList
(
List
<
T
>
cloudletFinishedList
)
{
this
.
cloudletFinishedList
=
cloudletFinishedList
;
this
.
cloudletFinishedList
=
cloudletFinishedList
;
...
@@ -785,7 +816,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -785,7 +816,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/*
/*
* (non-Javadoc)
* (non-Javadoc)
*
*
* @see org.cloudbus.cloudsim.CloudletScheduler# getTotalCurrentAvailableMipsForCloudlet
* @see org.cloudbus.cloudsim.CloudletScheduler#
* getTotalCurrentAvailableMipsForCloudlet
* (org.cloudbus.cloudsim.ResCloudlet, java.util.List)
* (org.cloudbus.cloudsim.ResCloudlet, java.util.List)
*/
*/
@Override
@Override
...
@@ -806,36 +838,34 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
...
@@ -806,36 +838,34 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/*
/*
* (non-Javadoc)
* (non-Javadoc)
*
*
* @see org.cloudbus.cloudsim.CloudletScheduler# getTotalCurrentAllocatedMipsForCloudlet
* @see org.cloudbus.cloudsim.CloudletScheduler#
* getTotalCurrentAllocatedMipsForCloudlet
* (org.cloudbus.cloudsim.ResCloudlet, double)
* (org.cloudbus.cloudsim.ResCloudlet, double)
*/
*/
@Override
@Override
public
double
getTotalCurrentAllocatedMipsForCloudlet
(
ResCloudlet
rcl
,
double
time
)
{
public
double
getTotalCurrentAllocatedMipsForCloudlet
(
ResCloudlet
rcl
,
double
time
)
{
// TODO Auto-generated method stub
return
0.0
;
return
0.0
;
}
}
/*
/*
* (non-Javadoc)
* (non-Javadoc)
*
*
* @see org.cloudbus.cloudsim.CloudletScheduler# getTotalCurrentRequestedMipsForCloudlet
* @see org.cloudbus.cloudsim.CloudletScheduler#
* getTotalCurrentRequestedMipsForCloudlet
* (org.cloudbus.cloudsim.ResCloudlet, double)
* (org.cloudbus.cloudsim.ResCloudlet, double)
*/
*/
@Override
@Override
public
double
getTotalCurrentRequestedMipsForCloudlet
(
ResCloudlet
rcl
,
double
time
)
{
public
double
getTotalCurrentRequestedMipsForCloudlet
(
ResCloudlet
rcl
,
double
time
)
{
// TODO Auto-generated method stub
return
0.0
;
return
0.0
;
}
}
@Override
@Override
public
double
getCurrentRequestedUtilizationOfBw
()
{
public
double
getCurrentRequestedUtilizationOfBw
()
{
// TODO Auto-generated method stub
return
0
;
return
0
;
}
}
@Override
@Override
public
double
getCurrentRequestedUtilizationOfRam
()
{
public
double
getCurrentRequestedUtilizationOfRam
()
{
// TODO Auto-generated method stub
return
0
;
return
0
;
}
}
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/NetworkConstants.java
View file @
4f25a01a
package
org
.
cloudbus
.
cloudsim
.
network
.
datacenter
;
package
org
.
cloudbus
.
cloudsim
.
network
.
datacenter
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
NetworkConstants
{
public
class
NetworkConstants
{
public
static
int
maxhostVM
=
2
;
public
static
int
HOST_PEs
=
8
;
public
static
int
maxhostVM
=
2
;
public
static
double
maxMemperVM
=
1024
*
1024
;
// kb
public
static
int
HOST_PEs
=
8
;
public
static
double
maxMemperVM
=
1024
*
1024
;
//kb
public
static
int
currentCloudletId
=
0
;
public
static
int
currentAppId
=
0
;
// stage type
public
static
final
int
EXECUTION
=
0
;
public
static
final
int
WAIT_SEND
=
1
;
public
static
final
int
WAIT_RECV
=
2
;
public
static
final
int
FINISH
=
-
2
;
// number of switches at each level
public
static
final
int
ROOT_LEVEL
=
0
;
public
static
final
int
Agg_LEVEL
=
1
;
public
static
final
int
EDGE_LEVEL
=
2
;
public
static
int
currentCloudletId
=
0
;
public
static
final
int
PES_NUMBER
=
4
;
public
static
int
currentAppId
=
0
;
public
static
final
int
FILE_SIZE
=
300
;
public
static
final
int
OUTPUT_SIZE
=
300
;
public
static
final
int
COMMUNICATION_LENGTH
=
1
;
//stage type
public
static
boolean
BASE
=
true
;
public
static
final
int
EXECUTION
=
0
;
public
static
final
int
WAIT_SEND
=
1
;
public
static
final
int
WAIT_RECV
=
2
;
public
static
final
int
FINISH
=-
2
;
public
static
long
BandWidthEdgeAgg
=
100
*
1024
*
1024
;
// 100 Megabits
public
static
long
BandWidthEdgeHost
=
100
*
1024
*
1024
;
//
public
static
long
BandWidthAggRoot
=
20
*
1024
*
1024
*
2
;
// 40gb
public
static
double
SwitchingDelayRoot
=
.
002
85
;
public
static
double
SwitchingDelayAgg
=
.
00245
;
// .00245
public
static
double
SwitchingDelayEdge
=
.
00157
;
// ms
//number of switches at each level
public
static
double
EdgeSwitchPort
=
4
;
// number of host
public
static
final
int
ROOT_LEVEL
=
0
;
public
static
final
int
Agg_LEVEL
=
1
;
public
static
final
int
EDGE_LEVEL
=
2
;
public
static
final
int
PES_NUMBER
=
4
;
public
static
double
AggSwitchPort
=
1
;
// number of Edge
public
static
final
int
FILE_SIZE
=
300
;
public
static
final
int
OUTPUT_SIZE
=
300
;
public
static
final
int
COMMUNICATION_LENGTH
=
1
;
public
static
double
RootSwitchPort
=
1
;
// number of Agg
public
static
boolean
BASE
=
true
;
public
static
double
seed
=
199
;
public
static
boolean
logflag
=
false
;
public
static
long
BandWidthEdgeAgg
=
100
*
1024
*
1024
;
//100 Megabits
public
static
int
iteration
=
10
;
public
static
long
BandWidthEdgeHost
=
100
*
1024
*
1024
;
//
public
static
int
nexttime
=
1000
;
public
static
long
BandWidthAggRoot
=
20
*
1024
*
1024
*
2
;
//40gb
public
static
double
SwitchingDelayRoot
=.
002
85
;
public
static
int
totaldatatransfer
=
0
;
public
static
double
SwitchingDelayAgg
=.
00245
;
//.00245
public
static
double
SwitchingDelayEdge
=.
00157
;
//ms
public
static
double
EdgeSwitchPort
=
4
;
//number of host
public
static
double
AggSwitchPort
=
1
;
//number of Edge
public
static
double
RootSwitchPort
=
1
;
//number of Agg
public
static
double
seed
=
199
;
public
static
boolean
logflag
=
false
;
public
static
int
iteration
=
10
;
public
static
int
nexttime
=
1000
;
public
static
int
totaldatatransfer
=
0
;
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/NetworkDatacenter.java
View file @
4f25a01a
...
@@ -8,42 +8,33 @@ package org.cloudbus.cloudsim.network.datacenter;
...
@@ -8,42 +8,33 @@ package org.cloudbus.cloudsim.network.datacenter;
* Copyright (c) 2009-2010, The University of Melbourne, Australia
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
*/
import
java.text.DecimalFormat
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
org.cloudbus.cloudsim.Cloudlet
;
import
org.cloudbus.cloudsim.Cloudlet
;
import
org.cloudbus.cloudsim.CloudletScheduler
;
import
org.cloudbus.cloudsim.CloudletScheduler
;
import
org.cloudbus.cloudsim.DataCloudTags
;
import
org.cloudbus.cloudsim.Datacenter
;
import
org.cloudbus.cloudsim.Datacenter
;
import
org.cloudbus.cloudsim.DatacenterCharacteristics
;
import
org.cloudbus.cloudsim.DatacenterCharacteristics
;
import
org.cloudbus.cloudsim.File
;
import
org.cloudbus.cloudsim.Host
;
import
org.cloudbus.cloudsim.Host
;
import
org.cloudbus.cloudsim.InfoPacket
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Storage
;
import
org.cloudbus.cloudsim.Storage
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.VmAllocationPolicy
;
import
org.cloudbus.cloudsim.VmAllocationPolicy
;
import
org.cloudbus.cloudsim.core.CloudSim
;
import
org.cloudbus.cloudsim.core.CloudSim
;
import
org.cloudbus.cloudsim.core.CloudSimTags
;
import
org.cloudbus.cloudsim.core.CloudSimTags
;
import
org.cloudbus.cloudsim.core.SimEntity
;
import
org.cloudbus.cloudsim.core.SimEvent
;
import
org.cloudbus.cloudsim.core.SimEvent
;
/**
/**
* NetworkDatacenter class is a Datacenter whose hostList are virtualized and
* NetworkDatacenter class is a Datacenter whose hostList are virtualized and
* networked. It contains all the information about internal network. For example,
* networked. It contains all the information about internal network. For
* which VM is connected to Switch etc.
* example, which VM is connected to Switch etc. It deals with processing of VM
* It deals with processing of VM queries (i.e., handling of VMs)
* queries (i.e., handling of VMs) instead of processing Cloudlet-related
* instead of processing Cloudlet-related queries. So, even though an
* queries. So, even though an AllocPolicy will be instantiated (in the init()
* AllocPolicy will be instantiated (in the init() method of the superclass, it
* method of the superclass, it will not be used, as processing of cloudlets are
* will not be used, as processing of cloudlets are handled by the
* handled by the CloudletScheduler and processing of VirtualMachines are
* CloudletScheduler and processing of VirtualMachines are handled by the
* handled by the VmAllocationPolicy.
* VmAllocationPolicy.
*
*
* Please refer to following publication for more details:
* Please refer to following publication for more details:
*
*
...
@@ -57,38 +48,42 @@ import org.cloudbus.cloudsim.core.SimEvent;
...
@@ -57,38 +48,42 @@ import org.cloudbus.cloudsim.core.SimEvent;
*/
*/
public
class
NetworkDatacenter
extends
Datacenter
{
public
class
NetworkDatacenter
extends
Datacenter
{
/**
/**
* Allocates a new NetworkDatacenter object.
* Allocates a new NetworkDatacenter object.
*
*
* @param name the name to be associated with this entity (as
* @param name
* required by Sim_entity class from simjava package)
* the name to be associated with this entity (as required by
* @param characteristics an object of DatacenterCharacteristics
* Sim_entity class from simjava package)
* @param storageList a LinkedList of storage elements, for data simulation
* @param characteristics
* @param vmAllocationPolicy the vmAllocationPolicy
* an object of DatacenterCharacteristics
* @param storageList
* a LinkedList of storage elements, for data simulation
* @param vmAllocationPolicy
* the vmAllocationPolicy
*
*
* @throws Exception This happens when one of the following scenarios occur:
* @throws Exception
* This happens when one of the following scenarios occur:
* <ul>
* <ul>
*
<li>
creating this entity before initializing CloudSim package
*
<li>
creating this entity before initializing CloudSim package
*
<li>
this entity name is <tt>null</tt> or empty
*
<li>
this entity name is <tt>null</tt> or empty
*
<li>
this entity has <tt>zero</tt> number of PEs (Processing
*
<li>
this entity has <tt>zero</tt> number of PEs (Processing
* Elements). <br>
* Elements). <br>
*
No PEs mean the Cloudlets can't be processed.
*
No PEs mean the Cloudlets can't be processed. A CloudResource
*
A CloudResource must contain one or more Machines.
*
must contain one or more Machines. A Machine must contain one
*
A Machine must contain one
or more PEs.
*
or more PEs.
* </ul>
* </ul>
*
*
* @pre name != null
* @pre name != null
* @pre resource != null
* @pre resource != null
* @post $none
* @post $none
*/
*/
public
NetworkDatacenter
(
String
name
,
public
NetworkDatacenter
(
String
name
,
DatacenterCharacteristics
characteristics
,
DatacenterCharacteristics
characteristics
,
VmAllocationPolicy
vmAllocationPolicy
,
List
<
Storage
>
storageList
,
VmAllocationPolicy
vmAllocationPolicy
,
List
<
Storage
>
storageList
,
double
schedulingInterval
)
throws
Exception
{
double
schedulingInterval
)
throws
Exception
{
super
(
name
,
characteristics
,
vmAllocationPolicy
,
storageList
,
super
(
name
,
characteristics
,
vmAllocationPolicy
,
storageList
,
schedulingInterval
);
schedulingInterval
);
// TODO Auto-generated constructor stub
VmToSwitchid
=
new
HashMap
<
Integer
,
Integer
>();
VmToSwitchid
=
new
HashMap
<
Integer
,
Integer
>();
HostToSwitchid
=
new
HashMap
<
Integer
,
Integer
>();
HostToSwitchid
=
new
HashMap
<
Integer
,
Integer
>();
VmtoHostlist
=
new
HashMap
<
Integer
,
Integer
>();
VmtoHostlist
=
new
HashMap
<
Integer
,
Integer
>();
...
@@ -102,8 +97,8 @@ public class NetworkDatacenter extends Datacenter {
...
@@ -102,8 +97,8 @@ public class NetworkDatacenter extends Datacenter {
public
Map
<
Integer
,
Integer
>
VmtoHostlist
;
public
Map
<
Integer
,
Integer
>
VmtoHostlist
;
/**
/**
* Get list of all EdgeSwitches in the Datacenter network
* Get list of all EdgeSwitches in the Datacenter network
One can design
*
One can design
similar functions for other type of switches.
* similar functions for other type of switches.
*
*
*/
*/
public
Map
<
Integer
,
Switch
>
getEdgeSwitch
()
{
public
Map
<
Integer
,
Switch
>
getEdgeSwitch
()
{
...
@@ -116,10 +111,10 @@ public class NetworkDatacenter extends Datacenter {
...
@@ -116,10 +111,10 @@ public class NetworkDatacenter extends Datacenter {
return
edgeswitch
;
return
edgeswitch
;
}
}
/**
/**
* Create the VM within the NetworkDatacenter.
* Create the VM within the NetworkDatacenter. It can be directly accessed
* It can be directly accessed by Datacenter Broker
* by Datacenter Broker which manage allocation of Cloudlets.
* which manage allocation of Cloudlets.
*
*
*
*
*/
*/
...
@@ -128,11 +123,9 @@ public class NetworkDatacenter extends Datacenter {
...
@@ -128,11 +123,9 @@ public class NetworkDatacenter extends Datacenter {
boolean
result
=
getVmAllocationPolicy
().
allocateHostForVm
(
vm
);
boolean
result
=
getVmAllocationPolicy
().
allocateHostForVm
(
vm
);
if
(
result
)
{
if
(
result
)
{
this
.
VmToSwitchid
.
put
(
vm
.
getId
(),
this
.
VmToSwitchid
.
put
(
vm
.
getId
(),
((
NetworkHost
)
vm
.
getHost
()).
sw
.
getId
());
((
NetworkHost
)
vm
.
getHost
()).
sw
.
getId
());
this
.
VmtoHostlist
.
put
(
vm
.
getId
(),
vm
.
getHost
().
getId
());
this
.
VmtoHostlist
.
put
(
vm
.
getId
(),
vm
.
getHost
().
getId
());
System
.
out
.
println
(
vm
.
getId
()
+
" VM is created on "
System
.
out
.
println
(
vm
.
getId
()
+
" VM is created on "
+
vm
.
getHost
().
getId
());
+
vm
.
getHost
().
getId
());
double
amount
=
0.0
;
double
amount
=
0.0
;
if
(
getDebts
().
containsKey
(
vm
.
getUserId
()))
{
if
(
getDebts
().
containsKey
(
vm
.
getUserId
()))
{
amount
=
getDebts
().
get
(
vm
.
getUserId
());
amount
=
getDebts
().
get
(
vm
.
getUserId
());
...
@@ -144,22 +137,24 @@ public class NetworkDatacenter extends Datacenter {
...
@@ -144,22 +137,24 @@ public class NetworkDatacenter extends Datacenter {
getVmList
().
add
(
vm
);
getVmList
().
add
(
vm
);
vm
.
updateVmProcessing
(
CloudSim
.
clock
(),
getVmAllocationPolicy
()
vm
.
updateVmProcessing
(
CloudSim
.
clock
(),
getVmAllocationPolicy
()
.
getHost
(
vm
).
getVmScheduler
()
.
get
Host
(
vm
).
getVmScheduler
().
get
AllocatedMipsForVm
(
vm
));
.
getAllocatedMipsForVm
(
vm
));
}
}
return
result
;
return
result
;
}
}
/**
/**
* Processes a Cloudlet submission.
* Processes a Cloudlet submission.
*
*
* @param ev a SimEvent object
* @param ev
* @param ack an acknowledgement
* a SimEvent object
* @param ack
* an acknowledgement
*
*
* @pre ev != null
* @pre ev != null
* @post $none
* @post $none
*/
*/
@Override
protected
void
processCloudletSubmit
(
SimEvent
ev
,
boolean
ack
)
{
protected
void
processCloudletSubmit
(
SimEvent
ev
,
boolean
ack
)
{
updateCloudletProcessing
();
updateCloudletProcessing
();
...
@@ -170,8 +165,7 @@ public class NetworkDatacenter extends Datacenter {
...
@@ -170,8 +165,7 @@ public class NetworkDatacenter extends Datacenter {
// checks whether this Cloudlet has finished or not
// checks whether this Cloudlet has finished or not
if
(
cl
.
isFinished
())
{
if
(
cl
.
isFinished
())
{
String
name
=
CloudSim
.
getEntityName
(
cl
.
getUserId
());
String
name
=
CloudSim
.
getEntityName
(
cl
.
getUserId
());
Log
.
printLine
(
getName
()
+
": Warning - Cloudlet #"
Log
.
printLine
(
getName
()
+
": Warning - Cloudlet #"
+
cl
.
getCloudletId
()
+
" owned by "
+
name
+
cl
.
getCloudletId
()
+
" owned by "
+
name
+
" is already completed/finished."
);
+
" is already completed/finished."
);
Log
.
printLine
(
"Therefore, it is not being executed again"
);
Log
.
printLine
(
"Therefore, it is not being executed again"
);
Log
.
printLine
();
Log
.
printLine
();
...
@@ -198,21 +192,23 @@ public class NetworkDatacenter extends Datacenter {
...
@@ -198,21 +192,23 @@ public class NetworkDatacenter extends Datacenter {
}
}
// process this Cloudlet to this CloudResource
// process this Cloudlet to this CloudResource
cl
.
setResourceParameter
(
getId
(),
getCharacteristics
()
cl
.
setResourceParameter
(
getId
(),
getCharacteristics
()
.
getCostPerSecond
(),
getCharacteristics
()
.
getCostPer
Second
(),
getCharacteristics
().
getCostPer
Bw
());
.
getCostPerBw
());
int
userId
=
cl
.
getUserId
();
int
userId
=
cl
.
getUserId
();
int
vmId
=
cl
.
getVmId
();
int
vmId
=
cl
.
getVmId
();
double
fileTransferTime
=
predictFileTransferTime
(
cl
double
fileTransferTime
=
predictFileTransferTime
(
cl
.
getRequiredFiles
());
// time
.
getRequiredFiles
());
// time to transfer the files
// to
// transfer
// the
// files
Host
host
=
getVmAllocationPolicy
().
getHost
(
vmId
,
userId
);
Host
host
=
getVmAllocationPolicy
().
getHost
(
vmId
,
userId
);
Vm
vm
=
host
.
getVm
(
vmId
,
userId
);
Vm
vm
=
host
.
getVm
(
vmId
,
userId
);
CloudletScheduler
scheduler
=
vm
.
getCloudletScheduler
();
CloudletScheduler
scheduler
=
vm
.
getCloudletScheduler
();
// System.out.println("cloudlet recieved by VM"+vmId);
// System.out.println("cloudlet recieved by VM"+vmId);
double
estimatedFinishTime
=
scheduler
.
cloudletSubmit
(
cl
,
double
estimatedFinishTime
=
scheduler
.
cloudletSubmit
(
cl
,
fileTransferTime
);
fileTransferTime
);
// if (estimatedFinishTime > 0.0 && estimatedFinishTime <
// if (estimatedFinishTime > 0.0 && estimatedFinishTime <
// getSchedulingInterval()) { //if this cloudlet is in the exec
// getSchedulingInterval()) { //if this cloudlet is in the exec
...
@@ -226,8 +222,7 @@ public class NetworkDatacenter extends Datacenter {
...
@@ -226,8 +222,7 @@ public class NetworkDatacenter extends Datacenter {
estimatedFinishTime
+=
fileTransferTime
;
estimatedFinishTime
+=
fileTransferTime
;
// estimatedFinishTime += CloudSim.clock();
// estimatedFinishTime += CloudSim.clock();
// Log.printLine(CloudSim.clock()+": Next event scheduled to +"+estimatedFinishTime);
// Log.printLine(CloudSim.clock()+": Next event scheduled to +"+estimatedFinishTime);
send
(
getId
(),
estimatedFinishTime
,
send
(
getId
(),
estimatedFinishTime
,
CloudSimTags
.
VM_DATACENTER_EVENT
);
CloudSimTags
.
VM_DATACENTER_EVENT
);
// event to update the stages
// event to update the stages
send
(
getId
(),
0.0001
,
CloudSimTags
.
VM_DATACENTER_EVENT
);
send
(
getId
(),
0.0001
,
CloudSimTags
.
VM_DATACENTER_EVENT
);
...
@@ -244,12 +239,10 @@ public class NetworkDatacenter extends Datacenter {
...
@@ -244,12 +239,10 @@ public class NetworkDatacenter extends Datacenter {
sendNow
(
cl
.
getUserId
(),
tag
,
data
);
sendNow
(
cl
.
getUserId
(),
tag
,
data
);
}
}
}
catch
(
ClassCastException
c
)
{
}
catch
(
ClassCastException
c
)
{
Log
.
printLine
(
getName
()
+
".processCloudletSubmit(): "
Log
.
printLine
(
getName
()
+
".processCloudletSubmit(): "
+
"ClassCastException error."
);
+
"ClassCastException error."
);
c
.
printStackTrace
();
c
.
printStackTrace
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
printLine
(
getName
()
+
".processCloudletSubmit(): "
Log
.
printLine
(
getName
()
+
".processCloudletSubmit(): "
+
"Exception error."
);
+
"Exception error."
);
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/NetworkHost.java
View file @
4f25a01a
...
@@ -9,13 +9,10 @@
...
@@ -9,13 +9,10 @@
package
org
.
cloudbus
.
cloudsim
.
network
.
datacenter
;
package
org
.
cloudbus
.
cloudsim
.
network
.
datacenter
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
org.cloudbus.cloudsim.Datacenter
;
import
org.cloudbus.cloudsim.Host
;
import
org.cloudbus.cloudsim.Host
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Pe
;
import
org.cloudbus.cloudsim.Pe
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.VmScheduler
;
import
org.cloudbus.cloudsim.VmScheduler
;
...
@@ -27,11 +24,11 @@ import org.cloudbus.cloudsim.provisioners.BwProvisioner;
...
@@ -27,11 +24,11 @@ import org.cloudbus.cloudsim.provisioners.BwProvisioner;
import
org.cloudbus.cloudsim.provisioners.RamProvisioner
;
import
org.cloudbus.cloudsim.provisioners.RamProvisioner
;
/**
/**
* NetworkHost class extends Host to support simulation of networked
datacenters.
* NetworkHost class extends Host to support simulation of networked
*
It executes actions related to management of packets (send and receive)other than that of
*
datacenters. It executes actions related to management of packets (send and
*
virtual machines (e.g., creation and destruction). A host has a defined
*
receive)other than that of virtual machines (e.g., creation and destruction).
*
policy for provisioning memory and bw, as well as an allocation policy for
*
A host has a defined policy for provisioning memory and bw, as well as an
* Pe's to virtual machines.
*
allocation policy for
Pe's to virtual machines.
*
*
* Please refer to following publication for more details:
* Please refer to following publication for more details:
*
*
...
@@ -42,7 +39,7 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner;
...
@@ -42,7 +39,7 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner;
*
*
*
*
* @author Saurabh Kumar Garg
* @author Saurabh Kumar Garg
* @since CloudSim Toolkit
1
.0
* @since CloudSim Toolkit
3
.0
*/
*/
public
class
NetworkHost
extends
Host
{
public
class
NetworkHost
extends
Host
{
...
@@ -50,7 +47,7 @@ public class NetworkHost extends Host {
...
@@ -50,7 +47,7 @@ public class NetworkHost extends Host {
public
List
<
NetworkPacket
>
packetTosendGlobal
;
public
List
<
NetworkPacket
>
packetTosendGlobal
;
public
List
<
NetworkPacket
>
packetrecieved
;
public
List
<
NetworkPacket
>
packetrecieved
;
public
double
memory
;
public
double
memory
;
public
Switch
sw
;
//Edge switch in general
public
Switch
sw
;
//
Edge switch in general
public
double
bandwidth
;
// latency
public
double
bandwidth
;
// latency
public
List
<
Double
>
CPUfinTimeCPU
=
new
ArrayList
<
Double
>();
// time when
public
List
<
Double
>
CPUfinTimeCPU
=
new
ArrayList
<
Double
>();
// time when
// last job will
// last job will
...
@@ -59,9 +56,13 @@ public class NetworkHost extends Host {
...
@@ -59,9 +56,13 @@ public class NetworkHost extends Host {
public
double
fintime
=
0
;
public
double
fintime
=
0
;
public
NetworkHost
(
int
id
,
RamProvisioner
ramProvisioner
,
public
NetworkHost
(
BwProvisioner
bwProvisioner
,
long
storage
,
int
id
,
List
<?
extends
Pe
>
peList
,
VmScheduler
vmScheduler
)
{
RamProvisioner
ramProvisioner
,
BwProvisioner
bwProvisioner
,
long
storage
,
List
<?
extends
Pe
>
peList
,
VmScheduler
vmScheduler
)
{
super
(
id
,
ramProvisioner
,
bwProvisioner
,
storage
,
peList
,
vmScheduler
);
super
(
id
,
ramProvisioner
,
bwProvisioner
,
storage
,
peList
,
vmScheduler
);
this
.
packetrecieved
=
new
ArrayList
<
NetworkPacket
>();
this
.
packetrecieved
=
new
ArrayList
<
NetworkPacket
>();
...
@@ -84,6 +85,7 @@ public class NetworkHost extends Host {
...
@@ -84,6 +85,7 @@ public class NetworkHost extends Host {
* @pre currentTime >= 0.0
* @pre currentTime >= 0.0
* @post $none
* @post $none
*/
*/
@Override
public
double
updateVmsProcessing
(
double
currentTime
)
{
public
double
updateVmsProcessing
(
double
currentTime
)
{
double
smallerTime
=
Double
.
MAX_VALUE
;
double
smallerTime
=
Double
.
MAX_VALUE
;
// insert in each vm packet recieved
// insert in each vm packet recieved
...
@@ -93,18 +95,19 @@ public class NetworkHost extends Host {
...
@@ -93,18 +95,19 @@ public class NetworkHost extends Host {
// continue;
// continue;
// }
// }
double
time
=
((
NetworkVm
)
vm
).
updateVmProcessing
(
currentTime
,
double
time
=
((
NetworkVm
)
vm
).
updateVmProcessing
(
currentTime
,
getVmScheduler
()
getVmScheduler
()
.
getAllocatedMipsForVm
(
vm
));
.
getAllocatedMipsForVm
(
vm
));
if
(
time
>
0.0
&&
time
<
smallerTime
)
{
if
(
time
>
0.0
&&
time
<
smallerTime
)
{
smallerTime
=
time
;
smallerTime
=
time
;
}
}
}
}
//send the packets to other hosts/VMs
//
send the packets to other hosts/VMs
sendpackets
();
sendpackets
();
return
smallerTime
;
return
smallerTime
;
}
}
/**
/**
* Receives packet and forward it to the corresponding VM for processing
* Receives packet and forward it to the corresponding VM for processing
* host.
* host.
...
@@ -119,13 +122,14 @@ public class NetworkHost extends Host {
...
@@ -119,13 +122,14 @@ public class NetworkHost extends Host {
// insertthe packet in recievedlist of VM
// insertthe packet in recievedlist of VM
Vm
vm
=
VmList
.
getById
(
getVmList
(),
hs
.
pkt
.
reciever
);
Vm
vm
=
VmList
.
getById
(
getVmList
(),
hs
.
pkt
.
reciever
);
List
<
HostPacket
>
pktlist
=
((
NetworkCloudletSpaceSharedScheduler
)
vm
List
<
HostPacket
>
pktlist
=
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pktrecv
.
get
CloudletScheduler
()).
pktrecv
.
get
(
hs
.
pkt
.
sender
);
.
get
(
hs
.
pkt
.
sender
);
if
(
pktlist
==
null
)
{
if
(
pktlist
==
null
)
{
pktlist
=
new
ArrayList
<
HostPacket
>();
pktlist
=
new
ArrayList
<
HostPacket
>();
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pktrecv
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pktrecv
.
put
(
.
put
(
hs
.
pkt
.
sender
,
pktlist
);
hs
.
pkt
.
sender
,
pktlist
);
}
}
pktlist
.
add
(
hs
.
pkt
);
pktlist
.
add
(
hs
.
pkt
);
...
@@ -133,29 +137,28 @@ public class NetworkHost extends Host {
...
@@ -133,29 +137,28 @@ public class NetworkHost extends Host {
}
}
packetrecieved
.
clear
();
packetrecieved
.
clear
();
}
}
/**
/**
* Send packet check whether a packet belongs to a local VM or to a VM hosted on other machine.
* Send packet check whether a packet belongs to a local VM or to a VM
* hosted on other machine.
*
*
*
*
*/
*/
private
void
sendpackets
()
{
private
void
sendpackets
()
{
for
(
Vm
vm
:
super
.
getVmList
())
{
for
(
Vm
vm
:
super
.
getVmList
())
{
for
(
Entry
<
Integer
,
List
<
HostPacket
>>
es
:
((
NetworkCloudletSpaceSharedScheduler
)
vm
for
(
Entry
<
Integer
,
List
<
HostPacket
>>
es
:
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pkttosend
.
entrySet
())
.
getCloudletScheduler
()).
pkttosend
.
entrySet
())
{
{
List
<
HostPacket
>
pktlist
=
es
.
getValue
();
List
<
HostPacket
>
pktlist
=
es
.
getValue
();
for
(
HostPacket
pkt
:
pktlist
)
{
for
(
HostPacket
pkt
:
pktlist
)
{
NetworkPacket
hpkt
=
new
NetworkPacket
(
this
.
getId
(),
pkt
,
NetworkPacket
hpkt
=
new
NetworkPacket
(
this
.
getId
(),
pkt
,
vm
.
getId
(),
pkt
.
sender
);
vm
.
getId
(),
pkt
.
sender
);
Vm
vm2
=
VmList
.
getById
(
this
.
getVmList
(),
hpkt
.
recievervmid
);
Vm
vm2
=
VmList
if
(
vm2
!=
null
)
{
.
getById
(
this
.
getVmList
(),
hpkt
.
recievervmid
);
if
(
vm2
!=
null
)
this
.
packetTosendLocal
.
add
(
hpkt
);
this
.
packetTosendLocal
.
add
(
hpkt
);
else
}
else
{
this
.
packetTosendGlobal
.
add
(
hpkt
);
this
.
packetTosendGlobal
.
add
(
hpkt
);
}
}
}
pktlist
.
clear
();
pktlist
.
clear
();
}
}
...
@@ -172,12 +175,13 @@ public class NetworkHost extends Host {
...
@@ -172,12 +175,13 @@ public class NetworkHost extends Host {
Vm
vm
=
VmList
.
getById
(
getVmList
(),
hs
.
pkt
.
reciever
);
Vm
vm
=
VmList
.
getById
(
getVmList
(),
hs
.
pkt
.
reciever
);
// Vm vm=getVmList().get(hs.pkt.reciever);
// Vm vm=getVmList().get(hs.pkt.reciever);
List
<
HostPacket
>
pktlist
=
((
NetworkCloudletSpaceSharedScheduler
)
vm
List
<
HostPacket
>
pktlist
=
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pktrecv
.
get
CloudletScheduler
()).
pktrecv
.
get
(
hs
.
pkt
.
sender
);
.
get
(
hs
.
pkt
.
sender
);
if
(
pktlist
==
null
)
{
if
(
pktlist
==
null
)
{
pktlist
=
new
ArrayList
<
HostPacket
>();
pktlist
=
new
ArrayList
<
HostPacket
>();
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pktrecv
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pktrecv
.
put
(
.
put
(
hs
.
pkt
.
sender
,
pktlist
);
hs
.
pkt
.
sender
,
pktlist
);
}
}
pktlist
.
add
(
hs
.
pkt
);
pktlist
.
add
(
hs
.
pkt
);
...
@@ -188,13 +192,13 @@ public class NetworkHost extends Host {
...
@@ -188,13 +192,13 @@ public class NetworkHost extends Host {
// continue;
// continue;
// }
// }
double
time
=
((
NetworkVm
)
vm
).
updateVmProcessing
(
CloudSim
vm
.
updateVmProcessing
(
CloudSim
.
clock
(),
getVmScheduler
().
getAllocatedMipsForVm
(
vm
));
.
clock
(),
getVmScheduler
().
getAllocatedMipsForVm
(
vm
));
}
}
}
}
//Sending packet to other VMs therefore packet is forwarded to a Edge switch
// Sending packet to other VMs therefore packet is forwarded to a Edge
// switch
this
.
packetTosendLocal
.
clear
();
this
.
packetTosendLocal
.
clear
();
double
avband
=
this
.
bandwidth
/
packetTosendGlobal
.
size
();
double
avband
=
this
.
bandwidth
/
packetTosendGlobal
.
size
();
...
@@ -203,16 +207,19 @@ public class NetworkHost extends Host {
...
@@ -203,16 +207,19 @@ public class NetworkHost extends Host {
NetworkConstants
.
totaldatatransfer
+=
hs
.
pkt
.
data
;
NetworkConstants
.
totaldatatransfer
+=
hs
.
pkt
.
data
;
// System.out.println(hs.pkt.virtualsendid+" "+hs.pkt.virtualrecvid+" "+hs.pkt.data);
// System.out.println(hs.pkt.virtualsendid+" "+hs.pkt.virtualrecvid+" "+hs.pkt.data);
CloudSim
.
send
(
this
.
getDatacenter
().
getId
(),
this
.
sw
.
getId
(),
delay
,
CloudSim
.
send
(
CloudSimTags
.
Network_Event_UP
,
hs
);
this
.
getDatacenter
().
getId
(),
this
.
sw
.
getId
(),
delay
,
CloudSimTags
.
Network_Event_UP
,
hs
);
// send to switch with delay
// send to switch with delay
}
}
this
.
packetTosendGlobal
.
clear
();
this
.
packetTosendGlobal
.
clear
();
}
}
@SuppressWarnings
(
"unchecked"
)
public
double
getMaxUtilizationAmongVmsPes
(
Vm
vm
)
{
public
double
getMaxUtilizationAmongVmsPes
(
Vm
vm
)
{
return
PeList
.
getMaxUtilizationAmongVmsPes
(
(
List
<
Pe
>)
getPeList
(),
vm
);
return
PeList
.
getMaxUtilizationAmongVmsPes
(
getPeList
(),
vm
);
}
}
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/NetworkVm.java
View file @
4f25a01a
package
org
.
cloudbus
.
cloudsim
.
network
.
datacenter
;
package
org
.
cloudbus
.
cloudsim
.
network
.
datacenter
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.cloudbus.cloudsim.CloudletScheduler
;
import
org.cloudbus.cloudsim.CloudletScheduler
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.Vm
;
/**
/**
* NetworkVm class extends Vm to support simulation of networked datacenters.
* NetworkVm class extends Vm to support simulation of networked datacenters.
It
*
It
executes actions related to management of packets (send and receive).
* executes actions related to management of packets (send and receive).
*
*
* Please refer to following publication for more details:
* Please refer to following publication for more details:
*
*
...
@@ -19,16 +18,23 @@ import org.cloudbus.cloudsim.Vm;
...
@@ -19,16 +18,23 @@ import org.cloudbus.cloudsim.Vm;
*
*
*
*
* @author Saurabh Kumar Garg
* @author Saurabh Kumar Garg
* @since CloudSim Toolkit
1
.0
* @since CloudSim Toolkit
3
.0
*/
*/
public
class
NetworkVm
extends
Vm
implements
Comparable
{
public
class
NetworkVm
extends
Vm
implements
Comparable
<
Object
>
{
public
NetworkVm
(
int
id
,
int
userId
,
double
mips
,
int
pesNumber
,
int
ram
,
long
bw
,
long
size
,
String
vmm
,
CloudletScheduler
cloudletScheduler
)
{
super
(
id
,
userId
,
mips
,
pesNumber
,
ram
,
bw
,
size
,
vmm
,
cloudletScheduler
);
public
NetworkVm
(
int
id
,
int
userId
,
double
mips
,
int
pesNumber
,
int
ram
,
long
bw
,
long
size
,
String
vmm
,
CloudletScheduler
cloudletScheduler
)
{
super
(
id
,
userId
,
mips
,
pesNumber
,
ram
,
bw
,
size
,
vmm
,
cloudletScheduler
);
// TODO Auto-generated constructor stub
cloudletlist
=
new
ArrayList
<
NetworkCloudlet
>();
cloudletlist
=
new
ArrayList
<
NetworkCloudlet
>();
}
}
...
@@ -45,10 +51,12 @@ public class NetworkVm extends Vm implements Comparable {
...
@@ -45,10 +51,12 @@ public class NetworkVm extends Vm implements Comparable {
public
int
compareTo
(
Object
arg0
)
{
public
int
compareTo
(
Object
arg0
)
{
NetworkVm
hs
=
(
NetworkVm
)
arg0
;
NetworkVm
hs
=
(
NetworkVm
)
arg0
;
if
(
hs
.
finishtime
>
this
.
finishtime
)
if
(
hs
.
finishtime
>
this
.
finishtime
)
{
return
-
1
;
return
-
1
;
if
(
hs
.
finishtime
<
this
.
finishtime
)
}
if
(
hs
.
finishtime
<
this
.
finishtime
)
{
return
1
;
return
1
;
}
return
0
;
return
0
;
}
}
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/Switch.java
View file @
4f25a01a
...
@@ -4,9 +4,9 @@ import java.util.ArrayList;
...
@@ -4,9 +4,9 @@ import java.util.ArrayList;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.SortedMap
;
import
java.util.SortedMap
;
import
java.util.TreeMap
;
import
java.util.TreeMap
;
import
java.util.Map.Entry
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.Vm
;
...
@@ -67,30 +67,7 @@ public class Switch extends SimEntity {
...
@@ -67,30 +67,7 @@ public class Switch extends SimEntity {
public
Switch
(
String
name
,
int
level
,
NetworkDatacenter
dc
)
{
public
Switch
(
String
name
,
int
level
,
NetworkDatacenter
dc
)
{
super
(
name
);
super
(
name
);
this
.
level
=
level
;
this
.
level
=
level
;
/*
* if(level==Constants.EDGE_LEVEL) { hostlist=new HashMap<Integer,HPCHost>();
* uplinkswitchpktlist=new HashMap<Integer,List<HostPacket>>(); packetTohost=new
* HashMap<Integer,List<HostPacket>>(); uplinkbandwidth=Constants.BandWidthEdgeAgg;
* downlinkbandwidth=Constants.BandWidthEdgeHost; latency=Constants.SwitchingDelayEdge;
* numport=Constants.EdgeSwitchPort; uplinkswitches=new ArrayList<Switch>();
*
* } if(level==Constants.Agg_LEVEL) { downlinkswitchpktlist=new
* HashMap<Integer,List<HostPacket>>(); uplinkswitchpktlist=new
* HashMap<Integer,List<HostPacket>>(); uplinkbandwidth=Constants.BandWidthAggRoot;
* downlinkbandwidth=Constants.BandWidthEdgeAgg; latency=Constants.SwitchingDelayAgg;
* numport=Constants.AggSwitchPort; uplinkswitches=new ArrayList<Switch>();
* downlinkswitches=new ArrayList<Switch>(); } if(level==Constants.ROOT_LEVEL) {
* downlinkswitchpktlist=new HashMap<Integer,List<HostPacket>>(); downlinkswitches=new
* ArrayList<Switch>();
*
* downlinkbandwidth=Constants.BandWidthAggRoot; latency=Constants.SwitchingDelayRoot;
* numport=Constants.RootSwitchPort;
*
* }
*/
this
.
dc
=
dc
;
this
.
dc
=
dc
;
// TODO Auto-generated constructor stub
}
}
@Override
@Override
...
@@ -131,7 +108,6 @@ public class Switch extends SimEntity {
...
@@ -131,7 +108,6 @@ public class Switch extends SimEntity {
}
}
protected
void
processhostpacket
(
SimEvent
ev
)
{
protected
void
processhostpacket
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
// Send packet to host
// Send packet to host
NetworkPacket
hspkt
=
(
NetworkPacket
)
ev
.
getData
();
NetworkPacket
hspkt
=
(
NetworkPacket
)
ev
.
getData
();
NetworkHost
hs
=
hostlist
.
get
(
hspkt
.
recieverhostid
);
NetworkHost
hs
=
hostlist
.
get
(
hspkt
.
recieverhostid
);
...
@@ -139,7 +115,6 @@ public class Switch extends SimEntity {
...
@@ -139,7 +115,6 @@ public class Switch extends SimEntity {
}
}
protected
void
processpacket_down
(
SimEvent
ev
)
{
protected
void
processpacket_down
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
// packet coming from up level router.
// packet coming from up level router.
// has to send downward
// has to send downward
// check which switch to forward to
// check which switch to forward to
...
@@ -178,7 +153,6 @@ public class Switch extends SimEntity {
...
@@ -178,7 +153,6 @@ public class Switch extends SimEntity {
}
}
protected
void
processpacket_up
(
SimEvent
ev
)
{
protected
void
processpacket_up
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
// packet coming from down level router.
// packet coming from down level router.
// has to send up
// has to send up
// check which switch to forward to
// check which switch to forward to
...
@@ -277,13 +251,11 @@ public class Switch extends SimEntity {
...
@@ -277,13 +251,11 @@ public class Switch extends SimEntity {
}
}
private
void
registerHost
(
SimEvent
ev
)
{
private
void
registerHost
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
NetworkHost
hs
=
(
NetworkHost
)
ev
.
getData
();
NetworkHost
hs
=
(
NetworkHost
)
ev
.
getData
();
hostlist
.
put
(
hs
.
getId
(),
(
NetworkHost
)
ev
.
getData
());
hostlist
.
put
(
hs
.
getId
(),
(
NetworkHost
)
ev
.
getData
());
}
}
protected
void
processpacket
(
SimEvent
ev
)
{
protected
void
processpacket
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
// send packet to itself with switching delay (discarding other)
// send packet to itself with switching delay (discarding other)
CloudSim
.
cancelAll
(
getId
(),
new
PredicateType
(
CloudSimTags
.
Network_Event_UP
));
CloudSim
.
cancelAll
(
getId
(),
new
PredicateType
(
CloudSimTags
.
Network_Event_UP
));
schedule
(
getId
(),
switching_delay
,
CloudSimTags
.
Network_Event_UP
);
schedule
(
getId
(),
switching_delay
,
CloudSimTags
.
Network_Event_UP
);
...
@@ -294,12 +266,10 @@ public class Switch extends SimEntity {
...
@@ -294,12 +266,10 @@ public class Switch extends SimEntity {
}
}
private
void
processOtherEvent
(
SimEvent
ev
)
{
private
void
processOtherEvent
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
}
}
protected
void
processpacketforward
(
SimEvent
ev
)
{
protected
void
processpacketforward
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
// search for the host and packets..send to them
// search for the host and packets..send to them
if
(
downlinkswitchpktlist
!=
null
)
{
if
(
downlinkswitchpktlist
!=
null
)
{
...
@@ -338,8 +308,6 @@ public class Switch extends SimEntity {
...
@@ -338,8 +308,6 @@ public class Switch extends SimEntity {
}
}
if
(
packetTohost
!=
null
)
{
if
(
packetTohost
!=
null
)
{
for
(
Entry
<
Integer
,
List
<
NetworkPacket
>>
es
:
packetTohost
.
entrySet
())
{
for
(
Entry
<
Integer
,
List
<
NetworkPacket
>>
es
:
packetTohost
.
entrySet
())
{
int
tosend
=
es
.
getKey
();
NetworkHost
hs
=
hostlist
.
get
(
tosend
);
List
<
NetworkPacket
>
hspktlist
=
es
.
getValue
();
List
<
NetworkPacket
>
hspktlist
=
es
.
getValue
();
if
(!
hspktlist
.
isEmpty
())
{
if
(!
hspktlist
.
isEmpty
())
{
double
avband
=
downlinkbandwidth
/
hspktlist
.
size
();
double
avband
=
downlinkbandwidth
/
hspktlist
.
size
();
...
@@ -360,8 +328,11 @@ public class Switch extends SimEntity {
...
@@ -360,8 +328,11 @@ public class Switch extends SimEntity {
}
}
private
NetworkHost
getHostwithVM
(
int
vmid
)
{
//
// TODO Auto-generated method stub
// R: We changed visibility of the below methods from private to protected.
//
protected
NetworkHost
getHostwithVM
(
int
vmid
)
{
for
(
Entry
<
Integer
,
NetworkHost
>
es
:
hostlist
.
entrySet
())
{
for
(
Entry
<
Integer
,
NetworkHost
>
es
:
hostlist
.
entrySet
())
{
Vm
vm
=
VmList
.
getById
(
es
.
getValue
().
getVmList
(),
vmid
);
Vm
vm
=
VmList
.
getById
(
es
.
getValue
().
getVmList
(),
vmid
);
if
(
vm
!=
null
)
{
if
(
vm
!=
null
)
{
...
@@ -371,8 +342,7 @@ public class Switch extends SimEntity {
...
@@ -371,8 +342,7 @@ public class Switch extends SimEntity {
return
null
;
return
null
;
}
}
private
List
<
NetworkVm
>
getfreeVmlist
(
int
numVMReq
)
{
protected
List
<
NetworkVm
>
getfreeVmlist
(
int
numVMReq
)
{
// TODO Auto-generated method stub
List
<
NetworkVm
>
freehostls
=
new
ArrayList
<
NetworkVm
>();
List
<
NetworkVm
>
freehostls
=
new
ArrayList
<
NetworkVm
>();
for
(
Entry
<
Integer
,
NetworkVm
>
et
:
Vmlist
.
entrySet
())
{
for
(
Entry
<
Integer
,
NetworkVm
>
et
:
Vmlist
.
entrySet
())
{
if
(
et
.
getValue
().
isFree
())
{
if
(
et
.
getValue
().
isFree
())
{
...
@@ -386,8 +356,7 @@ public class Switch extends SimEntity {
...
@@ -386,8 +356,7 @@ public class Switch extends SimEntity {
return
freehostls
;
return
freehostls
;
}
}
private
List
<
NetworkHost
>
getfreehostlist
(
int
numhost
)
{
protected
List
<
NetworkHost
>
getfreehostlist
(
int
numhost
)
{
// TODO Auto-generated method stub
List
<
NetworkHost
>
freehostls
=
new
ArrayList
<
NetworkHost
>();
List
<
NetworkHost
>
freehostls
=
new
ArrayList
<
NetworkHost
>();
for
(
Entry
<
Integer
,
NetworkHost
>
et
:
hostlist
.
entrySet
())
{
for
(
Entry
<
Integer
,
NetworkHost
>
et
:
hostlist
.
entrySet
())
{
if
(
et
.
getValue
().
getNumberOfFreePes
()
==
et
.
getValue
().
getNumberOfPes
())
{
if
(
et
.
getValue
().
getNumberOfFreePes
()
==
et
.
getValue
().
getNumberOfPes
())
{
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/WorkflowApp.java
View file @
4f25a01a
...
@@ -22,65 +22,110 @@ import org.cloudbus.cloudsim.UtilizationModel;
...
@@ -22,65 +22,110 @@ import org.cloudbus.cloudsim.UtilizationModel;
import
org.cloudbus.cloudsim.UtilizationModelFull
;
import
org.cloudbus.cloudsim.UtilizationModelFull
;
import
org.cloudbus.cloudsim.core.CloudSim
;
import
org.cloudbus.cloudsim.core.CloudSim
;
public
class
WorkflowApp
extends
AppCloudlet
{
public
class
WorkflowApp
extends
AppCloudlet
{
public
WorkflowApp
(
int
type
,
int
appID
,
double
deadline
,
public
WorkflowApp
(
int
type
,
int
appID
,
double
deadline
,
int
numbervm
,
int
userId
)
{
int
numbervm
,
int
userId
)
{
super
(
type
,
appID
,
deadline
,
numbervm
,
userId
);
super
(
type
,
appID
,
deadline
,
numbervm
,
userId
);
// TODO Auto-generated constructor stub
this
.
exeTime
=
100
;
this
.
exeTime
=
100
;
this
.
numbervm
=
3
;
this
.
numbervm
=
3
;
}
}
public
void
createCloudletList
(
List
<
Integer
>
vmIdList
){
@Override
public
void
createCloudletList
(
List
<
Integer
>
vmIdList
)
{
long
fileSize
=
NetworkConstants
.
FILE_SIZE
;
long
fileSize
=
NetworkConstants
.
FILE_SIZE
;
long
outputSize
=
NetworkConstants
.
OUTPUT_SIZE
;
long
outputSize
=
NetworkConstants
.
OUTPUT_SIZE
;
int
pesNumber
=
NetworkConstants
.
PES_NUMBER
;
int
memory
=
100
;
int
memory
=
100
;
UtilizationModel
utilizationModel
=
new
UtilizationModelFull
();
UtilizationModel
utilizationModel
=
new
UtilizationModelFull
();
int
i
=
0
;
int
i
=
0
;
//Task A
// Task A
NetworkCloudlet
cl
=
new
NetworkCloudlet
(
NetworkConstants
.
currentCloudletId
,
0
,
1
,
fileSize
,
outputSize
,
memory
,
utilizationModel
,
utilizationModel
,
utilizationModel
);
NetworkCloudlet
cl
=
new
NetworkCloudlet
(
cl
.
numStage
=
2
;
NetworkConstants
.
currentCloudletId
,
0
,
1
,
fileSize
,
outputSize
,
memory
,
utilizationModel
,
utilizationModel
,
utilizationModel
);
cl
.
numStage
=
2
;
NetworkConstants
.
currentCloudletId
++;
NetworkConstants
.
currentCloudletId
++;
cl
.
setUserId
(
userId
);
cl
.
setUserId
(
userId
);
cl
.
submittime
=
CloudSim
.
clock
();
cl
.
submittime
=
CloudSim
.
clock
();
cl
.
currStagenum
=
-
1
;
cl
.
currStagenum
=
-
1
;
cl
.
setVmId
(
vmIdList
.
get
(
i
));
cl
.
setVmId
(
vmIdList
.
get
(
i
));
//first stage: big computation
// first stage: big computation
cl
.
stages
.
add
(
new
TaskStage
(
NetworkConstants
.
EXECUTION
,
0
,
1000
*
0.8
,
0
,
memory
,
vmIdList
.
get
(
0
),
cl
.
getCloudletId
()));
cl
.
stages
.
add
(
new
TaskStage
(
NetworkConstants
.
EXECUTION
,
0
,
1000
*
0.8
,
0
,
memory
,
vmIdList
.
get
(
0
),
cl
cl
.
stages
.
add
(
new
TaskStage
(
NetworkConstants
.
WAIT_SEND
,
1000
,
0
,
1
,
memory
,
vmIdList
.
get
(
2
),
cl
.
getCloudletId
()+
2
));
.
getCloudletId
()));
cl
.
stages
.
add
(
new
TaskStage
(
NetworkConstants
.
WAIT_SEND
,
1000
,
0
,
1
,
memory
,
vmIdList
.
get
(
2
),
cl
.
getCloudletId
()
+
2
));
clist
.
add
(
cl
);
clist
.
add
(
cl
);
i
++;
i
++;
//Task B
// Task B
NetworkCloudlet
clb
=
new
NetworkCloudlet
(
NetworkConstants
.
currentCloudletId
,
0
,
1
,
fileSize
,
outputSize
,
memory
,
utilizationModel
,
utilizationModel
,
utilizationModel
);
NetworkCloudlet
clb
=
new
NetworkCloudlet
(
clb
.
numStage
=
2
;
NetworkConstants
.
currentCloudletId
,
0
,
1
,
fileSize
,
outputSize
,
memory
,
utilizationModel
,
utilizationModel
,
utilizationModel
);
clb
.
numStage
=
2
;
NetworkConstants
.
currentCloudletId
++;
NetworkConstants
.
currentCloudletId
++;
clb
.
setUserId
(
userId
);
clb
.
setUserId
(
userId
);
clb
.
submittime
=
CloudSim
.
clock
();
clb
.
submittime
=
CloudSim
.
clock
();
clb
.
currStagenum
=
-
1
;
clb
.
currStagenum
=
-
1
;
clb
.
setVmId
(
vmIdList
.
get
(
i
));
clb
.
setVmId
(
vmIdList
.
get
(
i
));
//
first stage: big computation
//
first stage: big computation
clb
.
stages
.
add
(
new
TaskStage
(
NetworkConstants
.
EXECUTION
,
0
,
1000
*
0.8
,
0
,
memory
,
vmIdList
.
get
(
1
),
clb
.
getCloudletId
()));
clb
.
stages
.
add
(
new
TaskStage
(
clb
.
stages
.
add
(
new
TaskStage
(
NetworkConstants
.
WAIT_SEND
,
1000
,
0
,
1
,
memory
,
vmIdList
.
get
(
2
),
clb
.
getCloudletId
()+
1
));
NetworkConstants
.
EXECUTION
,
0
,
1000
*
0.8
,
0
,
memory
,
vmIdList
.
get
(
1
),
clb
.
getCloudletId
()));
clb
.
stages
.
add
(
new
TaskStage
(
NetworkConstants
.
WAIT_SEND
,
1000
,
0
,
1
,
memory
,
vmIdList
.
get
(
2
),
clb
.
getCloudletId
()
+
1
));
clist
.
add
(
clb
);
clist
.
add
(
clb
);
i
++;
i
++;
//Task C
// Task C
NetworkCloudlet
clc
=
new
NetworkCloudlet
(
NetworkConstants
.
currentCloudletId
,
0
,
1
,
fileSize
,
outputSize
,
memory
,
utilizationModel
,
utilizationModel
,
utilizationModel
);
NetworkCloudlet
clc
=
new
NetworkCloudlet
(
clc
.
numStage
=
2
;
NetworkConstants
.
currentCloudletId
,
0
,
1
,
fileSize
,
outputSize
,
memory
,
utilizationModel
,
utilizationModel
,
utilizationModel
);
clc
.
numStage
=
2
;
NetworkConstants
.
currentCloudletId
++;
NetworkConstants
.
currentCloudletId
++;
clc
.
setUserId
(
userId
);
clc
.
setUserId
(
userId
);
clc
.
submittime
=
CloudSim
.
clock
();
clc
.
submittime
=
CloudSim
.
clock
();
clc
.
currStagenum
=
-
1
;
clc
.
currStagenum
=
-
1
;
clc
.
setVmId
(
vmIdList
.
get
(
i
));
clc
.
setVmId
(
vmIdList
.
get
(
i
));
//first stage: big computation
// first stage: big computation
clc
.
stages
.
add
(
new
TaskStage
(
NetworkConstants
.
WAIT_RECV
,
1000
,
0
,
0
,
memory
,
vmIdList
.
get
(
0
),
cl
.
getCloudletId
()));
clc
.
stages
.
add
(
new
TaskStage
(
NetworkConstants
.
WAIT_RECV
,
1000
,
0
,
0
,
memory
,
vmIdList
.
get
(
0
),
cl
clc
.
stages
.
add
(
new
TaskStage
(
NetworkConstants
.
WAIT_RECV
,
1000
,
0
,
1
,
memory
,
vmIdList
.
get
(
1
),
cl
.
getCloudletId
()+
1
));
.
getCloudletId
()));
clc
.
stages
.
add
(
new
TaskStage
(
NetworkConstants
.
EXECUTION
,
0
,
1000
*
0.8
,
1
,
memory
,
vmIdList
.
get
(
0
),
clc
.
getCloudletId
()));
clc
.
stages
.
add
(
new
TaskStage
(
NetworkConstants
.
WAIT_RECV
,
1000
,
0
,
1
,
memory
,
vmIdList
.
get
(
1
),
cl
.
getCloudletId
()
+
1
));
clc
.
stages
.
add
(
new
TaskStage
(
NetworkConstants
.
EXECUTION
,
0
,
1000
*
0.8
,
1
,
memory
,
vmIdList
.
get
(
0
),
clc
.
getCloudletId
()));
clist
.
add
(
clc
);
clist
.
add
(
clc
);
...
...
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