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
1c980a4e
Commit
1c980a4e
authored
Jan 10, 2012
by
rodrigo.calheiros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CloudSin version String updated to 3.0.
parent
6ef9f1ed
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
234 additions
and
186 deletions
+234
-186
CloudSim.java
...im/src/main/java/org/cloudbus/cloudsim/core/CloudSim.java
+234
-186
No files found.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/core/CloudSim.java
View file @
1c980a4e
...
...
@@ -38,7 +38,7 @@ import org.cloudbus.cloudsim.core.predicates.PredicateNone;
public
class
CloudSim
{
/** The Constant CLOUDSIM_VERSION_STRING. */
private
static
final
String
CLOUDSIM_VERSION_STRING
=
"
2.1.1
"
;
private
static
final
String
CLOUDSIM_VERSION_STRING
=
"
3.0
"
;
/** The id of CIS entity. */
private
static
int
cisId
=
-
1
;
...
...
@@ -66,15 +66,21 @@ public class CloudSim {
/**
* Initialises all the common attributes.
*
* @param _calendar the _calendar
* @param _traceFlag the _trace flag
* @param numUser number of users
* @throws Exception This happens when creating this entity before initialising
* CloudSim package or this entity name is <tt>null</tt> or empty
* @param _calendar
* the _calendar
* @param _traceFlag
* the _trace flag
* @param numUser
* number of users
* @throws Exception
* This happens when creating this entity before initialising
* CloudSim package or this entity name is <tt>null</tt> or
* empty
* @pre $none
* @post $none
*/
private
static
void
initCommonVariable
(
Calendar
_calendar
,
boolean
_traceFlag
,
int
numUser
)
throws
Exception
{
private
static
void
initCommonVariable
(
Calendar
_calendar
,
boolean
_traceFlag
,
int
numUser
)
throws
Exception
{
initialize
();
// NOTE: the order for the below 3 lines are important
traceFlag
=
_traceFlag
;
...
...
@@ -103,14 +109,17 @@ public class CloudSim {
* </ul>
* <p>
*
* @param numUser the number of User Entities created. This parameters indicates
* @param numUser
* the number of User Entities created. This parameters indicates
* that {@link gridsim.CloudSimShutdown} first waits for all user
* entities's END_OF_SIMULATION signal before issuing terminate
* signal to other entities
* @param cal starting time for this simulation. If it is <tt>null</tt>,
* @param cal
* starting time for this simulation. If it is <tt>null</tt>,
* then the time will be taken from
* <tt>Calendar.getInstance()</tt>
* @param traceFlag <tt>true</tt> if CloudSim trace need to be written
* @param traceFlag
* <tt>true</tt> if CloudSim trace need to be written
*
* @see gridsim.CloudSimShutdown
* @see CloudInformationService.CloudInformationService
...
...
@@ -144,7 +153,8 @@ public class CloudSim {
* been setup and added.
*
* @return the double
* @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.
* @see gridsim.CloudSim#init(int, Calendar, boolean)
...
...
@@ -176,8 +186,10 @@ public class CloudSim {
* should be only called if any of the user defined entities
* <b>explicitly</b> want to terminate simulation during execution.
*
* @throws NullPointerException This happens when creating this entity before initialising
* CloudSim package or this entity name is <tt>null</tt> or empty
* @throws NullPointerException
* This happens when creating this entity before initialising
* CloudSim package or this entity name is <tt>null</tt> or
* empty
*
* @see gridsim.CloudSim#init(int, Calendar, boolean)
* @see Simulation#runStop()
...
...
@@ -205,12 +217,12 @@ public class CloudSim {
}
/**
* This method is called if one wants to terminate the simulation at a
*
given
time.
* This method is called if one wants to terminate the simulation at a
given
* time.
*
* @param time
the time at which the simulation has to be terminated
*
@return true, if successful
* otherwise.
* @param time
*
the time at which the simulation has to be terminated
*
@return true, if successful
otherwise.
*/
public
static
boolean
terminateSimulation
(
double
time
)
{
if
(
time
<=
clock
)
{
...
...
@@ -224,8 +236,8 @@ public class CloudSim {
/**
* Gets a new copy of initial simulation Calendar.
*
* @return a new copy of Calendar object or
if CloudSim hasn't
*
been
initialized
* @return a new copy of Calendar object or
if CloudSim hasn't been
*
initialized
* @see gridsim.CloudSim#init(int, Calendar, boolean, String[], String[],
* String)
* @see gridsim.CloudSim#init(int, Calendar, boolean)
...
...
@@ -257,8 +269,8 @@ public class CloudSim {
* Sends a request to Cloud Information Service (GIS) entity to get the list
* of all Cloud hostList.
*
* @return A List containing CloudResource ID (as an Integer object)
*
or if a
CIS entity hasn't been created before
* @return A List containing CloudResource ID (as an Integer object)
or if a
*
CIS entity hasn't been created before
* @pre $none
* @post $none
*/
...
...
@@ -349,7 +361,8 @@ public class CloudSim {
/**
* Get the entity with a given id.
*
* @param id the entity's unique id number
* @param id
* the entity's unique id number
* @return The entity, or if it could not be found
*/
public
static
SimEntity
getEntity
(
int
id
)
{
...
...
@@ -359,7 +372,8 @@ public class CloudSim {
/**
* Get the entity with a given name.
*
* @param name The entity's name
* @param name
* The entity's name
* @return The entity
*/
public
static
SimEntity
getEntity
(
String
name
)
{
...
...
@@ -369,7 +383,8 @@ public class CloudSim {
/**
* Get the id of an entity with a given name.
*
* @param name The entity's name
* @param name
* The entity's name
* @return The entity's unique id number
*/
public
static
int
getEntityId
(
String
name
)
{
...
...
@@ -384,7 +399,8 @@ public class CloudSim {
/**
* Gets name of the entity given its entity ID.
*
* @param entityID the entity ID
* @param entityID
* the entity ID
* @return the Entity name or if this object does not have one
* @pre entityID > 0
* @post $none
...
...
@@ -402,7 +418,8 @@ public class CloudSim {
/**
* Gets name of the entity given its entity ID.
*
* @param entityID the entity ID
* @param entityID
* the entity ID
* @return the Entity name or if this object does not have one
* @pre entityID > 0
* @post $none
...
...
@@ -434,7 +451,8 @@ public class CloudSim {
* with existing simulations since entities are automatically added to the
* simulation upon instantiation.
*
* @param e The new entity
* @param e
* The new entity
*/
public
static
void
addEntity
(
SimEntity
e
)
{
SimEvent
evt
;
...
...
@@ -456,7 +474,8 @@ public class CloudSim {
* simulation is running. It should <b>not</b> be called from user
* simulations.
*
* @param e The new entity
* @param e
* The new entity
*/
protected
static
void
addEntityDynamically
(
SimEntity
e
)
{
if
(
e
==
null
)
{
...
...
@@ -471,8 +490,7 @@ public class CloudSim {
* Internal method used to run one tick of the simulation. This method
* should <b>not</b> be called in simulations.
*
* @return true, if successful
* otherwise
* @return true, if successful otherwise
*/
public
static
boolean
runClockTick
()
{
SimEntity
ent
;
...
...
@@ -532,8 +550,10 @@ public class CloudSim {
/**
* Used to hold an entity for some time.
*
* @param src the src
* @param delay the delay
* @param src
* the src
* @param delay
* the delay
*/
public
static
void
hold
(
int
src
,
long
delay
)
{
SimEvent
e
=
new
SimEvent
(
SimEvent
.
HOLD_DONE
,
clock
+
delay
,
src
);
...
...
@@ -544,8 +564,10 @@ public class CloudSim {
/**
* Used to pause an entity for some time.
*
* @param src the src
* @param delay the delay
* @param src
* the src
* @param delay
* the delay
*/
public
static
void
pause
(
int
src
,
double
delay
)
{
SimEvent
e
=
new
SimEvent
(
SimEvent
.
HOLD_DONE
,
clock
+
delay
,
src
);
...
...
@@ -556,11 +578,16 @@ public class CloudSim {
/**
* Used to send an event from one entity to another.
*
* @param src the src
* @param dest the dest
* @param delay the delay
* @param tag the tag
* @param data the data
* @param src
* the src
* @param dest
* the dest
* @param delay
* the delay
* @param tag
* the tag
* @param data
* the data
*/
public
static
void
send
(
int
src
,
int
dest
,
double
delay
,
int
tag
,
Object
data
)
{
if
(
delay
<
0
)
{
...
...
@@ -572,13 +599,19 @@ public class CloudSim {
}
/**
* Used to send an event from one entity to another, with priority in the queue.
* Used to send an event from one entity to another, with priority in the
* queue.
*
* @param src the src
* @param dest the dest
* @param delay the delay
* @param tag the tag
* @param data the data
* @param src
* the src
* @param dest
* the dest
* @param delay
* the delay
* @param tag
* the tag
* @param data
* the data
*/
public
static
void
sendFirst
(
int
src
,
int
dest
,
double
delay
,
int
tag
,
Object
data
)
{
if
(
delay
<
0
)
{
...
...
@@ -590,12 +623,15 @@ public class CloudSim {
}
/**
* Sets an entity's state to be waiting. The predicate used to wait for an event
* is now passed to Sim_system. Only events that satisfy the predicate will be
* passed to the entity. This is done to avoid unnecessary context switches.
* Sets an entity's state to be waiting. The predicate used to wait for an
* event is now passed to Sim_system. Only events that satisfy the predicate
* will be passed to the entity. This is done to avoid unnecessary context
* switches.
*
* @param src the src
* @param p the p
* @param src
* the src
* @param p
* the p
*/
public
static
void
wait
(
int
src
,
Predicate
p
)
{
entities
.
get
(
src
).
setState
(
SimEntity
.
WAITING
);
...
...
@@ -606,10 +642,13 @@ public class CloudSim {
}
/**
* Checks if events for a specific entity are present in the deferred event queue.
* Checks if events for a specific entity are present in the deferred event
* queue.
*
* @param d the d
* @param p the p
* @param d
* the d
* @param p
* the p
*
* @return the int
*/
...
...
@@ -629,8 +668,10 @@ public class CloudSim {
/**
* Selects an event matching a predicate.
*
* @param src the src
* @param p the p
* @param src
* the src
* @param p
* the p
*
* @return the sim event
*/
...
...
@@ -650,8 +691,10 @@ public class CloudSim {
/**
* Find first deferred event matching a predicate.
*
* @param src the src
* @param p the p
* @param src
* the src
* @param p
* the p
* @return the sim event
*/
public
static
SimEvent
findFirstDeferred
(
int
src
,
Predicate
p
)
{
...
...
@@ -669,8 +712,10 @@ public class CloudSim {
/**
* Removes an event from the event queue.
*
* @param src the src
* @param p the p
* @param src
* the src
* @param p
* the p
*
* @return the sim event
*/
...
...
@@ -689,11 +734,14 @@ public class CloudSim {
}
/**
* Removes all events that match a given predicate from the future event queue
* returns true if at least one event has been cancelled; false otherwise.
* Removes all events that match a given predicate from the future event
* queue returns true if at least one event has been cancelled; false
* otherwise.
*
* @param src the src
* @param p the p
* @param src
* the src
* @param p
* the p
*
* @return true, if successful
*/
...
...
@@ -717,7 +765,8 @@ public class CloudSim {
/**
* Processes an event.
*
* @param e the e
* @param e
* the e
*/
private
static
void
processEvent
(
SimEvent
e
)
{
int
dest
,
src
;
...
...
@@ -742,8 +791,7 @@ public class CloudSim {
// Check for matching wait
dest
=
e
.
getDestination
();
if
(
dest
<
0
)
{
throw
new
IllegalArgumentException
(
"Attempt to send to a null entity detected."
);
throw
new
IllegalArgumentException
(
"Attempt to send to a null entity detected."
);
}
else
{
int
tag
=
e
.
getTag
();
dest_ent
=
entities
.
get
(
dest
);
...
...
@@ -795,8 +843,7 @@ public class CloudSim {
* Check if the simulation is still running. This method should be used by
* entities to check if they should continue executing.
*
* @return if the simulation is still running,
* otherwise
* @return if the simulation is still running, otherwise
*/
public
static
boolean
running
()
{
return
running
;
...
...
@@ -805,8 +852,7 @@ public class CloudSim {
/**
* This method is called if one wants to pause the simulation.
*
* @return true, if successful
* otherwise.
* @return true, if successful otherwise.
*/
public
static
boolean
pauseSimulation
()
{
paused
=
true
;
...
...
@@ -817,9 +863,9 @@ public class CloudSim {
* This method is called if one wants to pause the simulation at a given
* time.
*
* @param time
the time at which the simulation has to be paused
*
@return true, if successful
* otherwise.
* @param time
*
the time at which the simulation has to be paused
*
@return true, if successful
otherwise.
*/
public
static
boolean
pauseSimulation
(
long
time
)
{
if
(
time
<=
clock
)
{
...
...
@@ -834,8 +880,7 @@ public class CloudSim {
* This method is called if one wants to resume the simulation that has
* previously been paused.
*
* @return if the simulation has been restarted or or
* otherwise.
* @return if the simulation has been restarted or or otherwise.
*/
public
static
boolean
resumeSimulation
()
{
paused
=
false
;
...
...
@@ -862,14 +907,16 @@ public class CloudSim {
break
;
}
//this block allows termination of simulation at a specific time
//
this block allows termination of simulation at a specific time
if
(
terminateAt
>
0.0
&&
clock
>=
terminateAt
)
{
terminateSimulation
();
clock
=
terminateAt
;
break
;
}
if
(
pauseAt
!=
-
1
&&
((
future
.
size
()
>
0
&&
clock
<=
pauseAt
&&
pauseAt
<=
future
.
iterator
().
next
().
eventTime
())
||
future
.
size
()
==
0
&&
pauseAt
<=
clock
))
{
if
(
pauseAt
!=
-
1
&&
((
future
.
size
()
>
0
&&
clock
<=
pauseAt
&&
pauseAt
<=
future
.
iterator
().
next
()
.
eventTime
())
||
future
.
size
()
==
0
&&
pauseAt
<=
clock
))
{
pauseSimulation
();
clock
=
pauseAt
;
}
...
...
@@ -934,7 +981,8 @@ public class CloudSim {
/**
* Prints a message about the progress of the simulation.
*
* @param message the message
* @param message
* the message
*/
private
static
void
printMessage
(
String
message
)
{
Log
.
printLine
(
message
);
...
...
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