From: <mar...@us...> - 2008-02-17 05:40:27
|
Revision: 105 http://gridsim.svn.sourceforge.net/gridsim/?rev=105&view=rev Author: marcos_dias Date: 2008-02-16 21:40:32 -0800 (Sat, 16 Feb 2008) Log Message: ----------- This update contains: + Changes in the multiple queue easy backfilling policy to make it reusable when implementing other multiple queue policies. + A preliminary implementation of a multiple queue policy that uses conservative backfilling. + A preliminary implementation of a multiple queue policy that uses conservative backfilling and supports advance reservation. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java branches/gridsim4.0-branch3/source/gridsim/GridResource.java branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartitionPredicate.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java Added Paths: ----------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/QueuePredicateExample.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultipleQueues.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultipleQueues.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultipleQueues.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPProfileEntry.java Removed Paths: ------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/QueuePredicateExample.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/QueuePredicateExample.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/QueuePredicateExample.java 2008-02-17 05:40:32 UTC (rev 105) @@ -0,0 +1,63 @@ +package examples.workload.parallel; + +import gridsim.turbo.QueuePartitionPredicate; +import gridsim.turbo.SSGridlet; +import gridsim.turbo.SSReservation; +import gridsim.turbo.ScheduleItem; + +/** + * Example of queue predicate. This predicate filters + * gridlets according to their runtime + * + * @author Marcos Dias de Assuncao + */ +class QueuePredicateExample implements QueuePartitionPredicate { + int minRuntime_; + int maxRuntime_; + int resRating_; + + /* + * Default constructor + */ + public QueuePredicateExample(int minRuntime, + int maxRuntime, int rating) { + this.minRuntime_ = minRuntime; + this.maxRuntime_ = maxRuntime; + this.resRating_ = rating; + } + + /* + * (non-Javadoc) + * @see gridsim.turbo.QueuePredicate#match(gridsim.turbo.ScheduleItem) + */ + public boolean match(ScheduleItem item) { + double runtime = 0; + if(!item.isAdvanceReservation()) + runtime = forecastExecutionTime((SSGridlet)item); + else + runtime = ((SSReservation)item).getDurationTime(); + + if(runtime < minRuntime_ || runtime >= maxRuntime_) + return false; + + return true; + } + + /* + * Forecast execution time of a Gridlet. + * <tt>execution time = length / available rating</tt> + * @param gridlet the gridlet to be considered + * @return Gridlet's execution time. + */ + private double forecastExecutionTime(SSGridlet gridlet) { + double executionTime = (gridlet.getLength() / resRating_); + + // This is as a safeguard since the finish time can be extremely + // small close to 0.0, such as 4.5474735088646414E-14. Hence causing + // some Gridlets never to be finished and consequently hang the program + if (executionTime < 1.0) { + executionTime = 1.0; + } + return executionTime; + } +} \ No newline at end of file Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2008-02-17 05:40:32 UTC (rev 105) @@ -37,8 +37,6 @@ // ASCII text, gzip or zip. String fileName = args[0]; - // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf - ArrayList<GridResource> resources = new ArrayList<GridResource>(); ////////////////////////////////////////// Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java 2008-02-17 05:40:32 UTC (rev 105) @@ -0,0 +1,180 @@ + +package examples.workload.parallel; + +import gridsim.AllocPolicy; +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.ResourceCharacteristics; +import gridsim.turbo.EBMultipleQueues; +import gridsim.turbo.TResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example + */ +public class TurboExampleCBMultiQueues01 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + String fileName = args[0]; + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode + GridSim.startGridSimulation(true); + + // Start the simulation in normal mode +// GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // this resource will use an aggressive backfilling policy (EASY) + TResourceCharacteristics resConfig = + new TResourceCharacteristics(arch, os, mList, + TResourceCharacteristics.MULTI_CONSERVATIVE_BACKFILLING_QUEUES, + time_zone, cost); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + GridResource gridRes = null; + + try { + gridRes = new GridResource(name, baud_rate, seed, + resConfig, peakLoad, offPeakLoad, holidayLoad, weekends, + holidays); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java 2008-02-17 05:40:32 UTC (rev 105) @@ -0,0 +1,202 @@ + +package examples.workload.parallel; + +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.turbo.CBMultipleQueues; +import gridsim.turbo.EBMultipleQueues; +import gridsim.turbo.TResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example + */ +public class TurboExampleCBMultiQueues02 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + String fileName = args[0]; + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode + GridSim.startGridSimulation(true); + + // Start the simulation in normal mode +// GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // this resource will use an aggressive backfilling policy (EASY) + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.MULTI_CONSERVATIVE_BACKFILLING_QUEUES, + time_zone, cost); + + CBMultipleQueues policy = null; + try { + policy = new CBMultipleQueues(name, "Policy", 3); + } catch (Exception e1) { + e1.printStackTrace(); + } + + // creates three partitions, one for small jobs, one for medium size jobs + // and another for long jobs + QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); + QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); + QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + + policy.createPartition(0, resConfig.getNumPE() / 3, express); + policy.createPartition(1, resConfig.getNumPE() / 3, medium); + policy.createPartition(2, resConfig.getNumPE() / 3, large); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + GridResource gridRes = null; + + ResourceCalendar resCalendar = new ResourceCalendar(time_zone, + peakLoad, offPeakLoad, holidayLoad, weekends, + holidays, seed); + + try { + gridRes = new GridResource(name, baud_rate, resConfig, + resCalendar, policy); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + + + + + Copied: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java (from rev 104, branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java) =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java 2008-02-17 05:40:32 UTC (rev 105) @@ -0,0 +1,179 @@ + +package examples.workload.parallel; + +import gridsim.AllocPolicy; +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.ResourceCharacteristics; +import gridsim.turbo.EBMultipleQueues; +import gridsim.turbo.TResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example + */ +public class TurboExampleEBMultiQueues01 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + String fileName = args[0]; + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode +// GridSim.startGridSimulation(true); + + // Start the simulation in normal mode + GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // this resource will use an aggressive backfilling policy (EASY) + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.MULTI_EASY_BACKFILLING_QUEUES, + time_zone, cost); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + GridResource gridRes = null; + + try { + gridRes = new GridResource(name, baud_rate, seed, + resConfig, peakLoad, offPeakLoad, holidayLoad, weekends, + holidays); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + Copied: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java (from rev 104, branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java) =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-02-17 05:40:32 UTC (rev 105) @@ -0,0 +1,195 @@ + +package examples.workload.parallel; + +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.turbo.EBMultipleQueues; +import gridsim.turbo.TResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example + */ +public class TurboExampleEBMultiQueues02 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + String fileName = args[0]; + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode + GridSim.startGridSimulation(true); + + // Start the simulation in normal mode +// GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // this resource will use an aggressive backfilling policy (EASY) + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.MULTI_EASY_BACKFILLING_QUEUES, + time_zone, cost); + + EBMultipleQueues policy = null; + try { + policy = new EBMultipleQueues(name, "Policy", 3); + } catch (Exception e1) { + e1.printStackTrace(); + } + + // creates three partitions, one for small jobs, one for medium size jobs + // and another for long jobs + QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); + QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); + QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + + policy.createPartition(0, resConfig.getNumPE() / 3, express); + policy.createPartition(1, resConfig.getNumPE() / 3, medium); + policy.createPartition(2, resConfig.getNumPE() / 3, large); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + GridResource gridRes = null; + + ResourceCalendar resCalendar = new ResourceCalendar(time_zone, + peakLoad, offPeakLoad, holidayLoad, weekends, + holidays, seed); + + try { + gridRes = new GridResource(name, baud_rate, resConfig, + resCalendar, policy); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java 2008-02-17 05:40:32 UTC (rev 105) @@ -37,8 +37,6 @@ // ASCII text, gzip or zip. String fileName = args[0]; - // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf - ArrayList<GridResource> resources = new ArrayList<GridResource>(); ////////////////////////////////////////// Deleted: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java 2008-02-17 05:40:32 UTC (rev 105) @@ -1,181 +0,0 @@ - -package examples.workload.parallel; - -import gridsim.AllocPolicy; -import gridsim.GridResource; -import gridsim.GridSim; -import gridsim.Machine; -import gridsim.MachineList; -import gridsim.ResourceCalendar; -import gridsim.ResourceCharacteristics; -import gridsim.turbo.MultipleEasyBackfillingQueues; -import gridsim.turbo.TResourceCharacteristics; -import gridsim.util.Workload; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.LinkedList; -import java.util.Random; - - -/** - * Test Driver class for this example - */ -public class TurboExampleMultiEBQueues01 -{ - /** - * Creates main() to run this example - */ - public static void main(String[] args) - { - long startTime = System.currentTimeMillis(); - if(args.length == 0){ - System.out.println("Please provide the location of the workload file!"); - System.exit(1); - } - - try { - - ////////////////////////////////////////// - // Get the workload to be used The format should be: - // ASCII text, gzip or zip. - - String fileName = args[0]; - // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf - - ArrayList<GridResource> resources = new ArrayList<GridResource>(); - - ////////////////////////////////////////// - // Initialize the GridSim package. It should be called - // before creating any entities. We can't run this example without - // initializing GridSim first. We will get run-time exception - // error. - - // number of grid user entities + any Workload entities. - int num_user = 1; - Calendar calendar = Calendar.getInstance(); - boolean trace_flag = false; // mean trace GridSim events - - // Initialize the GridSim package without any statistical - // functionalities. Hence, no GridSim_stat.txt file is created. - System.out.println("Initializing GridSim package"); - GridSim.init(num_user, calendar, trace_flag); - - ////////////////////////////////////////// - // Creates one or more GridResource entities - int totalResource = 1; // total number of Grid resources - int rating = 377; // rating of each PE in MIPS - int totalPE = 9; // total number of PEs for each Machine - int totalMachine = 128; // total number of Machines - int i = 0; - - String[] resArray = new String[totalResource]; - for (i = 0; i < totalResource; i++) { - String resName = "Res_" + i; - GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); - resources.add(resource); - - // add a resource name into an array - resArray[i] = resName; - } - - ////////////////////////////////////////// - // Creates one Workload trace entity. - - int resID = 0; - Random r = new Random(); - resID = r.nextInt(totalResource); - Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); - - ////////////////////////////////////////// - // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); - - // Start the simulation in normal mode - GridSim.startGridSimulation(); - - ////////////////////////////////////////// - // Final step: Prints the Gridlets when simulation is over - long finishTime = System.currentTimeMillis(); - System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); - - // prints the Gridlets inside a Workload entity - // workload.printGridletList(trace_flag); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * Creates one Grid resource. A Grid resource contains one or more - * Machines. Similarly, a Machine contains one or more PEs (Processing - * Elements or CPUs). - * @param name a Grid Resource name - * @param peRating rating of each PE - * @param totalMachine total number of Machines - * @param totalPE total number of PEs for each Machine - */ - private static GridResource createGridResource(String name, int peRating, - int totalMachine, int totalPE) - { - - ////////////////////////////////////////// - // Here are the steps needed to create a Grid resource: - // 1. We need to create an object of MachineList to store one or more - // Machines - MachineList mList = new MachineList(); - - for (int i = 0; i < totalMachine; i++) - { - ////////////////////////////////////////// - // 4. Create one Machine with its id and list of PEs or CPUs - mList.add( new Machine(i, totalPE, peRating) ); - } - - ////////////////////////////////////////// - // 5. Create a ResourceCharacteristics object that stores the - // properties of a Grid resource: architecture, OS, list of - // Machines, allocation policy: time- or space-shared, time zone - // and its price (G$/PE time unit). - String arch = "Sun Ultra"; // system architecture - String os = "Solaris"; // operating system - double time_zone = 0.0; // time zone this resource located - double cost = 3.0; // the cost of using this resource - - // this resource will use an aggressive backfilling policy (EASY) - TResourceCharacteristics resConfig = new TResourceCharacteristics( - arch, os, mList, TResourceCharacteristics.MULTIPLE_EASY_BACKFILLING_QUEUES, - time_zone, cost); - - ////////////////////////////////////////// - // 6. Finally, we need to create a GridResource object. - double baud_rate = 10000.0; // communication speed - long seed = 11L*13*17*19*23+1; - double peakLoad = 0.0; // the resource load during peak hour - double offPeakLoad = 0.0; // the resource load during off-peak hr - double holidayLoad = 0.0; // the resource load during holiday - - // incorporates weekends so the grid resource is on 7 days a week - LinkedList weekends = new LinkedList(); - weekends.add(new Integer(Calendar.SATURDAY)); - weekends.add(new Integer(Calendar.SUNDAY)); - - // incorporates holidays. However, no holidays are set in this example - LinkedList holidays = new LinkedList(); - GridResource gridRes = null; - - try { - gridRes = new GridResource(name, baud_rate, seed, - resConfig, peakLoad, offPeakLoad, holidayLoad, weekends, - holidays); - } - catch (Exception e) { - e.printStackTrace(); - } - - System.out.println("Creates one Grid resource with name = " + name); - return gridRes; - } -} // end class - Deleted: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java 2008-02-17 05:40:32 UTC (rev 105) @@ -1,255 +0,0 @@ - -package examples.workload.parallel; - -import gridsim.GridResource; -import gridsim.GridSim; -import gridsim.Machine; -import gridsim.MachineList; -import gridsim.ResourceCalendar; -import gridsim.turbo.MultipleEasyBackfillingQueues; -import gridsim.turbo.QueuePartitionPredicate; -import gridsim.turbo.SSGridlet; -import gridsim.turbo.TResourceCharacteristics; -import gridsim.util.Workload; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.LinkedList; -import java.util.Random; - - -/** - * Test Driver class for this example - */ -public class TurboExampleMultiEBQueues02 -{ - /** - * Creates main() to run this example - */ - public static void main(String[] args) - { - long startTime = System.currentTimeMillis(); - if(args.length == 0){ - System.out.println("Please provide the location of the workload file!"); - System.exit(1); - } - - try { - - ////////////////////////////////////////// - // Get the workload to be used The format should be: - // ASCII text, gzip or zip. - - String fileName = args[0]; - // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf - - ArrayList<GridResource> resources = new ArrayList<GridResource>(); - - ////////////////////////////////////////// - // Initialize the GridSim package. It should be called - // before creating any entities. We can't run this example without - // initializing GridSim first. We will get run-time exception - // error. - - // number of grid user entities + any Workload entities. - int num_user = 1; - Calendar calendar = Calendar.getInstance(); - boolean trace_flag = false; // mean trace GridSim events - - // Initialize the GridSim package without any statistical - // functionalities. Hence, no GridSim_stat.txt file is created. - System.out.println("Initializing GridSim package"); - GridSim.init(num_user, calendar, trace_flag); - - ////////////////////////////////////////// - // Creates one or more GridResource entities - int totalResource = 1; // total number of Grid resources - int rating = 377; // rating of each PE in MIPS - int totalPE = 9; // total number of PEs for each Machine - int totalMachine = 128; // total number of Machines - int i = 0; - - String[] resArray = new String[totalResource]; - for (i = 0; i < totalResource; i++) { - String resName = "Res_" + i; - GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); - resources.add(resource); - - // add a resource name into an array - resArray[i] = resName; - } - - ////////////////////////////////////////// - // Creates one Workload trace entity. - - int resID = 0; - Random r = new Random(); - resID = r.nextInt(totalResource); - Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); - - ////////////////////////////////////////// - // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); - - // Start the simulation in normal mode - GridSim.startGridSimulation(); - - ////////////////////////////////////////// - // Final step: Prints the Gridlets when simulation is over - long finishTime = System.currentTimeMillis(); - System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); - - // prints the Gridlets inside a Workload entity - // workload.printGridletList(trace_flag); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * Creates one Grid resource. A Grid resource contains one or more - * Machines. Similarly, a Machine contains one or more PEs (Processing - * Elements or CPUs). - * @param name a Grid Resource name - * @param peRating rating of each PE - * @param totalMachine total number of Machines - * @param totalPE total number of PEs for each Machine - */ - private static GridResource createGridResource(String name, int peRating, - int totalMachine, int totalPE) - { - - ////////////////////////////////////////// - // Here are the steps needed to create a Grid resource: - // 1. We need to create an object of MachineList to store one or more - // Machines - MachineList mList = new MachineList(); - - for (int i = 0; i < totalMachine; i++) - { - ////////////////////////////////////////// - // 4. Create one Machine with its id and list of PEs or CPUs - mList.add( new Machine(i, totalPE, peRating) ); - } - - ////////////////////////////////////////// - // 5. Create a ResourceCharacteristics object that stores the - // properties of a Grid resource: architecture, OS, list of - // Machines, allocation policy: time- or space-shared, time zone - // and its price (G$/PE time unit). - String arch = "Sun Ultra"; // system architecture - String os = "Solaris"; // operating system - double time_zone = 0.0; // time zone this resource located - double cost = 3.0; // the cost of using this resource - - // this resource will use an aggressive backfilling policy (EASY) - TResourceCharacteristics resConfig = new TResourceCharacteristics( - arch, os, mList, TResourceCharacteristics.MULTIPLE_EASY_BACKFILLING_QUEUES, - time_zone, cost); - - MultipleEasyBackfillingQueues policy = null; - try { - policy = new MultipleEasyBackfillingQueues(name, "Policy", 3); - } catch (Exception e1) { - e1.printStackTrace(); - } - - // creates three partitions, one for small jobs, one for medium size jobs - // and another for long jobs - QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); - QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); - QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); - - policy.createPartition(0, resConfig.getNumPE() / 3, express); - policy.createPartition(1, resConfig.getNumPE() / 3, medium); - policy.createPartition(2, resConfig.getNumPE() / 3, large); - - ////////////////////////////////////////// - // 6. Finally, we need to create a GridResource object. - double baud_rate = 10000.0; // communication speed - long seed = 11L*13*17*19*23+1; - double peakLoad = 0.0; // the resource load during peak hour - double offPeakLoad = 0.0; // the resource load during off-peak hr - double holidayLoad = 0.0; // the resource load during holiday - - // incorporates weekends so the grid resource is on 7 days a week - LinkedList weekends = new LinkedList(); - weekends.add(new Integer(Calendar.SATURDAY)); - weekends.add(new Integer(Calendar.SUNDAY)); - - // incorporates holidays. However, no holidays are set in this example - LinkedList holidays = new LinkedList(); - GridResource gridRes = null; - - ResourceCalendar resCalendar = new ResourceCalendar(time_zone, - peakLoad, offPeakLoad, holidayLoad, weekends, - holidays, seed); - - try { - gridRes = new GridResource(name, baud_rate, resConfig, - resCalendar, policy); - } - catch (Exception e) { - e.printStackTrace(); - } - - System.out.println("Creates one Grid resource with name = " + name); - return gridRes; - } -} // end class - -/** - * Example of queue predicate. This predicate filters - * gridlets according to their runtime - * - * @author Marcos Dias de Assuncao - */ -class QueuePredicateExample implements QueuePartitionPredicate { - int minRuntime_; - int maxRuntime_; - int resRating_; - - /* - * Default constructor - */ - public QueuePredicateExample(int minRuntime, - int maxRuntime, int rating) { - this.minRuntime_ = minRuntime; - this.maxRuntime_ = maxRuntime; - this.resRating_ = rating; - } - - /* - * (non-Javadoc) - * @see gridsim.turbo.QueuePredicate#match(gridsim.turbo.SSGridlet) - */ - public boolean match(SSGridlet gridlet) { - double runtime = forecastExecutionTime(gridlet); - if(runtime < minRuntime_ || runtime >= maxRuntime_) - return false; - - return true; - } - - /* - * Forecast execution time of a Gridlet. - * <tt>execution time = length / available rating</tt> - * @param gridlet the gridlet to be considered - * @return Gridlet's execution time. - */ - private double forecastExecutionTime(SSGridlet gridlet) { - double executionTime = (gridlet.getLength() / resRating_); - - // This is as a safeguard since the finish time can be extremely - // small close to 0.0, such as 4.5474735088646414E-14. Hence causing - // some Gridlets never to be finished and consequently hang the program - if (executionTime < 1.0) { - executionTime = 1.0; - } - return executionTime; - } -} - - - Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2008-02-17 05:40:32 UTC (rev 105) @@ -37,8 +37,6 @@ // ASCII text, gzip or zip. String fileName = args[0]; - // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf - ArrayList<GridResource> resources = new ArrayList<GridResource>(); ////////////////////////////////////////// Modified: branches/gridsim4.0-branch3/source/gridsim/GridResource.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/GridResource.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/source/gridsim/GridResource.java 2008-02-17 05:40:32 UTC (rev 105) @@ -11,9 +11,10 @@ import gridsim.net.*; import gridsim.turbo.ARParallelSpaceShared; +import gridsim.turbo.CBMultipleQueues; import gridsim.turbo.EBParallelSpaceShared; import gridsim.turbo.CBParallelSpaceShared; -import gridsim.turbo.MultipleEasyBackfillingQueues; +import gridsim.turbo.EBMultipleQueues; import gridsim.turbo.TResourceCharacteristics; import gridsim.index.*; @@ -647,10 +648,15 @@ break; // creates the scheduler with only one queue - case TResourceCharacteristics.MULTIPLE_EASY_BACKFILLING_QUEUES: - policy_ = new MultipleEasyBackfillingQueues(super.get_name(), - "MultipleEasyBackfillingQueues", 1); + case TResourceCharacteristics.MULTI_EASY_BACKFILLING_QUEUES: + policy_ = new EBMultipleQueues(super.get_name(), + "EBMultipleQueues", 1); break; + + case TResourceCharacteristics.MULTI_CONSERVATIVE_BACKFILLING_QUEUES: + policy_ = new CBMultipleQueues(super.get_name(), + "CBMultipleQueues", 1); + break; default: throw new Exception(super.get_name()+" : Error - supports"+ Modified: branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java 2008-02-17 05:40:32 UTC (rev 105) @@ -18,8 +18,6 @@ import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -206,27 +204,6 @@ status_ = new JLabel("Current simulation time is " + GridSim.clock() + " seconds."); statusPanel.add(status_); - /* to show simulation time when mouse cursor passing over buttons */ - ... [truncated message content] |