|
From: <mar...@us...> - 2008-11-16 10:43:05
|
Revision: 259
http://gridsim.svn.sourceforge.net/gridsim/?rev=259&view=rev
Author: marcos_dias
Date: 2008-11-16 10:42:53 +0000 (Sun, 16 Nov 2008)
Log Message:
-----------
A few improvements in the source code.
Modified Paths:
--------------
branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java
branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java
branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java
branches/gridsim4.0-branch3/source/eduni/simjava/Sim_system.java
branches/gridsim4.0-branch3/source/gridsim/GridSim.java
branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java
branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java
branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java
branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java
branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java
branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java
branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java
branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java
branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java
branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java
branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java
branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java
branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java
branches/gridsim4.0-branch3/source/gridsim/turbo/FilterARMessage.java
branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java
branches/gridsim4.0-branch3/source/gridsim/turbo/MAUIEBParallelSpaceShared.java
branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java
branches/gridsim4.0-branch3/source/gridsim/turbo/MPProfileEntry.java
branches/gridsim4.0-branch3/source/gridsim/turbo/OrderGridletByStartTime.java
branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java
branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java
branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartition.java
branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java
branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java
branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java
branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java
branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java
branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java
branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java
branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlot.java
branches/gridsim4.0-branch3/source/gridsim/turbo/WorkloadInterface.java
Removed Paths:
-------------
branches/gridsim4.0-branch3/source/eduni/simjava/Sim_outfile.java
branches/gridsim4.0-branch3/source/eduni/simjava/Sim_output.java
Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java
===================================================================
--- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -122,10 +122,10 @@
//////////////////////////////////////////
// Starts the simulation in debug mode
- GridSim.startGridSimulation(true);
+// GridSim.startGridSimulation(true);
// Start the simulation in normal mode
-// GridSim.startGridSimulation();
+ GridSim.startGridSimulation();
//////////////////////////////////////////
// Final step: Prints the Gridlets when simulation is over
Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java
===================================================================
--- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -92,10 +92,10 @@
//////////////////////////////////////////
// Starts the simulation in debug mode
- GridSim.startGridSimulation(true);
+// GridSim.startGridSimulation(true);
// Start the simulation in normal mode
-// GridSim.startGridSimulation();
+ GridSim.startGridSimulation();
//////////////////////////////////////////
// Final step: Prints the Gridlets when simulation is over
Modified: branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java
===================================================================
--- branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -157,19 +157,6 @@
}
/**
- * Write a trace message.
- * @param level The level at which the trace should be printed, used
- * with <code>Sim_system.set_trace_level()</code> to control
- * what traces are printed
- * @param msg The message to be printed
- */
- public void sim_trace(int level, String msg) {
- if((level & Sim_system.get_trace_level()) != 0) {
- Sim_system.ent_trace(me, msg);
- }
- }
-
- /**
* Signal that an event has completed service.
* @param e The event that has completed service
*/
@@ -177,9 +164,6 @@
if (!Sim_system.running()) {
return;
}
-
- // Notify Sim_system (used for run length determination)
- Sim_system.job_completed(me, e.get_tag());
}
@@ -477,7 +461,6 @@
if (!Sim_system.running()) {
return;
}
- double start_time = Sim_system.sim_clock();
Sim_system.hold(me,delay);
Sim_system.paused();
restart.p();
@@ -507,10 +490,6 @@
if (!Sim_system.running()) {
return;
}
- double start_time = Sim_system.sim_clock();
- if (Sim_system.default_tracing()) {
- Sim_system.trace(me, "start holding");
- }
sim_wait_for(p, ev);
if (!Sim_system.running()) return;
}
@@ -521,7 +500,7 @@
* events.
* @param delay The time period for which the entity will be active unless interrupted
* @param ev The event to which the arriving event will be copied to
- * @return The time of the specified time period remaining after the arrival occured
+ * @return The time of the specified time period remaining after the arrival occurred
*/
public double sim_process_for(double delay, Sim_event ev) {
if (delay < 0.0) {
@@ -552,16 +531,13 @@
}
double start_time = Sim_system.sim_clock();
double time_left = 0.0;
- if (Sim_system.default_tracing()) {
- Sim_system.trace(me, "start holding");
- }
sim_schedule(me, delay, 9999); // Send self 'hold done' msg
sim_wait_for(p, ev);
if (!Sim_system.running()) return 0.0;
if (ev.get_tag() != 9999) { // interrupted
Sim_type_p stp = new Sim_type_p(9999);
time_left = delay - (ev.event_time() - start_time);
- int success = sim_cancel(stp,null);
+ sim_cancel(stp,null);
}
if (time_left <= 0.0) {
return 0.0;
@@ -610,9 +586,6 @@
if (!Sim_system.running()) {
return;
}
- if (Sim_system.default_tracing()) {
- Sim_system.trace(me, "start pausing");
- }
sim_wait_for(p, ev);
}
@@ -637,7 +610,7 @@
* @param p The predicate to match
* @param delay The time period for which the entity will be inactive unless interrupted
* @param ev The event to which the arriving event will be copied to
- * @return The time of the specified time period remaining after the arrival occured
+ * @return The time of the specified time period remaining after the arrival occurred
*/
public double sim_pause_for(Sim_predicate p, double delay, Sim_event ev) {
if (delay < 0.0) {
@@ -648,16 +621,13 @@
}
double start_time = Sim_system.sim_clock();
double time_left = 0.0;
- if (Sim_system.default_tracing()) {
- Sim_system.trace(me, "start pausing");
- }
sim_schedule(me, delay, 9999); // Send self 'hold done' msg
sim_wait_for(p, ev);
if (!Sim_system.running()) return 0.0;
if (ev.get_tag() != 9999) { // interrupted
Sim_type_p stp = new Sim_type_p(9999);
time_left = delay - (ev.event_time() - start_time);
- int success = sim_cancel(stp,null);
+ sim_cancel(stp,null);
}
if (time_left <= 0.0) {
return 0.0;
@@ -749,7 +719,7 @@
if (ev.get_tag() != 9999) { // interrupted
Sim_type_p stp = new Sim_type_p(9999);
time_left = delay - (ev.event_time() - Sim_system.sim_clock());
- int success = sim_cancel(stp, null);
+ sim_cancel(stp, null);
}
if (time_left <= 0.0) {
return 0.0;
Deleted: branches/gridsim4.0-branch3/source/eduni/simjava/Sim_outfile.java
===================================================================
--- branches/gridsim4.0-branch3/source/eduni/simjava/Sim_outfile.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/eduni/simjava/Sim_outfile.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -1,53 +0,0 @@
-/* Sim_outfile.java */
-
-package eduni.simjava;
-
-import java.io.PrintWriter;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-/**
- * The default trace output class, which implements the Sim_output
- * interface. This class implements output to a file called tracefile
- * in the current directory, and is used by default in full Java applications.
- * Note that it can't be used in applets, because they do not allow access
- * to files.
- * @see Sim_output
- * @version 1.0, 4 September
- * @version 1.1, 24 March 1997
- * @author Ross McNab, Fred Howell
- */
-public class Sim_outfile implements Sim_output {
- private PrintWriter trcstream;
-
- /**
- * Constructor
- */
- public Sim_outfile() { }
-
- /**
- * Attempt to open the file
- */
- public void initialise() {
- try {
- trcstream = new PrintWriter(new FileOutputStream("sim_trace"));
- } catch(IOException e) {
- System.out.println("Sim_system: Error - could not open trace file");
- }
- }
-
- /**
- * Print a trace line to the file
- * @param msg The message to print
- */
- public void println(String msg) {
- trcstream.println(msg);
- }
-
- /**
- * Close the file
- */
- public void close() {
- trcstream.close();
- }
-}
Deleted: branches/gridsim4.0-branch3/source/eduni/simjava/Sim_output.java
===================================================================
--- branches/gridsim4.0-branch3/source/eduni/simjava/Sim_output.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/eduni/simjava/Sim_output.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -1,28 +0,0 @@
-/* Sim_output.java */
-
-package eduni.simjava;
-
-/**
- * The interface that a trace output class must provide.
- * @see Sim_system
- * @version 1.0, 4 September 1996
- * @author Ross McNab
- */
-public interface Sim_output {
-
- /**
- * Called by <code>Sim_system</code> before the simulation starts.
- */
- public void initialise();
-
- /**
- * Called by <code>Sim_system</code> to output a trace line.
- * @param msg The trace message
- */
- public void println(String msg);
-
- /**
- * Called by <code>Sim_system</code> at the end of the simulation.
- */
- public void close();
-}
Modified: branches/gridsim4.0-branch3/source/eduni/simjava/Sim_system.java
===================================================================
--- branches/gridsim4.0-branch3/source/eduni/simjava/Sim_system.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/eduni/simjava/Sim_system.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -49,12 +49,6 @@
*/
public class Sim_system {
- // Fields for the management of the trace file
- private static int[] trace_tags; // The tags for which trace will be generated
- private static boolean default_trace = true, // Flag for including or not the default trace
- entity_trace = true, // Flag for including or not the entity trace
- event_trace = true; // Flag for including or not the event specific trace
-
// Private data members
private static List entities; // The current entity list
private static Evqueue future; // The future event queue
@@ -63,9 +57,6 @@
private static boolean running; // Flag for checking if the simulation is running
private static Semaphore onestopped; // Semaphore for synchronising entities
private static Semaphore onecompleted; // Semaphore for registering entities having completed
- private static Sim_output trcout; // The output object for trace messages
- private static int trace_level; // The trace level for which event trace will be generated
- private static boolean auto_trace; // Should we print trace messages?
private static HashMap wait_predicates; // The predicates used in entity wait methods
// Private fields used for seed generation
@@ -91,15 +82,6 @@
* at the start of the simulation.
*/
public static void initialise() {
- initialise(new Sim_outfile());
- }
-
- /**
- * Initialise the system to draw <code>simdiag</code> diagrams. This method
- * should be used directly only by expert users.
- * @param out The <code>Sim_output</code> instance that will receive the simulation trace
- */
- public static void initialise(Sim_output out) {
System.out.println("Initialising...");
entities = new ArrayList();
future = new Evqueue();
@@ -109,10 +91,6 @@
running = false;
onestopped = new Semaphore(0);
onecompleted = new Semaphore(0);
- trcout = out;
- trcout.initialise();
- trace_level = 0xff;
- auto_trace = false;
}
// The two standard predicates
@@ -144,21 +122,6 @@
public static int get_num_entities() { return entities.size(); }
/**
- * Get the current trace level (initially <code>0xff</code>), which
- * controls trace output. This method is identical to <code>get_trace_level()</code> and
- * is present for compatibility with existing simulations.
- * @return The trace level
- */
- public static int get_trc_level() { return trace_level; } // For compatibility with previous versions
-
- /**
- * Get the current trace level (initially <code>0xff</code>), which
- * controls trace output.
- * @return The trace level
- */
- public static int get_trace_level() { return trace_level; }
-
- /**
* Get the entity with a given id.
* @param id The entity's unique id number
* @return The entity, or <code>null</code> if it could not be found
@@ -203,8 +166,6 @@
return id;
}
- // ADDED BY MARCOS TO GET THE LIST OF ENTITIES IN THE SIMULATION
-
/**
* Returns a list of entities created for the simulation
* @return the entity iterator
@@ -217,8 +178,6 @@
return list;
}
- // END OF METHODS ADDED BY MARCOS
-
/**
* Get the currently running entity.
* @return The entity, or <code>null</code> if none are running
@@ -230,26 +189,6 @@
// Public update methods
/**
- * Set the trace level which controls entity trace output. This method is identical to
- * <code>set_trace_level()</code> and is present for compatibility with existing simulations.
- * @param level The new level
- */
- public static void set_trc_level(int level) { auto_trace = true; trace_level = level; }
-
- /**
- * Set the trace level which controls entity trace output.
- * @param level The new level
- */
- public static void set_trace_level(int level) { auto_trace = true; trace_level = level; }
-
- /**
- * Switch the trace messages on and off.
- * @param on If <code>true</code> then the messages are switched on, if <code>false</code>
- they are switched off.
- */
- public static void set_auto_trace(boolean on) { auto_trace = on; }
-
- /**
* Add a new entity to the simulation. This is present for compatibility with existing
* simulations since entities are automatically added to the simulation upon instantiation.
* @param e The new entity
@@ -367,19 +306,12 @@
*/
public static void run_stop() {
print_message("Simulation completed.");
- trcout.close();
}
//
// Package level methods
//
- /**
- * Get the object to which the simulation trace is sent.
- * @return The trace handler
- */
- public static Sim_output get_trcout() { return trcout; }
-
// Entity service methods
// Called by an entity just before it become non-RUNNABLE
@@ -390,9 +322,6 @@
Sim_event e = new Sim_event(Sim_event.HOLD_DONE,clock+delay,src);
future.add_event(e);
((Sim_entity)entities.get(src)).set_state(Sim_entity.HOLDING);
- if (auto_trace && default_trace) {
- trace(src, "start processing");
- }
}
// Used to pause an entity for some time
@@ -400,9 +329,6 @@
Sim_event e = new Sim_event(Sim_event.HOLD_DONE,clock+delay,src);
future.add_event(e);
((Sim_entity)entities.get(src)).set_state(Sim_entity.HOLDING);
- if (auto_trace && default_trace) {
- trace(src, "start pausing");
- }
}
// Used to send an event from one entity to another
@@ -411,11 +337,6 @@
throw new Sim_exception("Sim_system: Send delay can't be negative.");
}
Sim_event e = new Sim_event(Sim_event.SEND, clock+delay, src, dest, tag, data);
- if (auto_trace && (default_trace || (event_trace && is_trace_tag(tag)))) {
- trace(src, "scheduling event type "+tag+" for "+
- ((Sim_entity)entities.get(dest)).get_name()+
- " with delay "+delay);
- }
future.add_event(e);
}
@@ -428,9 +349,6 @@
// If a predicate has been used store it in order to check it
wait_predicates.put(new Integer(src), p);
}
- if (auto_trace && default_trace) {
- trace(src,"waiting for an event");
- }
}
// Checks if events for a specific entity are present in the deferred event queue
@@ -464,14 +382,8 @@
}
if (found) {
((Sim_entity)entities.get(src)).set_evbuf((Sim_event)ev.clone());
- if (auto_trace && (default_trace || (event_trace &&is_trace_tag(ev.get_tag())))) {
- trace(src,"selected event type " + ev.get_tag() + " (event time was "+ev.event_time()+")");
- }
} else {
((Sim_entity)entities.get(src)).set_evbuf(null);
- if (auto_trace && (default_trace)) {
- trace(src,"no event selected");
- }
}
}
@@ -494,14 +406,8 @@
if (found) {
((Sim_entity)entities.get(src)).set_evbuf((Sim_event)ev.clone());
- if (auto_trace && (default_trace || (event_trace && is_trace_tag(ev.get_tag())))) {
- trace(src,"cancelled event type " + ev.get_tag() + " (event time was "+ev.event_time()+")");
- }
} else {
((Sim_entity)entities.get(src)).set_evbuf(null);
- if (auto_trace && default_trace) {
- trace(src,"no event cancelled");
- }
}
}
@@ -529,9 +435,7 @@
// Processes an event
private static void process_event(Sim_event e) {
- // ADDED BY MARCOS TO ALLOW THE
- // SIMULATION TO BE PAUSED
-
+ // ADDED TO ALLOW THE SIMULATION TO BE PAUSED
synchronized(syncObj){
if(clock >= pauseAt)
@@ -600,7 +504,7 @@
/**
* Set the sample generators' seed sequence. If this method is not called the defaults
* are 4851 as the root seed and 100000 as the desired sample spacing.
- * @param seed_specing The seed spacing
+ * @param seed_spacing The seed spacing
* @param root_seed The seed used to generate all the simulation's seeds
*/
public static void set_seed_sequence(int seed_spacing, long root_seed) {
@@ -663,14 +567,6 @@
return new_seed;
}
- // Called when an event is considered to have completed service. If the event that completed is the one
- // that determines the run length condition.
- static synchronized void job_completed(int entity, int event_tag) {
- if (auto_trace && (default_trace || (event_trace && is_trace_tag(event_tag)))) {
- trace(entity, "event type " + event_tag + " completed service");
- }
- }
-
/**
* Internal method used to start the simulation. This method should <b>not</b> be used by user simulations.
*/
@@ -697,8 +593,7 @@
return running;
}
- // ADDED BY MARCOS TO ALLOW THE SIMULATION TO BE
- // PAUSED AND RESUMED
+ // ADDED TO ALLOW THE SIMULATION TO BE PAUSED AND RESUMED
/**
* This method is called if one wants to
@@ -716,7 +611,7 @@
/**
* This method is called if one wants to pause the simulation
* at a given time
- * @time the time at which the simulation has to be paused
+ * @param time the time at which the simulation has to be paused
* @return <tt>true</tt>if the simulation has been paused
* or <tt>false</tt> otherwise.
*/
@@ -748,7 +643,7 @@
}
}
- // END OF METHODS ADDED BY MARCOS
+ // END OF METHODS USED TO PAUSE THE SIMULATION
/**
* Start the simulation running. This should be called after all the entities have been setup
@@ -795,93 +690,6 @@
private static void print_message(String message) {
System.out.println(message);
}
-
- // TRACE METHODS
-
- /**
- * Set the desired contents of the trace file. The default is to include all trace, if tracing is
- * switched on.
- * @param default_trace If set to <code>true</code> the default trace will be included in the trace file,
- * if <code>false</code> it will not
- * @param entity_trace If set to <code>true</code> the trace generated by the entities will be
- * included in the trace file, if <code>false</code> it will not
- * @param event_trace If set to <code>true</code> the trace file will include trace for the selected
- * event types, if <code>false</code> it will not
- */
- public static void set_trace_detail(boolean default_trace, boolean entity_trace, boolean event_trace) {
- auto_trace = true;
- Sim_system.default_trace = default_trace;
- Sim_system.entity_trace = entity_trace;
- Sim_system.event_trace = event_trace;
- }
-
- /**
- * Generate trace for a specific event type.
- * @param tag The event type
- */
- public static void track_event(int tag) {
- auto_trace = true;
- if (trace_tags == null) {
- trace_tags = new int[1];
- trace_tags[0] = tag;
- } else {
- int[] temp = trace_tags;
- trace_tags = new int[temp.length + 1];
- for (int i=0; i < temp.length; i++) {
- trace_tags[i] = temp[i];
- }
- trace_tags[temp.length] = tag;
- }
- }
-
- /**
- * Generate trace for a set of specific event types
- * @tags The set of event types
- */
- public static void track_events(int[] tags) {
- auto_trace = true;
- if (trace_tags == null) {
- trace_tags = tags;
- } else {
- int[] temp = trace_tags;
- trace_tags = new int[temp.length + tags.length];
- for (int i=0; i < temp.length; i++) {
- trace_tags[i] = temp[i];
- }
- for (int i=(temp.length-1); i < tags.length; i++) {
- trace_tags[i] = tags[i];
- }
- }
- }
-
- // Adds a trace message
- static synchronized void trace(int src, String msg) {
- trcout.println("u: " + ((Sim_entity)entities.get(src)).get_name() + " at " + clock + ": " + msg);
- }
-
- // Called by entities to generate trace messages
- static synchronized void ent_trace(int src, String msg) {
- if ((auto_trace && entity_trace)) trace(src, msg);
- }
-
- // Checks to see whether this tag is a tag for which tracing is specified
- private static boolean is_trace_tag(int tag) {
- boolean result = false;
- if (trace_tags != null) {
- for (int i=0; i < trace_tags.length; i++) {
- if (trace_tags[i] == tag) {
- result = true;
- break;
- }
- }
- }
- return result;
- }
-
- // Check if the default trace is being produce
- static boolean default_tracing() {
- return (auto_trace && default_trace);
- }
}
Modified: branches/gridsim4.0-branch3/source/gridsim/GridSim.java
===================================================================
--- branches/gridsim4.0-branch3/source/gridsim/GridSim.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/gridsim/GridSim.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -83,7 +83,7 @@
private final int ARRAY_SIZE = 3;
private final int SIZE = 12; // Integer object size incl. overhead
private final int RESULT = 1; // array[0] = gridlet id, [1] = result
- private final static String GRIDSIM_VERSION_STRING = "Turbo Alpha 0.1";
+ private final static String GRIDSIM_VERSION_STRING = "Alpha 0.1";
// These attributes are set to be used by the Graphical User Interface
public static boolean debugMode_ = false;
@@ -123,7 +123,7 @@
private static Calendar calendar_ = null; // a Calendar object
private static GridInformationService gis_ = null; // a GIS object
private final static int NOT_FOUND = -1; // a constant
- private static boolean traceFlag_;
+ private static boolean traceFlag_ = false;
////////////////////////////////////////////////////////////////////////
@@ -278,7 +278,7 @@
* processings to be excluded from writing
* into a file
* @param reportWriterName a <tt>ReportWriter</tt> entity name. This entity
- * can be found inside a gridbroker package.
+ * can be found inside a grid broker package.
* @see gridsim.GridSimShutdown
* @see gridsim.GridStatistics
* @see gridsim.GridInformationService
@@ -543,8 +543,7 @@
* @param shouldPause indicates whether the simulation should be paused after
* notifying the listeners. <tt>true</tt> indicates that it should pause and
* <tt>false</tt> means that it should not.
- * @param itemList the list of gridlets to provide to the listeners
- *
+ * @param itemList the list of schedule items to provide to the listeners
* @see AllocationAction#ITEM_ARRIVED
* @see AllocationAction#ITEM_SCHEDULED
* @see AllocationAction#ITEM_CANCELLED
@@ -572,8 +571,7 @@
* @param shouldPause indicates whether the simulation should be paused after
* notifying the listeners. <tt>true</tt> indicates that it should pause and
* <tt>false</tt> means that it should not.
- * @param item the gridlet to provide to the listeners
- *
+ * @param item the schedule item to provide to the listeners
* @see AllocationAction#ITEM_ARRIVED
* @see AllocationAction#ITEM_SCHEDULED
* @see AllocationAction#ITEM_CANCELLED
@@ -603,8 +601,6 @@
* @param shouldPause indicates whether the simulation should be paused after
* notifying the listeners. <tt>true</tt> indicates that it should pause and
* <tt>false</tt> means that it should not.
- * @param gridlet the gridlet to provide to the listeners
- *
* @see AllocationAction#ITEM_ARRIVED
* @see AllocationAction#ITEM_SCHEDULED
* @see AllocationAction#ITEM_CANCELLED
@@ -694,8 +690,6 @@
{
// NOTE: the order for the below 3 lines are important
Sim_system.initialise();
- Sim_system.set_trc_level(1);
- Sim_system.set_auto_trace(traceFlag);
// Set the current Wall clock time as the starting time of simulation
calendar_ = cal;
@@ -731,7 +725,7 @@
* @post $none
*/
public static void startGridSimulation() throws NullPointerException {
- System.out.println("Starting GridSim " + GRIDSIM_VERSION_STRING);
+ System.out.println("Starting GridSim version " + GRIDSIM_VERSION_STRING);
try {
Sim_system.run();
}
@@ -760,7 +754,7 @@
*/
public static void startGridSimulation(boolean debug)
throws NullPointerException {
- System.out.println("Starting GridSim " + GRIDSIM_VERSION_STRING);
+ System.out.println("Starting GridSim version " + GRIDSIM_VERSION_STRING);
if(!debug) {
disableDebugMode();
startGridSimulation();
Modified: branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java
===================================================================
--- branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -1018,6 +1018,7 @@
// the list model. This is a wrapper around the vector
// of elements to be shown in the list
private class ItemListModel extends AbstractListModel {
+ private static final long serialVersionUID = -8237271304298777156L;
private Vector<ScheduleItem> items_ = new Vector<ScheduleItem>();
public Object getElementAt(int index) {
@@ -1077,6 +1078,8 @@
* Panel that contains information about the colors
*/
private class ColorLabelPanel extends JPanel {
+ private static final long serialVersionUID = 4737308429990400119L;
+
public ColorLabelPanel() {
super();
setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java
===================================================================
--- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -7,6 +7,11 @@
package gridsim.turbo;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+
import eduni.simjava.Sim_event;
import gridsim.GridSim;
import gridsim.GridSimTags;
@@ -14,11 +19,6 @@
import gridsim.IO_data;
import gridsim.gui.AllocationAction;
-import java.util.Calendar;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-
/**
* This class implements a non-FCFS policy to schedule parallel jobs. The
* policy is based on conservative backfilling and supports advance reservation.
@@ -68,7 +68,7 @@
// internal event tags used by this gridlet
// a tag to denote expiry time
- private final int EXPIRY_TIME = 12;
+ private static final int EXPIRY_TIME = 12;
// last time the expiration of reservations was checked
private double lastCheckExpiryTime_;
@@ -181,7 +181,7 @@
double currentTime = GridSim.clock();
- int freePE;
+ int freePE = 0;
int reqPE = gridlet.getNumPE();
// gets the advance reservation
SSReservation sRes = reservTable_.get(gridlet.getReservationID());
@@ -247,8 +247,7 @@
else {
// selects a list of ranges for the gridlet from the PEs available
// for the reservation
- PERangeList selected = null;
- success = ( ( selected = sRes.selectPERangeList(reqPE) ) != null );
+ PERangeList selected = sRes.selectPERangeList(reqPE);
sgl.setPERangeList(selected);
double resStartTime = sRes.getStartTime();
@@ -282,7 +281,7 @@
//---------------------------------------------------------------
// sends back an ack if required
- if (ack == true) {
+ if (ack) {
super.sendAck(GridSimTags.GRIDLET_SUBMIT_ACK, true,
gridlet.getGridletID(), gridlet.getUserID()
);
@@ -300,7 +299,6 @@
*/
public boolean handleCreateReservation(ARMessage message) {
double currentTime = GridSim.clock();
- boolean success;
// gets the reservation object and extract some
// information from it
@@ -313,7 +311,7 @@
ARMessage response = message.createResponse();
// validate the reservation, check num of PEs required, partition, etc.
- success = validateReservation(sRes);
+ boolean success = validateReservation(sRes);
if(!success) {
reservation.setStatus(Reservation.STATUS_FAILED);
@@ -323,8 +321,9 @@
}
double startTime = reservation.getStartTime();
- if(startTime == 0 || startTime < currentTime)
+ if(startTime == 0.0 || startTime < currentTime) {
startTime = currentTime;
+ }
double expTime = Double.NaN;
@@ -659,8 +658,9 @@
break;
}
}
- else
+ else {
super.processOtherEvent(ev);
+ }
}
// --------------------- PROTECTED METHODS -----------------------
@@ -783,8 +783,9 @@
/**
* This method is called to start a reservation and consequently update
* the availability profile.
- * @refTime the reservations whose start time is smaller
+ * @param refTime the reservations whose start time is smaller
* or equals to refTime will be started
+ * @return the number of reservations started
*/
protected int startReservations(double refTime) {
LinkedList<SSReservation> startedReservations = new LinkedList<SSReservation>();
@@ -961,8 +962,9 @@
// to be returned. It removes repeated entries.
for(int i=anchorIndex+1; i<length; i++) {
MPProfileEntry nextEntry = profile_.get(i);
- if(nextEntry.getTime() <= startTime)
+ if(nextEntry.getTime() <= startTime) {
continue;
+ }
if(nextEntry.getTime() > finishTime){
break;
}
@@ -1021,7 +1023,6 @@
/**
* Checks for expiry time of a given reservations in the list.
- * @param reservation the reservation to be checked
*/
private void checkExpiryTime() {
Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java
===================================================================
--- branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -7,6 +7,11 @@
package gridsim.turbo;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+
import eduni.simjava.Sim_event;
import gridsim.GridSim;
import gridsim.GridSimTags;
@@ -14,11 +19,6 @@
import gridsim.IO_data;
import gridsim.gui.AllocationAction;
-import java.util.Calendar;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-
/**
* This class implements a non-FCFS policy to schedule parallel jobs. The
* policy is based on easy backfilling and supports advance reservation.
@@ -76,7 +76,7 @@
// internal event tags used by this gridlet
// a tag to denote expiry time
- private final int EXPIRY_TIME = 12;
+ private static final int EXPIRY_TIME = 12;
// last time the expiration of reservations was checked
private double lastCheckExpiryTime_;
@@ -189,7 +189,7 @@
double currentTime = GridSim.clock();
- int freePE;
+ int freePE = 0;
int reqPE = gridlet.getNumPE();
// gets the advance reservation
SSReservation sRes = reservTable_.get(gridlet.getReservationID());
@@ -255,8 +255,7 @@
else {
// selects a list of ranges for the gridlet from the PEs available
// for the reservation
- PERangeList selected = null;
- success = ( ( selected = sRes.selectPERangeList(reqPE) ) != null );
+ PERangeList selected = sRes.selectPERangeList(reqPE);
sgl.setPERangeList(selected);
double resStartTime = sRes.getStartTime();
@@ -308,7 +307,6 @@
*/
public boolean handleCreateReservation(ARMessage message) {
double currentTime = GridSim.clock();
- boolean success;
// gets the reservation object and extract some
// information from it
@@ -321,7 +319,7 @@
ARMessage response = message.createResponse();
// validate the reservation, check num of PEs required, partition, etc.
- success = validateReservation(sRes);
+ boolean success = validateReservation(sRes);
if(!success) {
reservation.setStatus(Reservation.STATUS_FAILED);
@@ -331,8 +329,9 @@
}
double startTime = reservation.getStartTime();
- if(startTime == 0 || startTime < currentTime)
+ if(startTime == 0 || startTime < currentTime) {
startTime = currentTime;
+ }
double expTime = Double.NaN;
@@ -812,8 +811,9 @@
// to be returned. It removes repeated entries.
for(int i=anchorIndex+1; i<length; i++) {
MPProfileEntry nextEntry = profile_.get(i);
- if(nextEntry.getTime() <= startTime)
+ if(nextEntry.getTime() <= startTime) {
continue;
+ }
if(nextEntry.getTime() > finishTime){
break;
}
@@ -898,8 +898,9 @@
// to be returned. It removes repeated entries.
for(int i=anchorIndex+1; i<length; i++) {
MPProfileEntry nextEntry = profile_.get(i);
- if(nextEntry.getTime() <= startTime)
+ if(nextEntry.getTime() <= startTime) {
continue;
+ }
if(nextEntry.getTime() > finishTime){
break;
}
@@ -958,7 +959,6 @@
/**
* Checks for expiry time of a given reservations in the list.
- * @param reservation the reservation to be checked
*/
private void checkExpiryTime() {
Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java
===================================================================
--- branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -252,8 +252,9 @@
* <tt>false</tt> otherwise
*/
public boolean setDestinationID(int destId) {
- if(destId < 0)
+ if(destId < 0) {
return false;
+ }
dstId_ = destId;
return true;
}
@@ -321,8 +322,9 @@
* or <tt>false</tt> otherwise
*/
public boolean setReservation(Reservation reservation) {
- if(reservation == null)
+ if(reservation == null) {
return false;
+ }
reservation_ = reservation;
return true;
@@ -341,10 +343,12 @@
* @return the reservation id of <tt>-1</tt> if not found
*/
public int getReservationID() {
- if(reservation_ != null)
+ if(reservation_ != null) {
return reservation_.getID();
- else
+ }
+ else {
return -1;
+ }
}
/**
@@ -362,8 +366,9 @@
* @return <tt>true</tt> if successfully or <tt>false</tt> otherwise
*/
public boolean setPrice(double price) {
- if(price <= 0.0)
+ if(price <= 0.0) {
return false;
+ }
price_ = price;
return true;
Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java
===================================================================
--- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -7,6 +7,12 @@
package gridsim.turbo;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+
import eduni.simjava.Sim_event;
import gridsim.GridSim;
import gridsim.GridSimTags;
@@ -14,12 +20,6 @@
import gridsim.IO_data;
import gridsim.gui.AllocationAction;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-
/**
* <tt>ARParallelSpaceShared</tt> class is an allocation policy for
* <tt>ARTGridResource</tt> that implements conservative backfilling and
@@ -96,7 +96,7 @@
// internal event tags used by this gridlet
// a tag to denote expiry time
- private final int EXPIRY_TIME = 12;
+ private static final int EXPIRY_TIME = 12;
// last time the expiration of reservations was checked
private double lastCheckExpiryTime_;
@@ -658,8 +658,9 @@
break;
}
}
- else
+ else {
super.processOtherEvent(ev);
+ }
}
/**
@@ -686,7 +687,7 @@
double currentTime = GridSim.clock();
- int freePE;
+ int freePE = 0;
int reqPE = gridlet.getNumPE();
// gets the advance reservation
SSReservation sRes = reservTable_.get(gridlet.getReservationID());
@@ -752,8 +753,7 @@
else {
// selects a list of ranges for the gridlet from the PEs available
// for the reservation
- PERangeList selected = null;
- success = ( ( selected = sRes.selectPERangeList(reqPE) ) != null );
+ PERangeList selected = sRes.selectPERangeList(reqPE);
sgl.setPERangeList(selected);
double resStartTime = sRes.getStartTime();
@@ -787,7 +787,7 @@
//---------------------------------------------------------------
// sends back an ack if required
- if (ack == true) {
+ if (ack) {
super.sendAck(GridSimTags.GRIDLET_SUBMIT_ACK, true,
gridlet.getGridletID(), gridlet.getUserID()
);
@@ -846,7 +846,6 @@
/**
* Checks for expiry time of a given reservations in the list.
- * @param reservation the reservation to be checked
*/
private void checkExpiryTime() {
@@ -910,8 +909,9 @@
/**
* This method is called to start a reservation and consequently update
* the availability profile.
- * @refTime the reservations whose start time is smaller
+ * @param refTime the reservations whose start time is smaller
* or equals to refTime will be started
+ * @return the number of reservations started
*/
private int startReservation(double refTime) {
@@ -1001,6 +1001,7 @@
* to handle a reservation.
*
* @param reqPE the number of PEs
+ * @param startTime the supposed start time for the reservation
* @param duration the duration in seconds to execute the reservation
* @return an array[2] of Objects as follows:<br>
* array[0] the index of the anchor point<br>
@@ -1092,8 +1093,9 @@
}
}
- if(tailEntry != null)
+ if(tailEntry != null) {
tailIndex = availProfile_.indexOf(tailEntry);
+ }
// creates the array with the result
Object[] result = new Object[3];
Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java
===================================================================
--- branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -8,13 +8,14 @@
package gridsim.turbo;
+import java.util.Calendar;
+
import eduni.simjava.Sim_event;
import gridsim.GridResource;
import gridsim.GridSim;
import gridsim.GridSimTags;
import gridsim.ResourceCalendar;
import gridsim.net.Link;
-import java.util.Calendar;
/**
* <tt>ARTGridResource</tt> class handles all Advanced Reservation functionalities.
@@ -238,7 +239,7 @@
success = checkResourceType(message);
// if this resource doesn't support AR then exit
- if (success == false) {
+ if (!success) {
return;
}
@@ -271,6 +272,9 @@
case ARMessage.TYPE_AR_LIST_FREE_TIME:
arPolicy_.handleQueryAvailability(message);
break;
+
+ default:
+ break;
}
}
catch (Exception e) {
@@ -306,6 +310,10 @@
case ARMessage.TYPE_AR_LIST_FREE_TIME:
errorMessage = " cannot list free time slots.";
break;
+
+ default:
+ errorMessage = " unknown message.";
+ break;
}
System.out.println(super.get_name() + ": Error - " + errorMessage);
Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java
===================================================================
--- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -98,8 +98,9 @@
while(it.hasNext()) {
AvailabilityInfoEntry entry = it.next();
- if(entry.getTime() > time)
+ if(entry.getTime() > time) {
break;
+ }
preceding = entry;
}
@@ -148,11 +149,13 @@
public double getPotentialStartTime(double readyTime,
int duration, int reqPE, double deadline) {
- if(readyTime < startTime_)
+ if(readyTime < startTime_) {
readyTime = startTime_;
+ }
- if(readyTime > finishTime_)
+ if(readyTime > finishTime_) {
return UNKNOWN;
+ }
// the anchor index, the entry in the profile where
// the request would be placed OR the closest entry to the
@@ -168,8 +171,9 @@
anchorEntry = getPrecedingEntry(readyTime);
int firstAnchorIndex = super.indexOf(anchorEntry);
- if(firstAnchorIndex == -1)
+ if(firstAnchorIndex == -1) {
firstAnchorIndex = 0;
+ }
for(int j=firstAnchorIndex; j<length; j++) {
AvailabilityInfoEntry entry = super.get(j);
@@ -182,10 +186,12 @@
else {
// sets the start time as the time of the entry
- if(entry.getTime() < readyTime)
+ if(entry.getTime() < readyTime) {
potStartTime = readyTime;
- else
+ }
+ else {
potStartTime = entry.getTime();
+ }
// calculates when the finish time will be if
// the gridlet is put at this position
@@ -193,8 +199,9 @@
// The job would not complete before the deadline, then just
// return the potential start time as unknown
- if(potFinishTime > deadline)
+ if(potFinishTime > deadline) {
return UNKNOWN;
+ }
// if an entry with enough PEs is found, then scan the list
// from that point onwards analysing the intersection of
@@ -327,8 +334,9 @@
int size = super.size();
int firstIndex = super.indexOf(entry);
- if(firstIndex < 0)
+ if(firstIndex < 0) {
firstIndex = 0;
+ }
for(int i=firstIndex; i<size; i++) {
entry = super.get(i);
@@ -394,8 +402,9 @@
// gets the part of the profile relevant to create the slots
AvailabilityInfo subProfile = getSubAvailabilityInfo(startTime, finishTime);
- if(subProfile == null || subProfile.size() == 0)
+ if(subProfile == null || subProfile.size() == 0) {
return slots;
+ }
double slotStart = 0;
double slotFinish = 0;
@@ -412,8 +421,9 @@
startIdx = i;
endIdx = i;
- if(entry.getNumPE() == 0)
+ if(entry.getNumPE() == 0) {
continue;
+ }
// check all time slots starting at slotStart
do {
@@ -429,8 +439,9 @@
endIdx = j;
continue;
}
- else
+ else {
break;
+ }
}
if(intersect != null && intersect.getNumPE() > 0) {
@@ -467,8 +478,9 @@
AvailabilityInfo info = new AvailabilityInfo();
// start time cannot be smaller than the start time of the info obj
- if(startTime < startTime_)
+ if(startTime < startTime_) {
startTime = startTime_;
+ }
// start time cannot be larger than the finish time of the info obj
if(startTime > finishTime_) {
@@ -488,8 +500,9 @@
for(int i=index+1; i<length; i++) {
entry = super.get(i);
- if(entry.getTime() <= startTime)
+ if(entry.getTime() <= startTime) {
continue;
+ }
if(entry.getTime() > finishTime) {
break;
}
@@ -519,8 +532,9 @@
public void allocate(double startTime,
double finishTime, PERangeList selected) {
- if(startTime == finishTime_)
+ if(startTime == finishTime_) {
return;
+ }
// check whether a new tail is needed to mark the end of the request
if(finishTime < finishTime_) {
Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java
===================================================================
--- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -67,8 +67,9 @@
* <tt>false</tt> otherwise.
*/
public boolean setTime(double time) {
- if(time < 0)
+ if(time < 0) {
return false;
+ }
time_ = time;
return true;
@@ -121,8 +122,9 @@
* @return <tt>true</tt> if the ranges changed as result of this call
*/
public boolean addRanges(PERangeList list) {
- if(availRanges_ == null)
+ if(availRanges_ == null) {
availRanges_ = new PERangeList();
+ }
return availRanges_.addAll(list);
}
@@ -153,10 +155,12 @@
* @return the number of PEs
*/
public int getNumPE() {
- if(availRanges_ == null)
+ if(availRanges_ == null) {
return 0;
- else
+ }
+ else {
return availRanges_.getNumPE();
+ }
}
/**
Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java
===================================================================
--- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -118,8 +118,9 @@
AvailabilityProfileEntry previousEntry = null;
for(AvailabilityProfileEntry entry : this) {
- if(entry.getTime() < startTime)
+ if(entry.getTime() < startTime) {
continue;
+ }
if(entry.getTime() > finishTime) {
break;
}
Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java
===================================================================
--- branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -7,15 +7,15 @@
package gridsim.turbo;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Iterator;
+
import gridsim.GridSim;
import gridsim.GridSimTags;
import gridsim.Gridlet;
import gridsim.gui.AllocationAction;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Iterator;
-
/**
* This class implements a non-FCFS policy to schedule parallel jobs. The
* policy is based on conservative backfilling. This policy can use
@@ -135,7 +135,7 @@
//---------------------------------------------------------------
// sends back an ack if required
- if (ack == true) {
+ if (ack) {
super.sendAck(GridSimTags.GRIDLET_SUBMIT_ACK, true,
gridlet.getGridletID(), gridlet.getUserID()
);
@@ -250,8 +250,9 @@
removeGridlet(sgl);
// compress the schedule, that is, moves the gridlets forwards
- if(!sgl.hasReserved())
+ if(!sgl.hasReserved()) {
compressSchedule(referenceTime, sgl.getStatus() == Gridlet.INEXEC);
+ }
//------------------- USED FOR DEBUGGING PURPOSES ONLY -----------------
@@ -273,7 +274,7 @@
* Schedules a gridlet. This method will find the anchor point for
* the gridlet and allocate the resources for it
* @param sgl the resource gridlet
- * return <tt>true</tt> if gridlet was scheduled; <tt>false</tt> otherwise.
+ * @return <tt>true</tt> if gridlet was scheduled; <tt>false</tt> otherwise.
*/
protected boolean scheduleGridlet(SSGridlet sgl) {
int reqPE = sgl.getNumPE();
@@ -298,11 +299,9 @@
Object[] availObj =
profile_.checkPERangesAvailability(reqPE, executionTime);
- int anchor;
- double startTimeQueue;
- if (availObjQueue == null)
- startTimeQueue = Double.MAX_VALUE;
- else {
+ int anchor = -1;
+ double startTimeQueue = Double.MAX_VALUE;
+ if (!(availObjQueue == null)) {
anchor = (Integer)availObjQueue[0];
startTimeQueue=profile_.get(anchor).getTime();
}
@@ -511,8 +510,9 @@
// iterates the waiting queue and for each gridlet, put the ranges
// used back in the profile. That is, updates the entries
- if(jobOrderHeuristic_ != null)
+ if(jobOrderHeuristic_ != null) {
Collections.sort(queuedGridlets_, jobOrderHeuristic_);
+ }
Iterator<SSGridlet> iterQueue = queuedGridlets_.iterator();
while(iterQueue.hasNext()) {
Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java
===================================================================
--- branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -8,6 +8,12 @@
package gridsim.turbo;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedList;
+
import eduni.simjava.Sim_event;
import eduni.simjava.Sim_system;
import gridsim.GridSim;
@@ -15,12 +21,6 @@
import gridsim.Gridlet;
import gridsim.gui.AllocationAction;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.LinkedList;
-
/**
* <tt>CBParallelSpaceShared</tt> class is an allocation policy for
* <tt>GridResource</tt> that implements conservative backfilling.
@@ -181,7 +181,7 @@
// if the simulation finishes then exit the loop
if (ev.get_tag() == GridSimTags.END_OF_SIMULATION ||
- super.isEndSimulation() == true) {
+ super.isEndSimulation()) {
break;
}
@@ -212,8 +212,9 @@
* <tt>false</tt> otherwise.
*/
public boolean setJobOrderingHeuristic(Comparator<SSGridlet> comparator) {
- if(comparator == null)
+ if(comparator == null) {
return false;
+ }
jobOrderHeuristic_ = comparator;
return true;
@@ -285,7 +286,7 @@
//---------------------------------------------------------------
// sends back an ack if required
- if (ack == true) {
+ if (ack) {
super.sendAck(GridSimTags.GRIDLET_SUBMIT_ACK, true,
gridlet.getGridletID(), gridlet.getUserID()
);
@@ -435,8 +436,9 @@
removeGridlet(isRunning, sgl);
// compress the schedule, that is, moves the gridlets forwards
- if(!sgl.hasReserved())
+ if(!sgl.hasReserved()) {
compressSchedule(referenceTime, sgl.getStatus() == Gridlet.INEXEC);
+ }
//------------------- USED FOR DEBUGGING PURPOSES ONLY -----------------
@@ -531,8 +533,9 @@
// iterates the waiting queue and for each gridlet, put the ranges
// used back in the profile. That is, updates the entries
- if(jobOrderHeuristic_ != null)
+ if(jobOrderHeuristic_ != null) {
Collections.sort(queuedGridlets_, jobOrderHeuristic_);
+ }
Iterator<SSGridlet> iterQueue = queuedGridlets_.iterator();
while(iterQueue.hasNext()) {
@@ -763,11 +766,13 @@
}
lastScheduleUpdate_ = currentTime;
}
- else
+ else {
processOtherEvent(ev);
+ }
}
- else
+ else {
processOtherEvent(ev);
+ }
}
/**
@@ -905,8 +910,9 @@
PERangeList intersectList = resource_.getFreePERanges();
// if time is unknown, then make the current time the start time
- if(startTime < 0)
+ if(startTime < 0) {
startTime = GridSim.clock();
+ }
// the gridlet's expected finish time
double finishTime = startTime + duration;
@@ -928,8 +934,9 @@
if(entryTime < finishTime) {
PERangeList listEntry = entry.getPERanges();
intersectList = PERangeList.intersection(listEntry, intersectList);
- if(intersectList == null || intersectList.getNumPE() < reqPE)
+ if(intersectList == null || intersectList.getNumPE() < reqPE) {
break;
+ }
}
tailEntry = entry;
}
@@ -1111,8 +1118,9 @@
}
}
- if(intersectList == null || intersectList.getNumPE() < reqPE)
+ if(intersectList == null || intersectList.getNumPE() < reqPE) {
return null;
+ }
anchorIndex = availProfile_.indexOf(anchorEntry);
tailIndex = availProfile_.indexOf(tailEntry);
Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java
===================================================================
--- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-10-12 10:59:53 UTC (rev 258)
+++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-11-16 10:42:53 UTC (rev 259)
@@ -7,6 +7,12 @@
package gridsim.turbo;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+
import eduni.simjava.Sim_event;
import eduni.simjava.Sim_system;
import gridsim.GridSim;
@@ -15,12 +21,6 @@
import gridsim.ParameterException;
import gridsim.gui.AllocationAction;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-
/**
* This class implements a non-FCFS policy to schedule parallel jobs. The
* policy is based on aggressive (EASY) backfilling. This policy can use
@@ -211,8 +211,9 @@
* <tt>false</tt> otherwise.
*/
public boolean setJobOrderingHeuristic(Comparator<SSGridlet> comparator) {
- if(comparator == null)
+ if(comparator == null) {
return false;
+ }
jobOrderHeuristic_ = comparator;
return true;
@@ -258,8 +259,9 @@
* <tt>false</tt> otherwise.
*/
public boolean setPrioritySelector(PrioritySelector selector) {
- if(selector == null || Sim_system.running())
+ if(selector == null || Sim_system.running()) {
return false;
+ }
prioritySelector_ = selector;
return true;
@@ -310,17 +312,25 @@
}
// divides the PEs and assigns them to the partitions
else {
- int allocPE = 0;
PERangeList freeRanges = resource_.getFreePERanges().clone();
- for(QueuePartition partition : profile_.getPartitions()) {
- allocPE += partition.getInitialNumPEs();
+ Iterator<QueuePartition> it = profile_.getPartitions().iterator();
+ while (it.hasNext()) {
+ ...
[truncated message content] |