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
Expand all
Hide 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
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.text.DecimalFormat
;
import
java.util.ArrayList
;
...
...
@@ -10,20 +8,13 @@ import java.util.LinkedList;
import
java.util.List
;
import
org.cloudbus.cloudsim.Cloudlet
;
import
org.cloudbus.cloudsim.CloudletSchedulerSpaceShared
;
import
org.cloudbus.cloudsim.DatacenterCharacteristics
;
import
org.cloudbus.cloudsim.Host
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Pe
;
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.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.NetDatacenterBroker
;
import
org.cloudbus.cloudsim.network.datacenter.NetworkConstants
;
...
...
@@ -37,13 +28,6 @@ import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
public
class
TestExample
{
/**
* @param args
*/
/** The cloudlet list. */
private
static
List
<
AppCloudlet
>
cloudletList
;
/** The vmlist. */
private
static
List
<
NetworkVm
>
vmlist
;
...
...
@@ -72,11 +56,9 @@ public class TestExample {
// Third step: Create Broker
NetDatacenterBroker
broker
=
createBroker
();
int
brokerId
=
broker
.
getId
();
broker
.
setLinkDC
(
datacenter0
);
// broker.setLinkDC(datacenter0);
// Fifth step: Create one Cloudlet
cloudletList
=
new
ArrayList
<
AppCloudlet
>();
vmlist
=
new
ArrayList
<
NetworkVm
>();
...
...
@@ -92,9 +74,9 @@ public class TestExample {
// Final step: Print results when simulation is over
List
<
Cloudlet
>
newList
=
broker
.
getCloudletReceivedList
();
printCloudletList
(
newList
);
System
.
out
.
println
(
"numberofcloudlet "
+
newList
.
size
()
+
" Cached "
+
NetDatacenterBroker
.
cachedcloudlet
+
" Data transfered "
+
NetworkConstants
.
totaldatatransfer
);
System
.
out
.
println
(
"numberofcloudlet "
+
newList
.
size
()
+
" Cached "
+
NetDatacenterBroker
.
cachedcloudlet
+
" Data transfered "
+
NetworkConstants
.
totaldatatransfer
);
// Print the debt of each user to each datacenter
datacenter0
.
printDebts
();
...
...
@@ -133,70 +115,72 @@ public class TestExample {
// 4. Create Host with its id and list of PEs and add them to the list
// of machines
int
hostId
=
0
;
int
ram
=
2048
;
// host memory (MB)
long
storage
=
1000000
;
// host storage
int
bw
=
10000
;
for
(
int
i
=
0
;
i
<
NetworkConstants
.
EdgeSwitchPort
*
NetworkConstants
.
AggSwitchPort
for
(
int
i
=
0
;
i
<
NetworkConstants
.
EdgeSwitchPort
*
NetworkConstants
.
AggSwitchPort
*
NetworkConstants
.
RootSwitchPort
;
i
++)
{
// 2. A Machine contains one or more PEs or CPUs/Cores.
// In this example, it will have only one core.
// 3. Create PEs and add these into an object of PowerPeList.
List
<
Pe
>
peList
=
new
ArrayList
<
Pe
>();
peList
.
add
(
new
Pe
(
0
,
new
PeProvisionerSimple
(
mips
)));
// need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList
.
add
(
new
Pe
(
1
,
new
PeProvisionerSimple
(
mips
)));
// need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList
.
add
(
new
Pe
(
2
,
new
PeProvisionerSimple
(
mips
)));
// need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList
.
add
(
new
Pe
(
3
,
new
PeProvisionerSimple
(
mips
)));
// need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList
.
add
(
new
Pe
(
4
,
new
PeProvisionerSimple
(
mips
)));
// need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList
.
add
(
new
Pe
(
5
,
new
PeProvisionerSimple
(
mips
)));
// need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList
.
add
(
new
Pe
(
6
,
new
PeProvisionerSimple
(
mips
)));
// need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList
.
add
(
new
Pe
(
7
,
new
PeProvisionerSimple
(
mips
)));
// need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
// 4. Create PowerHost with its id and list of PEs and add them to
// the list of machines
hostList
.
add
(
new
NetworkHost
(
i
,
new
RamProvisionerSimple
(
ram
),
new
BwProvisionerSimple
(
bw
),
storage
,
peList
,
hostList
.
add
(
new
NetworkHost
(
i
,
new
RamProvisionerSimple
(
ram
),
new
BwProvisionerSimple
(
bw
),
storage
,
peList
,
new
VmSchedulerTimeShared
(
peList
)));
// This is our machine
}
...
...
@@ -211,23 +195,34 @@ public class TestExample {
double
cost
=
3.0
;
// the cost of using processing in this resource
double
costPerMem
=
0.05
;
// the cost of using memory in this resource
double
costPerStorage
=
0.001
;
// the cost of using storage in this
// resource
// resource
double
costPerBw
=
0.0
;
// the cost of using bw in this resource
LinkedList
<
Storage
>
storageList
=
new
LinkedList
<
Storage
>();
// we are
// not
// adding
// SAN
// not
// adding
// SAN
// devices by now
DatacenterCharacteristics
characteristics
=
new
DatacenterCharacteristics
(
arch
,
os
,
vmm
,
hostList
,
time_zone
,
cost
,
costPerMem
,
costPerStorage
,
costPerBw
);
arch
,
os
,
vmm
,
hostList
,
time_zone
,
cost
,
costPerMem
,
costPerStorage
,
costPerBw
);
// 6. Finally, we need to create a NetworkDatacenter object.
NetworkDatacenter
datacenter
=
null
;
try
{
datacenter
=
new
NetworkDatacenter
(
name
,
characteristics
,
new
NetworkVmAllocationPolicy
(
hostList
),
storageList
,
0
);
datacenter
=
new
NetworkDatacenter
(
name
,
characteristics
,
new
NetworkVmAllocationPolicy
(
hostList
),
storageList
,
0
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -263,17 +258,14 @@ public class TestExample {
* list of Cloudlets
* @throws IOException
*/
private
static
void
printCloudletList
(
List
<
Cloudlet
>
list
)
throws
IOException
{
private
static
void
printCloudletList
(
List
<
Cloudlet
>
list
)
throws
IOException
{
int
size
=
list
.
size
();
Cloudlet
cloudlet
;
double
fintime
=
0
;
String
indent
=
" "
;
Log
.
printLine
();
Log
.
printLine
(
"========== OUTPUT =========="
);
Log
.
printLine
(
"Cloudlet ID"
+
indent
+
"STATUS"
+
indent
+
"Data center ID"
+
indent
+
"VM ID"
+
indent
+
"Time"
+
indent
+
"Start Time"
+
indent
+
"Finish Time"
);
Log
.
printLine
(
"Cloudlet ID"
+
indent
+
"STATUS"
+
indent
+
"Data center ID"
+
indent
+
"VM ID"
+
indent
+
"Time"
+
indent
+
"Start Time"
+
indent
+
"Finish Time"
);
DecimalFormat
dft
=
new
DecimalFormat
(
"###.##"
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
...
...
@@ -282,13 +274,9 @@ public class TestExample {
if
(
cloudlet
.
getCloudletStatus
()
==
Cloudlet
.
SUCCESS
)
{
Log
.
print
(
"SUCCESS"
);
fintime
=
cloudlet
.
getFinishTime
();
Log
.
printLine
(
indent
+
indent
+
cloudlet
.
getResourceId
()
+
indent
+
indent
+
indent
+
cloudlet
.
getVmId
()
+
indent
+
indent
+
dft
.
format
(
cloudlet
.
getActualCPUTime
())
+
indent
+
indent
+
dft
.
format
(
cloudlet
.
getExecStartTime
())
+
indent
+
indent
Log
.
printLine
(
indent
+
indent
+
cloudlet
.
getResourceId
()
+
indent
+
indent
+
indent
+
cloudlet
.
getVmId
()
+
indent
+
indent
+
dft
.
format
(
cloudlet
.
getActualCPUTime
())
+
indent
+
indent
+
dft
.
format
(
cloudlet
.
getExecStartTime
())
+
indent
+
indent
+
dft
.
format
(
cloudlet
.
getFinishTime
()));
}
}
...
...
@@ -297,24 +285,11 @@ public class TestExample {
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
EdgeSwitch
edgeswitch
[]
=
new
EdgeSwitch
[
1
];
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
edgeswitch
[
i
]
=
new
EdgeSwitch
(
"Edge"
+
i
,
NetworkConstants
.
EDGE_LEVEL
,
dc
);
edgeswitch
[
i
]
=
new
EdgeSwitch
(
"Edge"
+
i
,
NetworkConstants
.
EDGE_LEVEL
,
dc
);
// edgeswitch[i].uplinkswitches.add(null);
dc
.
Switchlist
.
put
(
edgeswitch
[
i
].
getId
(),
edgeswitch
[
i
]);
// aggswitch[(int)
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/EdgeSwitch.java
View file @
4f25a01a
...
...
@@ -16,10 +16,10 @@ import org.cloudbus.cloudsim.core.predicates.PredicateType;
* It interacts with other switches in order to exchange
* packets. Please refer to following publication for more details:
*
* Saurabh Kumar Garg and Rajkumar Buyya, NetworkCloudSim: Modelling Parallel
* Applications in Cloud Simulations, Proceedings of the 4th IEEE/ACM International
* Conference on Utility and Cloud Computing (UCC 2011, IEEE CS Press, USA),
* Melbourne, Australia, December 5-7, 2011.
* Saurabh Kumar Garg and Rajkumar Buyya, NetworkCloudSim: Modelling Parallel
* Applications in Cloud Simulations, Proceedings of the 4th IEEE/ACM International
* Conference on Utility and Cloud Computing (UCC 2011, IEEE CS Press, USA),
* Melbourne, Australia, December 5-7, 2011.
*
* @author Saurabh Kumar Garg
* @since CloudSim Toolkit 3.0
...
...
@@ -31,25 +31,24 @@ public class EdgeSwitch extends Switch{
/**
* Constructor for Edge Switch
* We have to specify switches that are connected to its downlink and uplink ports,
* and corresponding bandwidths. In this switch downlink ports are
* and corresponding bandwidths. In this switch downlink ports are
* connected to hosts not to a switch.
*
* @param name Name of the switch
* @param name Name of the switch
* @param level At which level switch is with respect to hosts.
* @param dc Pointer to Datacenter
*/
public
EdgeSwitch
(
String
name
,
int
level
,
NetworkDatacenter
dc
)
{
super
(
name
,
level
,
dc
);
hostlist
=
new
HashMap
<
Integer
,
NetworkHost
>();
uplinkswitchpktlist
=
new
HashMap
<
Integer
,
List
<
NetworkPacket
>>();
packetTohost
=
new
HashMap
<
Integer
,
List
<
NetworkPacket
>>();
uplinkbandwidth
=
NetworkConstants
.
BandWidthEdgeAgg
;
uplinkbandwidth
=
NetworkConstants
.
BandWidthEdgeAgg
;
downlinkbandwidth
=
NetworkConstants
.
BandWidthEdgeHost
;
this
.
switching_delay
=
NetworkConstants
.
SwitchingDelayEdge
;
numport
=
NetworkConstants
.
EdgeSwitchPort
;
uplinkswitches
=
new
ArrayList
<
Switch
>();
// TODO Auto-generated constructor stub
}
/**
* Send Packet to switch connected through a uplink port
...
...
@@ -58,66 +57,64 @@ public class EdgeSwitch extends Switch{
*/
@Override
protected
void
processpacket_up
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
//packet coming from down level router/host.
//has to send up
//check which switch to forward to
//check which switch to forward to
//add packet in the switch list
//
//int src=ev.getSource();
NetworkPacket
hspkt
=(
NetworkPacket
)
ev
.
getData
();
int
recvVMid
=
hspkt
.
pkt
.
reciever
;
CloudSim
.
cancelAll
(
getId
(),
new
PredicateType
(
CloudSimTags
.
Network_Event_send
));
int
recvVMid
=
hspkt
.
pkt
.
reciever
;
CloudSim
.
cancelAll
(
getId
(),
new
PredicateType
(
CloudSimTags
.
Network_Event_send
));
schedule
(
getId
(),
this
.
switching_delay
,
CloudSimTags
.
Network_Event_send
);
// packet is recieved from host
//packet is to be sent to aggregate level or to another host in the same level
int
hostid
=
dc
.
VmtoHostlist
.
get
(
recvVMid
);
NetworkHost
hs
=
this
.
hostlist
.
get
(
hostid
);
hspkt
.
recieverhostid
=
hostid
;
//packet needs to go to a host which is connected directly to switch
if
(
hs
!=
null
)
{
//packet to be sent to host connected to the switch
List
<
NetworkPacket
>
pktlist
=
this
.
packetTohost
.
get
(
hostid
);
if
(
pktlist
==
null
){
pktlist
=
new
ArrayList
<
NetworkPacket
>();
this
.
packetTohost
.
put
(
hostid
,
pktlist
);
}
pktlist
.
add
(
hspkt
);
return
;
}
//otherwise
//packet is to be sent to upper switch
//ASSUMPTION EACH EDGE is Connected to one aggregate level switch
//if there are more than one Aggregate level switch one need to modify following code
Switch
sw
=
this
.
uplinkswitches
.
get
(
0
);
List
<
NetworkPacket
>
pktlist
=
this
.
uplinkswitchpktlist
.
get
(
sw
.
getId
());
if
(
pktlist
==
null
){
pktlist
=
new
ArrayList
<
NetworkPacket
>();
this
.
uplinkswitchpktlist
.
put
(
sw
.
getId
(),
pktlist
);
}
pktlist
.
add
(
hspkt
);
return
;
// packet is recieved from host
//packet is to be sent to aggregate level or to another host in the same level
int
hostid
=
dc
.
VmtoHostlist
.
get
(
recvVMid
);
NetworkHost
hs
=
this
.
hostlist
.
get
(
hostid
);
hspkt
.
recieverhostid
=
hostid
;
//packet needs to go to a host which is connected directly to switch
if
(
hs
!=
null
)
{
//packet to be sent to host connected to the switch
List
<
NetworkPacket
>
pktlist
=
this
.
packetTohost
.
get
(
hostid
);
if
(
pktlist
==
null
){
pktlist
=
new
ArrayList
<
NetworkPacket
>();
this
.
packetTohost
.
put
(
hostid
,
pktlist
);
}
pktlist
.
add
(
hspkt
);
return
;
}
//otherwise
//packet is to be sent to upper switch
//ASSUMPTION EACH EDGE is Connected to one aggregate level switch
//if there are more than one Aggregate level switch one need to modify following code
Switch
sw
=
this
.
uplinkswitches
.
get
(
0
);
List
<
NetworkPacket
>
pktlist
=
this
.
uplinkswitchpktlist
.
get
(
sw
.
getId
());
if
(
pktlist
==
null
){
pktlist
=
new
ArrayList
<
NetworkPacket
>();
this
.
uplinkswitchpktlist
.
put
(
sw
.
getId
(),
pktlist
);
}
pktlist
.
add
(
hspkt
);
return
;
}
/**
* Send Packet to hosts connected to the switch
*
* @param ev Event/packet to process
*/
@Override
protected
void
processpacketforward
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
//search for the host and packets..send to them
if
(
this
.
uplinkswitchpktlist
!=
null
)
{
for
(
Entry
<
Integer
,
List
<
NetworkPacket
>>
es:
uplinkswitchpktlist
.
entrySet
())
...
...
@@ -132,7 +129,7 @@ public class EdgeSwitch extends Switch{
{
NetworkPacket
hspkt
=
it
.
next
();
double
delay
=
1000
*
hspkt
.
pkt
.
data
/
avband
;
this
.
send
(
tosend
,
delay
,
CloudSimTags
.
Network_Event_UP
,
hspkt
);
}
hspktlist
.
clear
();
...
...
@@ -143,8 +140,6 @@ public class EdgeSwitch extends Switch{
{
for
(
Entry
<
Integer
,
List
<
NetworkPacket
>>
es:
packetTohost
.
entrySet
())
{
int
tosend
=
es
.
getKey
();
NetworkHost
hs
=
this
.
hostlist
.
get
(
tosend
);
List
<
NetworkPacket
>
hspktlist
=
es
.
getValue
();
if
(!
hspktlist
.
isEmpty
()){
double
avband
=
this
.
downlinkbandwidth
/
hspktlist
.
size
();
...
...
@@ -157,13 +152,13 @@ public class EdgeSwitch extends Switch{
}
hspktlist
.
clear
();
}
}
}
}
//or to switch at next level.
//clear the list
}
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/NetDatacenterBroker.java
View file @
4f25a01a
...
...
@@ -13,14 +13,8 @@ import java.util.HashMap;
import
java.util.LinkedList
;
import
java.util.List
;
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.CloudletSchedulerSpaceShared
;
import
org.cloudbus.cloudsim.DatacenterCharacteristics
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Vm
;
...
...
@@ -29,14 +23,13 @@ import org.cloudbus.cloudsim.core.CloudSimTags;
import
org.cloudbus.cloudsim.core.SimEntity
;
import
org.cloudbus.cloudsim.core.SimEvent
;
import
org.cloudbus.cloudsim.distributions.UniformDistr
;
import
org.cloudbus.cloudsim.lists.CloudletList
;
import
org.cloudbus.cloudsim.lists.VmList
;
/**
* NetDatacentreBroker represents a broker acting on behalf of Datacenter
* provider. It hides VM management, as vm creation, submission of cloudlets to
* this VMs and destruction of VMs. NOTE- It is an example only. It work on behalf of a provider not for
* users. One has to implement interaction with user broker to this broker.
* users. One has to implement interaction with user broker to this broker.
*
* @author Saurabh Kumar Garg
* @since CloudSim Toolkit 3.0
...
...
@@ -56,7 +49,7 @@ public class NetDatacenterBroker extends SimEntity {
private
List
<?
extends
AppCloudlet
>
appCloudletList
;
/** The Appcloudlet submitted list. */
private
Map
<
Integer
,
Integer
>
appCloudletRecieved
;
private
final
Map
<
Integer
,
Integer
>
appCloudletRecieved
;
private
List
<?
extends
Cloudlet
>
cloudletSubmittedList
;
...
...
@@ -170,8 +163,8 @@ public class NetDatacenterBroker extends SimEntity {
// public void bindCloudletToVm(int cloudletId, int vmId){
// CloudletList.getById(getCloudletList(), cloudletId).setVmId(vmId);
// }
public
void
setLinkDC
(
NetworkDatacenter
linkDC
)
{
this
.
linkDC
=
linkDC
;
public
void
setLinkDC
(
NetworkDatacenter
a
linkDC
)
{
linkDC
=
a
linkDC
;
}
/**
...
...
@@ -191,26 +184,27 @@ public class NetDatacenterBroker extends SimEntity {
case
CloudSimTags
.
RESOURCE_CHARACTERISTICS_REQUEST
:
processResourceCharacteristicsRequest
(
ev
);
break
;
// Resource characteristics answer
// Resource characteristics answer
case
CloudSimTags
.
RESOURCE_CHARACTERISTICS
:
processResourceCharacteristics
(
ev
);
break
;
// VM Creation answer
// VM Creation answer
// A finished cloudlet returned
// A finished cloudlet returned
case
CloudSimTags
.
CLOUDLET_RETURN
:
processCloudletReturn
(
ev
);
break
;
// if the simulation finishes
// if the simulation finishes
case
CloudSimTags
.
END_OF_SIMULATION
:
shutdownEntity
();
break
;
case
CloudSimTags
.
NextCycle
:
if
(
NetworkConstants
.
BASE
)
this
.
createVmsInDatacenterBase
(
this
.
linkDC
.
getId
());
if
(
NetworkConstants
.
BASE
)
{
this
.
createVmsInDatacenterBase
(
linkDC
.
getId
());
}
break
;
// other unknown tags are processed by this method
// other unknown tags are processed by this method
default
:
processOtherEvent
(
ev
);
break
;
...
...
@@ -229,7 +223,7 @@ public class NetDatacenterBroker extends SimEntity {
*/
protected
void
processResourceCharacteristics
(
SimEvent
ev
)
{
DatacenterCharacteristics
characteristics
=
(
DatacenterCharacteristics
)
ev
.
getData
();
.
getData
();
getDatacenterCharacteristicsList
().
put
(
characteristics
.
getId
(),
characteristics
);
...
...
@@ -341,8 +335,6 @@ public class NetDatacenterBroker extends SimEntity {
// send as much vms as possible for this datacenter before trying the
// next one
int
requestedVms
=
0
;
String
datacenterName
=
CloudSim
.
getEntityName
(
datacenterId
);
int
j
=
0
;
// All host will have two VMs (assumption) VM is the minimum unit
...
...
@@ -360,16 +352,14 @@ public class NetDatacenterBroker extends SimEntity {
NetworkConstants
.
currentAppId
++;
}
int
seed
=
5
;
int
k
=
0
;
int
totalvm
=
this
.
vmsCreatedList
.
size
();
int
currentvmid
=
0
;
//schedule the application on VMs
for
(
AppCloudlet
app
:
this
.
getAppCloudletList
())
{
List
<
Integer
>
vmids
=
new
ArrayList
<
Integer
>();
int
numVms
=
this
.
linkDC
.
getVmList
().
size
();
int
numVms
=
linkDC
.
getVmList
().
size
();
UniformDistr
ufrnd
=
new
UniformDistr
(
0
,
numVms
,
5
);
for
(
int
i
=
0
;
i
<
app
.
numbervm
;
i
++)
{
...
...
@@ -409,18 +399,17 @@ public class NetDatacenterBroker extends SimEntity {
CloudSimTags
.
NextCycle
);
}
setVmsRequested
(
requestedVms
);
setVmsAcks
(
0
);
}
private
void
CreateVMs
(
int
datacenterId
)
{
// TODO Auto-generated method stub
int
numVM
=
this
.
linkDC
.
getHostList
().
size
()
*
NetworkConstants
.
maxhostVM
;
// two
// VMs
// per
// host
int
numVM
=
linkDC
.
getHostList
().
size
()
*
NetworkConstants
.
maxhostVM
;
// two
// VMs
// per
// host
for
(
int
i
=
0
;
i
<
numVM
;
i
++)
{
int
requestedVms
=
0
;
int
vmid
=
i
;
...
...
@@ -429,14 +418,14 @@ public class NetDatacenterBroker extends SimEntity {
int
ram
=
512
;
// vm memory (MB)
long
bw
=
1000
;
int
pesNumber
=
NetworkConstants
.
HOST_PEs
/
NetworkConstants
.
maxhostVM
;
// number
// of
// cpus
// of
// cpus
String
vmm
=
"Xen"
;
// VMM name
// create VM
NetworkVm
vm
=
new
NetworkVm
(
vmid
,
this
.
getId
(),
mips
,
pesNumber
,
ram
,
bw
,
size
,
vmm
,
new
NetworkCloudletSpaceSharedScheduler
());
this
.
linkDC
.
processVmCreateNetwork
(
vm
);
linkDC
.
processVmCreateNetwork
(
vm
);
// add the VM to the vmList
getVmList
().
add
(
vm
);
requestedVms
++;
...
...
@@ -545,6 +534,7 @@ public class NetDatacenterBroker extends SimEntity {
this
.
cloudletList
=
cloudletList
;
}
@SuppressWarnings
(
"unchecked"
)
public
<
T
extends
AppCloudlet
>
List
<
T
>
getAppCloudletList
()
{
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;
import
org.cloudbus.cloudsim.Cloudlet
;
import
org.cloudbus.cloudsim.UtilizationModel
;
/**
* NetworkCloudlet class extends Cloudlet to support simulation of complex
applications.
*
Each such network Cloudlet represents a task of the application. Each task consists of several
*
stages.
* NetworkCloudlet class extends Cloudlet to support simulation of complex
*
applications. Each such network Cloudlet represents a task of the
*
application. Each task consists of several stages.
*
* Please refer to following publication for more details:
*
...
...
@@ -16,54 +17,61 @@ import org.cloudbus.cloudsim.UtilizationModel;
* Applications in Cloud Simulations, Proceedings of the 4th IEEE/ACM
* International Conference on Utility and Cloud Computing (UCC 2011, IEEE CS
* Press, USA), Melbourne, Australia, December 5-7, 2011.
*
*
*
* @author Saurabh Kumar Garg
* @since CloudSim Toolkit 1.0
*/
public
class
NetworkCloudlet
extends
Cloudlet
implements
Comparable
{
public
class
NetworkCloudlet
extends
Cloudlet
implements
Comparable
<
Object
>
{
long
memory
;
public
NetworkCloudlet
(
int
cloudletId
,
long
cloudletLength
,
int
pesNumber
,
long
cloudletFileSize
,
long
cloudletOutputSize
,
long
memory
,
public
NetworkCloudlet
(
int
cloudletId
,
long
cloudletLength
,
int
pesNumber
,
long
cloudletFileSize
,
long
cloudletOutputSize
,
long
memory
,
UtilizationModel
utilizationModelCpu
,
UtilizationModel
utilizationModelRam
,
UtilizationModel
utilizationModelBw
)
{
super
(
cloudletId
,
cloudletLength
,
pesNumber
,
cloudletFileSize
,
cloudletOutputSize
,
utilizationModelCpu
,
utilizationModelRam
,
super
(
cloudletId
,
cloudletLength
,
pesNumber
,
cloudletFileSize
,
cloudletOutputSize
,
utilizationModelCpu
,
utilizationModelRam
,
utilizationModelBw
);
// TODO Auto-generated constructor stub
currStagenum
=
-
1
;
this
.
memory
=
memory
;
stages
=
new
ArrayList
<
TaskStage
>();
}
public
double
submittime
;
//time when cloudlet will be submitted
public
double
finishtime
;
//time when cloudlet finish execution
public
double
exetime
;
//execution time for cloudlet
public
double
numStage
;
//number of stages in cloudlet
public
int
currStagenum
;
//current stage of cloudlet execution
public
double
submittime
;
//
time when cloudlet will be submitted
public
double
finishtime
;
//
time when cloudlet finish execution
public
double
exetime
;
//
execution time for cloudlet
public
double
numStage
;
//
number of stages in cloudlet
public
int
currStagenum
;
//
current stage of cloudlet execution
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
ArrayList
<
TaskStage
>
stages
;
//all stages which cloudlet execution consists of.
public
ArrayList
<
TaskStage
>
stages
;
// all stages which cloudlet execution
// consists of.
public
double
starttime
;
@Override
public
int
compareTo
(
Object
arg0
)
{
// TODO Auto-generated method stub
NetworkCloudlet
s1
=
(
NetworkCloudlet
)
arg0
;
int
alpha
=
0
;
return
0
;
}
public
double
getSubmittime
()
{
// TODO Auto-generated method stub
return
submittime
;
}
;
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/NetworkCloudletSpaceSharedScheduler.java
View file @
4f25a01a
This diff is collapsed.
Click to expand it.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/NetworkConstants.java
View file @
4f25a01a
package
org
.
cloudbus
.
cloudsim
.
network
.
datacenter
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
NetworkConstants
{
public
static
int
maxhostVM
=
2
;
public
static
int
HOST_PEs
=
8
;
public
static
int
maxhostVM
=
2
;
public
static
int
HOST_PEs
=
8
;
public
static
double
maxMemperVM
=
1024
*
1024
;
// kb
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
int
currentAppId
=
0
;
public
static
final
int
PES_NUMBER
=
4
;
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
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
boolean
BASE
=
true
;
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
final
int
ROOT_LEVEL
=
0
;
public
static
final
int
Agg_LEVEL
=
1
;
public
static
final
int
EDGE_LEVEL
=
2
;
public
static
double
EdgeSwitchPort
=
4
;
// number of host
public
static
final
int
PES_NUMBER
=
4
;
public
static
final
int
FILE_SIZE
=
300
;
public
static
final
int
OUTPUT_SIZE
=
300
;
public
static
double
AggSwitchPort
=
1
;
// number of Edge
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
long
BandWidthEdgeHost
=
100
*
1024
*
1024
;
//
public
static
long
BandWidthAggRoot
=
20
*
1024
*
1024
*
2
;
//40gb
public
static
int
iteration
=
10
;
public
static
int
nexttime
=
1000
;
public
static
double
SwitchingDelayRoot
=.
002
85
;
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
;
public
static
int
totaldatatransfer
=
0
;
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/NetworkDatacenter.java
View file @
4f25a01a
This diff is collapsed.
Click to expand it.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/NetworkHost.java
View file @
4f25a01a
...
...
@@ -9,13 +9,10 @@
package
org
.
cloudbus
.
cloudsim
.
network
.
datacenter
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map.Entry
;
import
org.cloudbus.cloudsim.Datacenter
;
import
org.cloudbus.cloudsim.Host
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Pe
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.VmScheduler
;
...
...
@@ -27,11 +24,11 @@ import org.cloudbus.cloudsim.provisioners.BwProvisioner;
import
org.cloudbus.cloudsim.provisioners.RamProvisioner
;
/**
* NetworkHost class extends Host to support simulation of networked
datacenters.
*
It executes actions related to management of packets (send and receive)other than that of
*
virtual machines (e.g., creation and destruction). A host has a defined
*
policy for provisioning memory and bw, as well as an allocation policy for
* Pe's to virtual machines.
* NetworkHost class extends Host to support simulation of networked
*
datacenters. It executes actions related to management of packets (send and
*
receive)other than that of virtual machines (e.g., creation and destruction).
*
A host has a defined policy for provisioning memory and bw, as well as an
*
allocation policy for
Pe's to virtual machines.
*
* Please refer to following publication for more details:
*
...
...
@@ -39,10 +36,10 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner;
* Applications in Cloud Simulations, Proceedings of the 4th IEEE/ACM
* International Conference on Utility and Cloud Computing (UCC 2011, IEEE CS
* Press, USA), Melbourne, Australia, December 5-7, 2011.
*
*
*
* @author Saurabh Kumar Garg
* @since CloudSim Toolkit
1
.0
* @since CloudSim Toolkit
3
.0
*/
public
class
NetworkHost
extends
Host
{
...
...
@@ -50,20 +47,24 @@ public class NetworkHost extends Host {
public
List
<
NetworkPacket
>
packetTosendGlobal
;
public
List
<
NetworkPacket
>
packetrecieved
;
public
double
memory
;
public
Switch
sw
;
//Edge switch in general
public
Switch
sw
;
//
Edge switch in general
public
double
bandwidth
;
// latency
public
List
<
Double
>
CPUfinTimeCPU
=
new
ArrayList
<
Double
>();
// time when
// last job will
// finish on
// CPU1
// last job will
// finish on
// CPU1
public
double
fintime
=
0
;
public
NetworkHost
(
int
id
,
RamProvisioner
ramProvisioner
,
BwProvisioner
bwProvisioner
,
long
storage
,
List
<?
extends
Pe
>
peList
,
VmScheduler
vmScheduler
)
{
public
NetworkHost
(
int
id
,
RamProvisioner
ramProvisioner
,
BwProvisioner
bwProvisioner
,
long
storage
,
List
<?
extends
Pe
>
peList
,
VmScheduler
vmScheduler
)
{
super
(
id
,
ramProvisioner
,
bwProvisioner
,
storage
,
peList
,
vmScheduler
);
this
.
packetrecieved
=
new
ArrayList
<
NetworkPacket
>();
this
.
packetTosendGlobal
=
new
ArrayList
<
NetworkPacket
>();
this
.
packetTosendLocal
=
new
ArrayList
<
NetworkPacket
>();
...
...
@@ -79,11 +80,12 @@ public class NetworkHost extends Host {
*
* @return expected time of completion of the next cloudlet in all VMs in
* this host. Double.MAX_VALUE if there is no future events expected
* in th
is host
* in th is host
*
* @pre currentTime >= 0.0
* @post $none
*/
@Override
public
double
updateVmsProcessing
(
double
currentTime
)
{
double
smallerTime
=
Double
.
MAX_VALUE
;
// insert in each vm packet recieved
...
...
@@ -93,18 +95,19 @@ public class NetworkHost extends Host {
// continue;
// }
double
time
=
((
NetworkVm
)
vm
).
updateVmProcessing
(
currentTime
,
getVmScheduler
()
.
getAllocatedMipsForVm
(
vm
));
double
time
=
((
NetworkVm
)
vm
).
updateVmProcessing
(
currentTime
,
getVmScheduler
()
.
getAllocatedMipsForVm
(
vm
));
if
(
time
>
0.0
&&
time
<
smallerTime
)
{
smallerTime
=
time
;
}
}
//send the packets to other hosts/VMs
//
send the packets to other hosts/VMs
sendpackets
();
return
smallerTime
;
}
/**
* Receives packet and forward it to the corresponding VM for processing
* host.
...
...
@@ -112,49 +115,49 @@ public class NetworkHost extends Host {
*
*/
private
void
recvpackets
()
{
for
(
NetworkPacket
hs
:
packetrecieved
)
{
// hs.stime=hs.rtime;
hs
.
pkt
.
recievetime
=
CloudSim
.
clock
();
// insertthe packet in recievedlist of VM
Vm
vm
=
VmList
.
getById
(
getVmList
(),
hs
.
pkt
.
reciever
);
List
<
HostPacket
>
pktlist
=
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
get
CloudletScheduler
()).
pktrecv
.
get
(
hs
.
pkt
.
sender
);
List
<
HostPacket
>
pktlist
=
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pktrecv
.
get
(
hs
.
pkt
.
sender
);
if
(
pktlist
==
null
)
{
pktlist
=
new
ArrayList
<
HostPacket
>();
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pktrecv
.
put
(
hs
.
pkt
.
sender
,
pktlist
);
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pktrecv
.
put
(
hs
.
pkt
.
sender
,
pktlist
);
}
pktlist
.
add
(
hs
.
pkt
);
}
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
()
{
for
(
Vm
vm
:
super
.
getVmList
())
{
for
(
Entry
<
Integer
,
List
<
HostPacket
>>
es
:
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pkttosend
.
entrySet
())
{
.
getCloudletScheduler
()).
pkttosend
.
entrySet
())
{
List
<
HostPacket
>
pktlist
=
es
.
getValue
();
for
(
HostPacket
pkt
:
pktlist
)
{
NetworkPacket
hpkt
=
new
NetworkPacket
(
this
.
getId
(),
pkt
,
vm
.
getId
(),
pkt
.
sender
);
Vm
vm2
=
VmList
.
getById
(
this
.
getVmList
(),
hpkt
.
recievervmid
);
if
(
vm2
!=
null
)
NetworkPacket
hpkt
=
new
NetworkPacket
(
this
.
getId
(),
pkt
,
vm
.
getId
(),
pkt
.
sender
);
Vm
vm2
=
VmList
.
getById
(
this
.
getVmList
(),
hpkt
.
recievervmid
);
if
(
vm2
!=
null
)
{
this
.
packetTosendLocal
.
add
(
hpkt
);
else
}
else
{
this
.
packetTosendGlobal
.
add
(
hpkt
);
}
}
pktlist
.
clear
();
...
...
@@ -172,12 +175,13 @@ public class NetworkHost extends Host {
Vm
vm
=
VmList
.
getById
(
getVmList
(),
hs
.
pkt
.
reciever
);
// Vm vm=getVmList().get(hs.pkt.reciever);
List
<
HostPacket
>
pktlist
=
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
get
CloudletScheduler
()).
pktrecv
.
get
(
hs
.
pkt
.
sender
);
List
<
HostPacket
>
pktlist
=
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pktrecv
.
get
(
hs
.
pkt
.
sender
);
if
(
pktlist
==
null
)
{
pktlist
=
new
ArrayList
<
HostPacket
>();
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pktrecv
.
put
(
hs
.
pkt
.
sender
,
pktlist
);
((
NetworkCloudletSpaceSharedScheduler
)
vm
.
getCloudletScheduler
()).
pktrecv
.
put
(
hs
.
pkt
.
sender
,
pktlist
);
}
pktlist
.
add
(
hs
.
pkt
);
...
...
@@ -188,14 +192,14 @@ public class NetworkHost extends Host {
// continue;
// }
double
time
=
((
NetworkVm
)
vm
).
updateVmProcessing
(
CloudSim
.
clock
(),
getVmScheduler
().
getAllocatedMipsForVm
(
vm
));
vm
.
updateVmProcessing
(
CloudSim
.
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
();
double
avband
=
this
.
bandwidth
/
packetTosendGlobal
.
size
();
for
(
NetworkPacket
hs
:
packetTosendGlobal
)
{
...
...
@@ -203,16 +207,19 @@ public class NetworkHost extends Host {
NetworkConstants
.
totaldatatransfer
+=
hs
.
pkt
.
data
;
// System.out.println(hs.pkt.virtualsendid+" "+hs.pkt.virtualrecvid+" "+hs.pkt.data);
CloudSim
.
send
(
this
.
getDatacenter
().
getId
(),
this
.
sw
.
getId
(),
delay
,
CloudSimTags
.
Network_Event_UP
,
hs
);
CloudSim
.
send
(
this
.
getDatacenter
().
getId
(),
this
.
sw
.
getId
(),
delay
,
CloudSimTags
.
Network_Event_UP
,
hs
);
// send to switch with delay
}
this
.
packetTosendGlobal
.
clear
();
}
@SuppressWarnings
(
"unchecked"
)
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
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.cloudbus.cloudsim.CloudletScheduler
;
import
org.cloudbus.cloudsim.Vm
;
/**
* NetworkVm class extends Vm to support simulation of networked datacenters.
*
It
executes actions related to management of packets (send and receive).
* NetworkVm class extends Vm to support simulation of networked datacenters.
It
* executes actions related to management of packets (send and receive).
*
* Please refer to following publication for more details:
*
...
...
@@ -16,19 +15,26 @@ import org.cloudbus.cloudsim.Vm;
* Applications in Cloud Simulations, Proceedings of the 4th IEEE/ACM
* International Conference on Utility and Cloud Computing (UCC 2011, IEEE CS
* Press, USA), Melbourne, Australia, December 5-7, 2011.
*
*
*
* @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
>();
}
...
...
@@ -45,10 +51,12 @@ public class NetworkVm extends Vm implements Comparable {
public
int
compareTo
(
Object
arg0
)
{
NetworkVm
hs
=
(
NetworkVm
)
arg0
;
if
(
hs
.
finishtime
>
this
.
finishtime
)
if
(
hs
.
finishtime
>
this
.
finishtime
)
{
return
-
1
;
if
(
hs
.
finishtime
<
this
.
finishtime
)
}
if
(
hs
.
finishtime
<
this
.
finishtime
)
{
return
1
;
}
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;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.SortedMap
;
import
java.util.TreeMap
;
import
java.util.Map.Entry
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Vm
;
...
...
@@ -67,30 +67,7 @@ public class Switch extends SimEntity {
public
Switch
(
String
name
,
int
level
,
NetworkDatacenter
dc
)
{
super
(
name
);
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
;
// TODO Auto-generated constructor stub
}
@Override
...
...
@@ -104,34 +81,33 @@ public class Switch extends SimEntity {
// Log.printLine(CloudSim.clock()+"[Broker]: event received:"+ev.getTag());
switch
(
ev
.
getTag
())
{
// Resource characteristics request
case
CloudSimTags
.
Network_Event_UP
:
// process the packet from down switch or host
processpacket_up
(
ev
);
break
;
case
CloudSimTags
.
Network_Event_DOWN
:
// process the packet from uplink
processpacket_down
(
ev
);
break
;
case
CloudSimTags
.
Network_Event_send
:
processpacketforward
(
ev
);
break
;
case
CloudSimTags
.
Network_Event_Host
:
processhostpacket
(
ev
);
break
;
// Resource characteristics answer
case
CloudSimTags
.
RESOURCE_Register
:
registerHost
(
ev
);
break
;
// other unknown tags are processed by this method
default
:
processOtherEvent
(
ev
);
break
;
case
CloudSimTags
.
Network_Event_UP
:
// process the packet from down switch or host
processpacket_up
(
ev
);
break
;
case
CloudSimTags
.
Network_Event_DOWN
:
// process the packet from uplink
processpacket_down
(
ev
);
break
;
case
CloudSimTags
.
Network_Event_send
:
processpacketforward
(
ev
);
break
;
case
CloudSimTags
.
Network_Event_Host
:
processhostpacket
(
ev
);
break
;
// Resource characteristics answer
case
CloudSimTags
.
RESOURCE_Register
:
registerHost
(
ev
);
break
;
// other unknown tags are processed by this method
default
:
processOtherEvent
(
ev
);
break
;
}
}
protected
void
processhostpacket
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
// Send packet to host
NetworkPacket
hspkt
=
(
NetworkPacket
)
ev
.
getData
();
NetworkHost
hs
=
hostlist
.
get
(
hspkt
.
recieverhostid
);
...
...
@@ -139,7 +115,6 @@ public class Switch extends SimEntity {
}
protected
void
processpacket_down
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
// packet coming from up level router.
// has to send downward
// check which switch to forward to
...
...
@@ -178,7 +153,6 @@ public class Switch extends SimEntity {
}
protected
void
processpacket_up
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
// packet coming from down level router.
// has to send up
// check which switch to forward to
...
...
@@ -277,13 +251,11 @@ public class Switch extends SimEntity {
}
private
void
registerHost
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
NetworkHost
hs
=
(
NetworkHost
)
ev
.
getData
();
hostlist
.
put
(
hs
.
getId
(),
(
NetworkHost
)
ev
.
getData
());
}
protected
void
processpacket
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
// send packet to itself with switching delay (discarding other)
CloudSim
.
cancelAll
(
getId
(),
new
PredicateType
(
CloudSimTags
.
Network_Event_UP
));
schedule
(
getId
(),
switching_delay
,
CloudSimTags
.
Network_Event_UP
);
...
...
@@ -294,12 +266,10 @@ public class Switch extends SimEntity {
}
private
void
processOtherEvent
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
}
protected
void
processpacketforward
(
SimEvent
ev
)
{
// TODO Auto-generated method stub
// search for the host and packets..send to them
if
(
downlinkswitchpktlist
!=
null
)
{
...
...
@@ -338,8 +308,6 @@ public class Switch extends SimEntity {
}
if
(
packetTohost
!=
null
)
{
for
(
Entry
<
Integer
,
List
<
NetworkPacket
>>
es
:
packetTohost
.
entrySet
())
{
int
tosend
=
es
.
getKey
();
NetworkHost
hs
=
hostlist
.
get
(
tosend
);
List
<
NetworkPacket
>
hspktlist
=
es
.
getValue
();
if
(!
hspktlist
.
isEmpty
())
{
double
avband
=
downlinkbandwidth
/
hspktlist
.
size
();
...
...
@@ -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
())
{
Vm
vm
=
VmList
.
getById
(
es
.
getValue
().
getVmList
(),
vmid
);
if
(
vm
!=
null
)
{
...
...
@@ -371,8 +342,7 @@ public class Switch extends SimEntity {
return
null
;
}
private
List
<
NetworkVm
>
getfreeVmlist
(
int
numVMReq
)
{
// TODO Auto-generated method stub
protected
List
<
NetworkVm
>
getfreeVmlist
(
int
numVMReq
)
{
List
<
NetworkVm
>
freehostls
=
new
ArrayList
<
NetworkVm
>();
for
(
Entry
<
Integer
,
NetworkVm
>
et
:
Vmlist
.
entrySet
())
{
if
(
et
.
getValue
().
isFree
())
{
...
...
@@ -386,8 +356,7 @@ public class Switch extends SimEntity {
return
freehostls
;
}
private
List
<
NetworkHost
>
getfreehostlist
(
int
numhost
)
{
// TODO Auto-generated method stub
protected
List
<
NetworkHost
>
getfreehostlist
(
int
numhost
)
{
List
<
NetworkHost
>
freehostls
=
new
ArrayList
<
NetworkHost
>();
for
(
Entry
<
Integer
,
NetworkHost
>
et
:
hostlist
.
entrySet
())
{
if
(
et
.
getValue
().
getNumberOfFreePes
()
==
et
.
getValue
().
getNumberOfPes
())
{
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/network/datacenter/WorkflowApp.java
View file @
4f25a01a
...
...
@@ -22,67 +22,112 @@ import org.cloudbus.cloudsim.UtilizationModel;
import
org.cloudbus.cloudsim.UtilizationModelFull
;
import
org.cloudbus.cloudsim.core.CloudSim
;
public
class
WorkflowApp
extends
AppCloudlet
{
public
class
WorkflowApp
extends
AppCloudlet
{
public
WorkflowApp
(
int
type
,
int
appID
,
double
deadline
,
int
numbervm
,
int
userId
)
{
super
(
type
,
appID
,
deadline
,
numbervm
,
userId
);
// TODO Auto-generated constructor stub
this
.
exeTime
=
100
;
this
.
numbervm
=
3
;
public
WorkflowApp
(
int
type
,
int
appID
,
double
deadline
,
int
numbervm
,
int
userId
)
{
super
(
type
,
appID
,
deadline
,
numbervm
,
userId
);
this
.
exeTime
=
100
;
this
.
numbervm
=
3
;
}
public
void
createCloudletList
(
List
<
Integer
>
vmIdList
){
@Override
public
void
createCloudletList
(
List
<
Integer
>
vmIdList
)
{
long
fileSize
=
NetworkConstants
.
FILE_SIZE
;
long
outputSize
=
NetworkConstants
.
OUTPUT_SIZE
;
int
pesNumber
=
NetworkConstants
.
PES_NUMBER
;
int
memory
=
100
;
int
memory
=
100
;
UtilizationModel
utilizationModel
=
new
UtilizationModelFull
();
int
i
=
0
;
//Task A
NetworkCloudlet
cl
=
new
NetworkCloudlet
(
NetworkConstants
.
currentCloudletId
,
0
,
1
,
fileSize
,
outputSize
,
memory
,
utilizationModel
,
utilizationModel
,
utilizationModel
);
cl
.
numStage
=
2
;
NetworkConstants
.
currentCloudletId
++;
cl
.
setUserId
(
userId
);
cl
.
submittime
=
CloudSim
.
clock
();
cl
.
currStagenum
=-
1
;
cl
.
setVmId
(
vmIdList
.
get
(
i
));
//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
.
WAIT_SEND
,
1000
,
0
,
1
,
memory
,
vmIdList
.
get
(
2
),
cl
.
getCloudletId
()+
2
));
clist
.
add
(
cl
);
i
++;
//Task B
NetworkCloudlet
clb
=
new
NetworkCloudlet
(
NetworkConstants
.
currentCloudletId
,
0
,
1
,
fileSize
,
outputSize
,
memory
,
utilizationModel
,
utilizationModel
,
utilizationModel
);
clb
.
numStage
=
2
;
NetworkConstants
.
currentCloudletId
++;
clb
.
setUserId
(
userId
);
clb
.
submittime
=
CloudSim
.
clock
();
clb
.
currStagenum
=-
1
;
clb
.
setVmId
(
vmIdList
.
get
(
i
));
//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
(
NetworkConstants
.
WAIT_SEND
,
1000
,
0
,
1
,
memory
,
vmIdList
.
get
(
2
),
clb
.
getCloudletId
()+
1
));
clist
.
add
(
clb
);
i
++;
//Task C
NetworkCloudlet
clc
=
new
NetworkCloudlet
(
NetworkConstants
.
currentCloudletId
,
0
,
1
,
fileSize
,
outputSize
,
memory
,
utilizationModel
,
utilizationModel
,
utilizationModel
);
clc
.
numStage
=
2
;
NetworkConstants
.
currentCloudletId
++;
clc
.
setUserId
(
userId
);
clc
.
submittime
=
CloudSim
.
clock
();
clc
.
currStagenum
=-
1
;
clc
.
setVmId
(
vmIdList
.
get
(
i
));
//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
,
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
);
int
i
=
0
;
// Task A
NetworkCloudlet
cl
=
new
NetworkCloudlet
(
NetworkConstants
.
currentCloudletId
,
0
,
1
,
fileSize
,
outputSize
,
memory
,
utilizationModel
,
utilizationModel
,
utilizationModel
);
cl
.
numStage
=
2
;
NetworkConstants
.
currentCloudletId
++;
cl
.
setUserId
(
userId
);
cl
.
submittime
=
CloudSim
.
clock
();
cl
.
currStagenum
=
-
1
;
cl
.
setVmId
(
vmIdList
.
get
(
i
));
// 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
.
WAIT_SEND
,
1000
,
0
,
1
,
memory
,
vmIdList
.
get
(
2
),
cl
.
getCloudletId
()
+
2
));
clist
.
add
(
cl
);
i
++;
// Task B
NetworkCloudlet
clb
=
new
NetworkCloudlet
(
NetworkConstants
.
currentCloudletId
,
0
,
1
,
fileSize
,
outputSize
,
memory
,
utilizationModel
,
utilizationModel
,
utilizationModel
);
clb
.
numStage
=
2
;
NetworkConstants
.
currentCloudletId
++;
clb
.
setUserId
(
userId
);
clb
.
submittime
=
CloudSim
.
clock
();
clb
.
currStagenum
=
-
1
;
clb
.
setVmId
(
vmIdList
.
get
(
i
));
// 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
(
NetworkConstants
.
WAIT_SEND
,
1000
,
0
,
1
,
memory
,
vmIdList
.
get
(
2
),
clb
.
getCloudletId
()
+
1
));
clist
.
add
(
clb
);
i
++;
// Task C
NetworkCloudlet
clc
=
new
NetworkCloudlet
(
NetworkConstants
.
currentCloudletId
,
0
,
1
,
fileSize
,
outputSize
,
memory
,
utilizationModel
,
utilizationModel
,
utilizationModel
);
clc
.
numStage
=
2
;
NetworkConstants
.
currentCloudletId
++;
clc
.
setUserId
(
userId
);
clc
.
submittime
=
CloudSim
.
clock
();
clc
.
currStagenum
=
-
1
;
clc
.
setVmId
(
vmIdList
.
get
(
i
));
// 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
,
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
);
}
}
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