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
841a9352
Commit
841a9352
authored
Feb 04, 2016
by
Manoel Campos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documentation of package org.cloudbus.cloudsim.core improved.
parent
e0205e64
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
247 additions
and
197 deletions
+247
-197
CloudletSchedulerTimeShared.java
...va/org/cloudbus/cloudsim/CloudletSchedulerTimeShared.java
+3
-0
Datacenter.java
...udsim/src/main/java/org/cloudbus/cloudsim/Datacenter.java
+3
-11
DatacenterBroker.java
...src/main/java/org/cloudbus/cloudsim/DatacenterBroker.java
+1
-1
Log.java
...les/cloudsim/src/main/java/org/cloudbus/cloudsim/Log.java
+2
-0
UtilizationModelFull.java
...main/java/org/cloudbus/cloudsim/UtilizationModelFull.java
+3
-1
Vm.java
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/Vm.java
+8
-1
CloudInformationService.java
...a/org/cloudbus/cloudsim/core/CloudInformationService.java
+37
-22
CloudSim.java
...im/src/main/java/org/cloudbus/cloudsim/core/CloudSim.java
+2
-2
CloudSimShutdown.java
...ain/java/org/cloudbus/cloudsim/core/CloudSimShutdown.java
+28
-26
CloudSimTags.java
...rc/main/java/org/cloudbus/cloudsim/core/CloudSimTags.java
+51
-44
DeferredQueue.java
...c/main/java/org/cloudbus/cloudsim/core/DeferredQueue.java
+5
-5
FutureQueue.java
...src/main/java/org/cloudbus/cloudsim/core/FutureQueue.java
+10
-6
SimEntity.java
...m/src/main/java/org/cloudbus/cloudsim/core/SimEntity.java
+68
-64
SimEvent.java
...im/src/main/java/org/cloudbus/cloudsim/core/SimEvent.java
+25
-14
Predicate.java
...java/org/cloudbus/cloudsim/core/predicates/Predicate.java
+1
-0
No files found.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/CloudletSchedulerTimeShared.java
View file @
841a9352
...
@@ -280,6 +280,9 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
...
@@ -280,6 +280,9 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
@Override
@Override
public
double
getTotalUtilizationOfCpu
(
double
time
)
{
public
double
getTotalUtilizationOfCpu
(
double
time
)
{
/*
* @todo
*/
double
totalUtilization
=
0
;
double
totalUtilization
=
0
;
for
(
ResCloudlet
gl
:
getCloudletExecList
())
{
for
(
ResCloudlet
gl
:
getCloudletExecList
())
{
totalUtilization
+=
gl
.
getCloudlet
().
getUtilizationOfCpu
(
time
);
totalUtilization
+=
gl
.
getCloudlet
().
getUtilizationOfCpu
(
time
);
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/Datacenter.java
View file @
841a9352
...
@@ -1045,31 +1045,23 @@ public class Datacenter extends SimEntity {
...
@@ -1045,31 +1045,23 @@ public class Datacenter extends SimEntity {
return
msg
;
return
msg
;
}
}
/*
* (non-Javadoc)
* @see cloudsim.core.SimEntity#shutdownEntity()
*/
@Override
@Override
public
void
shutdownEntity
()
{
public
void
shutdownEntity
()
{
Log
.
printConcatLine
(
getName
(),
" is shutting down..."
);
Log
.
printConcatLine
(
getName
(),
" is shutting down..."
);
}
}
/*
* (non-Javadoc)
* @see cloudsim.core.SimEntity#startEntity()
*/
@Override
@Override
public
void
startEntity
()
{
public
void
startEntity
()
{
Log
.
printConcatLine
(
getName
(),
" is starting..."
);
Log
.
printConcatLine
(
getName
(),
" is starting..."
);
// this resource should register to regional
G
IS.
// this resource should register to regional
C
IS.
// However, if not specified, then register to system
G
IS (the
// However, if not specified, then register to system
C
IS (the
// default CloudInformationService) entity.
// default CloudInformationService) entity.
int
gisID
=
CloudSim
.
getEntityId
(
regionalCisName
);
int
gisID
=
CloudSim
.
getEntityId
(
regionalCisName
);
if
(
gisID
==
-
1
)
{
if
(
gisID
==
-
1
)
{
gisID
=
CloudSim
.
getCloudInfoServiceEntityId
();
gisID
=
CloudSim
.
getCloudInfoServiceEntityId
();
}
}
// send the registration to
G
IS
// send the registration to
C
IS
sendNow
(
gisID
,
CloudSimTags
.
REGISTER_RESOURCE
,
getId
());
sendNow
(
gisID
,
CloudSimTags
.
REGISTER_RESOURCE
,
getId
());
// Below method is for a child class to override
// Below method is for a child class to override
registerOtherEntity
();
registerOtherEntity
();
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/DatacenterBroker.java
View file @
841a9352
...
@@ -23,7 +23,7 @@ import org.cloudbus.cloudsim.lists.VmList;
...
@@ -23,7 +23,7 @@ import org.cloudbus.cloudsim.lists.VmList;
/**
/**
* DatacentreBroker represents a broker acting on behalf of a user. It hides VM management, as vm
* DatacentreBroker represents a broker acting on behalf of a user. It hides VM management, as vm
* creation, submission of cloudlets to
this
VMs and destruction of VMs.
* creation, submission of cloudlets to VMs and destruction of VMs.
*
*
* @author Rodrigo N. Calheiros
* @author Rodrigo N. Calheiros
* @author Anton Beloglazov
* @author Anton Beloglazov
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/Log.java
View file @
841a9352
...
@@ -17,6 +17,8 @@ import java.io.OutputStream;
...
@@ -17,6 +17,8 @@ import java.io.OutputStream;
*
*
* @author Anton Beloglazov
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
* @since CloudSim Toolkit 2.0
* @todo To add a method to print formatted text, such as the
* {@link String#format(java.lang.String, java.lang.Object...)} method.
*/
*/
public
class
Log
{
public
class
Log
{
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/UtilizationModelFull.java
View file @
841a9352
...
@@ -18,7 +18,9 @@ package org.cloudbus.cloudsim;
...
@@ -18,7 +18,9 @@ package org.cloudbus.cloudsim;
public
class
UtilizationModelFull
implements
UtilizationModel
{
public
class
UtilizationModelFull
implements
UtilizationModel
{
/**
/**
* Gets the utilization percentage of a given resource.
* Gets the utilization percentage of a given resource
* in relation to the total capacity of that resource allocated
* to the cloudlet.
* @param time the time to get the resource usage, that isn't considered
* @param time the time to get the resource usage, that isn't considered
* for this UtilizationModel.
* for this UtilizationModel.
* @return Always return 1 (100% of utilization), independent of the time.
* @return Always return 1 (100% of utilization), independent of the time.
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/Vm.java
View file @
841a9352
...
@@ -73,7 +73,14 @@ public class Vm {
...
@@ -73,7 +73,14 @@ public class Vm {
/** Indicates if the VM is being instantiated. */
/** Indicates if the VM is being instantiated. */
private
boolean
beingInstantiated
;
private
boolean
beingInstantiated
;
/** The mips allocation history. */
/** The mips allocation history.
* @todo Instead of using a list, this attribute would be
* a map, where the key can be the history time
* and the value the history itself.
* By this way, if one wants to get the history for a given
* time, he/she doesn't have to iterate over the entire list
* to find the desired entry.
*/
private
final
List
<
VmStateHistoryEntry
>
stateHistory
=
new
LinkedList
<
VmStateHistoryEntry
>();
private
final
List
<
VmStateHistoryEntry
>
stateHistory
=
new
LinkedList
<
VmStateHistoryEntry
>();
/**
/**
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/core/CloudInformationService.java
View file @
841a9352
...
@@ -30,23 +30,37 @@ import org.cloudbus.cloudsim.Log;
...
@@ -30,23 +30,37 @@ import org.cloudbus.cloudsim.Log;
*/
*/
public
class
CloudInformationService
extends
SimEntity
{
public
class
CloudInformationService
extends
SimEntity
{
/** For all types of hostList. */
/** A list containing the id of all entities that are registered at the
* Cloud Information Service (CIS).
* @todo It is not clear if this list is a list of host id's or datacenter id's.
* The previous attribute documentation just said "For all types of hostList".
* It can be seen at the method {@link #processEvent(org.cloudbus.cloudsim.core.SimEvent)}
* that the list is updated when a CloudSimTags.REGISTER_RESOURCE event
* is received. However, only the Datacenter class sends and event
* of this type, including its id as parameter.
*
*/
private
final
List
<
Integer
>
resList
;
private
final
List
<
Integer
>
resList
;
/** Only for AR hostList. */
/** A list containing only the id of entities with Advanced Reservation feature
* that are registered at the CIS. */
private
final
List
<
Integer
>
arList
;
private
final
List
<
Integer
>
arList
;
/** List of all regional
G
IS. */
/** List of all regional
C
IS. */
private
final
List
<
Integer
>
gisList
;
private
final
List
<
Integer
>
gisList
;
/**
/**
*
Alloc
ates a new CloudInformationService object.
*
Instanti
ates a new CloudInformationService object.
*
*
* @param name the name to be associated with this entity (as required by
SimEntity
class)
* @param name the name to be associated with this entity (as required by
{@link SimEntity}
class)
* @throws Exception
This happens
when creating this entity before initialising CloudSim package
* @throws Exception when creating this entity before initialising CloudSim package
* or this entity name is <tt>null</tt> or empty
* or this entity name is <tt>null</tt> or empty
* @pre name != null
* @pre name != null
* @post $none
* @post $none
*
* @todo The use of Exception is not recommended. Specific exceptions
* would be thrown (such as {@link IllegalArgumentException})
* or {@link RuntimeException}
*/
*/
public
CloudInformationService
(
String
name
)
throws
Exception
{
public
CloudInformationService
(
String
name
)
throws
Exception
{
super
(
name
);
super
(
name
);
...
@@ -56,14 +70,14 @@ public class CloudInformationService extends SimEntity {
...
@@ -56,14 +70,14 @@ public class CloudInformationService extends SimEntity {
}
}
/**
/**
* Starts the CloudInformationService entity
.
* The method has no effect at the current class
.
*/
*/
@Override
@Override
public
void
startEntity
()
{
public
void
startEntity
()
{
}
}
/**
/**
* Processes events scheduled for th
is entity
.
* Processes events scheduled for th
e CIS
.
*
*
* @param ev the event to be handled.
* @param ev the event to be handled.
* @see SimEntity#processEvent(SimEvent)
* @see SimEntity#processEvent(SimEvent)
...
@@ -72,12 +86,12 @@ public class CloudInformationService extends SimEntity {
...
@@ -72,12 +86,12 @@ public class CloudInformationService extends SimEntity {
public
void
processEvent
(
SimEvent
ev
)
{
public
void
processEvent
(
SimEvent
ev
)
{
int
id
=
-
1
;
// requester id
int
id
=
-
1
;
// requester id
switch
(
ev
.
getTag
())
{
switch
(
ev
.
getTag
())
{
// storing regional
G
IS id
// storing regional
C
IS id
case
CloudSimTags
.
REGISTER_REGIONAL_GIS
:
case
CloudSimTags
.
REGISTER_REGIONAL_GIS
:
gisList
.
add
((
Integer
)
ev
.
getData
());
gisList
.
add
((
Integer
)
ev
.
getData
());
break
;
break
;
// request for all regional
G
IS list
// request for all regional
C
IS list
case
CloudSimTags
.
REQUEST_REGIONAL_GIS
:
case
CloudSimTags
.
REQUEST_REGIONAL_GIS
:
// Get ID of an entity that send this event
// Get ID of an entity that send this event
...
@@ -135,7 +149,7 @@ public class CloudInformationService extends SimEntity {
...
@@ -135,7 +149,7 @@ public class CloudInformationService extends SimEntity {
/**
/**
* Gets the list of all CloudResource IDs, including hostList that support Advance Reservation.
* Gets the list of all CloudResource IDs, including hostList that support Advance Reservation.
*
*
* @return
LinkedL
ist containing resource IDs. Each ID is represented by an Integer object.
* @return
l
ist containing resource IDs. Each ID is represented by an Integer object.
* @pre $none
* @pre $none
* @post $none
* @post $none
*/
*/
...
@@ -146,7 +160,7 @@ public class CloudInformationService extends SimEntity {
...
@@ -146,7 +160,7 @@ public class CloudInformationService extends SimEntity {
/**
/**
* Gets the list of CloudResource IDs that <b>only</b> support Advanced Reservation.
* Gets the list of CloudResource IDs that <b>only</b> support Advanced Reservation.
*
*
* @return
LinkedL
ist containing resource IDs. Each ID is represented by an Integer object.
* @return
l
ist containing resource IDs. Each ID is represented by an Integer object.
* @pre $none
* @pre $none
* @post $none
* @post $none
*/
*/
...
@@ -228,10 +242,10 @@ public class CloudInformationService extends SimEntity {
...
@@ -228,10 +242,10 @@ public class CloudInformationService extends SimEntity {
// //////////////////////// PROTECTED METHODS ////////////////////////////
// //////////////////////// PROTECTED METHODS ////////////////////////////
/**
/**
* This method needs to override by
a child clas
s for processing other events. These events are
* This method needs to override by
child classe
s for processing other events. These events are
* based on tags that are not mentioned in {@link #body()} method.
* based on tags that are not mentioned in {@link #body()} method.
*
*
* @param ev a Sim
_e
vent object
* @param ev a Sim
E
vent object
* @pre ev != null
* @pre ev != null
* @post $none
* @post $none
*/
*/
...
@@ -248,7 +262,7 @@ public class CloudInformationService extends SimEntity {
...
@@ -248,7 +262,7 @@ public class CloudInformationService extends SimEntity {
/**
/**
* Notifies the registered entities about the end of simulation. This method should be
* Notifies the registered entities about the end of simulation. This method should be
* overridden by
the child class
* overridden by
child classes.
*/
*/
protected
void
processEndSimulation
()
{
protected
void
processEndSimulation
()
{
// this should be overridden by the child class
// this should be overridden by the child class
...
@@ -257,10 +271,10 @@ public class CloudInformationService extends SimEntity {
...
@@ -257,10 +271,10 @@ public class CloudInformationService extends SimEntity {
// ////////////////// End of PROTECTED METHODS ///////////////////////////
// ////////////////// End of PROTECTED METHODS ///////////////////////////
/**
/**
* Checks
for a list for
a particular resource id.
* Checks
whether a list contains
a particular resource id.
*
*
* @param list list of
hostList
* @param list list of
resource id
* @param id a resource ID
* @param id a resource ID
to find
* @return true if a resource is in the list, otherwise false
* @return true if a resource is in the list, otherwise false
* @pre list != null
* @pre list != null
* @pre id > 0
* @pre id > 0
...
@@ -288,7 +302,7 @@ public class CloudInformationService extends SimEntity {
...
@@ -288,7 +302,7 @@ public class CloudInformationService extends SimEntity {
}
}
/**
/**
* Tells all registered entities the end of simulation.
* Tells all registered entities
about
the end of simulation.
*
*
* @pre $none
* @pre $none
* @post $none
* @post $none
...
@@ -305,7 +319,8 @@ public class CloudInformationService extends SimEntity {
...
@@ -305,7 +319,8 @@ public class CloudInformationService extends SimEntity {
}
}
/**
/**
* Sends a signal to all entity IDs mentioned in the given list.
* Sends a {@link CloudSimTags#END_OF_SIMULATION} signal to all entity IDs
* mentioned in the given list.
*
*
* @param list List storing entity IDs
* @param list List storing entity IDs
* @pre list != null
* @pre list != null
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/core/CloudSim.java
View file @
841a9352
...
@@ -175,7 +175,7 @@ public class CloudSim {
...
@@ -175,7 +175,7 @@ public class CloudSim {
* <p>
* <p>
* <b>Note</b>: This method should be called after all the entities have been setup and added.
* <b>Note</b>: This method should be called after all the entities have been setup and added.
*
*
* @return the
doubl
e
* @return the
last clock tim
e
* @throws NullPointerException This happens when creating this entity before initialising
* @throws NullPointerException This happens when creating this entity before initialising
* CloudSim package or this entity name is <tt>null</tt> or empty.
* CloudSim package or this entity name is <tt>null</tt> or empty.
* @see gridsim.CloudSim#init(int, Calendar, boolean)
* @see gridsim.CloudSim#init(int, Calendar, boolean)
...
@@ -872,7 +872,7 @@ public class CloudSim {
...
@@ -872,7 +872,7 @@ public class CloudSim {
* Start the simulation running. This should be called after all the entities have been setup
* Start the simulation running. This should be called after all the entities have been setup
* and added, and their ports linked.
* and added, and their ports linked.
*
*
* @return the
double
last clock value
* @return the last clock value
*/
*/
public
static
double
run
()
{
public
static
double
run
()
{
if
(!
running
)
{
if
(!
running
)
{
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/core/CloudSimShutdown.java
View file @
841a9352
...
@@ -8,13 +8,13 @@
...
@@ -8,13 +8,13 @@
package
org
.
cloudbus
.
cloudsim
.
core
;
package
org
.
cloudbus
.
cloudsim
.
core
;
import
java.
util.Calendar
;
import
java.
security.InvalidParameterException
;
/**
/**
* CloudimShutdown waits for termination of all CloudSim user entities to determine the end of
* CloudimShutdown waits for termination of all CloudSim user entities to determine the end of
* simulation. This class will be created by CloudSim upon initialisation of the simulation, i.e.
* simulation. This class will be created by CloudSim upon initialisation of the simulation, i.e.
* done via <tt>CloudSim.init()</tt> method. Hence, do not need to worry about creating an object of
* done via <tt>CloudSim.init()</tt> method. Hence, do not need to worry about creating an object of
* this class. This object signals the end of simulation to CloudInformationService (
G
IS) entity.
* this class. This object signals the end of simulation to CloudInformationService (
C
IS) entity.
*
*
* @author Manzur Murshed
* @author Manzur Murshed
* @author Rajkumar Buyya
* @author Rajkumar Buyya
...
@@ -22,25 +22,29 @@ import java.util.Calendar;
...
@@ -22,25 +22,29 @@ import java.util.Calendar;
*/
*/
public
class
CloudSimShutdown
extends
SimEntity
{
public
class
CloudSimShutdown
extends
SimEntity
{
/** The
num user
. */
/** The
total number of cloud users
. */
private
int
numUser
;
private
int
numUser
;
/**
/**
*
Alloc
ates a new CloudSimShutdown object.
*
Instanti
ates a new CloudSimShutdown object.
* <p>
* <p
/
>
* The total number of
grid user entity
plays an important role to determine whether all
* The total number of
cloud user entities
plays an important role to determine whether all
* hostList
should be shut down or not. If one or more users are still not finish
, then the
* hostList
' should be shut down or not. If one or more users are still not finished
, then the
* hostList will not be shut down. Therefore, it is important to give a correct number of total
* hostList
's
will not be shut down. Therefore, it is important to give a correct number of total
*
grid user entity
. Otherwise, CloudSim program will hang or encounter a weird behaviour.
*
cloud user entities
. Otherwise, CloudSim program will hang or encounter a weird behaviour.
*
*
* @param name the name to be associated with this entity (as required by
SimEntity
class)
* @param name the name to be associated with this entity (as required by
{@link SimEntity}
class)
* @param numUser total number of
grid user entity
* @param numUser total number of
cloud user entities
* @throws Exception
This happens
when creating this entity before initialising CloudSim package
* @throws Exception when creating this entity before initialising CloudSim package
* or this entity name is <tt>null</tt> or empty
* or this entity name is <tt>null</tt> or empty
* @see
gridsim.CloudSim#init(int, Calendar, boolean)
* @see
CloudSim#init(int, java.util.Calendar, boolean)
* @pre name != null
* @pre name != null
* @pre numUser >= 0
* @pre numUser >= 0
* @post $none
* @post $none
*
* @todo The use of Exception is not recommended. Specific exceptions
* would be thrown (such as {@link IllegalArgumentException})
* or {@link RuntimeException}
*/
*/
public
CloudSimShutdown
(
String
name
,
int
numUser
)
throws
Exception
{
public
CloudSimShutdown
(
String
name
,
int
numUser
)
throws
Exception
{
// NOTE: This entity doesn't use any I/O port.
// NOTE: This entity doesn't use any I/O port.
...
@@ -50,12 +54,12 @@ public class CloudSimShutdown extends SimEntity {
...
@@ -50,12 +54,12 @@ public class CloudSimShutdown extends SimEntity {
}
}
/**
/**
* The main method that shuts down hostList
and Cloud Information Service (G
IS). In addition,
* The main method that shuts down hostList
's and Cloud Information Service (C
IS). In addition,
* this method writes down a report at the end of a simulation based on
* this method writes down a report at the end of a simulation based on
* <tt>reportWriterName</tt> defined in the Constructor. <br>
* <tt>reportWriterName</tt> defined in the Constructor. <br
/
>
* <b>NOTE:</b> This method shuts down
grid hostList and G
IS entities either <tt>AFTER</tt> all
* <b>NOTE:</b> This method shuts down
cloud hostList's and C
IS entities either <tt>AFTER</tt> all
*
gri
d users have been shut down or an entity requires an abrupt end of the whole simulation.
*
clou
d users have been shut down or an entity requires an abrupt end of the whole simulation.
* In the first case, the number of
gri
d users given in the Constructor <tt>must</tt> be
* In the first case, the number of
clou
d users given in the Constructor <tt>must</tt> be
* correct. Otherwise, CloudSim package hangs forever or it does not terminate properly.
* correct. Otherwise, CloudSim package hangs forever or it does not terminate properly.
*
*
* @param ev the ev
* @param ev the ev
...
@@ -70,18 +74,16 @@ public class CloudSimShutdown extends SimEntity {
...
@@ -70,18 +74,16 @@ public class CloudSimShutdown extends SimEntity {
}
}
}
}
/*
/**
* (non-Javadoc)
* The method has no effect at the current class.
* @see org.cloudbus.cloudsim.core.SimEntity#startEntity()
*/
*/
@Override
@Override
public
void
startEntity
()
{
public
void
startEntity
()
{
// do nothing
// do nothing
}
}
/*
/**
* (non-Javadoc)
* The method has no effect at the current class.
* @see org.cloudbus.cloudsim.core.SimEntity#shutdownEntity()
*/
*/
@Override
@Override
public
void
shutdownEntity
()
{
public
void
shutdownEntity
()
{
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/core/CloudSimTags.java
View file @
841a9352
...
@@ -8,11 +8,15 @@
...
@@ -8,11 +8,15 @@
package
org
.
cloudbus
.
cloudsim
.
core
;
package
org
.
cloudbus
.
cloudsim
.
core
;
import
org.cloudbus.cloudsim.Datacenter
;
/**
/**
* Contains various static command tags that indicate a type of action that needs to be undertaken
* Contains various static command tags that indicate a type of action that needs to be undertaken
* by CloudSim entities when they receive or send events. <b>NOTE:</b> To avoid conflicts with other
* by CloudSim entities when they receive or send events. <b>NOTE:</b> To avoid conflicts with other
* tags, CloudSim reserves negative numbers, 0 - 299, and 9600.
* tags, CloudSim reserves negative numbers, 0 - 299, and 9600.
*
*
* @todo There aren't negative reserved tags, but only positive tags (with 2 exceptions).
*
* @author Manzur Murshed
* @author Manzur Murshed
* @author Rajkumar Buyya
* @author Rajkumar Buyya
* @author Anthony Sulistio
* @author Anthony Sulistio
...
@@ -20,25 +24,25 @@ package org.cloudbus.cloudsim.core;
...
@@ -20,25 +24,25 @@ package org.cloudbus.cloudsim.core;
*/
*/
public
class
CloudSimTags
{
public
class
CloudSimTags
{
/** Starting constant value for cloud-related tags **/
/** Starting constant value for cloud-related tags
.
**/
private
static
final
int
BASE
=
0
;
private
static
final
int
BASE
=
0
;
/** Starting constant value for network-related tags **/
/** Starting constant value for network-related tags
.
**/
private
static
final
int
NETBASE
=
100
;
private
static
final
int
NETBASE
=
100
;
/** Denotes boolean <tt>true</tt> in <tt>int</tt> value */
/** Denotes boolean <tt>true</tt> in <tt>int</tt> value
.
*/
public
static
final
int
TRUE
=
1
;
public
static
final
int
TRUE
=
1
;
/** Denotes boolean <tt>false</tt> in <tt>int</tt> value */
/** Denotes boolean <tt>false</tt> in <tt>int</tt> value
.
*/
public
static
final
int
FALSE
=
0
;
public
static
final
int
FALSE
=
0
;
/** Denotes the default baud rate for
some CloudSim entities
*/
/** Denotes the default baud rate for
CloudSim entities.
*/
public
static
final
int
DEFAULT_BAUD_RATE
=
9600
;
public
static
final
int
DEFAULT_BAUD_RATE
=
9600
;
/** Schedules an entity without any delay */
/** Schedules an entity without any delay
.
*/
public
static
final
double
SCHEDULE_NOW
=
0.0
;
public
static
final
double
SCHEDULE_NOW
=
0.0
;
/** Denotes the end of simulation */
/** Denotes the end of simulation
.
*/
public
static
final
int
END_OF_SIMULATION
=
-
1
;
public
static
final
int
END_OF_SIMULATION
=
-
1
;
/**
/**
...
@@ -57,37 +61,37 @@ public class CloudSimTags {
...
@@ -57,37 +61,37 @@ public class CloudSimTags {
public
static
final
int
EXPERIMENT
=
BASE
+
1
;
public
static
final
int
EXPERIMENT
=
BASE
+
1
;
/**
/**
* Denotes a
gri
d resource to be registered. This tag is normally used between
* Denotes a
clou
d resource to be registered. This tag is normally used between
*
CloudInformationService and CloudResouce entity
.
*
{@link CloudInformationService} and CloudResouce entities
.
*/
*/
public
static
final
int
REGISTER_RESOURCE
=
BASE
+
2
;
public
static
final
int
REGISTER_RESOURCE
=
BASE
+
2
;
/**
/**
* Denotes a
grid resource, that can support advance reservation, to be registered
. This tag is
* Denotes a
cloud resource to be registered, that can support advance reservation
. This tag is
* normally used between
CloudInformationService
and CloudResouce entity.
* normally used between
{@link CloudInformationService}
and CloudResouce entity.
*/
*/
public
static
final
int
REGISTER_RESOURCE_AR
=
BASE
+
3
;
public
static
final
int
REGISTER_RESOURCE_AR
=
BASE
+
3
;
/**
/**
* Denotes a list of all hostList, including the ones that can support advance reservation. This
* Denotes a list of all hostList
's
, including the ones that can support advance reservation. This
* tag is normally used between
CloudInformationService
and CloudSim entity.
* tag is normally used between
{@link CloudInformationService}
and CloudSim entity.
*/
*/
public
static
final
int
RESOURCE_LIST
=
BASE
+
4
;
public
static
final
int
RESOURCE_LIST
=
BASE
+
4
;
/**
/**
* Denotes a list of hostList that only support advance reservation. This tag is normally used
* Denotes a list of hostList
's
that only support advance reservation. This tag is normally used
* between
CloudInformationService
and CloudSim entity.
* between
{@link CloudInformationService}
and CloudSim entity.
*/
*/
public
static
final
int
RESOURCE_AR_LIST
=
BASE
+
5
;
public
static
final
int
RESOURCE_AR_LIST
=
BASE
+
5
;
/**
/**
* Denotes
gri
d resource characteristics information. This tag is normally used between CloudSim
* Denotes
clou
d resource characteristics information. This tag is normally used between CloudSim
* and CloudResource entity.
* and CloudResource entity.
*/
*/
public
static
final
int
RESOURCE_CHARACTERISTICS
=
BASE
+
6
;
public
static
final
int
RESOURCE_CHARACTERISTICS
=
BASE
+
6
;
/**
/**
* Denotes
gri
d resource allocation policy. This tag is normally used between CloudSim and
* Denotes
clou
d resource allocation policy. This tag is normally used between CloudSim and
* CloudResource entity.
* CloudResource entity.
*/
*/
public
static
final
int
RESOURCE_DYNAMICS
=
BASE
+
7
;
public
static
final
int
RESOURCE_DYNAMICS
=
BASE
+
7
;
...
@@ -120,37 +124,37 @@ public class CloudSimTags {
...
@@ -120,37 +124,37 @@ public class CloudSimTags {
public
static
final
int
RETURN_ACC_STATISTICS_BY_CATEGORY
=
BASE
+
12
;
public
static
final
int
RETURN_ACC_STATISTICS_BY_CATEGORY
=
BASE
+
12
;
/**
/**
* Denotes a request to register a CloudResource entity to a regional
CloudInformationService
* Denotes a request to register a CloudResource entity to a regional
*
(GIS) entity
*
{@link CloudInformationService} (CIS) entity.
*/
*/
public
static
final
int
REGISTER_REGIONAL_GIS
=
BASE
+
13
;
public
static
final
int
REGISTER_REGIONAL_GIS
=
BASE
+
13
;
/**
/**
* Denotes a request to get a list of other regional
GIS entities from the system GIS entity
* Denotes a request to get a list of other regional
CIS entities from the system CIS entity.
*/
*/
public
static
final
int
REQUEST_REGIONAL_GIS
=
BASE
+
14
;
public
static
final
int
REQUEST_REGIONAL_GIS
=
BASE
+
14
;
/**
/**
* Denotes request for
gri
d resource characteristics information. This tag is normally used
* Denotes request for
clou
d resource characteristics information. This tag is normally used
* between CloudSim and CloudResource entity.
* between CloudSim and CloudResource entity.
*/
*/
public
static
final
int
RESOURCE_CHARACTERISTICS_REQUEST
=
BASE
+
15
;
public
static
final
int
RESOURCE_CHARACTERISTICS_REQUEST
=
BASE
+
15
;
/** This tag is used by an entity to send ping requests */
/** This tag is used by an entity to send ping requests
.
*/
public
static
final
int
INFOPKT_SUBMIT
=
NETBASE
+
5
;
public
static
final
int
INFOPKT_SUBMIT
=
NETBASE
+
5
;
/** This tag is used to return the ping request back to sender */
/** This tag is used to return the ping request back to sender
.
*/
public
static
final
int
INFOPKT_RETURN
=
NETBASE
+
6
;
public
static
final
int
INFOPKT_RETURN
=
NETBASE
+
6
;
/**
/**
* Denotes the return of a Cloudlet back to sender.
This tag is normally used by CloudResource
* Denotes the return of a Cloudlet back to sender.
*
entity.
* This tag is normally used by CloudResource
entity.
*/
*/
public
static
final
int
CLOUDLET_RETURN
=
BASE
+
20
;
public
static
final
int
CLOUDLET_RETURN
=
BASE
+
20
;
/**
/**
* Denotes the submission of a Cloudlet.
This tag is normally used between CloudSim User and
* Denotes the submission of a Cloudlet.
*
CloudResource entity.
* This tag is normally used between CloudSim User and
CloudResource entity.
*/
*/
public
static
final
int
CLOUDLET_SUBMIT
=
BASE
+
21
;
public
static
final
int
CLOUDLET_SUBMIT
=
BASE
+
21
;
...
@@ -191,65 +195,68 @@ public class CloudSimTags {
...
@@ -191,65 +195,68 @@ public class CloudSimTags {
public
static
final
int
CLOUDLET_MOVE_ACK
=
BASE
+
30
;
public
static
final
int
CLOUDLET_MOVE_ACK
=
BASE
+
30
;
/**
/**
* Denotes a request to create a new VM in a
Datacentre With acknowledgement information sent by
* Denotes a request to create a new VM in a
{@link Datacenter} with acknowledgement
* the Datacentre
* information sent by the Datacenter.
*/
*/
public
static
final
int
VM_CREATE
=
BASE
+
31
;
public
static
final
int
VM_CREATE
=
BASE
+
31
;
/**
/**
* Denotes a request to create a new VM in a
Datacentre With acknowledgement information sent by
* Denotes a request to create a new VM in a
{@link Datacenter}
* the Datacentre
* with acknowledgement information sent by the Datacenter.
*/
*/
public
static
final
int
VM_CREATE_ACK
=
BASE
+
32
;
public
static
final
int
VM_CREATE_ACK
=
BASE
+
32
;
/**
/**
* Denotes a request to destroy a new VM in a
Datacentre
* Denotes a request to destroy a new VM in a
{@link Datacenter}.
*/
*/
public
static
final
int
VM_DESTROY
=
BASE
+
33
;
public
static
final
int
VM_DESTROY
=
BASE
+
33
;
/**
/**
* Denotes a request to destroy a new VM in a Datacentre
* Denotes a request to destroy a new VM in a {@link Datacenter}
* with acknowledgement information sent by the Datacener.
*/
*/
public
static
final
int
VM_DESTROY_ACK
=
BASE
+
34
;
public
static
final
int
VM_DESTROY_ACK
=
BASE
+
34
;
/**
/**
* Denotes a request to migrate a new VM in a
Datacentre
* Denotes a request to migrate a new VM in a
{@link Datacenter}.
*/
*/
public
static
final
int
VM_MIGRATE
=
BASE
+
35
;
public
static
final
int
VM_MIGRATE
=
BASE
+
35
;
/**
/**
* Denotes a request to migrate a new VM in a
Datacentre With acknowledgement information sent
* Denotes a request to migrate a new VM in a
{@link Datacenter}
* by the Datacentre
* with acknowledgement information sent by the Datacener.
*/
*/
public
static
final
int
VM_MIGRATE_ACK
=
BASE
+
36
;
public
static
final
int
VM_MIGRATE_ACK
=
BASE
+
36
;
/**
/**
* Denotes an event to send a file from a user to a
datacenter
* Denotes an event to send a file from a user to a
{@link Datacenter}.
*/
*/
public
static
final
int
VM_DATA_ADD
=
BASE
+
37
;
public
static
final
int
VM_DATA_ADD
=
BASE
+
37
;
/**
/**
* Denotes an event to send a file from a user to a datacenter
* Denotes an event to send a file from a user to a {@link Datacenter}
* with acknowledgement information sent by the Datacener.
*/
*/
public
static
final
int
VM_DATA_ADD_ACK
=
BASE
+
38
;
public
static
final
int
VM_DATA_ADD_ACK
=
BASE
+
38
;
/**
/**
* Denotes an event to remove a file from a
datacenter
* Denotes an event to remove a file from a
{@link Datacenter} .
*/
*/
public
static
final
int
VM_DATA_DEL
=
BASE
+
39
;
public
static
final
int
VM_DATA_DEL
=
BASE
+
39
;
/**
/**
* Denotes an event to remove a file from a datacenter
* Denotes an event to remove a file from a {@link Datacenter}
* with acknowledgement information sent by the Datacener.
*/
*/
public
static
final
int
VM_DATA_DEL_ACK
=
BASE
+
40
;
public
static
final
int
VM_DATA_DEL_ACK
=
BASE
+
40
;
/**
/**
* Denotes an internal event generated in a
PowerDatacenter
* Denotes an internal event generated in a
{@link Datacenter}.
*/
*/
public
static
final
int
VM_DATACENTER_EVENT
=
BASE
+
41
;
public
static
final
int
VM_DATACENTER_EVENT
=
BASE
+
41
;
/**
/**
* Denotes an internal event generated in a Broker
* Denotes an internal event generated in a Broker
.
*/
*/
public
static
final
int
VM_BROKER_EVENT
=
BASE
+
42
;
public
static
final
int
VM_BROKER_EVENT
=
BASE
+
42
;
...
@@ -265,9 +272,9 @@ public class CloudSimTags {
...
@@ -265,9 +272,9 @@ public class CloudSimTags {
public
static
final
int
NextCycle
=
BASE
+
48
;
public
static
final
int
NextCycle
=
BASE
+
48
;
/** Private Constructor */
/** Private Constructor
.
*/
private
CloudSimTags
()
{
private
CloudSimTags
()
{
throw
new
UnsupportedOperationException
(
"CloudSim
Tags cannot be instantiated"
);
throw
new
UnsupportedOperationException
(
"CloudSimTags cannot be instantiated"
);
}
}
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/core/DeferredQueue.java
View file @
841a9352
...
@@ -14,20 +14,20 @@ import java.util.List;
...
@@ -14,20 +14,20 @@ import java.util.List;
import
java.util.ListIterator
;
import
java.util.ListIterator
;
/**
/**
* This class implements the deferred event queue used by {@link
Simulation}. The event queue uses a
* This class implements the deferred event queue used by {@link
CloudSim}.
* linked list to store the events.
*
The event queue uses a
linked list to store the events.
*
*
* @author Marcos Dias de Assuncao
* @author Marcos Dias de Assuncao
* @since CloudSim Toolkit 1.0
* @since CloudSim Toolkit 1.0
* @see
Simulation
* @see
CloudSim
* @see SimEvent
* @see SimEvent
*/
*/
public
class
DeferredQueue
{
public
class
DeferredQueue
{
/** The list. */
/** The list
of events
. */
private
final
List
<
SimEvent
>
list
=
new
LinkedList
<
SimEvent
>();
private
final
List
<
SimEvent
>
list
=
new
LinkedList
<
SimEvent
>();
/** The max time. */
/** The max time
that an added event is scheduled
. */
private
double
maxTime
=
-
1
;
private
double
maxTime
=
-
1
;
/**
/**
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/core/FutureQueue.java
View file @
841a9352
...
@@ -14,24 +14,28 @@ import java.util.SortedSet;
...
@@ -14,24 +14,28 @@ import java.util.SortedSet;
import
java.util.TreeSet
;
import
java.util.TreeSet
;
/**
/**
* This class implements the future event queue used by {@link
Simulation}. The event queue uses a
* This class implements the future event queue used by {@link
CloudSim}.
* {@link TreeSet} in order to store the events.
*
The event queue uses a
{@link TreeSet} in order to store the events.
*
*
* @author Marcos Dias de Assuncao
* @author Marcos Dias de Assuncao
* @since CloudSim Toolkit 1.0
* @since CloudSim Toolkit 1.0
* @see Simulation
* @see Simulation
* @see java.util.TreeSet
* @see java.util.TreeSet
*
* @todo It would be used a common interface for queues
* such as this one and {@link DeferredQueue}
*/
*/
public
class
FutureQueue
{
public
class
FutureQueue
{
/** The sorted set. */
/** The sorted set
of events
. */
private
final
SortedSet
<
SimEvent
>
sortedSet
=
new
TreeSet
<
SimEvent
>();
private
final
SortedSet
<
SimEvent
>
sortedSet
=
new
TreeSet
<
SimEvent
>();
/** The serial. */
/** A incremental number used for {@link SimEvent#serial} event attribute.
*/
private
long
serial
=
0
;
private
long
serial
=
0
;
/**
/**
* Add a new event to the queue. Adding a new event to the queue preserves the temporal order of
* Add
s
a new event to the queue. Adding a new event to the queue preserves the temporal order of
* the events in the queue.
* the events in the queue.
*
*
* @param newEvent The event to be put in the queue.
* @param newEvent The event to be put in the queue.
...
@@ -42,7 +46,7 @@ public class FutureQueue {
...
@@ -42,7 +46,7 @@ public class FutureQueue {
}
}
/**
/**
* Add a new event to the head of the queue.
* Add
s
a new event to the head of the queue.
*
*
* @param newEvent The event to be put in the queue.
* @param newEvent The event to be put in the queue.
*/
*/
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/core/SimEntity.java
View file @
841a9352
This diff is collapsed.
Click to expand it.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/core/SimEvent.java
View file @
841a9352
...
@@ -17,27 +17,40 @@ package org.cloudbus.cloudsim.core;
...
@@ -17,27 +17,40 @@ package org.cloudbus.cloudsim.core;
*/
*/
public
class
SimEvent
implements
Cloneable
,
Comparable
<
SimEvent
>
{
public
class
SimEvent
implements
Cloneable
,
Comparable
<
SimEvent
>
{
/**
internal event type
**/
/**
Internal event type.
**/
private
final
int
etype
;
private
final
int
etype
;
/**
time at which event should occur
**/
/**
The time that this event was scheduled, at which it should occur.
**/
private
final
double
time
;
private
final
double
time
;
/**
time that the event was removed from the queue for service
**/
/**
Time that the event was removed from the queue to start service.
**/
private
double
endWaitingTime
;
private
double
endWaitingTime
;
/**
id of entity who scheduled event
**/
/**
Id of entity who scheduled the event.
**/
private
int
entSrc
;
private
int
entSrc
;
/**
id of entity event will be sent to
**/
/**
Id of entity that the event will be sent to.
**/
private
int
entDst
;
private
int
entDst
;
/**
the user defined type of the event
**/
/**
The user defined type of the event.
**/
private
final
int
tag
;
private
final
int
tag
;
/** any data the event is carrying **/
/**
* Any data the event is carrying.
* @todo I would be used generics to define the type of the event data.
* But this modification would incur several changes in the simulator core
* that has to be assessed first.
**/
private
final
Object
data
;
private
final
Object
data
;
/**
* An attribute to help CloudSim to identify the order of received events
* when multiple events are generated at the same time.
* If two events have the same {@link #time}, to know
* what event is greater than other (i.e. that happens after other),
* the {@link #compareTo(org.cloudbus.cloudsim.core.SimEvent)}
* makes use of this field.
*/
private
long
serial
=
-
1
;
private
long
serial
=
-
1
;
// Internal event types
// Internal event types
...
@@ -51,7 +64,7 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> {
...
@@ -51,7 +64,7 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> {
public
static
final
int
CREATE
=
3
;
public
static
final
int
CREATE
=
3
;
/**
/**
* Create a blank event.
* Create
s
a blank event.
*/
*/
public
SimEvent
()
{
public
SimEvent
()
{
etype
=
ENULL
;
etype
=
ENULL
;
...
@@ -87,7 +100,7 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> {
...
@@ -87,7 +100,7 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> {
}
}
/**
/**
*
Used to set the time at which this event finished waiting in the event
*
Sets the time that the event was removed from the queue to start service.
*
*
* @param end_waiting_time
* @param end_waiting_time
*/
*/
...
@@ -95,6 +108,8 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> {
...
@@ -95,6 +108,8 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> {
endWaitingTime
=
end_waiting_time
;
endWaitingTime
=
end_waiting_time
;
}
}
// ------------------- PUBLIC METHODS --------------------------
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"Event tag = "
+
tag
+
" source = "
+
CloudSim
.
getEntity
(
entSrc
).
getName
()
+
" destination = "
return
"Event tag = "
+
tag
+
" source = "
+
CloudSim
.
getEntity
(
entSrc
).
getName
()
+
" destination = "
...
@@ -102,7 +117,7 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> {
...
@@ -102,7 +117,7 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> {
}
}
/**
/**
*
T
he internal type
*
Gets t
he internal type
*
*
* @return
* @return
*/
*/
...
@@ -110,11 +125,7 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> {
...
@@ -110,11 +125,7 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> {
return
etype
;
return
etype
;
}
}
// ------------------- PUBLIC METHODS --------------------------
/**
* @see Comparable#compareTo(Object)
*/
@Override
@Override
public
int
compareTo
(
SimEvent
event
)
{
public
int
compareTo
(
SimEvent
event
)
{
if
(
event
==
null
)
{
if
(
event
==
null
)
{
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/core/predicates/Predicate.java
View file @
841a9352
...
@@ -33,6 +33,7 @@ import org.cloudbus.cloudsim.core.SimEvent;
...
@@ -33,6 +33,7 @@ import org.cloudbus.cloudsim.core.SimEvent;
* @todo It would be an interface, since it doesn't have any attributes, just
* @todo It would be an interface, since it doesn't have any attributes, just
* abstract methods.
* abstract methods.
* @todo There already is a native java {@link java.util.function.Predicate} interface.
* @todo There already is a native java {@link java.util.function.Predicate} interface.
* Maybe it was introduced with Java 8 (due to Stream and Lambda functions).
*
*
*/
*/
public
abstract
class
Predicate
{
public
abstract
class
Predicate
{
...
...
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