Added useful comments to the first example.

parent 7dd7b73d
......@@ -35,14 +35,11 @@ import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
/**
* A simple example showing how to create a datacenter with one host and run one
* cloudlet on it.
* A simple example showing how to create a data center with one host and run one cloudlet on it.
*/
public class CloudSimExample1 {
/** The cloudlet list. */
private static List<Cloudlet> cloudletList;
/** The vmlist. */
private static List<Vm> vmlist;
......@@ -53,17 +50,33 @@ public class CloudSimExample1 {
*/
@SuppressWarnings("unused")
public static void main(String[] args) {
Log.printLine("Starting CloudSimExample1...");
try {
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
// First step: Initialize the CloudSim package. It should be called before creating any entities.
int num_user = 1; // number of cloud users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false; // mean trace events
// Initialize the CloudSim library
Calendar calendar = Calendar.getInstance(); // Calendar whose fields have been initialized with the current date and time.
boolean trace_flag = false; // trace events
/* Comment Start - Dinesh Bhagwat
* Initialize the CloudSim library.
* init() invokes initCommonVariable() which in turn calls initialize() (all these 3 methods are defined in CloudSim.java).
* initialize() creates two collections - an ArrayList of SimEntity Objects (named entities which denote the simulation entities) and
* a LinkedHashMap (named entitiesByName which denote the LinkedHashMap of the same simulation entities), with name of every SimEntity as the key.
* initialize() creates two queues - a Queue of SimEvents (future) and another Queue of SimEvents (deferred).
* initialize() creates a HashMap of of Predicates (with integers as keys) - these predicates are used to select a particular event from the deferred queue.
* initialize() sets the simulation clock to 0 and running (a boolean flag) to false.
* Once initialize() returns (note that we are in method initCommonVariable() now), a CloudSimShutDown (which is derived from SimEntity) instance is created
* (with numuser as 1, its name as CloudSimShutDown, id as -1, and state as RUNNABLE). Then this new entity is added to the simulation
* While being added to the simulation, its id changes to 0 (from the earlier -1). The two collections - entities and entitiesByName are updated with this SimEntity.
* the shutdownId (whose default value was -1) is 0
* Once initCommonVariable() returns (note that we are in method init() now), a CloudInformationService (which is also derived from SimEntity) instance is created
* (with its name as CloudInformatinService, id as -1, and state as RUNNABLE). Then this new entity is also added to the simulation.
* While being added to the simulation, the id of the SimEntitiy is changed to 1 (which is the next id) from its earlier value of -1.
* The two collections - entities and entitiesByName are updated with this SimEntity.
* the cisId(whose default value is -1) is 1
* Comment End - Dinesh Bhagwat
*/
CloudSim.init(num_user, calendar, trace_flag);
// Second step: Create Datacenters
......@@ -257,5 +270,4 @@ public class CloudSimExample1 {
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment