You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(24) |
Sep
(14) |
Oct
(13) |
Nov
(5) |
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(2) |
Feb
(53) |
Mar
(29) |
Apr
(5) |
May
(11) |
Jun
(3) |
Jul
(7) |
Aug
(48) |
Sep
(10) |
Oct
(8) |
Nov
(1) |
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
(5) |
Oct
(2) |
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <sul...@us...> - 2007-09-01 02:48:18
|
Revision: 53 http://gridsim.svn.sourceforge.net/gridsim/?rev=53&view=rev Author: sulistio Date: 2007-08-31 19:48:15 -0700 (Fri, 31 Aug 2007) Log Message: ----------- changes for the new release Modified Paths: -------------- trunk/README.txt trunk/changelog.txt trunk/faq.txt trunk/release_note.txt Added Paths: ----------- trunk/javadoc.sh Modified: trunk/README.txt =================================================================== --- trunk/README.txt 2007-09-01 02:32:02 UTC (rev 52) +++ trunk/README.txt 2007-09-01 02:48:15 UTC (rev 53) @@ -1,33 +1,56 @@ + README file -=========== +Author: Anthony Sulistio (September 2007) + Directory Structure of GridSim Toolkit -------------------------------------- -$GRIDSIM/ - examples/ -- GridSim examples, see README.txt for details +$GRIDSIM/ -- the current GridSim directory (top level) + classes/ -- The GridSim class files + doc/ -- GridSim and SimJava API Documentation + eduni/ + gridsim/ + examples/ -- GridSim examples, see examples/README.txt for details jars/ -- jar archives source/ -- The GridSim Java source code gridsim/*.java - gridsim/auction/*.java -- framework for the Auction model - gridsim/datagrid/*.java -- framework for the DataGrid model - gridsim/filter/*.java - gridsim/index/*.java -- framework for the Network model - gridsim/net/*.java - gridsim/util/*.java + gridsim/auction/*.java -- framework for the auction model + gridsim/datagrid/*.java -- framework for the Data Grids model + gridsim/filter/*.java -- filters incoming events + gridsim/index/*.java -- framework for the Grid Info Service model + gridsim/net/*.java -- framework for the network model + gridsim/resFailure/*.java -- framework for the resource failure model + gridsim/util/*.java -- includes some statistics classes. +GridSim APIs and examples are also available on the GridSim website. +If you are looking for applications or programs built on top of GridSim, +such as gridbroker or Visual Modeler, they can be found below: +http://www.gridbus.org/gridsim/release.html + +Software Requirements : Java version 1.4.2 or newer +--------------------- +GridSim has been tested and ran on Sun's Java version 1.4.2 or newer. +Older versions of Java are not compatible. +If you have non-Sun Java version, such as gcj or J++, they may not be compatible. +You also need to install Ant to compile GridSim (explained in more details later). + + Installation and Running GridSim Toolkit ---------------------------------------- +There is no special program to install GridSim. You just need to +unzip the GridSim file to install. +If you want to remove GridSim, then remove the whole $GRIDSIM directory. NOTE: You do not need to compile GridSim source code. The JAR file is provided to compile and to run GridSim applications. Description of the following jar files: -*) gridsim.jar -- contains GridSim and SimJava class files -*) simjava2.jar -- contains SimJava v2.0 class files only +* gridsim.jar -- contains both GridSim and SimJava v2.0 class files +* simjava2.jar -- contains SimJava v2.0 class files only -Example to compile and running GridSim applications, do the following step: +To compile and run GridSim applications, do the following step: 1) Go the directory where the GridSim's Example1 reside In Unix or Linux: cd $GRIDSIM/examples/Example01 In Windows: cd %GRIDSIM%\examples\Example01 @@ -42,6 +65,8 @@ NOTE: * $GRIDSIM or %GRIDSIM% is the location of the GridSim Toolkit package. +* If you are using Java IDEs, such as Eclipse, JBuilder and JCreator, + their instructions (with screenshots) are found on the GridSim website. * Running GridSim of this version requires a lot of memory since there are many objects to be created. Therefore, it is recommended to have at least 512MB RAM or increase JVM heap size when running Java for large simulation experiments. @@ -54,16 +79,18 @@ To understand on how to use GridSim, please go through the examples provided in the $GRIDSIM/examples/ directory. Example 1 - 6 are mainly for beginners, whereas the rest describes more complex GridSim functionalities. +The same examples are also hosted in the GridSim website. At the moment, GridSim has two allocation policies or scheduling algorithms, i.e. First Come First Service (as described in SpaceShared.java) and Round Robin (as described in TimeShared.java). If you are interested in writing a new scheduling algorithm of a resource, then look closely on $GRIDSIM/examples/Example08/ directory. +We are certainly welcomed new additions of allocation policies into GridSim. -Using Ant ---------- +Compiling GridSim : Using Ant +----------------- This release contains a simple buildfile for compiling GridSim classes. You need to have ant installed (http://ant.apache.org/). Ant can be used in both Windows and Unix/Linux environment. @@ -77,23 +104,85 @@ NOTE: * You need to set up PATH for ant in Windows and/or Unix. -* rule for javadoc is not included yet. Use javadoc.sh script instead. +* rule for javadoc is not included yet. Use javadoc.sh script on Unix instead. + Alternatively, the GridSim API can be found below: + http://www.gridbus.org/gridsim/doc/ -Bug Reports and Feedback ------------------------- -Send any queries and feedbacks to ant...@cs... +Contacting Us : subscribe to Mailing Lists at SourceForge.net +------------- +Please read FAQ, examples, API and other documents in the GridSim website +before contacting us. +GridSim mailing lists can be found below: +http://sourceforge.net/projects/gridsim/ then click on the "Mailing Lists" tab. +Please subscribe to the following mailing lists: +gridsim-users (at) lists.sourceforge.net - for any queries and feedbacks +gridsim-developers (at) lists.sourceforge.net - for contributing to GridSim + +Contributors are always needed to improve and maintain GridSim. +Another option is to integrate your work/project into future GridSim releases. +If you want to contribute, advertise yourself to us. +Benefits of your contributions: +- you help future Grid researchers and students like you and us; +- you can proudly write your contributions in the resume or CV; +- you gain knowledge and skills in using SVN version control, Java, and OO; and +- more importantly, you are dealing with a real software engineering development + and working with collaborators or developers from other parts of the world + (at the moment, they are from "down under"). + You can not get this kind of unique experience by doing it yourself or + in university assignments or projects. + +NOTE: +* If you experience some problems when compiling/running GridSim, + write a detailed email. The more information you provide, the better + we analyze your problem. Hence, the sooner we can reply. +* Please send your questions to these mailing lists so that other people can + read and reply them. +* We have hectic schedules, so do not expect an instant reply. + + +Bugs Reporting +-------------- +If you found any bugs, please report them to: +http://sourceforge.net/projects/gridsim/ then click on the "Tracker" tab. + +To prevent any false reports, it is recommended that you email us first on +gridsim-developers (at) lists.sourceforge.net +to identify whether the problem is caused by bugs in the GridSim code +or something else, such as using Java version 1.3. + +Please be specific when you report a bug. We need information such as +GridSim version number, Java version number, detailed descriptions, +snippets of the (buggy) code and any exception errors. +A 'nobody' report in the tracker will probably be ignored. + + +Requesting New Features +----------------------- +If you decide to implement any new features, we will try our best to help you +with directions on where to start and how to design and implement without +breaking the existing design and code respectively. + + Acknowledgement --------------- -* Thank to Gokul Poduval and Chen-Kong Tham for working on gridsim.net package. -* Thank to Uros Cibej for providing build.xml file and instruction on how to - use ant. In addition, he is working on the gridsim.datagrid package. -* Thank to Marcos Dias de Assuncao for working on gridsim.auction package -* Thank to the following people for finding bugs in GridSim: -Anthony Sulistio and Gokul Poduval :) -Uros Cibej, Agustin Herraez, Sai Rahul Reddy, Jakub Milkiewicz, +For their outstanding contributions to GridSim : +* Agustin Caminero from The University of Castilla La Mancha, Spain + for his work on the gridsim.resFailure package. + +* Uros Cibej from The University of Ljubljana, Slovenia + for providing build.xml file and instruction on how to + use ant. In addition, he worked on the gridsim.datagrid package. + +* Gokul Poduval from National University of Singapore + for his work on the gridsim.net package. + +* Marcos Dias de Assuncao from Grids Lab, The University of Melbourne, Australia + for his work on the gridsim.auction package + +We also thank the following people for finding bugs in GridSim : +Gokul Poduval, Uros Cibej, Agustin Caminero, Sai Rahul Reddy, Jakub Milkiewicz, Mads Mbuso Sibeko, Felipe Ramos. - Modified: trunk/changelog.txt =================================================================== --- trunk/changelog.txt 2007-09-01 02:32:02 UTC (rev 52) +++ trunk/changelog.txt 2007-09-01 02:48:15 UTC (rev 53) @@ -1,7 +1,15 @@ # Changelog for GridSim Toolkit -# Maintained by Anthony Sulistio (ant...@cs...) -# $Id: changelog.txt,v 1.4 2006/03/09 07:57:32 anthony Exp $ +# Maintained by Anthony Sulistio +# $Id: changelog.txt,v 1.7 2007/09/01 02:40:12 anthony Exp $ + +Changes from 4.0 to 4.1 +- add a new functionality that supports resource failures during runtime. + This work was done in collaboration with Agustin Caminero from + Universidad de Castilla La Mancha (UCLM), Spain. +- fix few bugs in the code and examples. + +======================================================================= Changes from 3.3 to 4.0 - add two major new features: auction model and data grid - add a new packet scheduler for the network package @@ -13,7 +21,7 @@ ======================================================================= Changes from 3.2 to 3.3 No new additions, it mainly about bug fixes: -- for a Regional GIS feature (discovered by Agustin Herraez). +- for a Regional GIS feature (discovered by Agustin Caminero). Classes affected: AbstractGIS and RegionalGIS - inside GridSim class (discovered by Sai Rahul Reddy) for the below methods: @@ -32,7 +40,8 @@ - a Gridlet must have a ToS for Differentiated network. -- for advanced reservation feature (discovered by Jakub Milkiewicz). +- for advanced reservation feature, queryBusyTime() and queryFreeTime() +needs to know a time zone from user (discovered by Jakub Milkiewicz). ======================================================================= Modified: trunk/faq.txt =================================================================== --- trunk/faq.txt 2007-09-01 02:32:02 UTC (rev 52) +++ trunk/faq.txt 2007-09-01 02:48:15 UTC (rev 53) @@ -1,11 +1,59 @@ # Frequently Asked Questions (FAQ) -# Maintained by Anthony Sulistio (ant...@cs...) -# $Id: faq.txt,v 1.3 2006/03/11 04:49:03 anthony Exp $ +# Maintained by Anthony Sulistio +# $Id: faq.txt,v 1.7 2007/09/01 02:46:01 anthony Exp $ +Please read this document, FAQ, examples, API, etc before contacting us. +Moreover, look at the previous questions at the below website: +http://sourceforge.net/mail/?group_id=94592 -Questions related to GridSim -============================ +Send any queries and feedbacks to gridsim-users @ lists.sourceforge.net +--------------------------------------------------------- +Q: Where can I find gridbroker, visual modeler, ... ? + +A: If you are looking for applications or programs built on top of GridSim, +such as gridbroker or Visual Modeler, they can be found below: +http://www.gridbus.org/gridsim/release.html + +--------------------------------------------------------- +Q: I want to run the gridsim simulation on my computer but i can't because + Jcreator don't see the gridsim package. Please send to me the steps of + how compile and run the simulation. + +A: Go to GridSim website and there is an instruction on how to use it with + JCreator. http://www.gridbus.org/gridsim/paper/jcreator.pdf + + If you use JBuilder or Eclipse, the instructions can be found below: + http://www.gridbus.org/gridsim/paper/jbuilder.pdf + http://www.gridbus.org/gridsim/paper/eclipse.pdf + +--------------------------------------------------------- +Q: I would like to do some experiments for my research work on grid computing + using the simulator package that you have. Using the simulator, + can I simulate a grid environment with service providers requestors, + administartors etc. on a PC environment? Please pass on some resources, + links, and white papers and links where from I should download. + +Q: please help me by sending GridSim Package, give instructions and + also technical help to complete my project successfully. + +A: The best way to learn GridSim is by downloading it from below: + http://www.gridbus.org/gridsim/ + + Go through the provided examples. + In the website, it contains links to papers about GridSim. + + As long as you have JDK version 1.4 onwards, you can run GridSim + on a PC. However, if you run a huge simulation, you'd probably needs + bigger RAM and CPU. + +--------------------------------------------------------- +Q: Will GridSim require Globus? + +A: Why don't you download the GridSim toolkit and have a try? + Also, please read the README file. + +--------------------------------------------------------- Q: How do you compile and run GridSim application? A: For example, if you want to run Example1 @@ -19,8 +67,8 @@ In Windows: * go to the directory of where Example1 resides, i.e. at command prompt type: cd %GRIDSIM%\examples\Example01 - * to compile type: javac -classpath %GRIDSIM%\gridsim.jar:. Example1.java - * to run type: java -classpath gridsim.jar:. Example1 + * to compile type: javac -classpath %GRIDSIM%\gridsim.jar;. Example1.java + * to run type: java -classpath gridsim.jar;. Example1 The main difference is the use of ":" for Unix/Linux, and ";" for Windows @@ -176,6 +224,8 @@ A: For older GridSim versions, it runs one PE. Since GridSim ver3.0, each Gridlet can ask to be run on multiple PEs. However, it is up to the scheduler to handle this. + At the moment, by default, TimeShared and SpaceShared scheduler executes + an incoming Gridlet to only 1 PE. --------------------------------------------------------- Q: Is the model for parallel job included inside the GridSim? @@ -198,28 +248,76 @@ a different response that doesn't exist, etc ... --------------------------------------------------------- -Q: Does GridSim currently support the usage of any wireless network standard +Q: Does GridSim currently support the usage of any wireless network standard when specifying network topology? -A: No. We have NOT done so much about wireless network support in GridSim. - But if you are willing, we could explore this with you. +A: No. We have NOT done so much about wireless network support in GridSim. + But if you are willing, we could explore this with you. --------------------------------------------------------- Q: Does GridSim support multiple simulations or runs in a single program? A: No. Currently, GridSim only allows a single experiment to run in a main() - method. Hence, to calculate a confidence interval, you need to do this + method. Hence, to calculate a confidence interval, you need to do this manually. --------------------------------------------------------- Q: Does GridSim run in a cluster or a PC? -A: GridSim runs in a PC as a stand-alone program with multiple threads. +A: GridSim runs in a PC as a stand-alone program with multiple threads. This means if you want to run in a cluster, you just need to request 1 node. --------------------------------------------------------- +Q: I came across three variables: peak load, off-peak load and holiday load. + I understand from the study I have done that these variables represent + the load factor. I do not fully get what this means and was hoping that + you could help me out so I can progress further with my work. +A: These load factors are influencing the total execution time + of a job in a given resource. + If you set these loads to zero, means this resource is idle / free. + If you want to write a resource scheduler, like SpaceShared or TimeShared + then these load factors are important. +--------------------------------------------------------- +Q: for the Gridlet class, what are the units of file size, length, and output? + +A: the unit of file size and output is in byte. + For the Gridlet length, the unit is in MI (Millions Instructions). + A CPU clock is measured in MIPS (Millions Instructions Per Second) as + suggested by SPEC. + +--------------------------------------------------------- +Q: In the previous releases of GridSim you had to use +GridSim class to send messages to other entities. The provided "send" methods +included a parameter to indicate the sender of the request. It is no clear how +to indicate this with the "send" methods provided by the GridSimCore class. The +lack of ID information in the event raises an exception in the GridResource +class. Reading the source code of the GridResource class I've realized that the +way to send the ID of the sender could be the following: + +super.send(resourceId, GridSimTags.SCHEDULE_NOW, +GridSimTags.RESOURCE_CHARACTERISTICS, new Integer(this.get_id())); + +This solves the first problem but generates a new exception in other class: +Exception in thread "Thread-7" java.lang.ArrayIndexOutOfBoundsException: -1 + at java.util.ArrayList.get(ArrayList.java:323) + at eduni.simjava.Sim_system.send(Sim_system.java:600) + at eduni.simjava.Sim_entity.sim_schedule(Sim_entity.java:342) + at gridsim.net.Output.defaultSend(Unknown Source) + at gridsim.net.Output.body(Unknown Source) + at eduni.simjava.Sim_entity.run(Sim_entity.java:603) + +I've read the source of the Output class, but I've not found a solution to the +problem. Do you know where can be the problem? + +A: The problem was in the "baudRate" attribute that wasn't initialized. +So using GridSim(String name, double baudRate) the problem was solved. + +--------------------------------------------------------- + + + Questions related to GridBroker =============================== @@ -229,7 +327,32 @@ you use gridbroker.jar. Inside this jar file, it contains GridBroker, GridSim and SimJava classes. + Please do not use recent GridSim release jar file when running this broker + (see the below question). + --------------------------------------------------------- +Q: I have executed all gridsim examples. But while executing gridbroker +i.e C:\gridsimtoolkit-4.0\application\gridbroker\example\Example1.java +it gives following error after initializing gridsim: + +Initialising... +Starting GridSim version 4.0 +Entities started. +java.lang.IncompatibleClassChangeError + at gridbroker.Broker.body( Broker.java:649) + at eduni.simjava.Sim_entity.run(Sim_entity.java:603) + + +A: read the README.txt file located under $GRIDSIM/application/gridbroker. +./gridbroker.jar - A jar file containing GridBroker, GridSim v2.1, and + SimJava v1.2 classes. +NOTE: No updates or improvements on GridBroker package since GridSim v2.1, +hence, it is more stable under GridSim v2.1 and SimJava v1.2 release. + +You cant mixed up jars from different class versions. +That's why you have this error message. + +--------------------------------------------------------- Q: I want to create a specific application. Is it necessary to build on top of GridBroker? @@ -333,6 +456,3 @@ a valid entity name compare to the previous release. Hence, to fix this problem is to remove the unnecessary empty space, i.e. "GridResource 0" becomes "GridResource_0" - - - Added: trunk/javadoc.sh =================================================================== --- trunk/javadoc.sh (rev 0) +++ trunk/javadoc.sh 2007-09-01 02:48:15 UTC (rev 53) @@ -0,0 +1,33 @@ + +## A script to run javadoc (Anthony Sept 2004). + +year="2007" # year +ver="v4.1" # version number + +dir=./source # source directory that contains Java files +doc=./doc # output directory + +# Only creates GridSim javadoc. +javadoc -author -version -package -noqualifier java.* \ + -windowtitle 'GridSim '$ver' API Specification' \ + -doctitle '<b>GridSim</b> '$ver' API Specification' \ + -header '<b>GridSim</b><br><font size='-1'>'$ver'</font>' \ + -bottom 'The University of Melbourne, Australia, '$year \ + -d $doc -breakiterator \ + -tag pre:a:"Pre Condition:" \ + -tag post:a:"Post Condition:" \ + -tag invariant:t:"Invariant:" \ + $dir/gridsim/*.java \ + $dir/gridsim/util/*.java \ + $dir/gridsim/net/*.java \ + $dir/gridsim/filter/*.java \ + $dir/gridsim/index/*.java \ + $dir/gridsim/resFailure/*.java \ + $dir/gridsim/auction/*.java \ + $dir/gridsim/datagrid/*.java \ + $dir/gridsim/datagrid/filter/*.java \ + $dir/gridsim/datagrid/index/*.java \ + $dir/gridsim/datagrid/storage/*.java + +echo "javadoc is done ...." + Modified: trunk/release_note.txt =================================================================== --- trunk/release_note.txt 2007-09-01 02:32:02 UTC (rev 52) +++ trunk/release_note.txt 2007-09-01 02:48:15 UTC (rev 53) @@ -1,55 +1,56 @@ -Gridbus Project To Release GridSim Toolkit 4.0 + Gridbus Project to Release GridSim Toolkit 4.1 + September 2007 -The Gridbus Project and the GRIDS (Grid Computing and Distributed Systems) -Lab at the University of Melbourne, Australia has released the -next-version of Grid simulation software, the GridSim Toolkit 4.0. -The new version of GridSim -- add two major new features: auction model and data grid -- add a new packet scheduler for the network package -- add a network reader to read a network topology from a file and automatically -creates and link routers -- modify some of the network classes to incorporate this new packet scheduler -- fix few bugs +The Gridbus Project at The University of Melbourne, Australia has released the +next-version of Grid simulation software, the GridSim Toolkit 4.1. +The new version of GridSim adds a new functionality that supports +resource failures and failure detection of Grid resources. This work was done +in collaboration with Agustin Caminero, a Phd student from +Universidad de Castilla La Mancha (UCLM), Spain. All components developed as part of the GridSim Toolkit are released as "open source" under the GPL license to encourage innovation and pass full -freedom to our users. +freedom to our users. In addition, we have decided to use +SourceForge (http://sourceforge.net/projects/gridsim) for hosting +our future releases and developments. This allows us to share and +and to collaborate further on new functionalities. +Therefore, contributions to the GridSim Toolkit are greatly appreciated. The early version of our GridSim toolkit has been used/dowloaded by several academic and commercial organizations around the world including: -California Institute of Technology, Argonne National Labs, -University of Illinois, Manchester University, CERN, Carleton University, -University of Ljubljana, National University of Singapore, -Universidad de Castilla-La Mancha (UCLM) Spain, -Federal University of Ceara (UFC) Brazil, Brunel University UK, -Indian Institute of Technology, Tsinghua University, Sun Microsystems, -IBM, Unisys, HP, British Telecom and EMC Corp. +University of Southern California (USA), California Institute of Technology (USA), +Argonne National Labs (USA), University of Manchester (UK), CERN, +Universidad de Santiago de Compostela (Spain), Indian Institute of Technology, +Tsinghua University (China), Sun Microsystems, IBM Research, Unisys, HP, +Northrop Grumman Information Technology, British Telecom and EMC Corp. The GridSim software has been used for modeling and simulating many -interesting systems. For example, Unisys's usage in data center modeling -and University of Ljubljana's extension of GridSim to support DataGrid. -Our own usages include simulating economic Grid scheduler in a competitive +interesting systems and ideas. For example, IBM Research uses our DataGrid +package to simulate a grid meta-scheduler that tightly integrates +the compute and data transfer times of each job. +Another example is Universidad de Santiago de Compostela's extension of GridSim +to optimize execution of parallel applications on a Grid. +Our own uses include simulating economic Grid scheduler in a competitive economy model, economic based cluster scheduler and cooperative Grid federation. -The contributors to the GridSim software (early/new version) are: -* Rajkumar Buyya, GridS Lab @ The University of Melbourne. -* Manzur Murshed, GSCIT @ Monash University. -* Anthony Sulistio, GridS Lab @ The University of Melbourne. +The contributors to the GridSim software (from early to new version) are: +* Rajkumar Buyya, GRIDS Lab @ The University of Melbourne. +* Manzur Murshed, GSCIT @ Monash University, Australia. +* Anthony Sulistio, GRIDS Lab @ The University of Melbourne. * Gokul Poduval and Chen-Khong Tham, Dept. of Electrical & Computer Engineering @ National University of Singapore. -* Uros Cibej and Borut Robic, - Faculty of Computer and Information Service, +* Marcos Dias de Assuncao, GRIDS Lab @ The University of Melbourne. +* Uros Cibej and Borut Robic, Faculty of Computer and Information Service, The University of Ljubljana, Slovenia. -* Marcos Dias de Assuncao, GridS Lab @ The University of Melbourne. +* Agustin Caminero, Department of Computing Systems, + Universidad de Castilla La Mancha (UCLM), Spain. -GridSim visual modeller by: -* Anthony Sulistio, GridS Lab @ The University of Melbourne. -* Chee Shin Yeo, GridS Lab @ The University of Melbourne. -To download the GridSim software, usage documents and examples, -please visit the Gridbus Project Web site at +To download the GridSim software, please visit the Gridbus Project web site at http://www.gridbus.org/gridsim/ +Join the GridSim mailing lists at +http://sourceforge.net/projects/gridsim This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-09-01 02:32:05
|
Revision: 52 http://gridsim.svn.sourceforge.net/gridsim/?rev=52&view=rev Author: sulistio Date: 2007-08-31 19:32:02 -0700 (Fri, 31 Aug 2007) Log Message: ----------- add resource failures functionality to this trunk or merging from branches/gridsim4.0-branch1 dir. Modified Paths: -------------- trunk/source/gridsim/ARPolicy.java trunk/source/gridsim/AllocPolicy.java trunk/source/gridsim/GridInformationService.java trunk/source/gridsim/GridResource.java trunk/source/gridsim/GridSim.java trunk/source/gridsim/GridSimCore.java trunk/source/gridsim/GridSimTags.java trunk/source/gridsim/Gridlet.java trunk/source/gridsim/Machine.java trunk/source/gridsim/MachineList.java trunk/source/gridsim/PE.java trunk/source/gridsim/PEList.java trunk/source/gridsim/ResourceCharacteristics.java trunk/source/gridsim/index/AbstractGIS.java Added Paths: ----------- trunk/source/gridsim/resFailure/ trunk/source/gridsim/resFailure/AllocPolicyWithFailure.java trunk/source/gridsim/resFailure/AvailabilityInfo.java trunk/source/gridsim/resFailure/FailureMsg.java trunk/source/gridsim/resFailure/GridResourceWithFailure.java trunk/source/gridsim/resFailure/RegionalGISWithFailure.java trunk/source/gridsim/resFailure/SpaceSharedWithFailure.java trunk/source/gridsim/resFailure/TimeSharedWithFailure.java trunk/source/gridsim/resFailure/package.html trunk/source/gridsim/util/HyperExponential.java trunk/source/gridsim/util/LCGRandom.java trunk/source/gridsim/util/Variate.java trunk/source/gridsim/util/Weibull.java Modified: trunk/source/gridsim/ARPolicy.java =================================================================== --- trunk/source/gridsim/ARPolicy.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/ARPolicy.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: ARPolicy.java,v 1.18 2005/10/21 12:29:09 anthony Exp $ + * $Id: ARPolicy.java,v 1.19 2007/08/10 01:50:34 anthony Exp $ */ package gridsim; @@ -486,9 +486,9 @@ } /** - * Gets the current time. Time calculates from simulation init time + - * (GridSim.clock * MILLI_SEC). MILLI_SEC = 1000. - * @return current time in seconds + * Gets the current time. Time is calculated from simulation init time + + * (GridSim.clock() * MILLI_SEC), where MILLI_SEC = 1000. + * @return current time in milliseconds * @pre $none * @post $result > 0 */ Modified: trunk/source/gridsim/AllocPolicy.java =================================================================== --- trunk/source/gridsim/AllocPolicy.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/AllocPolicy.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: AllocPolicy.java,v 1.44 2006/03/09 05:56:31 anthony Exp $ + * $Id: AllocPolicy.java,v 1.45 2007/08/30 02:18:10 anthony Exp $ */ package gridsim; @@ -32,8 +32,7 @@ * Advanced Reservation functionalities need to extend from * {@link gridsim.ARPolicy} class instead. * - * @author Manzur Murshed and Rajkumar Buyya - * @author Anthony Sulistio (re-written this class) + * @author Anthony Sulistio * @since GridSim Toolkit 2.2 * @see gridsim.ARPolicy * @see gridsim.GridSim Modified: trunk/source/gridsim/GridInformationService.java =================================================================== --- trunk/source/gridsim/GridInformationService.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/GridInformationService.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: GridInformationService.java,v 1.31 2005/03/28 06:15:47 anthony Exp $ + * $Id: GridInformationService.java,v 1.32 2007/08/30 02:18:10 anthony Exp $ */ package gridsim; @@ -69,6 +69,7 @@ * </ul> * * @author Manzur Murshed and Rajkumar Buyya + * @author Anthony Sulistio (re-design this class) * @since GridSim Toolkit 1.0 * @invariant $none * @see gridsim.GridSimTags Modified: trunk/source/gridsim/GridResource.java =================================================================== --- trunk/source/gridsim/GridResource.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/GridResource.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: GridResource.java,v 1.61 2006/03/09 05:56:31 anthony Exp $ + * $Id: GridResource.java,v 1.62 2007/08/30 02:18:10 anthony Exp $ */ package gridsim; @@ -85,7 +85,7 @@ * connecting this entity to a router, etc. See the examples for more details. * * @author Manzur Murshed and Rajkumar Buyya - * @author Anthony Sulistio (re-written this class) + * @author Anthony Sulistio (re-design and re-written this class) * @since GridSim Toolkit 1.0 * @see gridsim.GridSimCore * @see gridsim.ResourceCharacteristics Modified: trunk/source/gridsim/GridSim.java =================================================================== --- trunk/source/gridsim/GridSim.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/GridSim.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: GridSim.java,v 1.65 2006/03/09 05:56:12 anthony Exp $ + * $Id: GridSim.java,v 1.67 2007/08/30 02:18:10 anthony Exp $ */ package gridsim; @@ -56,6 +56,7 @@ * </ul> * * @author Manzur Murshed and Rajkumar Buyya + * @author Anthony Sulistio (re-design this class) * @since GridSim Toolkit 1.0 * @see eduni.simjava.Sim_entity * @see gridsim.GridSimCore @@ -502,7 +503,7 @@ /** * Sets a <tt>GridInformationService</tt> (GIS) entity. - * This method is useful is you write a different type of GIS entity. + * This method is useful when you want a different type of GIS entity. * This method must be called before {@link #startGridSimulation()} method. * @param gis a GIS object * @return <tt>true</tt> if successful, <tt>false</tt> otherwise @@ -512,7 +513,8 @@ */ public static boolean setGIS(GridInformationService gis) { - if (gis == null) { + // ignore if an existing GIS object has already been created + if (gis == null || gis_ != null) { return false; } Modified: trunk/source/gridsim/GridSimCore.java =================================================================== --- trunk/source/gridsim/GridSimCore.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/GridSimCore.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: GridSimCore.java,v 1.13 2006/03/09 05:56:31 anthony Exp $ + * $Id: GridSimCore.java,v 1.14 2007/08/30 02:18:10 anthony Exp $ */ package gridsim; @@ -163,8 +163,7 @@ * </code> * </ul> * - * @author Manzur Murshed and Rajkumar Buyya - * @author Anthony Sulistio (re-written this class) + * @author Anthony Sulistio * @since GridSim Toolkit 3.0 * @see eduni.simjava.Sim_entity * @see gridsim.net.Output Modified: trunk/source/gridsim/GridSimTags.java =================================================================== --- trunk/source/gridsim/GridSimTags.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/GridSimTags.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: GridSimTags.java,v 1.46 2006/02/16 01:39:26 anthony Exp $ + * $Id: GridSimTags.java,v 1.49 2007/08/30 02:18:10 anthony Exp $ */ package gridsim; @@ -17,6 +17,7 @@ * numbers, 0 - 299, and 9600. * * @author Manzur Murshed and Rajkumar Buyya + * @author Anthony Sulistio * @since GridSim Toolkit 1.0 * @invariant $none */ @@ -240,6 +241,48 @@ public static final int GRIDLET_MOVE_ACK = BASE + 30; + ///////////////////////////////////////////////////////////// + // NOTE: below are new tags needed for the resource failure functionality + // added by Agustin Caminero, Universidad de Castilla La Mancha (UCLM), + // Spain. Nov 2006. + + /** + * Denotes a request to get the total number of machines of a resource. + * This tag is normally used between GridSim and GridResource entity. + */ + public static final int RESOURCE_NUM_MACHINES = BASE + 31; + + /** + * This tag is used to simulate a resource failure. + * A RegionalGIS object sends an event to itself by using this tag, + * so it can send a failure message to resources in the future. + * This tag is also used when a failed resource receives a ping request. + * In this case, the resource will use this tag in the ping response. + */ + public static final int GRIDRESOURCE_FAILURE = BASE + 32; + + /** + * This tag is used to tell a resource, which is currently failed or down, + * to come back to life. + */ + public static final int GRIDRESOURCE_RECOVERY = BASE + 33; + + /** + * This tag is used by a user to poll a resource to find out whether + * it is out of order or not. + */ + public static final int GRIDRESOURCE_FAILURE_INFO = BASE + 34; + + /** This tag is used by a user to poll a resource. */ + public static final int GRIDRESOURCE_POLLING = BASE + 35; + + /** The polling interval for users. */ + public static final int POLLING_TIME_USER = BASE + 36; + + /** The polling interval for the GIS entities. */ + public static final int POLLING_TIME_GIS = BASE + 37; + + /////////////////////////////////////////////////////////////// // The below tags are sent by AdvanceReservation to ARGridResource class @@ -667,7 +710,7 @@ public static final int AR_CREATE_FAIL_RESOURCE_FULL_IN_5_SECS = -12; /** - * New request of a reservation fails due to full in 10 seconds. + * New request of a reservation fails due to a resource full in 10 seconds. * This tag is sent by a resource or allocation policy to * AdvanceReservation entity. */ @@ -709,7 +752,7 @@ public static final int AR_CREATE_FAIL_RESOURCE_FULL_IN_5_MINS = -18; /** - * New request of a reservation fails due to full in 10 hours. + * New request of a reservation fails due to a resource full in 10 minutes. * This tag is sent by a resource or allocation policy to * AdvanceReservation entity. */ @@ -737,42 +780,42 @@ public static final int AR_CREATE_FAIL_RESOURCE_FULL_IN_45_MINS = -22; /** - * New request of a reservation fails due to full in 1 hour. + * New request of a reservation fails due to a resource full in 1 hour. * This tag is sent by a resource or allocation policy to * AdvanceReservation entity. */ public static final int AR_CREATE_FAIL_RESOURCE_FULL_IN_1_HOUR = -23; /** - * New request of a reservation fails due to full in 5 hours. + * New request of a reservation fails due to a resource full in 5 hours. * This tag is sent by a resource or allocation policy to * AdvanceReservation entity. */ public static final int AR_CREATE_FAIL_RESOURCE_FULL_IN_5_HOURS = -24; /** - * New request of a reservation fails due to full in 10 hours. + * New request of a reservation fails due to a resource full in 10 hours. * This tag is sent by a resource or allocation policy to * AdvanceReservation entity. */ public static final int AR_CREATE_FAIL_RESOURCE_FULL_IN_10_HOURS = -25; /** - * New request of a reservation fails due to full in 15 hours. + * New request of a reservation fails due to a resource full in 15 hours. * This tag is sent by a resource or allocation policy to * AdvanceReservation entity. */ public static final int AR_CREATE_FAIL_RESOURCE_FULL_IN_15_HOURS = -26; /** - * New request of a reservation fails due to full in 30 hours. + * New request of a reservation fails due to a resource full in 30 hours. * This tag is sent by a resource or allocation policy to * AdvanceReservation entity. */ public static final int AR_CREATE_FAIL_RESOURCE_FULL_IN_30_HOURS = -27; /** - * New request of a reservation fails due to full in 45 hours onwards. + * New request of a reservation fails due to a resource full in 45 hours onwards. * This tag is sent by a resource or allocation policy to * AdvanceReservation entity. */ Modified: trunk/source/gridsim/Gridlet.java =================================================================== --- trunk/source/gridsim/Gridlet.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/Gridlet.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: Gridlet.java,v 1.35 2005/09/20 07:04:34 anthony Exp $ + * $Id: Gridlet.java,v 1.37 2007/08/30 02:18:10 anthony Exp $ */ package gridsim; @@ -47,6 +47,7 @@ * {@link #Gridlet(int, double, long, long, boolean)} constructor instead. * * @author Manzur Murshed and Rajkumar Buyya + * @author Anthony Sulistio * @since GridSim Toolkit 1.0 * @invariant $none */ @@ -120,6 +121,10 @@ /** The Gridlet has been resumed from <tt>PAUSED</tt> state. */ public static final int RESUMED = 8; + /** The gridlet has failed due to a resource failure */ + public static final int FAILED_RESOURCE_UNAVAILABLE = 9; + + ///////////////////////////////////////////////////////////// /** @@ -879,7 +884,7 @@ } // throws an exception if the new status is outside the range - if (newStatus < Gridlet.CREATED || newStatus > Gridlet.RESUMED) + if (newStatus < Gridlet.CREATED || newStatus > Gridlet.FAILED_RESOURCE_UNAVAILABLE) { throw new Exception("Gridlet.setGridletStatus() : Error - " + "Invalid integer range for Gridlet status."); @@ -992,6 +997,10 @@ statusString = "Resumed"; break; + case Gridlet.FAILED_RESOURCE_UNAVAILABLE : + statusString = "Failed_resource_unavailable"; + break; + default: break; } Modified: trunk/source/gridsim/Machine.java =================================================================== --- trunk/source/gridsim/Machine.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/Machine.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: Machine.java,v 1.13 2004/11/01 02:52:36 anthony Exp $ + * $Id: Machine.java,v 1.14 2007/08/20 02:13:29 anthony Exp $ */ @@ -27,7 +27,10 @@ private PEList PEList_; private int id_; + // tells whether this machine is working properly or has failed. + private boolean failed_; + /** * Allocates a new Machine object * @param id the machine ID @@ -40,6 +43,7 @@ { this.id_ = id; this.PEList_ = list; + failed_ = false; } /** @@ -210,5 +214,45 @@ return totalInt + PEList_.getByteSize(); } + /** + * Sets the PEs of this machine to a FAILED status. + * NOTE: <tt>resName</tt> is used for debugging purposes, + * which is <b>ON</b> by default. + * Use {@link #setFailed(boolean)} if you do not want + * this information. + * + * @param resName the name of the resource + * @param fail true if this machine fails or false otherwise + * @return <tt>true</tt> if successful, <tt>false</tt> otherwise + */ + public boolean setFailed(String resName, boolean fail) + { + // all the PEs are failed (or recovered, depending on fail) + failed_ = fail; + PEList_.setStatusFailed(resName, id_, failed_); + return true; + } + + /** + * Sets the PEs of this machine to a FAILED status. + * @param fail true if this machine fails or false otherwise + * @return <tt>true</tt> if successful, <tt>false</tt> otherwise + */ + public boolean setFailed(boolean fail) + { + // all the PEs are failed (or recovered, depending on fail) + failed_ = fail; + PEList_.setStatusFailed(failed_); + return true; + } + + /** + * Checks whether this machine is failed or not. + * @return <tt>true</tt> if this machine is failed, <tt>false</tt> otherwise + */ + public boolean getFailed() { + return failed_; + } + } // end class Modified: trunk/source/gridsim/MachineList.java =================================================================== --- trunk/source/gridsim/MachineList.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/MachineList.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: MachineList.java,v 1.14 2004/11/01 02:52:36 anthony Exp $ + * $Id: MachineList.java,v 1.15 2007/08/20 02:13:29 anthony Exp $ */ package gridsim; @@ -171,11 +171,22 @@ while ( it.hasNext() ) { obj = (Machine) it.next(); - PEList myPElist = obj.getPEList(); - if (myPElist.getNumFreePE() >= numPE) { - return obj; // a machine with Free ID is found. + // If the machine is failed, do nothing. Otherwise... + if (obj.getFailed() == false) + { + PEList myPElist = obj.getPEList(); + if (myPElist.getNumFreePE() >= numPE) { + return obj; // a machine with Free ID is found. + } } + /************** + // Uncomment this if you want more info on the progress of sims + else + { + System.out.println("MachineList.getMachineWithFreePE(). MachineID: " + + obj.getMachineID() + ". Machine is failed. Try other machine."); + }*/ } return null; // none of the machines have free PE. @@ -234,5 +245,25 @@ return bSize; } + /** + * Gets the machine in a given position in the list. + * @param index a position index in the list + * @return the Machine object + */ + public Machine getMachineInPos(int index) + { + Machine obj = null; + Iterator it = super.iterator(); + int count = 0; + while ( (it.hasNext()) && (count <= index) ) + { + count++; + obj = (Machine) it.next(); + } + + return obj; + + } + } // end class Modified: trunk/source/gridsim/PE.java =================================================================== --- trunk/source/gridsim/PE.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/PE.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: PE.java,v 1.14 2005/03/28 07:10:14 anthony Exp $ + * $Id: PE.java,v 1.15 2007/08/30 01:20:19 anthony Exp $ */ package gridsim; @@ -26,13 +26,22 @@ // FOR SPACE SHARED RESOURCE: Jan 21 private boolean status_; // Status of PE: FREE or BUSY + // TODO: this is obviously clash BUSY with FAILED !!! So, change from the status + // of boolean to integer !! + /** Denotes PE is FREE for allocation */ public static final boolean FREE = true; /** Denotes PE is allocated and hence busy in processing Gridlet */ public static final boolean BUSY = false; + /** Denotes PE is failed and hence it can't process any Gridlet at this moment. + * This PE is failed because it belongs to a machine which is also failed. + */ + public static final boolean FAILED = false; + + /** * Allocates a new PE object * @param id the PE ID @@ -211,5 +220,14 @@ return totalInt; } + /** + * Sets this PE to FAILED. + * @pre $none + * @post $none + */ + public void setStatusFailed() { + status_ = FAILED; + } + } // end class Modified: trunk/source/gridsim/PEList.java =================================================================== --- trunk/source/gridsim/PEList.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/PEList.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: PEList.java,v 1.13 2004/11/01 02:52:36 anthony Exp $ + * $Id: PEList.java,v 1.14 2007/08/20 02:13:52 anthony Exp $ */ package gridsim; @@ -182,5 +182,47 @@ return super.size() * PE.getByteSize(); } + /** + * Sets the status of PEs of this machine to FAILED. + * NOTE: <tt>resName</tt> and <tt>machineID</tt> are used for debugging + * purposes, which is <b>ON</b> by default. + * Use {@link #setStatusFailed(boolean)} if you do not want + * this information. + * + * @param resName the name of the resource + * @param machineID the id of this machine + * @param fail the new value for the "failed" parameter + */ + public void setStatusFailed(String resName, int machineID, boolean fail) + { + String status = null; + if (fail == true) + status = "FAILED"; + else + status = "WORKING"; + + System.out.println(resName + " - Machine: " + machineID + + " is " + status); + + this.setStatusFailed(fail); + } + + /** + * Sets the status of PEs of this machine to FAILED. + * @param fail the new value for the "failed" parameter + */ + public void setStatusFailed(boolean fail) + { + // a loop to set the status of all the PEs in this machine + Iterator it = super.iterator(); + while ( it.hasNext() ) + { + PE obj = (PE) it.next(); + if (fail == true) + obj.setStatus(PE.FAILED); + else + obj.setStatus(PE.FREE); + } + } + } // end class - Modified: trunk/source/gridsim/ResourceCharacteristics.java =================================================================== --- trunk/source/gridsim/ResourceCharacteristics.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/ResourceCharacteristics.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: ResourceCharacteristics.java,v 1.22 2004/11/01 02:52:37 anthony Exp $ + * $Id: ResourceCharacteristics.java,v 1.23 2007/08/20 02:14:24 anthony Exp $ */ package gridsim; @@ -599,5 +599,47 @@ return totalSize; } + /** + * Gets the total number of machines. + * @return total number of machines this resource has. + */ + public int getNumMachines() { + return machineList_.size(); + } + + /** + * Gets the current number of failed machines. + * @return current number of failed machines this resource has. + */ + public int getNumFailedMachines() + { + int numFailedMachines = 0; + int numMach = machineList_.size(); + Machine mach; + + for (int i = 0; i < numMach; i++) + { + mach = machineList_.getMachineInPos(i); + if (mach.getFailed() == true) + numFailedMachines++; + } + + return numFailedMachines; + } + + /** + * Checks whether all machines of this resource are working properly or not. + * @return <tt>true</tt> if all machines are working, + * <tt>false</tt> otherwise + */ + public boolean isWorking() + { + boolean result = false; + if (this.getNumFailedMachines() == 0) + result = true; + + return result; + } + } // end class Modified: trunk/source/gridsim/index/AbstractGIS.java =================================================================== --- trunk/source/gridsim/index/AbstractGIS.java 2007-09-01 02:27:16 UTC (rev 51) +++ trunk/source/gridsim/index/AbstractGIS.java 2007-09-01 02:32:02 UTC (rev 52) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: AbstractGIS.java,v 1.6 2005/10/21 10:22:39 anthony Exp $ + * $Id: AbstractGIS.java,v 1.8 2007/08/30 01:38:43 anthony Exp $ */ package gridsim.index; @@ -26,8 +26,6 @@ */ public abstract class AbstractGIS extends GridSimCore { - private final int NUM_FORM = 2; // size of registration array - /** System GIS or {@link gridsim.GridInformationService} entity ID. */ protected int systemGIS_ = -1; @@ -93,20 +91,25 @@ * This tag should be called from a Regional GIS to a sender Regional GIS. */ public static final int GIS_INQUIRY_RESOURCE_RESULT = GIS_BASE + 10; - + /** Denotes an inquiry regarding to a list of local resources, * which supports advanced reservation. * This tag should be called from a Regional GIS to another. */ public static final int GIS_INQUIRY_RESOURCE_AR_LIST = GIS_BASE + 11; - + /** Denotes a result regarding to a list of local resources, * which supports advanced reservation. * This tag should be called from a Regional GIS to a sender Regional GIS. */ public static final int GIS_INQUIRY_RESOURCE_AR_RESULT = GIS_BASE + 12; + /** Denotes an inquiry regarding to a resource failure. + * The user sends this tag to the GIS to update its list of resources. + */ + public static final int NOTIFY_GIS_RESOURCE_FAILURE = GIS_BASE + 13; + /** * Creates a new regional GIS entity * @param name this regional GIS name Added: trunk/source/gridsim/resFailure/AllocPolicyWithFailure.java =================================================================== --- trunk/source/gridsim/resFailure/AllocPolicyWithFailure.java (rev 0) +++ trunk/source/gridsim/resFailure/AllocPolicyWithFailure.java 2007-09-01 02:32:02 UTC (rev 52) @@ -0,0 +1,37 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero + * Organization: Universidad de Castilla La Mancha (UCLM), Spain. + * Created on: Nov 2006. + */ + +package gridsim.resFailure; + +/** + * The structure of an allocation policy supporting resource failure. + * Use this class in addition to {@link gridsim.AllocPolicy} class. + * @author Agustin Caminero + * @since GridSim Toolkit 4.1 + * @see gridsim.AllocPolicy + */ + +public interface AllocPolicyWithFailure +{ + /** + * Sets the status of all Gridlets in this resource to <tt>FAILED</tt>. + * Then sends them back to users, and clean up the relevant lists. + */ + public abstract void setGridletsFailed(); + + /** + * Sets the status of all Gridlets in this machine to <tt>FAILED</tt>. + * Then sends them back to users, and clean up the relevant lists. + * @param failedMachID the id of the failed machine + */ + public abstract void setGridletsFailed(int failedMachID); + +} // end class Added: trunk/source/gridsim/resFailure/AvailabilityInfo.java =================================================================== --- trunk/source/gridsim/resFailure/AvailabilityInfo.java (rev 0) +++ trunk/source/gridsim/resFailure/AvailabilityInfo.java 2007-09-01 02:32:02 UTC (rev 52) @@ -0,0 +1,89 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero + * Organization: Universidad de Castilla La Mancha (UCLM), Spain. + * Created on: Nov 2006. + */ + + +package gridsim.resFailure; + +/** + * This class is used by GridSim users to check whether a particular resource + * is working or is totally failed. + * + * @author Agustin Caminero + * @since GridSim Toolkit 4.1 + */ + +public class AvailabilityInfo +{ + private int resID; + private int srcID; + private boolean availability; + + /** + * Creates a new object of this class + * @param res a resource id + * @param src the sender id + */ + public AvailabilityInfo(int res, int src) + { + resID = res; + srcID = src; + availability = true; // by default, true + } + + /** + * Gets the source or sender id + * @return sender id + */ + public int getSrcID() { + return srcID; + } + + /** + * Gets the resource id + * @return resource id + */ + public int getResID() { + return resID; + } + + /** + * Checks the availability of this resource + * @return <tt>true</tt> if available, <tt>false</tt> otherwise + */ + public boolean getAvailability() { + return availability; + } + + /** + * Sets the source or sender id + * @param src the sender id + */ + public void setSrcID(int src) { + srcID = src; + } + + /** + * Sets the resource id + * @param res a resource id + */ + public void setResID(int res) { + resID = res; + } + + /** + * Sets the resource availability + * @param av <tt>true</tt> if available, <tt>false</tt> otherwise + */ + public void setAvailability(boolean av) { + availability = av; + } + +} // end class Added: trunk/source/gridsim/resFailure/FailureMsg.java =================================================================== --- trunk/source/gridsim/resFailure/FailureMsg.java (rev 0) +++ trunk/source/gridsim/resFailure/FailureMsg.java 2007-09-01 02:32:02 UTC (rev 52) @@ -0,0 +1,103 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero + * Organization: Universidad de Castilla La Mancha (UCLM), Spain. + * Created on: Nov 2006. + */ + + +package gridsim.resFailure; + +/** + * This class is used by + * {@link gridsim.resFailure.RegionalGISWithFailure} to commnunicate with + * {@link gridsim.resFailure.GridResourceWithFailure} + * for simulating a resource failure. + * + * @author Agustin Caminero + * @since GridSim Toolkit 4.1 + */ + +public class FailureMsg +{ + /** The time that the failure will last */ + private double time; + + /** The id of the resource */ + private int res_id; + + /** The number of machines that will fail in this resource */ + private int numMachines; + + + /** + * Creates a new failure message + * @param time the time that the failure will last + * @param rid the resource id + */ + public FailureMsg(double time, int rid) { + this.time = time; + res_id = rid; + numMachines = 0; + } + + /** + * This method sets the time atribute of the ResourceFailure object + * @param time the time that the failure will last + */ + public void setTime(double time) + { + this.time = time; + } + + /** + * This method returns the time atribute of the ResourceFailure object + * @return time + */ + public double getTime() + { + return time; + } + + /** + * This method sets the res_id atribute of the ResourceFailure object + * @param r the resource id of the resource + */ + public void setRes(int r) + { + res_id = r; + } + + /** + * This method returns the res_id atribute of the ResourceFailure object + * @return the resource id + */ + public int getRes() + { + return res_id; + } + + /** + * This method sets the numMachines atribute of the ResourceFailure object + * @param n the number of machines which will fail in this resource + */ + public void setNumMachines(int n) + { + numMachines = n; + } + + /** + * This method returns the number of machines which will fail + * in this resource + * @return number of failed machines + */ + public double getNumMachines() + { + return numMachines; + } + +} // end class Added: trunk/source/gridsim/resFailure/GridResourceWithFailure.java =================================================================== --- trunk/source/gridsim/resFailure/GridResourceWithFailure.java (rev 0) +++ trunk/source/gridsim/resFailure/GridResourceWithFailure.java 2007-09-01 02:32:02 UTC (rev 52) @@ -0,0 +1,1386 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: Universidad de Castilla La Mancha (UCLM), Spain. + * Created on: Nov 2006. + */ + +package gridsim.resFailure; + +import gridsim.resFailure.*; +import gridsim.*; +import gridsim.net.*; +import gridsim.index.*; +import java.util.LinkedList; +import eduni.simjava.Sim_event; +import eduni.simjava.Sim_system; +import gridsim.resFailure.FailureMsg; +import java.io.FileWriter; + + +/** + * GridResourceWithFailure is based on {@link gridsim.GridResource}, but with + * added failure functionalities. + * GridResourceWithFailure extends the {@link gridsim.GridSimCore} class for + * gaining communication and concurrent entity capabilities. + * An instance of this class stimulates a resource + * with properties defined in an object of + * {@link gridsim.ResourceCharacteristics} class. + * + * @author Agustin Caminero and Anthony Sulistio + * @since GridSim Toolkit 4.1 + * @see gridsim.GridResource + * @see gridsim.ResourceCharacteristics + * @see gridsim.resFailure.AllocPolicyWithFailure + * @invariant $none + */ +public class GridResourceWithFailure extends GridSimCore +{ + /** Characteristics of this resource */ + protected ResourceCharacteristics resource_; + + /** a ResourceCalendar object */ + protected ResourceCalendar resCalendar_; + + /** A resource's scheduler. This object is reponsible in scheduling and + * and executing submitted Gridlets. + */ + protected AllocPolicy policy_; + + /** A scheduler type of this resource, such as FCFS, Round Robin, etc */ + protected int policyType_; + + /** Integer object size, including its overhead */ + protected final int SIZE = 12; + + /** Regional GIS entity name */ + protected String regionalGISName_; + + // a flag to denote whether to record events into a file or not + private boolean record_ = false; + + + /** + * Allocates a new GridResourceWithFailure object. When making a different + * type of GridResourceWithFailure object, use + * {@link #GridResourceWithFailure(String, double, ResourceCharacteristics, + * ResourceCalendar, AllocPolicyWithFailure)} + * and then overrides {@link #processOtherEvent(Sim_event)}. + * + * @param name the name to be associated with this entity (as + * required by Sim_entity class from simjava package) + * @param baud_rate network communication or bandwidth speed + * @param seed the initial seed + * @param resource an object of ResourceCharacteristics + * @param peakLoad the load during peak times + * @param offPeakLoad the load during off peak times + * @param relativeHolidayLoad the load during holiday times + * @param weekends a linked-list contains the weekend days + * @param holidays a linked-list contains the public holidays + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> creating this entity before initializing GridSim package + * <li> this entity name is <tt>null</tt> or empty + * <li> this entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs mean the Gridlets can't be processed. + * A GridResourceWithFailure must contain one or more Machines. + * A Machine must contain one or more PEs. + * </ul> + * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], + * String) + * @see gridsim.GridSim#init(int, Calendar, boolean) + * @see #GridResourceWithFailure(String, double, + * ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure) + * @pre name != null + * @pre baud_rate > 0 + * @pre resource != null + * @post $none + */ + public GridResourceWithFailure(String name, double baud_rate, long seed, + ResourceCharacteristics resource, double peakLoad, + double offPeakLoad, double relativeHolidayLoad, + LinkedList weekends, LinkedList holidays) throws Exception + { + super(name, baud_rate); + resource_ = resource; + + resCalendar_ = new ResourceCalendar(resource_.getResourceTimeZone(), + peakLoad, offPeakLoad, relativeHolidayLoad, weekends, + holidays, seed); + + policy_ = null; + + init(); + } + + /** + * Allocates a new GridResourceWithFailure object. When making a different + * type of GridResourceWithFailure object, use + * {@link #GridResourceWithFailure(String, double, ResourceCharacteristics, + * ResourceCalendar, AllocPolicyWithFailure)} + * and then overrides {@link #processOtherEvent(Sim_event)}. + * + * @param name the name to be associated with this entity (as + * required by Sim_entity class from simjava package) + * @param baud_rate network communication or bandwidth speed + * @param resource an object of ResourceCharacteristics + * @param calendar an object of ResourceCalendar + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> creating this entity before initializing GridSim package + * <li> this entity name is <tt>null</tt> or empty + * <li> this entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs mean the Gridlets can't be processed. + * A GridResourceWithFailure must contain one or more Machines. + * A Machine must contain one or more PEs. + * </ul> + * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], + * String) + * @see gridsim.GridSim#init(int, Calendar, boolean) + * @see #GridResourceWithFailure(String, double, + * ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure) + * @pre name != null + * @pre baud_rate > 0 + * @pre resource != null + * @pre calendar != null + * @post $none + */ + public GridResourceWithFailure(String name, double baud_rate, + ResourceCharacteristics resource, ResourceCalendar calendar) + throws Exception + { + super(name, baud_rate); + resource_ = resource; + + resCalendar_ = calendar; + policy_ = null; + init(); + } + + /** + * Allocates a new GridResourceWithFailure object. When making a different + * type of GridResourceWithFailure object, use this constructor and then + * overrides {@link #processOtherEvent(Sim_event)}. + * + * @param name the name to be associated with this entity (as + * required by Sim_entity class from simjava package) + * @param baud_rate network communication or bandwidth speed + * @param resource an object of ResourceCharacteristics + * @param calendar an object of ResourceCalendar + * @param policy a scheduling policy for this Grid resource. If no + * scheduling policy is defined, the default one is + * <tt>SpaceShared</tt> + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> creating this entity before initializing GridSim package + * <li> this entity name is <tt>null</tt> or empty + * <li> this entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs mean the Gridlets can't be processed. + * A GridResourceWithFailure must contain one or more Machines. + * A Machine must contain one or more PEs. + * </ul> + * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], + * String) + * @see gridsim.GridSim#init(int, Calendar, boolean) + * @see gridsim.resFailure.AllocPolicyWithFailure + * @pre name != null + * @pre baud_rate > 0 + * @pre resource != null + * @pre calendar != null + * @pre policy != null + * @post $none + */ + public GridResourceWithFailure(String name, double baud_rate, + ResourceCharacteristics resource, ResourceCalendar calendar, + AllocPolicyWithFailure policy) throws Exception + { + super(name, baud_rate); + resource_ = resource; + resCalendar_ = calendar; + + // the order between policy and init() is important + policy_ = (AllocPolicy) policy; + init(); + } + + //////////////////////////////////////////// + + /** + * Allocates a new GridResourceWithFailure object. When making a different + * type of GridResourceWithFailure object, use + * {@link #GridResourceWithFailure(String, Link, ResourceCharacteristics, + * ResourceCalendar, AllocPolicyWithFailure)} + * and then overrides {@link #processOtherEvent(Sim_event)}. + * + * @param name the name to be associated with this entity (as + * required by Sim_entity class from simjava package) + * @param link the link that will be used to connect this + * GridResourceWithFailure to another Entity or Router. + * @param seed the initial seed + * @param resource an object of ResourceCharacteristics + * @param peakLoad the load during peak times + * @param offPeakLoad the load during off peak times + * @param relativeHolidayLoad the load during holiday times + * @param weekends a linked-list contains the weekend days + * @param holidays a linked-list contains the public holidays + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> creating this entity before initializing GridSim package + * <li> this entity name is <tt>null</tt> or empty + * <li> this entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs mean the Gridlets can't be processed. + * A GridResourceWithFailure must contain one or more Machines. + * A Machine must contain one or more PEs. + * </ul> + * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], + * String) + * @pre name != null + * @pre link != null + * @pre resource != null + * @post $none + */ + public GridResourceWithFailure(String name, Link link, long seed, + ResourceCharacteristics resource, double peakLoad, + double offPeakLoad, double relativeHolidayLoad, + LinkedList weekends, LinkedList holidays) throws Exception + { + super(name, link); + resource_ = resource; + + resCalendar_ = new ResourceCalendar(resource_.getResourceTimeZone(), + peakLoad, offPeakLoad, relativeHolidayLoad, weekends, + holidays, seed); + + policy_ = null; + init(); + } + + /** + * Allocates a new GridResourceWithFailure object. When making a different + * type of GridResourceWithFailure object, use + * {@link #GridResourceWithFailure(String, Link, ResourceCharacteristics, + * ResourceCalendar, AllocPolicyWithFailure)} + * and then overrides {@link #processOtherEvent(Sim_event)}. + * + * @param name the name to be associated with this entity (as + * required by Sim_entity class from simjava package) + * @param link the link that will be used to connect this + * GridResourceWithFailure to another Entity or Router. + * @param resource an object of ResourceCharacteristics + * @param calendar an object of ResourceCalendar + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> creating this entity before initializing GridSim package + * <li> this entity name is <tt>null</tt> or empty + * <li> this entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs mean the Gridlets can't be processed. + * A GridResourceWithFailure must contain one or more Machines. + * A Machine must contain one or more PEs. + * </ul> + * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], + * String) + * @pre name != null + * @pre link != null + * @pre resource != null + * @pre calendar != null + * @post $none + */ + public GridResourceWithFailure(String name, Link link, + ResourceCharacteristics resource, ResourceCalendar calendar) + throws Exception + { + super(name, link); + resource_ = resource; + + resCalendar_ = calendar; + policy_ = null; + init(); + } + + /** + * Allocates a new GridResourceWithFailure object. When making a different + * type of GridResourceWithFailure object, use this constructor and then + * overrides {@link #processOtherEvent(Sim_event)}. + * + * @param name the name to be associated with this entity (as + * required by Sim_entity class from simjava package) + * @param link the link that will be used to connect this + * GridResourceWithFailure to another Entity or Router. + * @param resource an object of ResourceCharacteristics + * @param calendar an object of ResourceCalendar + * @param policy a scheduling policy for this Grid resource. If no + * scheduling policy is defined, the default one is + * <tt>SpaceShared</tt> + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> creating this entity before initializing GridSim package + * <li> this entity name is <tt>null</tt> or empty + * <li> this entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs mean the Gridlets can't be processed. + * A GridResourceWithFailure must contain one or more Machines. + * A Machine must contain one or more PEs. + * </ul> + * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], + * String) + * @see gridsim.resFailure.AllocPolicyWithFailure + * @pre name != null + * @pre link != null + * @pre resource != null + * @pre calendar != null + * @pre policy != null + * @post $none + */ + public GridResourceWithFailure(String name, Link link, + ResourceCharacteristics resource, ResourceCalendar calendar, + AllocPolicyWithFailure policy) throws Exception + { + super(name,link); + resource_ = resource; + resCalendar_ = calendar; + + // the order between policy and init() is important + policy_ = (AllocPolicy) policy; + init(); + } + + ///////////////////////////////////////////////// + + /** + * Sets a regional GridInformationService (GIS) entity for this resource + * to communicate with. This resource will then register its ID to the + * regional GIS entity, rather than {@link GridInformationService} or + * <tt>system GIS</tt>. + * @param regionalGIS name of regional GIS entity + * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise + * @pre regionalGIS != null + * @post $none + */ + public boolean setRegionalGIS(String regionalGIS) + { + if (regionalGIS == null || GridSim.getEntityId(regionalGIS) == -1) { + return false; + } + + regionalGISName_ = regionalGIS; + return true; + } + + /** + * Sets a regional GridInformationService (GIS) entity for this resource + * to communicate with. This resource will then register its ID to the + * regional GIS entity, rather than {@link GridInformationService} or + * <tt>system GIS</tt>. + * @param gis regional GIS entity object + * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise + * @pre gis != null + * @post $none + */ + public boolean setRegionalGIS(AbstractGIS gis) + { + if (gis == null) { + return false; + } + + return setRegionalGIS( gis.get_name() ); + } + + /** + * Asks this resource to record its activities. <br> + * NOTE: this method should be called <b>BEFORE</b> the simulation starts. + * If an existing file exists, the new activities will be appended at the + * end. The file name is this entity name. + * + * @param trace <tt>true</tt> if you want to record this resource's + * activities, <tt>false</tt> otherwise + */ + public void setTrace(boolean trace) { + record_ = trace; + initializeReportFile(); + } + + /** + * Handles external events that are coming to this GridResourceWithFailure + * entity. This method also registers the identity of this + * GridResourceWithFailure entity to <tt>GridInformationService</tt> class. + * <p> + * The services or tags available for this resource are: + * <ul> + * <li> {@link gridsim.GridSimTags#RESOURCE_CHARACTERISTICS} </li> + * <li> {@link gridsim.GridSimTags#RESOURCE_DYNAMICS} </li> + * <li> {@link gridsim.GridSimTags#GRIDLET_SUBMIT} </li> + * <li> {@link gridsim.GridSimTags#GRIDLET_CANCEL} </li> + * <li> {@link gridsim.GridSimTags#GRIDLET_PAUSE} </li> + * <li> {@link gridsim.GridSimTags#GRIDLET_RESUME} </li> + * <li> {@link gridsim.GridSimTags#GRIDLET_MOVE} </li> + * <li> {@link gridsim.GridSimTags#GRIDLET_STATUS} </li> + * </ul> + * <br> + * This method also calls these methods in the following order: + * <ol> + * <li> {@link #registerOtherEntity()} method + * <li> {@link #processOtherEvent(Sim_event)} method + * </ol> + * + * @pre $none + * @post $none + */ + public void body() + { + // send the registration to GIS + int register = 0; + if (policyType_ == ResourceCharacteristics.ADVANCE_RESERVATION) { + register = GridSimTags.REGISTER_RESOURCE_AR; + } + else { + register = GridSimTags.REGISTER_RESOURCE; + } + + // this resource should register to regional GIS. + // However, if not specified, then register to system GIS (the + // default GridInformationService) entity. + int gisID = GridSim.getEntityId(regionalGISName_); + if (gisID == -1) { + gisID = GridSim.getGridInfoServiceEntityId(); + } + // need to wait for few seconds before registering to a regional GIS. + // This is because to allow all routers to fill in their routing tables + else + { + super.sim_pause(GridSim.PAUSE); + System.out.println(super.get_name() + ".body(): wait for " + + GridSim.PAUSE + " seconds before registering to " + + regionalGISName_); + } + + // send the registration to GIS + super.send(super.output, GridSimTags.SCHEDULE_NOW, register, + new IO_data(new Integer(super.get_id()), SIZE, gisID) ); + + // Below method is for a child class to override + registerOtherEntity(); + + // Process events until END_OF_SIMULATION is received from the + // GridSimShutdown Entity + Sim_event ev = new Sim_event(); + while ( Sim_system.running() ) + { + super.sim_get_next(ev); + + // if the simulation finishes then exit the loop + if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) + { + System.out.println(get_name()+ ": end of simulation..."); + policy_.setEndSimulation(); + break; + } + + // process the received event + processEvent(ev); + } + + // remove I/O entities created during construction of this entity + super.terminateIOEntities(); + } + + + //////////////////// PROTECTED METHODS /////////////////////////////////// + + /** + * Overrides this method when making a new and different type of resource. + * This method is called by {@link #body()} for incoming unknown tags. + * <p> + * Another approach is to override the + * {@link gridsim.AllocPolicy#processOtherEvent(Sim_event)} method. + * This approach is desirable if you do not want to create a new type of + * grid resource. + * + * @param ev a Sim_event object + * @pre ev != null + * @post $none + */ + protected void processOtherEvent(Sim_event ev) + { + if (ev == null) + { + System.out.println(super.get_name() + ".processOtherEvent(): " + + "Error - an event is null."); + return; + } + + /**** // NOTE: now a resource passes a new event to the scheduler + System.out.println(super.get_name()+".processOtherEvent(): Unable to " + + "handle request from GridSimTags with tag number " + + ev.get_tag() ); + *****/ + + policy_.processOtherEvent(ev); + } + + /** + * Overrides this method when making a new and different type of resource. + * This method is called by {@link #body()} to register other type to + * {@link gridsim.GridInformationService} entity. In doing so, you + * need to create a new child class extending from + * {@link gridsim.GridInformationService}. + * <br> + * <b>NOTE:</b> You do not need to override {@link #body()} method, if + * you use this method. + * + * @pre $none + * @post $none + * @see gridsim.GridInformationService + */ + protected void registerOtherEntity() { + // empty. This should be override by a child class + } + + //////////////////// PRIVATE METHODS /////////////////////////////////// + + /** + * Initializes the resource allocation policy + * @throws Exception If number of PEs is zero + * @pre $none + * @post $none + */ + private void init() throws Exception + { + // If this resource doesn't have any PEs then no useful at all + if (resource_.getNumPE() == 0) + { + throw new Exception(super.get_name() + " : Error - this entity " + + "has no PEs. Therefore, can't process any Gridlets."); + } + + // stores id of this class + resource_.setResourceID( super.get_id() ); + + // if internal allocation policy is used + policyType_ = resource_.getResourceAllocationPolicy(); + if (policy_ == null) + { + switch (policyType_) + { + case ResourceCharacteristics.TIME_SHARED: + policy_ = new TimeSharedWithFailure(super.get_name(), "TimeShared"); + break; + + case ResourceCharacteristics.SPACE_SHARED: + policy_ = new SpaceSharedWithFailure(super.get_name(), "SpaceShared"); + break; + + default: + throw new Exception(super.get_name()+" : Error - supports"+ + " only TimeShared or SpaceShared policy."); + } + } + + policy_.init(resource_, resCalendar_, super.output); + record_ = false; + } + + /** + * Processes events or services that are available for this + * GridResourceWithFailure + * @param ev a Sim_event object + * @pre ev != null + * @post $none + */ + private void processEvent(Sim_event ev) + { + int src_id = -1; + + // GRIDRESOURCE_RECOVERY and GRIDRESOURCE_FAILURE_INFO (polling request) + // are ALWAYS processed. + if (ev.get_tag() == GridSimTags.GRIDRESOURCE_RECOVERY) + { + processRecovery(ev); + } + else if (ev.get_tag() == GridSimTags.GRIDRESOURCE_FAILURE_INFO) + { + processPolling(ev); + } + + // Only if the resource is not failed, then process other events + if (getResourceFailed() == false) + { + switch (ev.get_tag()) + { + + // Resource characteristics inquiry + case GridSimTags.RESOURCE_CHARACTERISTICS: + src_id = ((Integer) ev.get_data()).intValue(); + super.send(super.output, 0.0, ev.get_tag(), + new IO_data(resource_, resource_.getByteSize(), src_id)); + + break; + + // Resource dynamic info inquiry + case GridSimTags.RESOURCE_DYNAMICS: + src_id = ((Integer) ev.get_data()).intValue(); + super.send(super.output, 0.0, ev.get_tag(), + new IO_data(policy_.getTotalLoad(), + Accumulator.getByteSize(), src_id)); + break; + + case GridSimTags.RESOURCE_NUM_PE: + src_id = ((Integer) ev.get_data()).intValue(); + int numPE = resource_.getNumPE(); + super.send(super.output, 0.0, ev.get_tag(), + new IO_data(new Integer(numPE), SIZE, src_id)); + break; + + case GridSimTags.RESOURCE_NUM_FREE_PE: + src_id = ((Integer) ev.get_data()).intValue(); + ... [truncated message content] |
From: <sul...@us...> - 2007-09-01 02:27:14
|
Revision: 51 http://gridsim.svn.sourceforge.net/gridsim/?rev=51&view=rev Author: sulistio Date: 2007-08-31 19:27:16 -0700 (Fri, 31 Aug 2007) Log Message: ----------- change the submit time from int to long. for a trace that spans over 1 year period, the submit time is beyond the max limit of int. Modified Paths: -------------- trunk/source/gridsim/util/Workload.java Modified: trunk/source/gridsim/util/Workload.java =================================================================== --- trunk/source/gridsim/util/Workload.java 2007-09-01 02:10:24 UTC (rev 50) +++ trunk/source/gridsim/util/Workload.java 2007-09-01 02:27:16 UTC (rev 51) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * $Id: Workload.java,v 1.8 2006/06/30 04:30:03 anthony Exp $ + * $Id: Workload.java,v 1.9 2007/08/30 01:50:04 anthony Exp $ */ package gridsim.util; @@ -668,8 +668,8 @@ } // get the submit time - obj = new Integer( array[SUBMIT_TIME].trim() ); - int submitTime = obj.intValue(); + Long l = new Long( array[SUBMIT_TIME].trim() ); + long submitTime = l.intValue(); // get the run time obj = new Integer( array[REQ_RUN_TIME].trim() ); @@ -734,7 +734,7 @@ * @pre numProc > 0 * @post $none */ - private void submitGridlet(int id, int submitTime, int runTime, int numProc) + private void submitGridlet(int id, long submitTime, int runTime, int numProc) { // create the gridlet int len = runTime * rating_; // calculate a job length for each PE @@ -749,6 +749,11 @@ resName_ + " ..."); } + // check the submit time + if (submitTime < 0) { + submitTime = 0; + } + gridletID_++; // increment the counter // submit a gridlet to resource This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-09-01 02:10:25
|
Revision: 50 http://gridsim.svn.sourceforge.net/gridsim/?rev=50&view=rev Author: sulistio Date: 2007-08-31 19:10:24 -0700 (Fri, 31 Aug 2007) Log Message: ----------- add resource failure examples from gridsim4.0-branch1 to this trunk directory. Modified Paths: -------------- trunk/examples/README.txt Added Paths: ----------- trunk/examples/ResFailure/ trunk/examples/ResFailure/README.txt trunk/examples/ResFailure/ResFailureEx01/ trunk/examples/ResFailure/ResFailureEx01/Ex01_Regional_GIS trunk/examples/ResFailure/ResFailureEx01/Ex01_Res_0 trunk/examples/ResFailure/ResFailureEx01/Ex01_Res_1 trunk/examples/ResFailure/ResFailureEx01/Ex01_Res_2 trunk/examples/ResFailure/ResFailureEx01/Ex01_User0 trunk/examples/ResFailure/ResFailureEx01/Ex01_User0_Fin trunk/examples/ResFailure/ResFailureEx01/GridUserFailureEx01.java trunk/examples/ResFailure/ResFailureEx01/GridletSubmission.java trunk/examples/ResFailure/ResFailureEx01/README.txt trunk/examples/ResFailure/ResFailureEx01/ResFailureEx01.java trunk/examples/ResFailure/ResFailureEx01/network_ex01.txt trunk/examples/ResFailure/ResFailureEx01/output.txt trunk/examples/ResFailure/ResFailureEx02/ trunk/examples/ResFailure/ResFailureEx02/Ex02_Regional_GIS trunk/examples/ResFailure/ResFailureEx02/Ex02_Res_0 trunk/examples/ResFailure/ResFailureEx02/Ex02_Res_1 trunk/examples/ResFailure/ResFailureEx02/Ex02_Res_2 trunk/examples/ResFailure/ResFailureEx02/Ex02_Res_3 trunk/examples/ResFailure/ResFailureEx02/Ex02_Res_4 trunk/examples/ResFailure/ResFailureEx02/Ex02_Res_5 trunk/examples/ResFailure/ResFailureEx02/Ex02_User_0 trunk/examples/ResFailure/ResFailureEx02/GridUserFailureEx02.java trunk/examples/ResFailure/ResFailureEx02/GridletSubmission.java trunk/examples/ResFailure/ResFailureEx02/README.txt trunk/examples/ResFailure/ResFailureEx02/ResFailureEx02.java trunk/examples/ResFailure/ResFailureEx02/network_ex02.txt trunk/examples/ResFailure/ResFailureEx02/output.txt trunk/examples/ResFailure/ResFailureEx03/ trunk/examples/ResFailure/ResFailureEx03/Ex03_Regional_GIS_0 trunk/examples/ResFailure/ResFailureEx03/Ex03_Regional_GIS_1 trunk/examples/ResFailure/ResFailureEx03/Ex03_Regional_GIS_2 trunk/examples/ResFailure/ResFailureEx03/Ex03_Res_0 trunk/examples/ResFailure/ResFailureEx03/Ex03_Res_10 trunk/examples/ResFailure/ResFailureEx03/Ex03_Res_12 trunk/examples/ResFailure/ResFailureEx03/Ex03_Res_14 trunk/examples/ResFailure/ResFailureEx03/Ex03_Res_2 trunk/examples/ResFailure/ResFailureEx03/Ex03_Res_4 trunk/examples/ResFailure/ResFailureEx03/Ex03_Res_6 trunk/examples/ResFailure/ResFailureEx03/Ex03_Res_8 trunk/examples/ResFailure/ResFailureEx03/Ex03_User_0 trunk/examples/ResFailure/ResFailureEx03/GridUserFailureEx03.java trunk/examples/ResFailure/ResFailureEx03/GridletSubmission.java trunk/examples/ResFailure/ResFailureEx03/README.txt trunk/examples/ResFailure/ResFailureEx03/ResFailureEx03.java trunk/examples/ResFailure/ResFailureEx03/network_ex03.txt trunk/examples/ResFailure/ResFailureEx03/output.txt Modified: trunk/examples/README.txt =================================================================== --- trunk/examples/README.txt 2007-08-30 02:33:11 UTC (rev 49) +++ trunk/examples/README.txt 2007-09-01 02:10:24 UTC (rev 50) @@ -37,6 +37,8 @@ ./RegionalGIS : shows how to create multiple regional GridInformationService (GIS) entities in a network topology. +./ResFailure : shows how to use the resource failures of GridSim. + ./WorkloadTrace : shows few examples how to use workload traces from a file in GridSim. Added: trunk/examples/ResFailure/README.txt =================================================================== --- trunk/examples/ResFailure/README.txt (rev 0) +++ trunk/examples/ResFailure/README.txt 2007-09-01 02:10:24 UTC (rev 50) @@ -0,0 +1,18 @@ + +This directory contains few examples regarding to +resource failure functionalities. +Here are the summary of what each example does: +./ResFailureEx01 : shows a very basic example, + dealing with 1 user, 3 resources and 1 GIS entities. + +./ResFailureEx02 : shows a basic example, + dealing with 20 users, 6 resources and 1 GIS entities. + +./ResFailureEx03 : shows a more complex example, + dealing with 30 users, 15 resources and 3 GIS entities. + However, you can modify these parameters as you wish, + but keep in mind that the simulation might run longer + if you increase the numbers. + +NOTE: Detailed explanations are provided in the source file(s). + Added: trunk/examples/ResFailure/ResFailureEx01/Ex01_Regional_GIS =================================================================== --- trunk/examples/ResFailure/ResFailureEx01/Ex01_Regional_GIS (rev 0) +++ trunk/examples/ResFailure/ResFailureEx01/Ex01_Regional_GIS 2007-09-01 02:10:24 UTC (rev 50) @@ -0,0 +1,4 @@ +Event ResourceID Clock +Registering 10 10.020000998399999 +Registering 15 10.030000998399998 +Registering 20 10.040000998399998 Added: trunk/examples/ResFailure/ResFailureEx01/Ex01_Res_0 =================================================================== --- trunk/examples/ResFailure/ResFailureEx01/Ex01_Res_0 (rev 0) +++ trunk/examples/ResFailure/ResFailureEx01/Ex01_Res_0 2007-09-01 02:10:24 UTC (rev 50) @@ -0,0 +1 @@ +Event NumMachines Clock Added: trunk/examples/ResFailure/ResFailureEx01/Ex01_Res_1 =================================================================== --- trunk/examples/ResFailure/ResFailureEx01/Ex01_Res_1 (rev 0) +++ trunk/examples/ResFailure/ResFailureEx01/Ex01_Res_1 2007-09-01 02:10:24 UTC (rev 50) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 3 31.205408168820174 Added: trunk/examples/ResFailure/ResFailureEx01/Ex01_Res_2 =================================================================== --- trunk/examples/ResFailure/ResFailureEx01/Ex01_Res_2 (rev 0) +++ trunk/examples/ResFailure/ResFailureEx01/Ex01_Res_2 2007-09-01 02:10:24 UTC (rev 50) @@ -0,0 +1 @@ +Event NumMachines Clock Added: trunk/examples/ResFailure/ResFailureEx01/Ex01_User0 =================================================================== --- trunk/examples/ResFailure/ResFailureEx01/Ex01_User0 (rev 0) +++ trunk/examples/ResFailure/ResFailureEx01/Ex01_User0 2007-09-01 02:10:24 UTC (rev 50) @@ -0,0 +1,11 @@ +User Event GridletID Resource GridletStatus Clock +Ex01_User0 Sending 0 Ex01_Res_2 Created 374.04012479999994 +Ex01_User0 Sending 1 Ex01_Res_1 Created 374.77037439999924 +Ex01_User0 Sending 2 Ex01_Res_2 Created 375.50062399999854 +Ex01_User0 Sending 3 Ex01_Res_2 Created 376.23087359999784 +Ex01_User0 Sending 4 Ex01_Res_0 Created 376.96112319999713 +Ex01_User0 Receiving 0 Ex01_Res_2 Success 1233.4001439999986 +Ex01_User0 Receiving 1 Ex01_Res_1 Success 1234.130393599998 +Ex01_User0 Receiving 2 Ex01_Res_2 Success 1234.8606431999972 +Ex01_User0 Receiving 3 Ex01_Res_2 Success 1235.5306431999966 +Ex01_User0 Receiving 4 Ex01_Res_0 Success 1236.3211423999958 Added: trunk/examples/ResFailure/ResFailureEx01/Ex01_User0_Fin =================================================================== --- trunk/examples/ResFailure/ResFailureEx01/Ex01_User0_Fin (rev 0) +++ trunk/examples/ResFailure/ResFailureEx01/Ex01_User0_Fin 2007-09-01 02:10:24 UTC (rev 50) @@ -0,0 +1,6 @@ +User GridletID Resource Cost CPU time Latency +Ex01_User0 0 Ex01_Res_2 2574.0 858.0 245555.1188510172 +Ex01_User0 1 Ex01_Res_1 2574.0 858.0 245555.1188510172 +Ex01_User0 2 Ex01_Res_2 2574.0 858.0 245555.1188510172 +Ex01_User0 3 Ex01_Res_2 2571.809251200002 857.2697504000007 245555.1188510172 +Ex01_User0 4 Ex01_Res_0 2574.0 858.0 245555.1188510172 Added: trunk/examples/ResFailure/ResFailureEx01/GridUserFailureEx01.java =================================================================== --- trunk/examples/ResFailure/ResFailureEx01/GridUserFailureEx01.java (rev 0) +++ trunk/examples/ResFailure/ResFailureEx01/GridUserFailureEx01.java 2007-09-01 02:10:24 UTC (rev 50) @@ -0,0 +1,745 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + +import gridsim.*; +import gridsim.index.AbstractGIS; +import gridsim.net.Link; +import java.util.Random; +import java.util.ArrayList; +import java.io.FileWriter; +import gridsim.resFailure.RegionalGISWithFailure; +import eduni.simjava.Sim_system; +import eduni.simjava.Sim_event; + + +/** + * Creates a Grid User that also considers what happens if a resource fails. + * @author Agustin Caminero and Anthony Sulistio + * @since GridSim Toolkit 4.1 + */ +public class GridUserFailureEx01 extends GridUser +{ + // the base for our constants (chosen at random) + private static final int BASE = 440000; + + /** This constant is to tell the user when he should submit a gridlet */ + private static final int SUBMIT_GRIDLET = BASE + 1; + + private ArrayList GridletSubmittedList_; // list of submitted Gridlets + private GridletList GridletReceiveList_; // list of received Gridlets + + private int NUM_GRIDLETS; + private double pollingTime_; + + // The sizes of gridlets + private int gridletLength; + private int gridletInput; + private int gridletOutput; + + // we keep here the time when each gridlet is submitted + private double gridletSubmissionTime []; + private double gridletLatencyTime []; + + // a flag that denotes whether to trace GridSim events or not. + private boolean trace_flag; + + + /** + * Creates a GridUserFailure object + * @param name this entity name + * @param link a network link connecting this entity + * @param pollTime the time between polls + * @param glLength length (MI) for the gridlets of this user + * @param glIn input file size for the gridlets of this user + * @param glOut output file size for the gridlets of this user + * @param trace_flag a flag that denotes whether to trace this user events + * or not. + * @throws java.lang.Exception happens if either name or link is empty + */ + public GridUserFailureEx01(String name, Link link, double pollTime, + int glLength, int glIn, int glOut, boolean trace_flag) + throws Exception + { + super(name, link); + + this.GridletSubmittedList_ = new ArrayList(); + this.GridletReceiveList_ = new GridletList(); + pollingTime_ = pollTime; + + gridletLength = glLength; + gridletInput = glIn; + gridletOutput = glOut; + this.trace_flag = trace_flag; + } + + /** + * Sets the number of gridlets that this user has to submit. + * Also, create the submission and reception times arrays. + * @param gridlet_num the number of gridlets + */ + public void setGridletNumber(int gridlet_num) + { + NUM_GRIDLETS = gridlet_num; + + gridletSubmissionTime = new double[NUM_GRIDLETS]; + gridletLatencyTime = new double[NUM_GRIDLETS]; + } + + /** + * Handles incoming requests to this entity. + * This method specifies the behaviours and/or scenarios of a user. + */ + public void body() + { + initializeResultsFile(); + createGridlet(super.get_id(), NUM_GRIDLETS); + + // schedule the initial sending of gridlets. + // The sending will start in a ramdom time within 5 min + Random random = new Random(); + int init_time = random.nextInt(5*60); + + // sends a reminder to itself + super.send(super.get_id(), init_time, SUBMIT_GRIDLET); + System.out.println(super.get_name() + + ": initial SUBMIT_GRIDLET event will be at clock: " + + init_time + ". Current clock: " + GridSim.clock()); + + + //////////////////////////////////////////////////////////// + // Now, we have the framework of the entity: + while (Sim_system.running()) + { + Sim_event ev = new Sim_event(); + super.sim_get_next(ev); // get the next event in the queue + + switch (ev.get_tag()) + { + // submit a gridlet + case SUBMIT_GRIDLET: + processGridletSubmission(ev); // process the received event + break; + + // Receive a gridlet back + case GridSimTags.GRIDLET_RETURN: + processGridletReturn(ev); + break; + + case GridSimTags.END_OF_SIMULATION: + System.out.println("\n============== " + super.get_name() + + ". Ending simulation..."); + break; + + default: + System.out.println(super.get_name() + + ": Received an event: " + ev.get_tag()); + break; + + } // switch + + } // while + + // remove I/O entities created during construction of this entity + super.terminateIOEntities(); + + // prints the completed gridlets + printGridletList(GridletReceiveList_, super.get_name(), false, + gridletLatencyTime); + } // body() + + ///////////////////////////////////////////////////////////////////////// + + /** + * This functions process the submission of a gridlet. We have to get the + * list of available resources from the RegGIS, choose one of them, and + * submit the gridlet. + * @param ev an incoming event + */ + private void processGridletSubmission(Sim_event ev) + { + if (trace_flag) + { + System.out.println(super.get_name() + + ": received an SUBMIT_GRIDLET event. Clock: " + GridSim.clock()); + } + + /*********** + We have to submit: + - the gridlet whose id comes with the event + - all the gridlets with the "gridletSub.getSubmitted() == false" + + So, set the gridletSub.getSubmitted() to false for the gridlet whose + id comes with the event + ***********/ + + int i = 0; + GridletSubmission gridletSub; + int resourceID[]; + Random random = new Random(5); // a random generator with a random seed + int index; + Gridlet gl; + Integer obj; + int glID; + + // This is because the initial GRIDLET_SUBMIT event, at the beginning + // of sims, does not have any gridlet id. We have to submit + // all the gridlets. + if (ev.get_data() instanceof Integer) + { + obj = (Integer) ev.get_data(); + glID = obj.intValue(); // get the gridlet id. + } + else { + glID = 99; // a value at random, not used at all in this case + } + + while (i < GridletSubmittedList_.size()) + { + gridletSub = (GridletSubmission)GridletSubmittedList_.get(i); + + if ( (gridletSub.getGridlet()).getGridletID() == glID ) + { + // set this gridlet whose id comes with the event as not submitted, + // so that it is submitted as soon as possible. + ((GridletSubmission) GridletSubmittedList_.get(i)).setSubmitted(false); + } + + // Submit the gridlets with the "gridletSub.getSubmitted() == false" + if ( (gridletSub.getSubmitted() == false)) + { + // we have to resubmit this gridlet + gl = ((GridletSubmission) GridletSubmittedList_.get(i)).getGridlet(); + resourceID = getResList(); // Get list of resources from GIS + + // If we have resources in the list + if ((resourceID != null) && (resourceID.length != 0)) + { + index = random.nextInt(resourceID.length); + + // make sure the gridlet will be executed from the begining + resetGridlet(gl); + + // submits this gridlet to a resource + super.gridletSubmit(gl, resourceID[index]); + gridletSubmissionTime[gl.getGridletID()] = GridSim.clock(); + + // set this gridlet as submitted + ((GridletSubmission) GridletSubmittedList_.get(i)).setSubmitted(true); + + if (trace_flag) + { + System.out.println(super.get_name() + + ": Sending Gridlet #" + i + " to " + + GridSim.getEntityName(resourceID[index]) + + " at clock: " + GridSim.clock()); + + // Write into a results file + write(super.get_name(), "Sending", gl.getGridletID(), + GridSim.getEntityName(resourceID[index]), + gl.getGridletStatusString(), GridSim.clock()); + } + + } + // No resources available at this moment, so schedule an event + // in the future. The event wil be in 15 min (900 sec), as + // resource failures may last several hours. + // This event includes the gridletID, so that the user will + // try to submit only this gridlet + else + { + super.send(super.get_id(), GridSimTags.SCHEDULE_NOW + 900, + SUBMIT_GRIDLET, new Integer(gl.getGridletID()) ); + } + + }// if (gridletSub.getSubmitted() == false) + + i++; + } // while (i < GridletSubmittedList_.size()) + + } // processGridletSubmission + + /** + * This functions process the return of a gridlet. + * We pay attention to the status of the gridlet + * and then decide what we have to do the next + * @param ev an incoming event + */ + private void processGridletReturn(Sim_event ev) + { + if (trace_flag) + { + System.out.println(super.get_name() + + ": received an GRIDLET_RETURN event. Clock: " + GridSim.clock()); + } + + Object obj = (Object) ev.get_data(); + Gridlet gl = null; + Random random = new Random(5); // a random generator with a random seed + + if (obj instanceof Gridlet) + { + gl = (Gridlet) obj; + gridletLatencyTime[gl.getGridletID()] = GridSim.clock(); + + // Write into a results file + if (trace_flag) + { + write(super.get_name(), "Receiving", gl.getGridletID(), + GridSim.getEntityName(gl.getResourceID()), + gl.getGridletStatusString(), GridSim.clock()); + } + + ///////////////////////// Gridlet Success + if (gl.getGridletStatusString().compareTo("Success") == 0) + { + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + " with status Success at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID())); + + this.GridletReceiveList_.add(gl); // add into the received list + gridletLatencyTime[gl.getGridletID()] = + gridletLatencyTime[gl.getGridletID()] - + gridletSubmissionTime[gl.getGridletID()]; + + // We have received all the gridlets. So, finish the simulation. + if (GridletReceiveList_.size() == GridletSubmittedList_.size()) + { + super.finishSimulation(); + } + + } // if (gl.getGridletStatusString() == "Success") + + //////////////////////// Gridlet Failed + else if (gl.getGridletStatusString().compareTo("Failed") == 0) + { + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + " with status Failed at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID())); + + // Send the gridlet as soon as we have resources available. + // This gridlet will be resend as soon as possible, + // in the first loop. + int pos = findGridletInGridletSubmittedList(gl); + if (pos == -1) { + System.out.println(super.get_name() + + ". Gridlet not found in GridletSubmittedList."); + } + else + { + // set this gridlet as submitted, because otherwise + // this gridlet may be submitted several times. + // A gridlet will only be submitted when the event carrying + // its id reaches the user + ((GridletSubmission) GridletSubmittedList_.get(pos)).setSubmitted(true); + + // Now, schedule an event to itself to submit the gridlet + // The gridlet will be sent as soon as possible + Integer glID_Int = new Integer(gl.getGridletID()); + + // This event includes the gridletID, so that the user + // will try to submit only this gridlet + super.send(super.get_id(), GridSimTags.SCHEDULE_NOW, + SUBMIT_GRIDLET, glID_Int); + } + } // if (gl.getGridletStatusString() == "Failed") + + ////////////////////////////// Gridlet Failed_resource + else if (gl.getGridletStatusString().compareTo("Failed_resource_unavailable") == 0) + { + int pos = findGridletInGridletSubmittedList(gl); + if (pos == -1) { + System.out.println(super.get_name() + + ". Gridlet not found in GridletSubmittedList."); + } + else + { + // Now, set its submission time for a random time between + // 1 and the polling time + double resubmissionTime = random.nextDouble() * pollingTime_; + + // this is to prevent the gridlet from being submitted + // before its resubmission time. + // This is different from the FAILED case, because + // in that case, the gridlet should be resubmited as soon + // as possible. As oppossed to that, this gridlet should + // not be resubmited before its resubmission time. + ((GridletSubmission) GridletSubmittedList_.get(pos)).setSubmitted(true); + + + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + + " with status Failed_resource_unavailable at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID()) + + "(resID: " + gl.getResourceID() + + "). Resubmission time will be: " + + resubmissionTime + GridSim.clock()); + + // Now, we have to inform the GIS about this failure, so it + // can keep the list of resources up-to-date. + informGIS(gl.getResourceID()); + + // Now, schedule an event to itself to submit the gridlet + Integer glID_Int = new Integer(gl.getGridletID()); + + // This event includes the gridletID, so that the user + // will try to submit only this gridlet + super.send(super.get_id(), resubmissionTime, + SUBMIT_GRIDLET, glID_Int); + } + } // else if + else + { + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + " with status " + + gl.getGridletStatusString() + " at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID()) + + " resID: " + gl.getResourceID()); + } + + } // if (obj instanceof Gridlet) + } + + /** + * Prints the Gridlet objects + * @param list the list of gridlets + * @param name the name of the user + * @param detail if we want the gridlet's history or not + * @param gridletLatencyTime array containing the latencies of gridlets. + * Latencies are from the moment when the gridlet is sent, till + * the moment they are back at the user. + * They take into account the last submission of a gridlet + * (when the gridlet is successfully run) + */ + private void printGridletList(GridletList list, String name, + boolean detail, double gridletLatencyTime[]) + { + int size = list.size(); + Gridlet gridlet = null; + + String indent = " "; + System.out.println(); + System.out.println("============= OUTPUT for " + name + " =========="); + System.out.println("Gridlet ID" + indent + "STATUS" + indent + + "Resource ID" + indent + "Cost" + indent + + "CPU Time"+ indent + "Latency"); + + // a loop to print the overall result + int i = 0; + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list.get(i); + System.out.print(indent + gridlet.getGridletID() + indent + + indent); + + System.out.print(gridlet.getGridletStatusString()); + + System.out.println(indent + indent + gridlet.getResourceID() + + indent + indent + gridlet.getProcessingCost() + + indent + indent + gridlet.getActualCPUTime()+ + indent + indent + + gridletLatencyTime[gridlet.getGridletID()]); + + writeFin(name, gridlet.getGridletID(), + GridSim.getEntityName(gridlet.getResourceID()), + gridlet.getProcessingCost(), gridlet.getActualCPUTime(), + GridSim.clock()); + + + + } + + + if (detail == true) + { + // a loop to print each Gridlet's history + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list.get(i); + System.out.println(gridlet.getGridletHistory()); + + System.out.print("Gridlet #" + gridlet.getGridletID()); + System.out.println(", length = " + gridlet.getGridletLength() + + ", finished so far = " + + gridlet.getGridletFinishedSoFar()); + System.out.println("======================================\n"); + } + } + + System.out.println("================================================="); + + } + + /** + * This method will show you on how to create Gridlets + * @param userID owner ID of a Gridlet + * @param numGridlet number of Gridlet to be created + */ + private void createGridlet(int userID, int numGridlet) + { + for (int i = 0; i < numGridlet; i++) + { + // Creates a Gridlet + Gridlet gl = new Gridlet(i, gridletLength, gridletInput, gridletOutput); + gl.setUserID(userID); + + // Originally, gridlets are created to be submitted + // as soon as possible (the 0.0 param) + GridletSubmission gst = new GridletSubmission(gl, false); + + // add this gridlet into a list + this.GridletSubmittedList_.add(gst); + } + } + + /** + * Gets a list of received Gridlets + * @return a list of received/completed Gridlets + */ + public GridletList getGridletList() { + return GridletReceiveList_; + } + + /** + * Tells you the possition of this gridlet in the GridletSubmittedList_ + * @param gl the gridlet + * @return the position of this gridlet in the list of submitted gridlets + */ + private int findGridletInGridletSubmittedList(Gridlet gl) + { + Gridlet g = null; + GridletSubmission gst = null; + for (int i = 0; i< GridletSubmittedList_.size(); i++) + { + gst = (GridletSubmission)GridletSubmittedList_.get(i); + g = gst.getGridlet(); + + if ( g.getGridletID() == gl.getGridletID() ) + return i; + } + + return -1; + } + + /** This function resets the gridlet into its original values of + * length and gridletFinishedSoFar + * @param gl the gridlet to be resetted + */ + private void resetGridlet (Gridlet gl) + { + gl.setGridletLength(gridletLength); + gl.setGridletFinishedSoFar(0); + + } + + /** + * Write some data into the final results file. + * @param user user name + * @param glID gridlet id + * @param resName Name of the resource + * @param cost the processing cost of the gridlet + * @param cpu the cpu time + * @param clock Current time + */ + private void writeFin(String user, int glID, String resName, + double cost, double cpu, double clock) + { + if (trace_flag == false) { + return; + } + + // Write into a results file + FileWriter fwriter = null; + try + { + fwriter = new FileWriter(user+"_Fin", true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while opening file " + user+"_Fin"); + } + + try + { + fwriter.write(user +"\t "+ glID + "\t" + + resName + "\t" + cost + "\t"+ cpu + "\t" + + clock + "\n"); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while writing on file " + user+"_Fin"); + } + + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while closing file " + user+"_Fin"); + } + + } + + /** + * Write some data into a results file. + * @param user user name + * @param event Values: "Sending" or "Receive" a gridlet + * @param glID gridlet id + * @param resName Name of the resource + * @param status Status of the gridlet + * @param clock Current time + * */ + private void write(String user, String event, int glID, String resName, + String status, double clock) + { + if (trace_flag == false) { + return; + } + + // Write into a results file + FileWriter fwriter = null; + try + { + fwriter = new FileWriter(super.get_name(), true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while opening file " + super.get_name()); + } + + try + { + fwriter.write(user + "\t " + event + "\t" + glID + "\t" + + resName + "\t" + status + "\t\t" + clock + "\t" + "\n"); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while writing on file " + super.get_name()); + } + + + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while closing file " + super.get_name()); + } + + } + + /** + * This function informs the GIS of this user about the failure of a resource + * @param resID the id of the resource which has failed + */ + private void informGIS(int resID) + { + Integer resID_Int = new Integer(resID); + + super.send(super.output, 0.0, AbstractGIS.NOTIFY_GIS_RESOURCE_FAILURE, + new IO_data(resID_Int, Link.DEFAULT_MTU, super.getRegionalGISId()) ); + } + + /** + * Initialize the results files (put headers over each column) + * */ + private void initializeResultsFile() + { + if (trace_flag == false) { + return; + } + + // Initialize the results file + FileWriter fwriter = null; + FileWriter fwriterFin = null; + try + { + fwriter = new FileWriter(super.get_name(), true); + fwriterFin = new FileWriter(super.get_name() + "_Fin", true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while opening file " + super.get_name() + + " or " + super.get_name()+"_Fin"); + } + + try + { + fwriter.write( + "User \t\t Event \t GridletID \t Resource \t GridletStatus \t\t\t Clock\n"); + fwriterFin.write( + "User \t\t GridletID \t Resource \t Cost \t CPU time \t Latency\n"); + + + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while writing on file " + super.get_name()+ + " or " + super.get_name()+"_Fin"); + } + + try + { + fwriter.close(); + fwriterFin.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while closing file " + super.get_name()+ + " or " + super.get_name()+"_Fin"); + } + } + + /** + * This function retrieves a list of available resources from the GIS. + * @return an array containing the ids of the resources + */ + private int[] getResList() + { + Object[] resList = super.getLocalResourceList(); + int resourceID[] = null; + + // if we have any resource + if ((resList != null) && (resList.length != 0)) + { + resourceID = new int[resList.length]; + for (int x = 0; x < resList.length; x++) + { + // Resource list contains list of resource IDs + resourceID[x] = ((Integer) resList[x]).intValue(); + + if (trace_flag == true) + { + System.out.println(super.get_name() + + ": resource[" + x + "] = " + resourceID[x]); + } + } + + } + + return resourceID; + } + +} // end class Added: trunk/examples/ResFailure/ResFailureEx01/GridletSubmission.java =================================================================== --- trunk/examples/ResFailure/ResFailureEx01/GridletSubmission.java (rev 0) +++ trunk/examples/ResFailure/ResFailureEx01/GridletSubmission.java 2007-09-01 02:10:24 UTC (rev 50) @@ -0,0 +1,54 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + + +import gridsim.Gridlet; + +/** + * This class is just a wrapper to denote + * whether this gridlet has been already submitted or not + * @author Agustin Caminero and Anthony Sulistio + * @since GridSim Toolkit 4.1 + */ +public class GridletSubmission +{ + private Gridlet gl; + private boolean submitted; + + + public GridletSubmission(Gridlet gl,boolean submitted) + { + this.gl = gl; + this.submitted = submitted; + } + + public Gridlet getGridlet() + { + return gl; + } + + public boolean getSubmitted() + { + return submitted; + } + + public void setGridlet(Gridlet g) + { + this.gl = g; + } + + public void setSubmitted(boolean submitted) + { + this.submitted = submitted; + } + +} // end class Added: trunk/examples/ResFailure/ResFailureEx01/README.txt =================================================================== --- trunk/examples/ResFailure/ResFailureEx01/README.txt (rev 0) +++ trunk/examples/ResFailure/ResFailureEx01/README.txt 2007-09-01 02:10:24 UTC (rev 50) @@ -0,0 +1,68 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + +Welcome to the example of how to use the computing resource failure functionality +To compile the example source code: + In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx01.java + In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx01.java + +where $GRIDSIM or %GRIDSIM% is the location of the gridsimtoolkit package. + + +To run the class file: +In Unix/Linux: + java -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx01 network_ex01.txt > file.txt + +In Windows: + java -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx01 network_ex01.txt > file.txt + + +The above command means run the program and output the results into a file +named "file.txt" rather than into screen or standard output. +To prevent from overwriting an existing file, +I renamed "file.txt" into "output.txt" + +NOTE: This example uses probabilistic distributions and random variables. + Hence, when running this example many times, the values will be different. + + +When running the example file, it will produce the following files: + + sim_trace -> created by the SimJava2 package (lower-level) to trace every + events (performed by SimJava and GridSim) during the simulation. + We don't need to worry about this file. Not to important for our + example. + + sim_report -> created by the SimJava2 package (lower-level) of GridSim. + This is a simulation report that contains general information about + running this experiment. We don't need to worry about this file. + Not to important for our example. + + Ex01_Regional_GIS -> contains one line describing each + registering/removing an event that takes place at the GIS. Resources + register in the begining of simulations, and after recovering from a + failure affecting all their machines. Resources will be removed when + they suffer a failure affecting all their machines. + + Ex01_Res_0, Ex01_Res_1, Ex01_Res_2 -> records when the resource + suffers a failure and when it recovers from the failure. It also records + how many machines failed, and the time of the fail/recovery. + + Ex01_User0 -> contains one line for each event regarding to the Gridlets. + These events are the sending/reception of a gridlet, and + each line include the status of the gridlet, time and resource. + + Ex01_User0_Fin -> contains one line for each gridlet, showing the resource + it has been executed, its cost, CPU time and total latency. + +NOTE: When you run the program multiple times, the new statistics will be + appended at the end of a file. Added: trunk/examples/ResFailure/ResFailureEx01/ResFailureEx01.java =================================================================== --- trunk/examples/ResFailure/ResFailureEx01/ResFailureEx01.java (rev 0) +++ trunk/examples/ResFailure/ResFailureEx01/ResFailureEx01.java 2007-09-01 02:10:24 UTC (rev 50) @@ -0,0 +1,326 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + +import gridsim.resFailure.*; +import gridsim.*; +import gridsim.net.*; +import java.util.*; +import gridsim.util.NetworkReader; +import gridsim.util.HyperExponential; + + +/** + * This example shows a basic topology with 1 user, 3 resources and 1 GIS. + * All of them are connected by a router. + * There is only one VO in this example. + * @author Agustin Caminero and Anthony Sulistio + * @since GridSim Toolkit 4.1 + */ +public class ResFailureEx01 +{ + public static void main(String[] args) + { + System.out.println("Starting failure example 1..."); + + try + { + if (args.length < 1) + { + System.out.println("Usage: java ResFailureEx01 network_ex01.txt"); + return; + } + + + ////////////////////////////////////////// + // First step: 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 a run-time exception + // error. + + // a flag that denotes whether to trace GridSim events or not. + boolean trace_flag = false; // dont use SimJava trace + int num_user = 1; // number of grid users + Calendar calendar = Calendar.getInstance(); + + // Initialize the GridSim package + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + trace_flag = true; + + + ////////////////////////////////////////// + // Second step: Builds the network topology among Routers. + + String filename = args[0]; // get the network topology + System.out.println("Reading network from " + filename); + LinkedList routerList = NetworkReader.createFIFO(filename); + + + ////////////////////////////////////////// + // Third step: Creates one RegionalGISWithFailure entity, + // linked to a router in the topology + + Router router = null; + double baud_rate = 100000000; // 100Mbps, i.e. baud rate of links + double propDelay = 10; // propagation delay in milliseconds + int mtu = 1500; // max. transmission unit in byte + int totalMachines = 10; // num of machines each resource has + + String NAME = "Ex01_"; // a common name + String gisName = NAME + "Regional_GIS"; // GIS name + + // a network link attached to this regional GIS entity + Link link = new SimpleLink(gisName + "_link", baud_rate, + propDelay, mtu); + + + // HyperExponential: mean, standard deviation, stream + // how many resources will fail + HyperExponential failureNumResPattern = + new HyperExponential(totalMachines / 2, totalMachines, 4); + + // when they will fail + HyperExponential failureTimePattern = + new HyperExponential(25, 100, 4); + + // how long the failure will be + HyperExponential failureLengthPattern = + new HyperExponential(20, 25, 4); // big test: (20, 100, 4); + + + // creates a new Regional GIS entity that generates a resource + // failure message according to these patterns. + RegionalGISWithFailure gis = new RegionalGISWithFailure(gisName, + link, failureNumResPattern, failureTimePattern, + failureLengthPattern); + gis.setTrace(trace_flag); // record this GIS activity + + // link these GIS to a router + router = NetworkReader.getRouter("Router0", routerList); + linkNetwork(router, gis); + + // print some info messages + System.out.println("Created a REGIONAL GIS with name " + gisName + + " and id = " + gis.get_id() + ", connected to " + + router.get_name() ); + + + ////////////////////////////////////////// + // Fourth step: Creates one or more GridResourceWithFailure + // entities, linked to a router in the topology + + String sched_alg = "SPACE"; // use space-shared policy + int totalResource = 3; // number of resources + ArrayList resList = new ArrayList(totalResource); + + // Each resource may have different baud rate, + // totalMachine, rating, allocation policy and the router to + // which it will be connected. However, in this example, we assume + // all have the same properties for simplicity. + int totalPE = 4; // num of PEs each machine has + int rating = 49000; // rating (MIPS) of PEs + int GB = 1000000000; // 1 GB in bits + baud_rate = 2.5 * GB; + + for (int i = 0; i < totalResource; i++) + { + // gets the router object from the list + router = NetworkReader.getRouter("Router0", routerList); + + // creates a new grid resource + String resName = NAME + "Res_" + i; + GridResourceWithFailure res = createGridResource(resName, + baud_rate, propDelay, mtu, totalPE, totalMachines, + rating, sched_alg); + + // add a resource into a list + resList.add(res); + res.setRegionalGIS(gis); // set the regional GIS entity + res.setTrace(trace_flag); // record this resource activity + + // link a resource to this router object + linkNetwork(router, res); + + System.out.println("Created a RESOURCE (" + totalMachines + + " machines, each with " + totalPE + " PEs) with name = " + + resName + " and id = " + res.get_id() + + ", connected to router " + router.get_name() + + " and registered to " + gis.get_name() ); + } + + + ////////////////////////////////////////// + // Fifth step: Creates one GridUserFailure entity, + // linked to a router of the topology + + int totalGridlet = 5; // total jobs + double pollTime = 100; // time between polls + int glSize = 100000; // the size of gridlets (input/output) + int glLength = 42000000; // the length (MI) of gridlets + String userName = NAME + "User0"; + + // gets the router object from the list + router = NetworkReader.getRouter("Router0", routerList); + + // a network link attached to this entity + Link link2 = new SimpleLink(userName + "_link", baud_rate, + propDelay, mtu); + + GridUserFailureEx01 user = new GridUserFailureEx01(userName, link2, + pollTime, glLength, glSize, glSize, trace_flag); + + user.setRegionalGIS(gis); // set the regional GIS entity + user.setGridletNumber(totalGridlet); + + // link a resource to this router object + linkNetwork(router, user); + + System.out.println("Created a USER with name " + userName + + " and id = " + user.get_id() + ", connected to " + + router.get_name() + ", and with " + totalGridlet + + " gridlets. Registered to " + gis.get_name() ); + System.out.println(); + + + ////////////////////////////////////////// + // Sixth step: Starts the simulation + GridSim.startGridSimulation(); + System.out.println("\nFinish failure example 1... \n"); + } + catch (Exception e) + { + e.printStackTrace(); + System.out.println("Unwanted errors happen"); + } + } + + /** + * Links a particular entity with a given Router. + * + * @param router a Router object + * @param obj a GridSim entity to be attached to the Router + */ + private static void linkNetwork(Router router, GridSimCore obj) throws Exception + { + if (router == null) { + System.out.println("Error - router is NULL."); + return; + } + + // get the baud rate of a link + double baud_rate = obj.getLink().getBaudRate(); + + // create the packet scheduler for this link + PacketScheduler pktObj = new FIFOScheduler(router.get_name() + + "_to_" + obj.get_name() ); + + // attach this GridSim entity to a Router + router.attachHost(obj, pktObj); + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * <p> + * In this simple example, we are simulating one Grid resource with three + * Machines that contains one or more PEs. + * + * @param name a Grid Resource name + * @param baud_rate the bandwidth of this entity + * @param delay the propagation delay + * @param MTU Maximum Transmission Unit + * @param totalPE number of PE per machine + * @param totalMachine number of machines in this resources + * @param rating rating of mahcines in this resource + * @param sched_alg the scheduling algorithm of this resource + * @return a GridResource object + */ + private static GridResourceWithFailure createGridResource(String name, + double baud_rate, double delay, int MTU, int totalPE, + int totalMachine, int rating, String sched_alg) + { + // 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++) + { + // 2. A Machine contains one or more PEs or CPUs. Therefore, should + // create an object of PEList to store these PEs before creating + // a Machine. + PEList peList = new PEList(); + + // 3. Create PEs and add these into an object of PEList. + for (int k = 0; k < totalPE; k++) + { + // need to store PE id and MIPS Rating + peList.add( new PE(k, rating) ); + } + + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, peList) ); + } + + + // 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 = 9.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // we create Space_Shared_failure or Time_Shared_failure schedulers + int scheduling_alg = 0; // space_shared or time_shared + if (sched_alg.equals("SPACE") == true) { + scheduling_alg = ResourceCharacteristics.SPACE_SHARED; + } + else if (sched_alg.equals("TIME") == true) { + scheduling_alg = ResourceCharacteristics.TIME_SHARED; + } + + ResourceCharacteristics resConfig = new ResourceCharacteristics( + arch, os, mList, scheduling_alg, time_zone, cost); + + + // 6. Finally, we need to create a GridResource object. + 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(); + GridResourceWithFailure gridRes = null; + try + { + // creates a GridResource with a link + gridRes = new GridResourceWithFailure(name, + new SimpleLink(name + "_link", baud_rate, delay, MTU), + seed, resConfig, peakLoad, offPeakLoad, holidayLoad, + Weekends, Holidays); + } + catch (Exception e) { + e.printStackTrace(); + } + + return gridRes; + } + +} // end class Added: trunk/examples/ResFailure/ResFailureEx01/network_ex01.txt =================================================================== --- trunk/examples/ResFailure/ResFailureEx01/network_ex01.txt (rev 0) +++ trunk/examples/ResFailure/ResFailureEx01/network_ex01.txt 2007-09-01 02:10:24 UTC (rev 50) @@ -0,0 +1,15 @@ +# The topology of this example is as follows (with 1 user and 1 resource) +# +# user --- Router0 ---- Resource0 +# +# total number of Routers +1 + +# specifies each router name and whether to log its activities or not +# by default no logging is required +Router0 + +# specify the link between two Routers +# The format is: +# Router_name1 Router_name2 baud_rate(GB/s) prop_delay(ms) mtu(byte) + Added: trunk/examples/ResFailure/ResFailureEx01/output.txt =================================================================== --- trunk/examples/ResFailure/ResFailureEx01/output.txt (rev 0) +++ trunk/examples/ResFailure/ResFailureEx01/output.txt 2007-09-01 02:10:24 UTC (rev 50) @@ -0,0 +1,96 @@ +Starting failure example 1... +Initializing GridSim package +Initialising... +Reading network from network_ex01.txt +Created a REGIONAL GIS with name Ex01_Regional_GIS and id = 6, connected to Router0 +Created a RESOURCE (10 machines, each with 4 PEs) with name = Ex01_Res_0 and id = 10, connected to router Router0 and registered to Ex01_Regional_GIS +Created a RESOURCE (10 machines, each with 4 PEs) with name = Ex01_Res_1 and id = 15, connected to router Router0 and registered to Ex01_Regional_GIS +Created a RESOURCE (10 machines, each with 4 PEs) with name = Ex01_Res_2 and id = 20, connected to router Router0 and registered to Ex01_Regional_GIS +Created a USER with name Ex01_User0 and id = 25, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS + +Starting GridSim version 4.0 +Entities started. +Ex01_Regional_GIS: sends an autogenerated GRIDRESOURCE_FAILURE to itself. Clock(): 0.0. resTimeFail: 20.918443148412194 seconds +Ex01_User0: initial SUBMIT_GRIDLET event will be at clock: 294. Current clock: 0.0 +Ex01_Res_1.body(): wait for 10 seconds before registering to Ex01_Regional_GIS +Ex01_Res_0.body(): wait for 10 seconds before registering to Ex01_Regional_GIS +Ex01_Res_2.body(): wait for 10 seconds before registering to Ex01_Regional_GIS + +Ex01_Regional_GIS: registering Ex01_Res_0 +Ex01_Regional_GIS: list[0] = Ex01_Res_0 + + +Ex01_Regional_GIS: registering Ex01_Res_1 +Ex01_Regional_GIS: list[0] = Ex01_Res_0 +Ex01_Regional_GIS: list[1] = Ex01_Res_1 + + +Ex01_Regional_GIS: registering Ex01_Res_2 +Ex01_Regional_GIS: list[0] = Ex01_Res_0 +Ex01_Regional_GIS: list[1] = Ex01_Res_1 +Ex01_Regional_GIS: list[2] = Ex01_Res_2 + +Ex01_Regional_GIS: 3 resources will fail in this simulation. Num of failed machines on each resource will be decided later +Ex01_Regional_GIS: sends an autogenerated GRIDRESOURCE_FAILURE to itself. Clock: 20.918443148412194, resTimeFail: 9.29564320636208 seconds +Ex01_Regional_GIS: sends an autogenerated GRIDRESOURCE_FAILURE to itself. Clock: 20.918443148412194, resTimeFail: 10.226805942007969 seconds +Ex01_Regional_GIS: sends an autogenerated GRIDRESOURCE_FAILURE to itself. Clock: 20.918443148412194, resTimeFail: 9.592465799264474 seconds +Ex01_Regional_GIS: sends a GRIDRESOURCE_FAILURE event to the resource Ex01_Res_1. numMachFailed: 3. Clock: 31.185283368820173. Fail duration: 68.2010926576801 hours. Some machines may still work or may not. +Ex01_Res_1.processFailure(): receives an event GRIDRESOURCE_FAILURE. Clock: 31.205408168820174. There are STILL working machines in this resource. +Ex01_Res_1 - Machine: 0 is set to FAILED +Ex01_Res_1 - Machine: 0 is FAILED +Ex01_Res_1 - Machine: 1 is set to FAILED +Ex01_Res_1 - Machine: 1 is FAILED +Ex01_Res_1 - Machine: 2 is set to FAILED +Ex01_Res_1 - Machine: 2 is FAILED +Ex01_User0: received an SUBMIT_GRIDLET event. Clock: 294.0 +Ex01_User0: resource[0] = 10 +Ex01_User0: resource[1] = 15 +Ex01_User0: resource[2] = 20 +Ex01_User0: Sending Gridlet #0 to Ex01_Res_2 at clock: 374.04012479999994 +Ex01_User0: resource[0] = 10 +Ex01_User0: resource[1] = 15 +Ex01_User0: resource[2] = 20 +Ex01_User0: Sending Gridlet #1 to Ex01_Res_1 at clock: 374.77037439999924 +Ex01_User0: resource[0] = 10 +Ex01_User0: resource[1] = 15 +Ex01_User0: resource[2] = 20 +Ex01_User0: Sending Gridlet #2 to Ex01_Res_2 at clock: 375.50062399999854 +Ex01_User0: resource[0] = 10 +Ex01_User0: resource[1] = 15 +Ex01_User0: resource[2] = 20 +Ex01_User0: Sending Gridlet #3 to Ex01_Res_2 at clock: 376.23087359999784 +Ex01_User0: resource[0] = 10 +Ex01_User0: resource[1] = 15 +Ex01_User0: resource[2] = 20 +Ex01_User0: Sending Gridlet #4 to Ex01_Res_0 at clock: 376.96112319999713 +Ex01_User0: received an GRIDLET_RETURN event. Clock: 1233.4001439999986 +Ex01_User0: Receiving Gridlet #0 with status Success at time = 1233.4001439999986 from resource Ex01_Res_2 +Ex01_User0: received an GRIDLET_RETURN event. Clock: 1234.130393599998 +Ex01_User0: Receiving Gridlet #1 with status Success at time = 1234.130393599998 from resource Ex01_Res_1 +Ex01_User0: received an GRIDLET_RETURN event. Clock: 1234.8606431999972 +Ex01_User0: Receiving Gridlet #2 with status Success at time = 1234.8606431999972 from resource Ex01_Res_2 +Ex01_User0: received an GRIDLET_RETURN event. Clock: 1235.5306431999966 +Ex01_User0: Receiving Gridlet #3 with status Success at time = 1235.5306431999966 from resource Ex01_Res_2 +Ex01_User0:... [truncated message content] |
From: <sul...@us...> - 2007-08-30 02:33:09
|
Revision: 49 http://gridsim.svn.sourceforge.net/gridsim/?rev=49&view=rev Author: sulistio Date: 2007-08-29 19:33:11 -0700 (Wed, 29 Aug 2007) Log Message: ----------- a minor change Modified Paths: -------------- branches/gridsim4.0-branch1/examples/ResFailureEx02/ResFailureEx02.java branches/gridsim4.0-branch1/examples/ResFailureEx03/ResFailureEx03.java Added Paths: ----------- branches/gridsim4.0-branch1/examples/README.txt Added: branches/gridsim4.0-branch1/examples/README.txt =================================================================== --- branches/gridsim4.0-branch1/examples/README.txt (rev 0) +++ branches/gridsim4.0-branch1/examples/README.txt 2007-08-30 02:33:11 UTC (rev 49) @@ -0,0 +1,18 @@ + +This directory contains few examples regarding to +resource failure functionalities. +Here are the summary of what each example does: +./ResFailureEx01 : shows a very basic example, + dealing with 1 user, 3 resources and 1 GIS entities. + +./ResFailureEx02 : shows a basic example, + dealing with 20 users, 6 resources and 1 GIS entities. + +./ResFailureEx03 : shows a more complex example, + dealing with 30 users, 15 resources and 3 GIS entities. + However, you can modify these parameters as you wish, + but keep in mind that the simulation might run longer + if you increase the numbers. + +NOTE: Detailed explanations are provided in the source file(s). + Modified: branches/gridsim4.0-branch1/examples/ResFailureEx02/ResFailureEx02.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/ResFailureEx02.java 2007-08-30 02:01:05 UTC (rev 48) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/ResFailureEx02.java 2007-08-30 02:33:11 UTC (rev 49) @@ -19,7 +19,7 @@ /** - * This example shows a basic topology with 1 user, 3 resources and 1 GIS. + * This example shows a basic topology with 20 users, 6 resources and 1 GIS. * All of them are connected by a router. * There is only one VO in this example. * @author Agustin Caminero and Anthony Sulistio Modified: branches/gridsim4.0-branch1/examples/ResFailureEx03/ResFailureEx03.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/ResFailureEx03.java 2007-08-30 02:01:05 UTC (rev 48) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/ResFailureEx03.java 2007-08-30 02:33:11 UTC (rev 49) @@ -19,7 +19,7 @@ /** - * This example shows a basic topology with n user, m resources and p GISes. + * This example shows a basic topology with n users, m resources and p GISes. * All of them are connected by a router. * There is only one VO in this example. * @author Agustin Caminero and Anthony Sulistio This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-30 02:01:07
|
Revision: 48 http://gridsim.svn.sourceforge.net/gridsim/?rev=48&view=rev Author: sulistio Date: 2007-08-29 19:01:05 -0700 (Wed, 29 Aug 2007) Log Message: ----------- fix javadoc errors Modified Paths: -------------- branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java Modified: branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java =================================================================== --- branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java 2007-08-29 08:01:19 UTC (rev 47) +++ branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java 2007-08-30 02:01:05 UTC (rev 48) @@ -1338,8 +1338,7 @@ * The file name is this entity name. * * @param event Values: "Removing" or "Registering" a resource - * @param resID resource id - * @param clock Current time + * @param numMachines number of failed machines */ protected void write(String event, int numMachines) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-29 08:01:20
|
Revision: 47 http://gridsim.svn.sourceforge.net/gridsim/?rev=47&view=rev Author: sulistio Date: 2007-08-29 01:01:19 -0700 (Wed, 29 Aug 2007) Log Message: ----------- fix a minor typo Modified Paths: -------------- branches/gridsim4.0-branch1/examples/ResFailureEx02/README.txt branches/gridsim4.0-branch1/examples/ResFailureEx03/README.txt Modified: branches/gridsim4.0-branch1/examples/ResFailureEx02/README.txt =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/README.txt 2007-08-29 07:59:16 UTC (rev 46) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/README.txt 2007-08-29 08:01:19 UTC (rev 47) @@ -12,8 +12,8 @@ Welcome to the example of how to use the computing resource failure functionality To compile the example source code: - In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx01.java - In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx01.java + In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx02.java + In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx02.java where $GRIDSIM or %GRIDSIM% is the location of the gridsimtoolkit package. Modified: branches/gridsim4.0-branch1/examples/ResFailureEx03/README.txt =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/README.txt 2007-08-29 07:59:16 UTC (rev 46) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/README.txt 2007-08-29 08:01:19 UTC (rev 47) @@ -12,18 +12,18 @@ Welcome to the example of how to use the computing resource failure functionality To compile the example source code: - In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx01.java - In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx01.java + In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx03.java + In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx03.java where $GRIDSIM or %GRIDSIM% is the location of the gridsimtoolkit package. To run the class file: In Unix/Linux: - java -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx02 network_ex02.txt > file.txt + java -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx03 network_ex03.txt > file.txt In Windows: - java -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx02 network_ex02.txt > file.txt + java -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx03 network_ex03.txt > file.txt The above command means run the program and output the results into a file @@ -47,17 +47,17 @@ running this experiment. We don't need to worry about this file. Not to important for our example. - Ex02_Regional_GIS_0, ..., Ex02_Regional_GIS_2 -> contains one line describing each + Ex03_Regional_GIS_0, ..., Ex03_Regional_GIS_2 -> contains one line describing each registering/removing an event that takes place at the GIS. Resources register in the begining of simulations, and after recovering from a failure affecting all their machines. Resources will be removed when they suffer a failure affecting all their machines. - Ex02_Res_0, ... , Ex01_Res_8 -> records when the resource + Ex03_Res_0, ... , Ex03_Res_14 -> records when the resource suffers a failure and when it recovers from the failure. It also records how many machines failed, and the time of the fail/recovery. - Ex02_User_0 -> contains one line for each event regarding to the Gridlets. + Ex03_User_0 -> contains one line for each event regarding to the Gridlets. These events are the sending/reception of a gridlet, and each line include the status of the gridlet, time and resource. Then, when a simulation ends, this file shows the resource This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-29 07:59:22
|
Revision: 46 http://gridsim.svn.sourceforge.net/gridsim/?rev=46&view=rev Author: sulistio Date: 2007-08-29 00:59:16 -0700 (Wed, 29 Aug 2007) Log Message: ----------- initial release. added a more complex example. Added Paths: ----------- branches/gridsim4.0-branch1/examples/ResFailureEx03/ branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Regional_GIS_0 branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Regional_GIS_1 branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Regional_GIS_2 branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_0 branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_10 branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_12 branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_14 branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_2 branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_4 branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_6 branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_8 branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_User_0 branches/gridsim4.0-branch1/examples/ResFailureEx03/GridUserFailureEx03.java branches/gridsim4.0-branch1/examples/ResFailureEx03/GridletSubmission.java branches/gridsim4.0-branch1/examples/ResFailureEx03/README.txt branches/gridsim4.0-branch1/examples/ResFailureEx03/ResFailureEx03.java branches/gridsim4.0-branch1/examples/ResFailureEx03/network_ex03.txt branches/gridsim4.0-branch1/examples/ResFailureEx03/output.txt Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Regional_GIS_0 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Regional_GIS_0 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Regional_GIS_0 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,6 @@ +Event ResourceID Clock +Registering 20 10.020000998399999 +Registering 25 10.030000998399998 +Registering 45 10.040000998399998 +Registering 60 10.050000998399998 +Registering 90 10.060000998399998 Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Regional_GIS_1 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Regional_GIS_1 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Regional_GIS_1 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,4 @@ +Event ResourceID Clock +Registering 35 10.020000998399999 +Registering 70 10.030000998399998 +Registering 65 10.050001094399999 Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Regional_GIS_2 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Regional_GIS_2 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Regional_GIS_2 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,10 @@ +Event ResourceID Clock +Registering 40 10.020000998399999 +Registering 85 10.030000998399998 +Registering 80 10.040000998399998 +Registering 55 10.050000998399998 +Registering 30 10.060000998399998 +Registering 75 10.070000998399998 +Registering 50 10.080000998399997 +Removing 80 724.0 +Removing 30 774.0 Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_0 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_0 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_0 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1 @@ +Event NumMachines Clock Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_10 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_10 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_10 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 3 187.13035336319993 Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_12 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_12 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_12 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 16 394.15033328372874 Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_14 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_14 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_14 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 6 287.06017704959993 Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_2 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_2 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_2 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 16 395.26767949972304 Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_4 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_4 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_4 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 1 413.3268305733833 Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_6 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_6 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_6 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 8 409.80487370956115 Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_8 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_8 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_Res_8 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 1 30.571085997276676 Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_User_0 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_User_0 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/Ex03_User_0 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,19 @@ +Event GridletID Resource GridletStatus Clock +Sending 0 Ex03_Res_5 Created 861.2601247999999 +Sending 1 Ex03_Res_5 Created 862.0103743999994 +Sending 2 Ex03_Res_14 Created 862.7606239999989 +Sending 3 Ex03_Res_14 Created 863.5108735999984 +Sending 4 Ex03_Res_1 Created 864.3012431999979 +Receiving 0 Ex03_Res_5 Success 1723.2301439999962 +Receiving 2 Ex03_Res_14 Success 1724.2906431999957 +Receiving 4 Ex03_Res_1 Success 1726.1110223999945 +Receiving 1 Ex03_Res_5 Success 1726.721022399994 +Receiving 3 Ex03_Res_14 Success 1727.0310223999936 + + +GridletID Resource Cost CPU time Latency +0 Ex03_Res_5 2572.1100000000015 857.3700000000006 343644.7213540189 +2 Ex03_Res_14 2572.710000000001 857.5700000000004 343644.7213540189 +4 Ex03_Res_1 2572.7400000000016 857.5800000000005 343644.7213540189 +1 Ex03_Res_5 2572.470000000001 857.4900000000005 343644.7213540189 +3 Ex03_Res_14 2573.0700000000006 857.6900000000003 343644.7213540189 Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/GridUserFailureEx03.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/GridUserFailureEx03.java (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/GridUserFailureEx03.java 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,753 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + +import gridsim.*; +import gridsim.index.AbstractGIS; +import gridsim.net.Link; +import java.util.Random; +import java.util.ArrayList; +import java.io.FileWriter; +import gridsim.resFailure.RegionalGISWithFailure; +import eduni.simjava.Sim_system; +import eduni.simjava.Sim_event; + + +/** + * Creates a Grid User that also considers what happens if a resource fails. + * @author Agustin Caminero and Anthony Sulistio + * @since GridSim Toolkit 4.1 + */ +public class GridUserFailureEx03 extends GridUser +{ + // the base for our constants (chosen at random) + private static final int BASE = 440000; + + /** This constant is to tell the user when he should submit a gridlet */ + public static final int SUBMIT_GRIDLET = BASE + 1; + + private ArrayList GridletSubmittedList_; // list of submitted Gridlets + private GridletList GridletReceiveList_; // list of received Gridlets + + private int NUM_GRIDLETS; + private double pollingTime_; + + // The sizes of gridlets + private int gridletLength; + private int gridletInput; + private int gridletOutput; + + // we keep here the time when each gridlet is submitted + private double gridletSubmissionTime []; + private double gridletLatencyTime []; + + // a flag that denotes whether to trace GridSim events or not. + private boolean trace_flag; + + + /** + * Creates a GridUserFailure object + * @param name this entity name + * @param link a network link connecting this entity + * @param pollTime the time between polls + * @param glLength length (MI) for the gridlets of this user + * @param glIn input file size for the gridlets of this user + * @param glOut output file size for the gridlets of this user + * @param trace_flag a flag that denotes whether to trace this user events + * or not. + * @throws java.lang.Exception happens if either name or link is empty + */ + public GridUserFailureEx03(String name, Link link, double pollTime, + int glLength, int glIn, int glOut, boolean trace_flag) + throws Exception + { + super(name, link); + + this.GridletSubmittedList_ = new ArrayList(); + this.GridletReceiveList_ = new GridletList(); + pollingTime_ = pollTime; + + gridletLength = glLength; + gridletInput = glIn; + gridletOutput = glOut; + this.trace_flag = trace_flag; + } + + /** + * Sets the number of gridlets that this user has to submit. + * Also, create the submission and reception times arrays. + * @param gridlet_num the number of gridlets + */ + public void setGridletNumber(int gridlet_num) + { + NUM_GRIDLETS = gridlet_num; + + gridletSubmissionTime = new double[NUM_GRIDLETS]; + gridletLatencyTime = new double[NUM_GRIDLETS]; + } + + /** + * Handles incoming requests to this entity. + * This method specifies the behaviours and/or scenarios of a user. + */ + public void body() + { + initializeResultsFile(); + createGridlet(super.get_id(), NUM_GRIDLETS); + + // schedule the initial sending of gridlets in the future + // NOTE: if you have many resources and GIS entities, please make sure + // you wait for few minutes to allow GIS to receive registrations from + // resources. Otherwise, the resource does not exist when you submit. + int PAUSE = 10*60; // 10 mins + Random random = new Random(); + int init_time = PAUSE + random.nextInt(5*60); + + // sends a reminder to itself + super.send(super.get_id(), init_time, GridUserFailureEx03.SUBMIT_GRIDLET); + System.out.println(super.get_name() + + ": initial SUBMIT_GRIDLET event will be at clock: " + + init_time + ". Current clock: " + GridSim.clock()); + + + //////////////////////////////////////////////////////////// + // Now, we have the framework of the entity: + while (Sim_system.running()) + { + Sim_event ev = new Sim_event(); + super.sim_get_next(ev); // get the next event in the queue + + switch (ev.get_tag()) + { + // submit a gridlet + case GridUserFailureEx03.SUBMIT_GRIDLET: + processGridletSubmission(ev); // process the received event + break; + + // Receive a gridlet back + case GridSimTags.GRIDLET_RETURN: + processGridletReturn(ev); + break; + + case GridSimTags.END_OF_SIMULATION: + System.out.println("\n============== " + super.get_name() + + ". Ending simulation..."); + break; + + default: + System.out.println(super.get_name() + + ": Received an event: " + ev.get_tag()); + break; + + } // switch + + } // while + + // wait for few seconds before printing the output + super.sim_pause( super.get_id()*2 ); + + // remove I/O entities created during construction of this entity + super.terminateIOEntities(); + + // prints the completed gridlets + printGridletList(GridletReceiveList_, super.get_name(), false, + gridletLatencyTime); + } // body() + + ///////////////////////////////////////////////////////////////////////// + + /** + * This functions process the submission of a gridlet. We have to get the + * list of available resources from the RegGIS, choose one of them, and + * submit the gridlet. + * @param ev an incoming event + */ + private void processGridletSubmission(Sim_event ev) + { + if (trace_flag) + { + System.out.println(super.get_name() + + ": received an SUBMIT_GRIDLET event. Clock: " + GridSim.clock()); + } + + /*********** + We have to submit: + - the gridlet whose id comes with the event + - all the gridlets with the "gridletSub.getSubmitted() == false" + + So, set the gridletSub.getSubmitted() to false for the gridlet whose + id comes with the event + ***********/ + + int i = 0; + GridletSubmission gridletSub; + int resourceID[]; + Random random = new Random(5); // a random generator with a random seed + int index; + Gridlet gl; + Integer obj; + int glID; + + // This is because the initial GRIDLET_SUBMIT event, at the beginning + // of sims, does not have any gridlet id. We have to submit + // all the gridlets. + if (ev.get_data() instanceof Integer) + { + obj = (Integer) ev.get_data(); + glID = obj.intValue(); // get the gridlet id. + } + else { + glID = 99; // a value at random, not used at all in this case + } + + while (i < GridletSubmittedList_.size()) + { + gridletSub = (GridletSubmission)GridletSubmittedList_.get(i); + + if ( (gridletSub.getGridlet()).getGridletID() == glID ) + { + // set this gridlet whose id comes with the event as not submitted, + // so that it is submitted as soon as possible. + ((GridletSubmission) GridletSubmittedList_.get(i)).setSubmitted(false); + } + + // Submit the gridlets with the "gridletSub.getSubmitted() == false" + if ( (gridletSub.getSubmitted() == false)) + { + // we have to resubmit this gridlet + gl = ((GridletSubmission) GridletSubmittedList_.get(i)).getGridlet(); + resourceID = getResList(); // Get list of resources from GIS + + // If we have resources in the list + if ((resourceID != null) && (resourceID.length != 0)) + { + index = random.nextInt(resourceID.length); + + // make sure the gridlet will be executed from the begining + resetGridlet(gl); + + // submits this gridlet to a resource + super.gridletSubmit(gl, resourceID[index]); + gridletSubmissionTime[gl.getGridletID()] = GridSim.clock(); + + // set this gridlet as submitted + ((GridletSubmission) GridletSubmittedList_.get(i)).setSubmitted(true); + + if (trace_flag) + { + System.out.println(super.get_name() + + ": Sending Gridlet #" + i + " to " + + GridSim.getEntityName(resourceID[index]) + + " at clock: " + GridSim.clock()); + + // Write into a results file + write(super.get_name(), "Sending", gl.getGridletID(), + GridSim.getEntityName(resourceID[index]), + gl.getGridletStatusString(), GridSim.clock()); + } + + } + // No resources available at this moment, so schedule an event + // in the future. The event wil be in 15 min (900 sec), as + // resource failures may last several hours. + // This event includes the gridletID, so that the user will + // try to submit only this gridlet + else + { + super.send(super.get_id(), GridSimTags.SCHEDULE_NOW + 900, + GridUserFailureEx03.SUBMIT_GRIDLET, + new Integer(gl.getGridletID()) ); + } + + }// if (gridletSub.getSubmitted() == false) + + i++; + } // while (i < GridletSubmittedList_.size()) + + } // processGridletSubmission + + /** + * This functions process the return of a gridlet. + * We pay attention to the status of the gridlet + * and then decide what we have to do the next + * @param ev an incoming event + */ + private void processGridletReturn(Sim_event ev) + { + if (trace_flag) + { + System.out.println(super.get_name() + + ": received an GRIDLET_RETURN event. Clock: " + GridSim.clock()); + } + + Object obj = (Object) ev.get_data(); + Gridlet gl = null; + Random random = new Random(5); // a random generator with a random seed + + if (obj instanceof Gridlet) + { + gl = (Gridlet) obj; + gridletLatencyTime[gl.getGridletID()] = GridSim.clock(); + + // Write into a results file + if (trace_flag) + { + write(super.get_name(), "Receiving", gl.getGridletID(), + GridSim.getEntityName(gl.getResourceID()), + gl.getGridletStatusString(), GridSim.clock()); + } + + ///////////////////////// Gridlet Success + if (gl.getGridletStatusString().compareTo("Success") == 0) + { + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + " with status Success at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID())); + + this.GridletReceiveList_.add(gl); // add into the received list + gridletLatencyTime[gl.getGridletID()] = + gridletLatencyTime[gl.getGridletID()] - + gridletSubmissionTime[gl.getGridletID()]; + + // We have received all the gridlets. So, finish the simulation. + if (GridletReceiveList_.size() == GridletSubmittedList_.size()) + { + super.finishSimulation(); + } + + } // if (gl.getGridletStatusString() == "Success") + + //////////////////////// Gridlet Failed + else if (gl.getGridletStatusString().compareTo("Failed") == 0) + { + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + " with status Failed at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID())); + + // Send the gridlet as soon as we have resources available. + // This gridlet will be resend as soon as possible, + // in the first loop. + int pos = findGridletInGridletSubmittedList(gl); + if (pos == -1) { + System.out.println(super.get_name() + + ". Gridlet not found in GridletSubmittedList."); + } + else + { + // set this gridlet as submitted, because otherwise + // this gridlet may be submitted several times. + // A gridlet will only be submitted when the event carrying + // its id reaches the user + ((GridletSubmission) GridletSubmittedList_.get(pos)).setSubmitted(true); + + // Now, schedule an event to itself to submit the gridlet + // The gridlet will be sent as soon as possible + Integer glID_Int = new Integer(gl.getGridletID()); + + // This event includes the gridletID, so that the user + // will try to submit only this gridlet + super.send(super.get_id(), GridSimTags.SCHEDULE_NOW, + GridUserFailureEx03.SUBMIT_GRIDLET, glID_Int); + } + } // if (gl.getGridletStatusString() == "Failed") + + ////////////////////////////// Gridlet Failed_resource + else if (gl.getGridletStatusString().compareTo("Failed_resource_unavailable") == 0) + { + int pos = findGridletInGridletSubmittedList(gl); + if (pos == -1) { + System.out.println(super.get_name() + + ". Gridlet not found in GridletSubmittedList."); + } + else + { + // Now, set its submission time for a random time between + // 1 and the polling time + double resubmissionTime = random.nextDouble() * pollingTime_; + + // this is to prevent the gridlet from being submitted + // before its resubmission time. + // This is different from the FAILED case, because + // in that case, the gridlet should be resubmited as soon + // as possible. As oppossed to that, this gridlet should + // not be resubmited before its resubmission time. + ((GridletSubmission) GridletSubmittedList_.get(pos)).setSubmitted(true); + + + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + + " with status Failed_resource_unavailable at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID()) + + "(resID: " + gl.getResourceID() + + "). Resubmission time will be: " + + resubmissionTime + GridSim.clock()); + + // Now, we have to inform the GIS about this failure, so it + // can keep the list of resources up-to-date. + informGIS(gl.getResourceID()); + + // Now, schedule an event to itself to submit the gridlet + Integer glID_Int = new Integer(gl.getGridletID()); + + // This event includes the gridletID, so that the user + // will try to submit only this gridlet + super.send(super.get_id(), resubmissionTime, + GridUserFailureEx03.SUBMIT_GRIDLET, glID_Int); + } + } // else if + else + { + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + " with status " + + gl.getGridletStatusString() + " at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID()) + + " resID: " + gl.getResourceID()); + } + + } // if (obj instanceof Gridlet) + } + + /** + * Prints the Gridlet objects + * @param list the list of gridlets + * @param name the name of the user + * @param detail if we want the gridlet's history or not + * @param gridletLatencyTime array containing the latencies of gridlets. + * Latencies are from the moment when the gridlet is sent, till + * the moment they are back at the user. + * They take into account the last submission of a gridlet + * (when the gridlet is successfully run) + */ + private void printGridletList(GridletList list, String name, + boolean detail, double gridletLatencyTime[]) + { + int size = list.size(); + Gridlet gridlet = null; + + String indent = " "; + StringBuffer buffer = new StringBuffer(1000); + buffer.append("\n\n============== OUTPUT for " + name + " ==========="); + buffer.append("\nGridlet ID" + indent + "STATUS" + indent + + "Resource ID" + indent + indent + "Cost" + indent + + indent + "CPU Time" + indent + indent + "Latency"); + + // a loop to print the overall result + int i = 0; + boolean header = true; + + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list.get(i); + + buffer.append("\n"); + buffer.append(indent + gridlet.getGridletID() + indent + indent); + buffer.append( gridlet.getGridletStatusString() ); + buffer.append(indent + indent + gridlet.getResourceID() + + indent + gridlet.getProcessingCost() + + indent + gridlet.getActualCPUTime() + + indent + gridletLatencyTime[gridlet.getGridletID()]); + + if (i != 0) { + header = false; + } + + writeFin(name, gridlet.getGridletID(), + GridSim.getEntityName(gridlet.getResourceID()), + gridlet.getProcessingCost(), gridlet.getActualCPUTime(), + GridSim.clock(), header); + } + + if (detail == true) + { + // a loop to print each Gridlet's history + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list.get(i); + + buffer.append( gridlet.getGridletHistory() ); + buffer.append("Gridlet #" + gridlet.getGridletID()); + buffer.append(", length = " + gridlet.getGridletLength() + + ", finished so far = " + + gridlet.getGridletFinishedSoFar()); + buffer.append("==========================================="); + } + } + + buffer.append("\n===================================================="); + System.out.println( buffer.toString() ); + + } + + /** + * This method will show you on how to create Gridlets + * @param userID owner ID of a Gridlet + * @param numGridlet number of Gridlet to be created + */ + private void createGridlet(int userID, int numGridlet) + { + for (int i = 0; i < numGridlet; i++) + { + // Creates a Gridlet + Gridlet gl = new Gridlet(i, gridletLength, gridletInput, gridletOutput); + gl.setUserID(userID); + + // Originally, gridlets are created to be submitted + // as soon as possible (the 0.0 param) + GridletSubmission gst = new GridletSubmission(gl, false); + + // add this gridlet into a list + this.GridletSubmittedList_.add(gst); + } + } + + /** + * Gets a list of received Gridlets + * @return a list of received/completed Gridlets + */ + public GridletList getGridletList() { + return GridletReceiveList_; + } + + /** + * Tells you the possition of this gridlet in the GridletSubmittedList_ + * @param gl the gridlet + * @return the position of this gridlet in the list of submitted gridlets + */ + private int findGridletInGridletSubmittedList(Gridlet gl) + { + Gridlet g = null; + GridletSubmission gst = null; + for (int i = 0; i< GridletSubmittedList_.size(); i++) + { + gst = (GridletSubmission)GridletSubmittedList_.get(i); + g = gst.getGridlet(); + + if ( g.getGridletID() == gl.getGridletID() ) + return i; + } + + return -1; + } + + /** This function resets the gridlet into its original values of + * length and gridletFinishedSoFar + * @param gl the gridlet to be resetted + */ + private void resetGridlet (Gridlet gl) + { + gl.setGridletLength(gridletLength); + gl.setGridletFinishedSoFar(0); + + } + + /** + * Write some data into the final results file. + * @param user user name + * @param glID gridlet id + * @param resName Name of the resource + * @param cost the processing cost of the gridlet + * @param cpu the cpu time + * @param clock Current time + * @param header write a row header or not + * */ + private void writeFin(String user, int glID, String resName, + double cost, double cpu, double clock, + boolean header) + { + if (trace_flag == false) { + return; + } + + // Write into a results file + FileWriter fwriter = null; + try + { + fwriter = new FileWriter(user, true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while opening file " + user); + } + + try + { + if (header == true) { + fwriter.write( + "\n\nGridletID \t Resource \t Cost \t CPU time \t Latency\n"); + } + + fwriter.write(glID + "\t" + resName + "\t" + cost + "\t"+ cpu + + "\t" + + clock + "\n"); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while writing on file " + user); + } + + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while closing file " + user); + } + + } + + /** + * Write some data into a results file. + * @param user user name + * @param event Values: "Sending" or "Receive" a gridlet + * @param glID gridlet id + * @param resName Name of the resource + * @param status Status of the gridlet + * @param clock Current time + */ + private void write(String user, String event, int glID, String resName, + String status, double clock) + { + if (trace_flag == false) { + return; + } + + // Write into a results file + FileWriter fwriter = null; + try + { + fwriter = new FileWriter(super.get_name(), true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while opening file " + super.get_name()); + } + + try + { + fwriter.write(event + "\t\t" + glID + "\t" + resName + "\t" + status + + "\t\t" + clock + "\n"); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while writing on file " + super.get_name()); + } + + + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while closing file " + super.get_name()); + } + + } + + /** + * This function informs the GIS of this user about the failure of a resource + * @param resID the id of the resource which has failed + */ + private void informGIS(int resID) + { + Integer resID_Int = new Integer(resID); + + super.send(super.output, 0.0, AbstractGIS.NOTIFY_GIS_RESOURCE_FAILURE, + new IO_data(resID_Int, Link.DEFAULT_MTU, super.getRegionalGISId()) ); + } + + /** + * Initialize the results files (put headers over each column) + * */ + private void initializeResultsFile() + { + if (trace_flag == false) { + return; + } + + // Initialize the results file + FileWriter fwriter = null; + try + { + fwriter = new FileWriter(super.get_name(), true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while opening file " + super.get_name() + + " or " + super.get_name()+"_Fin"); + } + + try + { + fwriter.write( + "Event \t GridletID \t Resource \t GridletStatus \t\t Clock\n"); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while writing on file " + super.get_name()+ + " or " + super.get_name()+"_Fin"); + } + + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while closing file " + super.get_name()+ + " or " + super.get_name()+"_Fin"); + } + } + + /** + * This function retrieves a list of available resources from the GIS. + * @return an array containing the ids of the resources + */ + private int[] getResList() + { + Object[] resList = super.getLocalResourceList(); + int resourceID[] = null; + + // if we have any resource + if ((resList != null) && (resList.length != 0)) + { + resourceID = new int[resList.length]; + for (int x = 0; x < resList.length; x++) + { + // Resource list contains list of resource IDs + resourceID[x] = ((Integer) resList[x]).intValue(); + + if (trace_flag == true) + { + System.out.println(super.get_name() + + ": resource[" + x + "] = " + resourceID[x]); + } + } + + } + + return resourceID; + } + +} // end class Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/GridletSubmission.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/GridletSubmission.java (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/GridletSubmission.java 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,54 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + + +import gridsim.Gridlet; + +/** + * This class is just a wrapper to denote + * whether this gridlet has been already submitted or not + * @author Agustin Caminero and Anthony Sulistio + * @since GridSim Toolkit 4.1 + */ +public class GridletSubmission +{ + private Gridlet gl; + private boolean submitted; + + + public GridletSubmission(Gridlet gl,boolean submitted) + { + this.gl = gl; + this.submitted = submitted; + } + + public Gridlet getGridlet() + { + return gl; + } + + public boolean getSubmitted() + { + return submitted; + } + + public void setGridlet(Gridlet g) + { + this.gl = g; + } + + public void setSubmitted(boolean submitted) + { + this.submitted = submitted; + } + +} // end class Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/README.txt =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/README.txt (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/README.txt 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,67 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + +Welcome to the example of how to use the computing resource failure functionality +To compile the example source code: + In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx01.java + In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx01.java + +where $GRIDSIM or %GRIDSIM% is the location of the gridsimtoolkit package. + + +To run the class file: +In Unix/Linux: + java -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx02 network_ex02.txt > file.txt + +In Windows: + java -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx02 network_ex02.txt > file.txt + + +The above command means run the program and output the results into a file +named "file.txt" rather than into screen or standard output. +To prevent from overwriting an existing file, +I renamed "file.txt" into "output.txt" + +NOTE: This example uses probabilistic distributions and random variables. + Hence, when running this example many times, the values will be different. + + +When running the example file, it will produce the following files: + + sim_trace -> created by the SimJava2 package (lower-level) to trace every + events (performed by SimJava and GridSim) during the simulation. + We don't need to worry about this file. Not to important for our + example. + + sim_report -> created by the SimJava2 package (lower-level) of GridSim. + This is a simulation report that contains general information about + running this experiment. We don't need to worry about this file. + Not to important for our example. + + Ex02_Regional_GIS_0, ..., Ex02_Regional_GIS_2 -> contains one line describing each + registering/removing an event that takes place at the GIS. Resources + register in the begining of simulations, and after recovering from a + failure affecting all their machines. Resources will be removed when + they suffer a failure affecting all their machines. + + Ex02_Res_0, ... , Ex01_Res_8 -> records when the resource + suffers a failure and when it recovers from the failure. It also records + how many machines failed, and the time of the fail/recovery. + + Ex02_User_0 -> contains one line for each event regarding to the Gridlets. + These events are the sending/reception of a gridlet, and + each line include the status of the gridlet, time and resource. + Then, when a simulation ends, this file shows the resource + a Gridlet has been executed, its cost, CPU time and total latency. + +NOTE: When you run the program multiple times, the new statistics will be + appended at the end of a file. Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/ResFailureEx03.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/ResFailureEx03.java (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/ResFailureEx03.java 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,380 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + +import gridsim.resFailure.*; +import gridsim.*; +import gridsim.net.*; +import java.util.*; +import gridsim.util.NetworkReader; +import gridsim.util.HyperExponential; + + +/** + * This example shows a basic topology with n user, m resources and p GISes. + * All of them are connected by a router. + * There is only one VO in this example. + * @author Agustin Caminero and Anthony Sulistio + * @since GridSim Toolkit 4.1 + */ +public class ResFailureEx03 +{ + public static void main(String[] args) + { + System.out.println("Starting failure example 3..."); + + try + { + if (args.length < 1) + { + System.out.println("Usage: java ResFailureEx03 network_ex03.txt"); + return; + } + + // specify the number of users, resources and GISes + int num_user = 30; // number of grid users + int totalResource = 15; // number of resources + int num_GIS = 3; // number of regional GIS entity + Random random = new Random(); // randomize the selection + + + ////////////////////////////////////////// + // First step: 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 a run-time exception + // error. + + // a flag that denotes whether to trace GridSim events or not. + boolean trace_flag = false; // dont use SimJava trace + Calendar calendar = Calendar.getInstance(); + + // Initialize the GridSim package + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + trace_flag = true; + + + ////////////////////////////////////////// + // Second step: Builds the network topology among Routers. + + String filename = args[0]; // get the network topology + System.out.println("Reading network from " + filename); + LinkedList routerList = NetworkReader.createFIFO(filename); + + + ////////////////////////////////////////// + // Third step: Creates one RegionalGISWithFailure entity, + // linked to a router in the topology + + double baud_rate = 100000000; // 100Mbps, i.e. baud rate of links + double propDelay = 10; // propagation delay in milliseconds + int mtu = 1500; // max. transmission unit in byte + int totalMachines = 16; // num of machines each resource has + + Router router0 = NetworkReader.getRouter("Router0", routerList); + Router router1 = NetworkReader.getRouter("Router1", routerList); + + String NAME = "Ex03_"; // a common name + ArrayList gisList = new ArrayList(num_GIS); // list of GIS entities + + for (int i = 0; i < num_GIS; i++) + { + String gisName = NAME + "Regional_GIS_" + i; // GIS name + + // a network link attached to this regional GIS entity + Link link = new SimpleLink(gisName + "_link", baud_rate, + propDelay, mtu); + + + // HyperExponential: mean, standard deviation, stream + // how many resources will fail + HyperExponential failureNumResPattern = + new HyperExponential(totalMachines / 2, totalMachines, 4); + + // when they will fail + HyperExponential failureTimePattern = + new HyperExponential(25, 100, 4); + + // how long the failure will be + HyperExponential failureLengthPattern = + new HyperExponential(20, 25, 4); // big test: (20, 100, 4); + + + // creates a new Regional GIS entity that generates a resource + // failure message according to these patterns. + RegionalGISWithFailure gis = new RegionalGISWithFailure(gisName, + link, failureNumResPattern, failureTimePattern, + failureLengthPattern); + gis.setTrace(trace_flag); // record this GIS activity + gisList.add(gis); // add into the list + + // link these GIS to a router + String routerName = null; + if (random.nextBoolean() == true) + { + linkNetwork(router0, gis); + routerName = router0.get_name(); + } + else + { + linkNetwork(router1, gis); + routerName = router1.get_name(); + } + + // print some info messages + System.out.println("Created a REGIONAL GIS with name " + + gisName + " and id = " + gis.get_id() + + ", connected to " + routerName); + } + + ////////////////////////////////////////// + // Fourth step: Creates one or more GridResourceWithFailure + // entities, linked to a router in the topology + + String sched_alg = "SPACE"; // use space-shared policy + ArrayList resList = new ArrayList(totalResource); + + // Each resource may have different baud rate, + // totalMachine, rating, allocation policy and the router to + // which it will be connected. However, in this example, we assume + // all have the same properties for simplicity. + int totalPE = 4; // num of PEs each machine has + int rating = 49000; // rating (MIPS) of PEs + int GB = 1000000000; // 1 GB in bits + baud_rate = 2.5 * GB; + + for (int i = 0; i < totalResource; i++) + { + // creates a new grid resource + String resName = NAME + "Res_" + i; + GridResourceWithFailure res = createGridResource(resName, + baud_rate, propDelay, mtu, totalPE, totalMachines, + rating, sched_alg); + + if (i % 2 == 0) { + trace_flag = true; + } + else { + trace_flag = false; + } + + resList.add(res); // add a resource into a list + res.setTrace(trace_flag); // record this resource activity + + // link these GIS to a router + String routerName = null; + if (random.nextBoolean() == true) + { + linkNetwork(router0, res); + routerName = router0.get_name(); + } + else + { + linkNetwork(router1, res); + routerName = router1.get_name(); + } + + // randomly select which GIS to choose + int index = random.nextInt( gisList.size() ); + RegionalGISWithFailure gis = (RegionalGISWithFailure) gisList.get(index); + res.setRegionalGIS(gis); // set the regional GIS entity + + System.out.println("Created " + resName + " with id = " + + res.get_id() + ", linked to " + routerName + + " and registered to " + gis.get_name() ); + } + + + ////////////////////////////////////////// + // Fifth step: Creates one or more GridUserFailure entities, + // linked to a router of the topology + + int totalGridlet = 5; // total jobs + double pollTime = 100; // time between polls + int glSize = 100000; // the size of gridlets (input/output) + int glLength = 42000000; // the length (MI) of gridlets + + trace_flag = true; + for (int i = 0; i < num_user; i++) + { + String userName = NAME + "User_" + i; + + // a network link attached to this entity + Link link2 = new SimpleLink(userName + "_link", baud_rate, + propDelay, mtu); + + // only keeps track activities from User_0 + if (i != 0) { + trace_flag = false; + } + + GridUserFailureEx03 user = new GridUserFailureEx03(userName, link2, + pollTime, glLength, glSize, glSize, trace_flag); + user.setGridletNumber(totalGridlet); + + // link this user to a router + String routerName = null; + if (random.nextBoolean() == true) + { + linkNetwork(router0, user); + routerName = router0.get_name(); + } + else + { + linkNetwork(router1, user); + routerName = router1.get_name(); + } + + // randomly select which GIS to choose + int index = random.nextInt( gisList.size() ); + RegionalGISWithFailure gis = (RegionalGISWithFailure) gisList.get(index); + user.setRegionalGIS(gis); // set the regional GIS entity + + System.out.println("Created " + userName + + " with id = " + user.get_id() + ", linked to " + + routerName + ", and with " + totalGridlet + + " gridlets. Registered to " + gis.get_name() ); + } + System.out.println(); + + ////////////////////////////////////////// + // Sixth step: Starts the simulation + GridSim.startGridSimulation(); + System.out.println("\nFinish failure example 3... \n"); + } + catch (Exception e) + { + e.printStackTrace(); + System.out.println("Unwanted errors happen"); + } + } + + /** + * Links a particular entity with a given Router. + * + * @param router a Router object + * @param obj a GridSim entity to be attached to the Router + */ + private static void linkNetwork(Router router, GridSimCore obj) throws Exception + { + if (router == null) { + System.out.println("Error - router is NULL."); + return; + } + + // get the baud rate of a link + double baud_rate = obj.getLink().getBaudRate(); + + // create the packet scheduler for this link + PacketScheduler pktObj = new FIFOScheduler(router.get_name() + + "_to_" + obj.get_name() ); + + // attach this GridSim entity to a Router + router.attachHost(obj, pktObj); + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * <p> + * In this simple example, we are simulating one Grid resource with three + * Machines that contains one or more PEs. + * + * @param name a Grid Resource name + * @param baud_rate the bandwidth of this entity + * @param delay the propagation delay + * @param MTU Maximum Transmission Unit + * @param totalPE number of PE per machine + * @param totalMachine number of machines in this resources + * @param rating rating of mahcines in this resource + * @param sched_alg the scheduling algorithm of this resource + * @return a GridResource object + */ + private static GridResourceWithFailure createGridResource(String name, + double baud_rate, double delay, int MTU, int totalPE, + int totalMachine, int rating, String sched_alg) + { + // 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++) + { + // 2. A Machine contains one or more PEs or CPUs. Therefore, should + // create an object of PEList to store these PEs before creating + // a Machine. + PEList peList = new PEList(); + + // 3. Create PEs and add these into an object of PEList. + for (int k = 0; k < totalPE; k++) + { + // need to store PE id and MIPS Rating + peList.add( new PE(k, rating) ); + } + + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, peList) ); + } + + + // 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 = 9.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // we create Space_Shared_failure or Time_Shared_failure schedulers + int scheduling_alg = 0; // space_shared or time_shared + if (sched_alg.equals("SPACE") == true) { + scheduling_alg = ResourceCharacteristics.SPACE_SHARED; + } + else if (sched_alg.equals("TIME") == true) { + scheduling_alg = ResourceCharacteristics.TIME_SHARED; + } + + ResourceCharacteristics resConfig = new ResourceCharacteristics( + arch, os, mList, scheduling_alg, time_zone, cost); + + + // 6. Finally, we need to create a GridResource object. + 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(); + GridResourceWithFailure gridRes = null; + try + { + // creates a GridResource with a link + gridRes = new GridResourceWithFailure(name, + new SimpleLink(name + "_link", baud_rate, delay, MTU), + seed, resConfig, peakLoad, offPeakLoad, holidayLoad, + Weekends, Holidays); + } + catch (Exception e) { + e.printStackTrace(); + } + + return gridRes; + } + +} // end class Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/network_ex03.txt =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/network_ex03.txt (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/network_ex03.txt 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,13 @@ + +# total number of Routers +2 + +# specifies each router name and whether to log its activities or not +# by default no logging is required +Router0 +Router1 + +# specify the link between two Routers +# The format is: +# Router_name1 Router_name2 baud_rate(GB/s) prop_delay(ms) mtu(byte) +Router0 Router1 1 10.0 1500 Added: branches/gridsim4.0-branch1/examples/ResFailureEx03/output.txt =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx03/output.txt (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx03/output.txt 2007-08-29 07:59:16 UTC (rev 46) @@ -0,0 +1,920 @@ +Starting failure example 3... +Initializing GridSim package +Initialising... +Reading network from network_ex03.txt +Created a REGIONAL GIS with name Ex03_Regional_GIS_0 and id = 8, connected to Router1 +Created a REGIONAL GIS with name Ex03_Regional_GIS_1 and id = 12, connected to Router0 +Created a REGIONAL GIS with name Ex03_Regional_GIS_2 and id = 16, connected to Router0 +Created Ex03_Res_0 with id = 20, linked to Router1 and registered to Ex03_Regional_GIS_0 +Created Ex03_Res_1 with id = 25, linked to Router1 and registered to Ex03_Regional_GIS_0 +Created Ex03_Res_2 with id = 30, linked to Router1 and registered to Ex03_Regional_GIS_2 +Created Ex03_Res_3 with id = 35, linked to Router0 and registered to Ex03_Regional_GIS_1 +Created Ex03_Res_4 with id = 40, linked to Router0 and registered to Ex03_Regional_GIS_2 +Created Ex03_Res_5 with id = 45, linked to Router1 and registered to Ex03_Regional_GIS_0 +Created Ex03_Res_6 with id = 50, linked to Router1 and registered to Ex03_Regional_GIS_2 +Created Ex03_Res_7 with id = 55, linked to Router1 and registered to Ex03_Regional_GIS_2 +Created Ex03_Res_8 with id = 60, linked to Router1 and registered to Ex03_Regional_GIS_0 +Created Ex03_Res_9 with id = 65, linked to Router1 and registered to Ex03_Regional_GIS_1 +Created Ex03_Res_10 with id = 70, linked to Router0 and registered to Ex03_Regional_GIS_1 +Created Ex03_Res_11 with id = 75, linked to Router1 and registered to Ex03_Regional_GIS_2 +Created Ex03_Res_12 with id = 80, linked to Router0 and registered to Ex03_Regional_GIS_2 +Created Ex03_Res_13 with id = 85, linked to Router0 and registered... [truncated message content] |
From: <sul...@us...> - 2007-08-29 05:11:06
|
Revision: 45 http://gridsim.svn.sourceforge.net/gridsim/?rev=45&view=rev Author: sulistio Date: 2007-08-28 22:11:05 -0700 (Tue, 28 Aug 2007) Log Message: ----------- fixed a minor bug in naming entity name. Modified Paths: -------------- branches/gridsim4.0-branch1/examples/ResFailureEx02/ResFailureEx02.java Modified: branches/gridsim4.0-branch1/examples/ResFailureEx02/ResFailureEx02.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/ResFailureEx02.java 2007-08-29 05:10:36 UTC (rev 44) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/ResFailureEx02.java 2007-08-29 05:11:05 UTC (rev 45) @@ -75,7 +75,7 @@ int mtu = 1500; // max. transmission unit in byte int totalMachines = 16; // num of machines each resource has - String NAME = "Ex01_"; // a common name + String NAME = "Ex02_"; // a common name String gisName = NAME + "Regional_GIS"; // GIS name // a network link attached to this regional GIS entity This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-29 05:10:37
|
Revision: 44 http://gridsim.svn.sourceforge.net/gridsim/?rev=44&view=rev Author: sulistio Date: 2007-08-28 22:10:36 -0700 (Tue, 28 Aug 2007) Log Message: ----------- rename this file from Ex01_ to Ex02_ Added Paths: ----------- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Regional_GIS branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_0 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_1 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_2 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_3 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_4 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_5 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_User_0 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Regional_GIS =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Regional_GIS (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Regional_GIS 2007-08-29 05:10:36 UTC (rev 44) @@ -0,0 +1,9 @@ +Event ResourceID Clock +Registering 15 10.020000998399999 +Registering 20 10.030000998399998 +Registering 30 10.040000998399998 +Registering 25 10.050000998399998 +Registering 35 10.060000998399998 +Registering 10 10.070000998399998 +Removing 15 22.73144227840079 +Removing 10 289.4404053503977 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_0 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_0 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_0 2007-08-29 05:10:36 UTC (rev 44) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 16 287.06017704959993 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_1 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_1 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_1 2007-08-29 05:10:36 UTC (rev 44) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 16 22.031307878400685 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_2 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_2 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_2 2007-08-29 05:10:36 UTC (rev 44) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 1 31.205426140020172 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_3 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_3 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_3 2007-08-29 05:10:36 UTC (rev 44) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 3 30.27426340437428 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_4 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_4 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_4 2007-08-29 05:10:36 UTC (rev 44) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 3 30.571085997276676 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_5 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_5 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_Res_5 2007-08-29 05:10:36 UTC (rev 44) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 1 288.4904101503986 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_User_0 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_User_0 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex02_User_0 2007-08-29 05:10:36 UTC (rev 44) @@ -0,0 +1,19 @@ +Event GridletID Resource GridletStatus Clock +Sending 0 Ex01_Res_3 Created 289.0404101503981 +Sending 1 Ex01_Res_2 Created 289.9304101503973 +Sending 2 Ex01_Res_2 Created 290.8704101503964 +Sending 3 Ex01_Res_3 Created 291.72041015039565 +Sending 4 Ex01_Res_4 Created 292.5704101503949 +Receiving 1 Ex01_Res_2 Success 1159.070429350387 +Receiving 0 Ex01_Res_3 Success 1159.5404293503866 +Receiving 4 Ex01_Res_4 Success 1161.6004293503847 +Receiving 2 Ex01_Res_2 Success 1170.4804293503767 +Receiving 3 Ex01_Res_3 Success 1172.0604293503752 + + +GridletID Resource Cost CPU time Latency +1 Ex01_Res_2 2572.0800000000017 857.3600000000006 566164.7597809572 +0 Ex01_Res_3 2572.830000000001 857.6100000000004 566164.7597809572 +4 Ex01_Res_4 2572.830000000001 857.6100000000004 566164.7597809572 +2 Ex01_Res_2 2571.6900000000023 857.2300000000007 566164.7597809572 +3 Ex01_Res_3 2572.830000000001 857.6100000000004 566164.7597809572 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-29 05:09:18
|
Revision: 43 http://gridsim.svn.sourceforge.net/gridsim/?rev=43&view=rev Author: sulistio Date: 2007-08-28 22:09:18 -0700 (Tue, 28 Aug 2007) Log Message: ----------- this file should be renamed to Ex02_ not Ex01_ Removed Paths: ------------- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Regional_GIS branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_0 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_1 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_2 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_3 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_4 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_5 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_User_0 Deleted: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Regional_GIS =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Regional_GIS 2007-08-29 02:22:54 UTC (rev 42) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Regional_GIS 2007-08-29 05:09:18 UTC (rev 43) @@ -1,9 +0,0 @@ -Event ResourceID Clock -Registering 15 10.020000998399999 -Registering 20 10.030000998399998 -Registering 30 10.040000998399998 -Registering 25 10.050000998399998 -Registering 35 10.060000998399998 -Registering 10 10.070000998399998 -Removing 15 22.73144227840079 -Removing 10 289.4404053503977 Deleted: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_0 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_0 2007-08-29 02:22:54 UTC (rev 42) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_0 2007-08-29 05:09:18 UTC (rev 43) @@ -1,2 +0,0 @@ -Event NumMachines Clock -Failure 16 287.06017704959993 Deleted: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_1 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_1 2007-08-29 02:22:54 UTC (rev 42) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_1 2007-08-29 05:09:18 UTC (rev 43) @@ -1,2 +0,0 @@ -Event NumMachines Clock -Failure 16 22.031307878400685 Deleted: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_2 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_2 2007-08-29 02:22:54 UTC (rev 42) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_2 2007-08-29 05:09:18 UTC (rev 43) @@ -1,2 +0,0 @@ -Event NumMachines Clock -Failure 1 31.205426140020172 Deleted: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_3 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_3 2007-08-29 02:22:54 UTC (rev 42) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_3 2007-08-29 05:09:18 UTC (rev 43) @@ -1,2 +0,0 @@ -Event NumMachines Clock -Failure 3 30.27426340437428 Deleted: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_4 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_4 2007-08-29 02:22:54 UTC (rev 42) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_4 2007-08-29 05:09:18 UTC (rev 43) @@ -1,2 +0,0 @@ -Event NumMachines Clock -Failure 3 30.571085997276676 Deleted: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_5 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_5 2007-08-29 02:22:54 UTC (rev 42) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_5 2007-08-29 05:09:18 UTC (rev 43) @@ -1,2 +0,0 @@ -Event NumMachines Clock -Failure 1 288.4904101503986 Deleted: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_User_0 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_User_0 2007-08-29 02:22:54 UTC (rev 42) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_User_0 2007-08-29 05:09:18 UTC (rev 43) @@ -1,19 +0,0 @@ -Event GridletID Resource GridletStatus Clock -Sending 0 Ex01_Res_3 Created 289.0404101503981 -Sending 1 Ex01_Res_2 Created 289.9304101503973 -Sending 2 Ex01_Res_2 Created 290.8704101503964 -Sending 3 Ex01_Res_3 Created 291.72041015039565 -Sending 4 Ex01_Res_4 Created 292.5704101503949 -Receiving 1 Ex01_Res_2 Success 1159.070429350387 -Receiving 0 Ex01_Res_3 Success 1159.5404293503866 -Receiving 4 Ex01_Res_4 Success 1161.6004293503847 -Receiving 2 Ex01_Res_2 Success 1170.4804293503767 -Receiving 3 Ex01_Res_3 Success 1172.0604293503752 - - -GridletID Resource Cost CPU time Latency -1 Ex01_Res_2 2572.0800000000017 857.3600000000006 566164.7597809572 -0 Ex01_Res_3 2572.830000000001 857.6100000000004 566164.7597809572 -4 Ex01_Res_4 2572.830000000001 857.6100000000004 566164.7597809572 -2 Ex01_Res_2 2571.6900000000023 857.2300000000007 566164.7597809572 -3 Ex01_Res_3 2572.830000000001 857.6100000000004 566164.7597809572 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-29 02:23:09
|
Revision: 42 http://gridsim.svn.sourceforge.net/gridsim/?rev=42&view=rev Author: sulistio Date: 2007-08-28 19:22:54 -0700 (Tue, 28 Aug 2007) Log Message: ----------- initial release. add a more complex example of resource failure. this code was done by Agustin and modified by me. Modified Paths: -------------- branches/gridsim4.0-branch1/examples/ResFailureEx01/README.txt Added Paths: ----------- branches/gridsim4.0-branch1/examples/ResFailureEx02/ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Regional_GIS branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_0 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_1 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_2 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_3 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_4 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_5 branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_User_0 branches/gridsim4.0-branch1/examples/ResFailureEx02/GridUserFailureEx02.java branches/gridsim4.0-branch1/examples/ResFailureEx02/GridletSubmission.java branches/gridsim4.0-branch1/examples/ResFailureEx02/README.txt branches/gridsim4.0-branch1/examples/ResFailureEx02/ResFailureEx02.java branches/gridsim4.0-branch1/examples/ResFailureEx02/network_ex02.txt branches/gridsim4.0-branch1/examples/ResFailureEx02/output.txt Modified: branches/gridsim4.0-branch1/examples/ResFailureEx01/README.txt =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/README.txt 2007-08-29 02:16:53 UTC (rev 41) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/README.txt 2007-08-29 02:22:54 UTC (rev 42) @@ -59,8 +59,7 @@ Ex01_User0 -> contains one line for each event regarding to the Gridlets. These events are the sending/reception of a gridlet, and - each line include the status of the gridlet, - time, resource and VO. In this example we only have 1 VO. + each line include the status of the gridlet, time and resource. Ex01_User0_Fin -> contains one line for each gridlet, showing the resource it has been executed, its cost, CPU time and total latency. Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Regional_GIS =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Regional_GIS (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Regional_GIS 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,9 @@ +Event ResourceID Clock +Registering 15 10.020000998399999 +Registering 20 10.030000998399998 +Registering 30 10.040000998399998 +Registering 25 10.050000998399998 +Registering 35 10.060000998399998 +Registering 10 10.070000998399998 +Removing 15 22.73144227840079 +Removing 10 289.4404053503977 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_0 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_0 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_0 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 16 287.06017704959993 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_1 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_1 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_1 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 16 22.031307878400685 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_2 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_2 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_2 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 1 31.205426140020172 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_3 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_3 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_3 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 3 30.27426340437428 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_4 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_4 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_4 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 3 30.571085997276676 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_5 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_5 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_Res_5 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 1 288.4904101503986 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_User_0 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_User_0 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/Ex01_User_0 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,19 @@ +Event GridletID Resource GridletStatus Clock +Sending 0 Ex01_Res_3 Created 289.0404101503981 +Sending 1 Ex01_Res_2 Created 289.9304101503973 +Sending 2 Ex01_Res_2 Created 290.8704101503964 +Sending 3 Ex01_Res_3 Created 291.72041015039565 +Sending 4 Ex01_Res_4 Created 292.5704101503949 +Receiving 1 Ex01_Res_2 Success 1159.070429350387 +Receiving 0 Ex01_Res_3 Success 1159.5404293503866 +Receiving 4 Ex01_Res_4 Success 1161.6004293503847 +Receiving 2 Ex01_Res_2 Success 1170.4804293503767 +Receiving 3 Ex01_Res_3 Success 1172.0604293503752 + + +GridletID Resource Cost CPU time Latency +1 Ex01_Res_2 2572.0800000000017 857.3600000000006 566164.7597809572 +0 Ex01_Res_3 2572.830000000001 857.6100000000004 566164.7597809572 +4 Ex01_Res_4 2572.830000000001 857.6100000000004 566164.7597809572 +2 Ex01_Res_2 2571.6900000000023 857.2300000000007 566164.7597809572 +3 Ex01_Res_3 2572.830000000001 857.6100000000004 566164.7597809572 Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/GridUserFailureEx02.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/GridUserFailureEx02.java (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/GridUserFailureEx02.java 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,749 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + +import gridsim.*; +import gridsim.index.AbstractGIS; +import gridsim.net.Link; +import java.util.Random; +import java.util.ArrayList; +import java.io.FileWriter; +import gridsim.resFailure.RegionalGISWithFailure; +import eduni.simjava.Sim_system; +import eduni.simjava.Sim_event; + + +/** + * Creates a Grid User that also considers what happens if a resource fails. + * @author Agustin Caminero and Anthony Sulistio + * @since GridSim Toolkit 4.1 + */ +public class GridUserFailureEx02 extends GridUser +{ + // the base for our constants (chosen at random) + private static final int BASE = 440000; + + /** This constant is to tell the user when he should submit a gridlet */ + private static final int SUBMIT_GRIDLET = BASE + 1; + + private ArrayList GridletSubmittedList_; // list of submitted Gridlets + private GridletList GridletReceiveList_; // list of received Gridlets + + private int NUM_GRIDLETS; + private double pollingTime_; + + // The sizes of gridlets + private int gridletLength; + private int gridletInput; + private int gridletOutput; + + // we keep here the time when each gridlet is submitted + private double gridletSubmissionTime []; + private double gridletLatencyTime []; + + // a flag that denotes whether to trace GridSim events or not. + private boolean trace_flag; + + + /** + * Creates a GridUserFailure object + * @param name this entity name + * @param link a network link connecting this entity + * @param pollTime the time between polls + * @param glLength length (MI) for the gridlets of this user + * @param glIn input file size for the gridlets of this user + * @param glOut output file size for the gridlets of this user + * @param trace_flag a flag that denotes whether to trace this user events + * or not. + * @throws java.lang.Exception happens if either name or link is empty + */ + public GridUserFailureEx02(String name, Link link, double pollTime, + int glLength, int glIn, int glOut, boolean trace_flag) + throws Exception + { + super(name, link); + + this.GridletSubmittedList_ = new ArrayList(); + this.GridletReceiveList_ = new GridletList(); + pollingTime_ = pollTime; + + gridletLength = glLength; + gridletInput = glIn; + gridletOutput = glOut; + this.trace_flag = trace_flag; + } + + /** + * Sets the number of gridlets that this user has to submit. + * Also, create the submission and reception times arrays. + * @param gridlet_num the number of gridlets + */ + public void setGridletNumber(int gridlet_num) + { + NUM_GRIDLETS = gridlet_num; + + gridletSubmissionTime = new double[NUM_GRIDLETS]; + gridletLatencyTime = new double[NUM_GRIDLETS]; + } + + /** + * Handles incoming requests to this entity. + * This method specifies the behaviours and/or scenarios of a user. + */ + public void body() + { + initializeResultsFile(); + createGridlet(super.get_id(), NUM_GRIDLETS); + + // schedule the initial sending of gridlets. + // The sending will start in a ramdom time within 5 min + Random random = new Random(); + int init_time = random.nextInt(5*60); + + // sends a reminder to itself + super.send(super.get_id(), init_time, SUBMIT_GRIDLET); + System.out.println(super.get_name() + + ": initial SUBMIT_GRIDLET event will be at clock: " + + init_time + ". Current clock: " + GridSim.clock()); + + + //////////////////////////////////////////////////////////// + // Now, we have the framework of the entity: + while (Sim_system.running()) + { + Sim_event ev = new Sim_event(); + super.sim_get_next(ev); // get the next event in the queue + + switch (ev.get_tag()) + { + // submit a gridlet + case SUBMIT_GRIDLET: + processGridletSubmission(ev); // process the received event + break; + + // Receive a gridlet back + case GridSimTags.GRIDLET_RETURN: + processGridletReturn(ev); + break; + + case GridSimTags.END_OF_SIMULATION: + System.out.println("\n============== " + super.get_name() + + ". Ending simulation..."); + break; + + default: + System.out.println(super.get_name() + + ": Received an event: " + ev.get_tag()); + break; + + } // switch + + } // while + + // wait for few seconds before printing the output + super.sim_pause( super.get_id()*2 ); + + // remove I/O entities created during construction of this entity + super.terminateIOEntities(); + + // prints the completed gridlets + printGridletList(GridletReceiveList_, super.get_name(), false, + gridletLatencyTime); + } // body() + + ///////////////////////////////////////////////////////////////////////// + + /** + * This functions process the submission of a gridlet. We have to get the + * list of available resources from the RegGIS, choose one of them, and + * submit the gridlet. + * @param ev an incoming event + */ + private void processGridletSubmission(Sim_event ev) + { + if (trace_flag) + { + System.out.println(super.get_name() + + ": received an SUBMIT_GRIDLET event. Clock: " + GridSim.clock()); + } + + /*********** + We have to submit: + - the gridlet whose id comes with the event + - all the gridlets with the "gridletSub.getSubmitted() == false" + + So, set the gridletSub.getSubmitted() to false for the gridlet whose + id comes with the event + ***********/ + + int i = 0; + GridletSubmission gridletSub; + int resourceID[]; + Random random = new Random(5); // a random generator with a random seed + int index; + Gridlet gl; + Integer obj; + int glID; + + // This is because the initial GRIDLET_SUBMIT event, at the beginning + // of sims, does not have any gridlet id. We have to submit + // all the gridlets. + if (ev.get_data() instanceof Integer) + { + obj = (Integer) ev.get_data(); + glID = obj.intValue(); // get the gridlet id. + } + else { + glID = 99; // a value at random, not used at all in this case + } + + while (i < GridletSubmittedList_.size()) + { + gridletSub = (GridletSubmission)GridletSubmittedList_.get(i); + + if ( (gridletSub.getGridlet()).getGridletID() == glID ) + { + // set this gridlet whose id comes with the event as not submitted, + // so that it is submitted as soon as possible. + ((GridletSubmission) GridletSubmittedList_.get(i)).setSubmitted(false); + } + + // Submit the gridlets with the "gridletSub.getSubmitted() == false" + if ( (gridletSub.getSubmitted() == false)) + { + // we have to resubmit this gridlet + gl = ((GridletSubmission) GridletSubmittedList_.get(i)).getGridlet(); + resourceID = getResList(); // Get list of resources from GIS + + // If we have resources in the list + if ((resourceID != null) && (resourceID.length != 0)) + { + index = random.nextInt(resourceID.length); + + // make sure the gridlet will be executed from the begining + resetGridlet(gl); + + // submits this gridlet to a resource + super.gridletSubmit(gl, resourceID[index]); + gridletSubmissionTime[gl.getGridletID()] = GridSim.clock(); + + // set this gridlet as submitted + ((GridletSubmission) GridletSubmittedList_.get(i)).setSubmitted(true); + + if (trace_flag) + { + System.out.println(super.get_name() + + ": Sending Gridlet #" + i + " to " + + GridSim.getEntityName(resourceID[index]) + + " at clock: " + GridSim.clock()); + + // Write into a results file + write(super.get_name(), "Sending", gl.getGridletID(), + GridSim.getEntityName(resourceID[index]), + gl.getGridletStatusString(), GridSim.clock()); + } + + } + // No resources available at this moment, so schedule an event + // in the future. The event wil be in 15 min (900 sec), as + // resource failures may last several hours. + // This event includes the gridletID, so that the user will + // try to submit only this gridlet + else + { + super.send(super.get_id(), GridSimTags.SCHEDULE_NOW + 900, + SUBMIT_GRIDLET, new Integer(gl.getGridletID()) ); + } + + }// if (gridletSub.getSubmitted() == false) + + i++; + } // while (i < GridletSubmittedList_.size()) + + } // processGridletSubmission + + /** + * This functions process the return of a gridlet. + * We pay attention to the status of the gridlet + * and then decide what we have to do the next + * @param ev an incoming event + */ + private void processGridletReturn(Sim_event ev) + { + if (trace_flag) + { + System.out.println(super.get_name() + + ": received an GRIDLET_RETURN event. Clock: " + GridSim.clock()); + } + + Object obj = (Object) ev.get_data(); + Gridlet gl = null; + Random random = new Random(5); // a random generator with a random seed + + if (obj instanceof Gridlet) + { + gl = (Gridlet) obj; + gridletLatencyTime[gl.getGridletID()] = GridSim.clock(); + + // Write into a results file + if (trace_flag) + { + write(super.get_name(), "Receiving", gl.getGridletID(), + GridSim.getEntityName(gl.getResourceID()), + gl.getGridletStatusString(), GridSim.clock()); + } + + ///////////////////////// Gridlet Success + if (gl.getGridletStatusString().compareTo("Success") == 0) + { + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + " with status Success at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID())); + + this.GridletReceiveList_.add(gl); // add into the received list + gridletLatencyTime[gl.getGridletID()] = + gridletLatencyTime[gl.getGridletID()] - + gridletSubmissionTime[gl.getGridletID()]; + + // We have received all the gridlets. So, finish the simulation. + if (GridletReceiveList_.size() == GridletSubmittedList_.size()) + { + super.finishSimulation(); + } + + } // if (gl.getGridletStatusString() == "Success") + + //////////////////////// Gridlet Failed + else if (gl.getGridletStatusString().compareTo("Failed") == 0) + { + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + " with status Failed at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID())); + + // Send the gridlet as soon as we have resources available. + // This gridlet will be resend as soon as possible, + // in the first loop. + int pos = findGridletInGridletSubmittedList(gl); + if (pos == -1) { + System.out.println(super.get_name() + + ". Gridlet not found in GridletSubmittedList."); + } + else + { + // set this gridlet as submitted, because otherwise + // this gridlet may be submitted several times. + // A gridlet will only be submitted when the event carrying + // its id reaches the user + ((GridletSubmission) GridletSubmittedList_.get(pos)).setSubmitted(true); + + // Now, schedule an event to itself to submit the gridlet + // The gridlet will be sent as soon as possible + Integer glID_Int = new Integer(gl.getGridletID()); + + // This event includes the gridletID, so that the user + // will try to submit only this gridlet + super.send(super.get_id(), GridSimTags.SCHEDULE_NOW, + SUBMIT_GRIDLET, glID_Int); + } + } // if (gl.getGridletStatusString() == "Failed") + + ////////////////////////////// Gridlet Failed_resource + else if (gl.getGridletStatusString().compareTo("Failed_resource_unavailable") == 0) + { + int pos = findGridletInGridletSubmittedList(gl); + if (pos == -1) { + System.out.println(super.get_name() + + ". Gridlet not found in GridletSubmittedList."); + } + else + { + // Now, set its submission time for a random time between + // 1 and the polling time + double resubmissionTime = random.nextDouble() * pollingTime_; + + // this is to prevent the gridlet from being submitted + // before its resubmission time. + // This is different from the FAILED case, because + // in that case, the gridlet should be resubmited as soon + // as possible. As oppossed to that, this gridlet should + // not be resubmited before its resubmission time. + ((GridletSubmission) GridletSubmittedList_.get(pos)).setSubmitted(true); + + + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + + " with status Failed_resource_unavailable at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID()) + + "(resID: " + gl.getResourceID() + + "). Resubmission time will be: " + + resubmissionTime + GridSim.clock()); + + // Now, we have to inform the GIS about this failure, so it + // can keep the list of resources up-to-date. + informGIS(gl.getResourceID()); + + // Now, schedule an event to itself to submit the gridlet + Integer glID_Int = new Integer(gl.getGridletID()); + + // This event includes the gridletID, so that the user + // will try to submit only this gridlet + super.send(super.get_id(), resubmissionTime, + SUBMIT_GRIDLET, glID_Int); + } + } // else if + else + { + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + " with status " + + gl.getGridletStatusString() + " at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID()) + + " resID: " + gl.getResourceID()); + } + + } // if (obj instanceof Gridlet) + } + + /** + * Prints the Gridlet objects + * @param list the list of gridlets + * @param name the name of the user + * @param detail if we want the gridlet's history or not + * @param gridletLatencyTime array containing the latencies of gridlets. + * Latencies are from the moment when the gridlet is sent, till + * the moment they are back at the user. + * They take into account the last submission of a gridlet + * (when the gridlet is successfully run) + */ + private void printGridletList(GridletList list, String name, + boolean detail, double gridletLatencyTime[]) + { + int size = list.size(); + Gridlet gridlet = null; + + String indent = " "; + StringBuffer buffer = new StringBuffer(1000); + buffer.append("\n\n============== OUTPUT for " + name + " ==========="); + buffer.append("\nGridlet ID" + indent + "STATUS" + indent + + "Resource ID" + indent + indent + "Cost" + indent + + indent + "CPU Time" + indent + indent + "Latency"); + + // a loop to print the overall result + int i = 0; + boolean header = true; + + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list.get(i); + + buffer.append("\n"); + buffer.append(indent + gridlet.getGridletID() + indent + indent); + buffer.append( gridlet.getGridletStatusString() ); + buffer.append(indent + indent + gridlet.getResourceID() + + indent + gridlet.getProcessingCost() + + indent + gridlet.getActualCPUTime() + + indent + gridletLatencyTime[gridlet.getGridletID()]); + + if (i != 0) { + header = false; + } + + writeFin(name, gridlet.getGridletID(), + GridSim.getEntityName(gridlet.getResourceID()), + gridlet.getProcessingCost(), gridlet.getActualCPUTime(), + GridSim.clock(), header); + } + + if (detail == true) + { + // a loop to print each Gridlet's history + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list.get(i); + + buffer.append( gridlet.getGridletHistory() ); + buffer.append("Gridlet #" + gridlet.getGridletID()); + buffer.append(", length = " + gridlet.getGridletLength() + + ", finished so far = " + + gridlet.getGridletFinishedSoFar()); + buffer.append("==========================================="); + } + } + + buffer.append("\n===================================================="); + System.out.println( buffer.toString() ); + + } + + /** + * This method will show you on how to create Gridlets + * @param userID owner ID of a Gridlet + * @param numGridlet number of Gridlet to be created + */ + private void createGridlet(int userID, int numGridlet) + { + for (int i = 0; i < numGridlet; i++) + { + // Creates a Gridlet + Gridlet gl = new Gridlet(i, gridletLength, gridletInput, gridletOutput); + gl.setUserID(userID); + + // Originally, gridlets are created to be submitted + // as soon as possible (the 0.0 param) + GridletSubmission gst = new GridletSubmission(gl, false); + + // add this gridlet into a list + this.GridletSubmittedList_.add(gst); + } + } + + /** + * Gets a list of received Gridlets + * @return a list of received/completed Gridlets + */ + public GridletList getGridletList() { + return GridletReceiveList_; + } + + /** + * Tells you the possition of this gridlet in the GridletSubmittedList_ + * @param gl the gridlet + * @return the position of this gridlet in the list of submitted gridlets + */ + private int findGridletInGridletSubmittedList(Gridlet gl) + { + Gridlet g = null; + GridletSubmission gst = null; + for (int i = 0; i< GridletSubmittedList_.size(); i++) + { + gst = (GridletSubmission)GridletSubmittedList_.get(i); + g = gst.getGridlet(); + + if ( g.getGridletID() == gl.getGridletID() ) + return i; + } + + return -1; + } + + /** This function resets the gridlet into its original values of + * length and gridletFinishedSoFar + * @param gl the gridlet to be resetted + */ + private void resetGridlet (Gridlet gl) + { + gl.setGridletLength(gridletLength); + gl.setGridletFinishedSoFar(0); + + } + + /** + * Write some data into the final results file. + * @param user user name + * @param glID gridlet id + * @param resName Name of the resource + * @param cost the processing cost of the gridlet + * @param cpu the cpu time + * @param clock Current time + * @param header write a row header or not + * */ + private void writeFin(String user, int glID, String resName, + double cost, double cpu, double clock, + boolean header) + { + if (trace_flag == false) { + return; + } + + // Write into a results file + FileWriter fwriter = null; + try + { + fwriter = new FileWriter(user, true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while opening file " + user); + } + + try + { + if (header == true) { + fwriter.write( + "\n\nGridletID \t Resource \t Cost \t CPU time \t Latency\n"); + } + + fwriter.write(glID + "\t" + resName + "\t" + cost + "\t"+ cpu + + "\t" + + clock + "\n"); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while writing on file " + user); + } + + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while closing file " + user); + } + + } + + /** + * Write some data into a results file. + * @param user user name + * @param event Values: "Sending" or "Receive" a gridlet + * @param glID gridlet id + * @param resName Name of the resource + * @param status Status of the gridlet + * @param clock Current time + */ + private void write(String user, String event, int glID, String resName, + String status, double clock) + { + if (trace_flag == false) { + return; + } + + // Write into a results file + FileWriter fwriter = null; + try + { + fwriter = new FileWriter(super.get_name(), true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while opening file " + super.get_name()); + } + + try + { + fwriter.write(event + "\t\t" + glID + "\t" + resName + "\t" + status + + "\t\t" + clock + "\n"); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while writing on file " + super.get_name()); + } + + + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while closing file " + super.get_name()); + } + + } + + /** + * This function informs the GIS of this user about the failure of a resource + * @param resID the id of the resource which has failed + */ + private void informGIS(int resID) + { + Integer resID_Int = new Integer(resID); + + super.send(super.output, 0.0, AbstractGIS.NOTIFY_GIS_RESOURCE_FAILURE, + new IO_data(resID_Int, Link.DEFAULT_MTU, super.getRegionalGISId()) ); + } + + /** + * Initialize the results files (put headers over each column) + * */ + private void initializeResultsFile() + { + if (trace_flag == false) { + return; + } + + // Initialize the results file + FileWriter fwriter = null; + try + { + fwriter = new FileWriter(super.get_name(), true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while opening file " + super.get_name() + + " or " + super.get_name()+"_Fin"); + } + + try + { + fwriter.write( + "Event \t GridletID \t Resource \t GridletStatus \t\t Clock\n"); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while writing on file " + super.get_name()+ + " or " + super.get_name()+"_Fin"); + } + + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while closing file " + super.get_name()+ + " or " + super.get_name()+"_Fin"); + } + } + + /** + * This function retrieves a list of available resources from the GIS. + * @return an array containing the ids of the resources + */ + private int[] getResList() + { + Object[] resList = super.getLocalResourceList(); + int resourceID[] = null; + + // if we have any resource + if ((resList != null) && (resList.length != 0)) + { + resourceID = new int[resList.length]; + for (int x = 0; x < resList.length; x++) + { + // Resource list contains list of resource IDs + resourceID[x] = ((Integer) resList[x]).intValue(); + + if (trace_flag == true) + { + System.out.println(super.get_name() + + ": resource[" + x + "] = " + resourceID[x]); + } + } + + } + + return resourceID; + } + +} // end class Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/GridletSubmission.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/GridletSubmission.java (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/GridletSubmission.java 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,54 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + + +import gridsim.Gridlet; + +/** + * This class is just a wrapper to denote + * whether this gridlet has been already submitted or not + * @author Agustin Caminero and Anthony Sulistio + * @since GridSim Toolkit 4.1 + */ +public class GridletSubmission +{ + private Gridlet gl; + private boolean submitted; + + + public GridletSubmission(Gridlet gl,boolean submitted) + { + this.gl = gl; + this.submitted = submitted; + } + + public Gridlet getGridlet() + { + return gl; + } + + public boolean getSubmitted() + { + return submitted; + } + + public void setGridlet(Gridlet g) + { + this.gl = g; + } + + public void setSubmitted(boolean submitted) + { + this.submitted = submitted; + } + +} // end class Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/README.txt =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/README.txt (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/README.txt 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,67 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + +Welcome to the example of how to use the computing resource failure functionality +To compile the example source code: + In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx01.java + In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx01.java + +where $GRIDSIM or %GRIDSIM% is the location of the gridsimtoolkit package. + + +To run the class file: +In Unix/Linux: + java -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx02 network_ex02.txt > file.txt + +In Windows: + java -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx02 network_ex02.txt > file.txt + + +The above command means run the program and output the results into a file +named "file.txt" rather than into screen or standard output. +To prevent from overwriting an existing file, +I renamed "file.txt" into "output.txt" + +NOTE: This example uses probabilistic distributions and random variables. + Hence, when running this example many times, the values will be different. + + +When running the example file, it will produce the following files: + + sim_trace -> created by the SimJava2 package (lower-level) to trace every + events (performed by SimJava and GridSim) during the simulation. + We don't need to worry about this file. Not to important for our + example. + + sim_report -> created by the SimJava2 package (lower-level) of GridSim. + This is a simulation report that contains general information about + running this experiment. We don't need to worry about this file. + Not to important for our example. + + Ex02_Regional_GIS -> contains one line describing each + registering/removing an event that takes place at the GIS. Resources + register in the begining of simulations, and after recovering from a + failure affecting all their machines. Resources will be removed when + they suffer a failure affecting all their machines. + + Ex02_Res_0, ... , Ex01_Res_5 -> records when the resource + suffers a failure and when it recovers from the failure. It also records + how many machines failed, and the time of the fail/recovery. + + Ex02_User_0 -> contains one line for each event regarding to the Gridlets. + These events are the sending/reception of a gridlet, and + each line include the status of the gridlet, time and resource. + Then, when a simulation ends, this file shows the resource + a Gridlet has been executed, its cost, CPU time and total latency. + +NOTE: When you run the program multiple times, the new statistics will be + appended at the end of a file. Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/ResFailureEx02.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/ResFailureEx02.java (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/ResFailureEx02.java 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,334 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + +import gridsim.resFailure.*; +import gridsim.*; +import gridsim.net.*; +import java.util.*; +import gridsim.util.NetworkReader; +import gridsim.util.HyperExponential; + + +/** + * This example shows a basic topology with 1 user, 3 resources and 1 GIS. + * All of them are connected by a router. + * There is only one VO in this example. + * @author Agustin Caminero and Anthony Sulistio + * @since GridSim Toolkit 4.1 + */ +public class ResFailureEx02 +{ + public static void main(String[] args) + { + System.out.println("Starting failure example 2..."); + + try + { + if (args.length < 1) + { + System.out.println("Usage: java ResFailureEx02 network_ex02.txt"); + return; + } + + + ////////////////////////////////////////// + // First step: 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 a run-time exception + // error. + + // a flag that denotes whether to trace GridSim events or not. + boolean trace_flag = false; // dont use SimJava trace + int num_user = 20; // number of grid users + Calendar calendar = Calendar.getInstance(); + + // Initialize the GridSim package + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + trace_flag = true; + + + ////////////////////////////////////////// + // Second step: Builds the network topology among Routers. + + String filename = args[0]; // get the network topology + System.out.println("Reading network from " + filename); + LinkedList routerList = NetworkReader.createFIFO(filename); + + + ////////////////////////////////////////// + // Third step: Creates one RegionalGISWithFailure entity, + // linked to a router in the topology + + Router router = null; + double baud_rate = 100000000; // 100Mbps, i.e. baud rate of links + double propDelay = 10; // propagation delay in milliseconds + int mtu = 1500; // max. transmission unit in byte + int totalMachines = 16; // num of machines each resource has + + String NAME = "Ex01_"; // a common name + String gisName = NAME + "Regional_GIS"; // GIS name + + // a network link attached to this regional GIS entity + Link link = new SimpleLink(gisName + "_link", baud_rate, + propDelay, mtu); + + + // HyperExponential: mean, standard deviation, stream + // how many resources will fail + HyperExponential failureNumResPattern = + new HyperExponential(totalMachines / 2, totalMachines, 4); + + // when they will fail + HyperExponential failureTimePattern = + new HyperExponential(25, 100, 4); + + // how long the failure will be + HyperExponential failureLengthPattern = + new HyperExponential(20, 25, 4); // big test: (20, 100, 4); + + + // creates a new Regional GIS entity that generates a resource + // failure message according to these patterns. + RegionalGISWithFailure gis = new RegionalGISWithFailure(gisName, + link, failureNumResPattern, failureTimePattern, + failureLengthPattern); + gis.setTrace(trace_flag); // record this GIS activity + + // link these GIS to a router + router = NetworkReader.getRouter("Router0", routerList); + linkNetwork(router, gis); + + // print some info messages + System.out.println("Created a REGIONAL GIS with name " + gisName + + " and id = " + gis.get_id() + ", connected to " + + router.get_name() ); + + + ////////////////////////////////////////// + // Fourth step: Creates one or more GridResourceWithFailure + // entities, linked to a router in the topology + + String sched_alg = "SPACE"; // use space-shared policy + int totalResource = 6; // number of resources + ArrayList resList = new ArrayList(totalResource); + + // Each resource may have different baud rate, + // totalMachine, rating, allocation policy and the router to + // which it will be connected. However, in this example, we assume + // all have the same properties for simplicity. + int totalPE = 4; // num of PEs each machine has + int rating = 49000; // rating (MIPS) of PEs + int GB = 1000000000; // 1 GB in bits + baud_rate = 2.5 * GB; + + for (int i = 0; i < totalResource; i++) + { + // gets the router object from the list + router = NetworkReader.getRouter("Router0", routerList); + + // creates a new grid resource + String resName = NAME + "Res_" + i; + GridResourceWithFailure res = createGridResource(resName, + baud_rate, propDelay, mtu, totalPE, totalMachines, + rating, sched_alg); + + // add a resource into a list + resList.add(res); + res.setRegionalGIS(gis); // set the regional GIS entity + res.setTrace(trace_flag); // record this resource activity + + // link a resource to this router object + linkNetwork(router, res); + + System.out.println("Created a RESOURCE (" + totalMachines + + " machines, each with " + totalPE + " PEs) with name = " + + resName + " and id = " + res.get_id() + + ", connected to router " + router.get_name() + + " and registered to " + gis.get_name() ); + } + + + ////////////////////////////////////////// + // Fifth step: Creates one or more GridUserFailure entities, + // linked to a router of the topology + + int totalGridlet = 5; // total jobs + double pollTime = 100; // time between polls + int glSize = 100000; // the size of gridlets (input/output) + int glLength = 42000000; // the length (MI) of gridlets + + // gets the router object from the list + router = NetworkReader.getRouter("Router0", routerList); + + for (int i = 0; i < num_user; i++) + { + String userName = NAME + "User_" + i; + + // a network link attached to this entity + Link link2 = new SimpleLink(userName + "_link", baud_rate, + propDelay, mtu); + + // only keeps track activities from User_0 + if (i != 0) { + trace_flag = false; + } + + GridUserFailureEx02 user = new GridUserFailureEx02(userName, link2, + pollTime, glLength, glSize, glSize, trace_flag); + + user.setRegionalGIS(gis); // set the regional GIS entity + user.setGridletNumber(totalGridlet); + + // link a resource to this router object + linkNetwork(router, user); + + System.out.println("Created a USER with name " + userName + + " and id = " + user.get_id() + ", connected to " + + router.get_name() + ", and with " + totalGridlet + + " gridlets. Registered to " + gis.get_name() ); + } + System.out.println(); + + ////////////////////////////////////////// + // Sixth step: Starts the simulation + GridSim.startGridSimulation(); + System.out.println("\nFinish failure example 2... \n"); + } + catch (Exception e) + { + e.printStackTrace(); + System.out.println("Unwanted errors happen"); + } + } + + /** + * Links a particular entity with a given Router. + * + * @param router a Router object + * @param obj a GridSim entity to be attached to the Router + */ + private static void linkNetwork(Router router, GridSimCore obj) throws Exception + { + if (router == null) { + System.out.println("Error - router is NULL."); + return; + } + + // get the baud rate of a link + double baud_rate = obj.getLink().getBaudRate(); + + // create the packet scheduler for this link + PacketScheduler pktObj = new FIFOScheduler(router.get_name() + + "_to_" + obj.get_name() ); + + // attach this GridSim entity to a Router + router.attachHost(obj, pktObj); + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * <p> + * In this simple example, we are simulating one Grid resource with three + * Machines that contains one or more PEs. + * + * @param name a Grid Resource name + * @param baud_rate the bandwidth of this entity + * @param delay the propagation delay + * @param MTU Maximum Transmission Unit + * @param totalPE number of PE per machine + * @param totalMachine number of machines in this resources + * @param rating rating of mahcines in this resource + * @param sched_alg the scheduling algorithm of this resource + * @return a GridResource object + */ + private static GridResourceWithFailure createGridResource(String name, + double baud_rate, double delay, int MTU, int totalPE, + int totalMachine, int rating, String sched_alg) + { + // 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++) + { + // 2. A Machine contains one or more PEs or CPUs. Therefore, should + // create an object of PEList to store these PEs before creating + // a Machine. + PEList peList = new PEList(); + + // 3. Create PEs and add these into an object of PEList. + for (int k = 0; k < totalPE; k++) + { + // need to store PE id and MIPS Rating + peList.add( new PE(k, rating) ); + } + + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, peList) ); + } + + + // 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 = 9.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // we create Space_Shared_failure or Time_Shared_failure schedulers + int scheduling_alg = 0; // space_shared or time_shared + if (sched_alg.equals("SPACE") == true) { + scheduling_alg = ResourceCharacteristics.SPACE_SHARED; + } + else if (sched_alg.equals("TIME") == true) { + scheduling_alg = ResourceCharacteristics.TIME_SHARED; + } + + ResourceCharacteristics resConfig = new ResourceCharacteristics( + arch, os, mList, scheduling_alg, time_zone, cost); + + + // 6. Finally, we need to create a GridResource object. + 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(); + GridResourceWithFailure gridRes = null; + try + { + // creates a GridResource with a link + gridRes = new GridResourceWithFailure(name, + new SimpleLink(name + "_link", baud_rate, delay, MTU), + seed, resConfig, peakLoad, offPeakLoad, holidayLoad, + Weekends, Holidays); + } + catch (Exception e) { + e.printStackTrace(); + } + + return gridRes; + } + +} // end class Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/network_ex02.txt =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/network_ex02.txt (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/network_ex02.txt 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,15 @@ +# The topology of this example is as follows (with 20 users and 6 resources) +# +# user --- Router0 ---- Resource0 +# +# total number of Routers +1 + +# specifies each router name and whether to log its activities or not +# by default no logging is required +Router0 + +# specify the link between two Routers +# The format is: +# Router_name1 Router_name2 baud_rate(GB/s) prop_delay(ms) mtu(byte) + Added: branches/gridsim4.0-branch1/examples/ResFailureEx02/output.txt =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx02/output.txt (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx02/output.txt 2007-08-29 02:22:54 UTC (rev 42) @@ -0,0 +1,628 @@ +Starting failure example 2... +Initializing GridSim package +Initialising... +Reading network from network_ex02.txt +Created a REGIONAL GIS with name Ex01_Regional_GIS and id = 6, connected to Router0 +Created a RESOURCE (16 machines, each with 4 PEs) with name = Ex01_Res_0 and id = 10, connected to router Router0 and registered to Ex01_Regional_GIS +Created a RESOURCE (16 machines, each with 4 PEs) with name = Ex01_Res_1 and id = 15, connected to router Router0 and registered to Ex01_Regional_GIS +Created a RESOURCE (16 machines, each with 4 PEs) with name = Ex01_Res_2 and id = 20, connected to router Router0 and registered to Ex01_Regional_GIS +Created a RESOURCE (16 machines, each with 4 PEs) with name = Ex01_Res_3 and id = 25, connected to router Router0 and registered to Ex01_Regional_GIS +Created a RESOURCE (16 machines, each with 4 PEs) with name = Ex01_Res_4 and id = 30, connected to router Router0 and registered to Ex01_Regional_GIS +Created a RESOURCE (16 machines, each with 4 PEs) with name = Ex01_Res_5 and id = 35, connected to router Router0 and registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_0 and id = 40, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_1 and id = 44, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_2 and id = 48, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_3 and id = 52, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_4 and id = 56, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_5 and id = 60, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_6 and id = 64, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_7 and id = 68, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_8 and id = 72, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_9 and id = 76, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_10 and id = 80, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_11 and id = 84, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_12 and id = 88, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_13 and id = 92, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_14 and id = 96, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_15 and id = 100, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_16 and id = 104, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_17 and id = 108, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_18 and id = 112, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS +Created a USER with name Ex01_User_19 and id = 116, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS + +Starting GridSim version 4.0 +Entities started. +Ex01_User_17: initial SUBMIT_GRIDLET event will be at clock: 218. Current clock: 0.0 +Ex01_User_1: initial SUBMIT_GRIDLET event will be at clock: 12. Current clock: 0.0 +Ex01_User_10: initial SUBMIT_GRIDLET event will be at clock: 197. Current clock: 0.0 +Ex01_User_0: initial SUBMIT_GRIDLET event will be at clock: 194. Current clock: 0.0 +Ex01_User_3: initial SUBMIT_GRIDLET event will be at clock: 173. Current clock: 0.0 +Ex01_User_6: initial SUBMIT_GRIDLET event will be at clock: 112. Current clock: 0.0 +Ex01_User_2: initial SUBMIT_GRIDLET event will be at clock: 132. Current clock: 0.0 +Ex01_User_7: initial SUBMIT_GRIDLET event will be at clock: 197. Current clock: 0.0 +Ex01_User_11: initial SUBMIT_GRIDLET event will be at clock: 158. Current clock: 0.0 +Ex01_User_8: initial SUBMIT_GRIDLET event will be at clock: 50. Current clock: 0.0 +Ex01_User_16: initial SUBMIT_GRIDLET event will be at clock: 253. Current clock: 0.0 +Ex01_User_14: initial SUBMIT_GRIDLET event will be at clock: 159. Current clock: 0.0 +Ex01_User_15: initial SUBMIT_GRIDLET event will be at clock: 238. Current clock: 0.0 +Ex01_User_19: initial SUBMIT_GRIDLET event will be at clock: 7. Current clock: 0.0 +Ex01_User_5: initial SUBMIT_GRIDLET event will be at clock: 98. Current clock: 0.0 +Ex01_User_13: initial SUBMIT_GRIDLET event wi... [truncated message content] |
From: <sul...@us...> - 2007-08-29 02:16:53
|
Revision: 41 http://gridsim.svn.sourceforge.net/gridsim/?rev=41&view=rev Author: sulistio Date: 2007-08-28 19:16:53 -0700 (Tue, 28 Aug 2007) Log Message: ----------- fix few bugs regarding to writing an event to a file. Modified Paths: -------------- branches/gridsim4.0-branch1/examples/ResFailureEx01/GridUserFailureEx01.java Modified: branches/gridsim4.0-branch1/examples/ResFailureEx01/GridUserFailureEx01.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/GridUserFailureEx01.java 2007-08-29 01:28:04 UTC (rev 40) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/GridUserFailureEx01.java 2007-08-29 02:16:53 UTC (rev 41) @@ -423,7 +423,7 @@ * They take into account the last submission of a gridlet * (when the gridlet is successfully run) */ - private static void printGridletList(GridletList list, String name, + private void printGridletList(GridletList list, String name, boolean detail, double gridletLatencyTime[]) { int size = list.size(); @@ -552,10 +552,14 @@ * @param cost the processing cost of the gridlet * @param cpu the cpu time * @param clock Current time - * */ - private static void writeFin(String user, int glID, String resName, + */ + private void writeFin(String user, int glID, String resName, double cost, double cpu, double clock) { + if (trace_flag == false) { + return; + } + // Write into a results file FileWriter fwriter = null; try @@ -603,6 +607,10 @@ private void write(String user, String event, int glID, String resName, String status, double clock) { + if (trace_flag == false) { + return; + } + // Write into a results file FileWriter fwriter = null; try This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-29 01:28:04
|
Revision: 40 http://gridsim.svn.sourceforge.net/gridsim/?rev=40&view=rev Author: sulistio Date: 2007-08-28 18:28:04 -0700 (Tue, 28 Aug 2007) Log Message: ----------- a minor update Modified Paths: -------------- branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java Modified: branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java 2007-08-29 01:14:15 UTC (rev 39) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java 2007-08-29 01:28:04 UTC (rev 40) @@ -177,8 +177,6 @@ GridUserFailureEx01 user = new GridUserFailureEx01(userName, link2, pollTime, glLength, glSize, glSize, trace_flag); - // The last parameter is the GIS this user will use to get resources - // for his gridlets user.setRegionalGIS(gis); // set the regional GIS entity user.setGridletNumber(totalGridlet); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-29 01:14:15
|
Revision: 39 http://gridsim.svn.sourceforge.net/gridsim/?rev=39&view=rev Author: sulistio Date: 2007-08-28 18:14:15 -0700 (Tue, 28 Aug 2007) Log Message: ----------- add the output of this example. Added Paths: ----------- branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Regional_GIS branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Res_0 branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Res_1 branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Res_2 branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_User0 branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_User0_Fin branches/gridsim4.0-branch1/examples/ResFailureEx01/output.txt Added: branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Regional_GIS =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Regional_GIS (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Regional_GIS 2007-08-29 01:14:15 UTC (rev 39) @@ -0,0 +1,4 @@ +Event ResourceID Clock +Registering 10 10.020000998399999 +Registering 15 10.030000998399998 +Registering 20 10.040000998399998 Added: branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Res_0 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Res_0 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Res_0 2007-08-29 01:14:15 UTC (rev 39) @@ -0,0 +1 @@ +Event NumMachines Clock Added: branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Res_1 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Res_1 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Res_1 2007-08-29 01:14:15 UTC (rev 39) @@ -0,0 +1,2 @@ +Event NumMachines Clock +Failure 3 31.205408168820174 Added: branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Res_2 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Res_2 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_Res_2 2007-08-29 01:14:15 UTC (rev 39) @@ -0,0 +1 @@ +Event NumMachines Clock Added: branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_User0 =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_User0 (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_User0 2007-08-29 01:14:15 UTC (rev 39) @@ -0,0 +1,11 @@ +User Event GridletID Resource GridletStatus Clock +Ex01_User0 Sending 0 Ex01_Res_2 Created 374.04012479999994 +Ex01_User0 Sending 1 Ex01_Res_1 Created 374.77037439999924 +Ex01_User0 Sending 2 Ex01_Res_2 Created 375.50062399999854 +Ex01_User0 Sending 3 Ex01_Res_2 Created 376.23087359999784 +Ex01_User0 Sending 4 Ex01_Res_0 Created 376.96112319999713 +Ex01_User0 Receiving 0 Ex01_Res_2 Success 1233.4001439999986 +Ex01_User0 Receiving 1 Ex01_Res_1 Success 1234.130393599998 +Ex01_User0 Receiving 2 Ex01_Res_2 Success 1234.8606431999972 +Ex01_User0 Receiving 3 Ex01_Res_2 Success 1235.5306431999966 +Ex01_User0 Receiving 4 Ex01_Res_0 Success 1236.3211423999958 Added: branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_User0_Fin =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_User0_Fin (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/Ex01_User0_Fin 2007-08-29 01:14:15 UTC (rev 39) @@ -0,0 +1,6 @@ +User GridletID Resource Cost CPU time Latency +Ex01_User0 0 Ex01_Res_2 2574.0 858.0 245555.1188510172 +Ex01_User0 1 Ex01_Res_1 2574.0 858.0 245555.1188510172 +Ex01_User0 2 Ex01_Res_2 2574.0 858.0 245555.1188510172 +Ex01_User0 3 Ex01_Res_2 2571.809251200002 857.2697504000007 245555.1188510172 +Ex01_User0 4 Ex01_Res_0 2574.0 858.0 245555.1188510172 Added: branches/gridsim4.0-branch1/examples/ResFailureEx01/output.txt =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/output.txt (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/output.txt 2007-08-29 01:14:15 UTC (rev 39) @@ -0,0 +1,96 @@ +Starting failure example 1... +Initializing GridSim package +Initialising... +Reading network from network_ex01.txt +Created a REGIONAL GIS with name Ex01_Regional_GIS and id = 6, connected to Router0 +Created a RESOURCE (10 machines, each with 4 PEs) with name = Ex01_Res_0 and id = 10, connected to router Router0 and registered to Ex01_Regional_GIS +Created a RESOURCE (10 machines, each with 4 PEs) with name = Ex01_Res_1 and id = 15, connected to router Router0 and registered to Ex01_Regional_GIS +Created a RESOURCE (10 machines, each with 4 PEs) with name = Ex01_Res_2 and id = 20, connected to router Router0 and registered to Ex01_Regional_GIS +Created a USER with name Ex01_User0 and id = 25, connected to Router0, and with 5 gridlets. Registered to Ex01_Regional_GIS + +Starting GridSim version 4.0 +Entities started. +Ex01_Regional_GIS: sends an autogenerated GRIDRESOURCE_FAILURE to itself. Clock(): 0.0. resTimeFail: 20.918443148412194 seconds +Ex01_User0: initial SUBMIT_GRIDLET event will be at clock: 294. Current clock: 0.0 +Ex01_Res_1.body(): wait for 10 seconds before registering to Ex01_Regional_GIS +Ex01_Res_0.body(): wait for 10 seconds before registering to Ex01_Regional_GIS +Ex01_Res_2.body(): wait for 10 seconds before registering to Ex01_Regional_GIS + +Ex01_Regional_GIS: registering Ex01_Res_0 +Ex01_Regional_GIS: list[0] = Ex01_Res_0 + + +Ex01_Regional_GIS: registering Ex01_Res_1 +Ex01_Regional_GIS: list[0] = Ex01_Res_0 +Ex01_Regional_GIS: list[1] = Ex01_Res_1 + + +Ex01_Regional_GIS: registering Ex01_Res_2 +Ex01_Regional_GIS: list[0] = Ex01_Res_0 +Ex01_Regional_GIS: list[1] = Ex01_Res_1 +Ex01_Regional_GIS: list[2] = Ex01_Res_2 + +Ex01_Regional_GIS: 3 resources will fail in this simulation. Num of failed machines on each resource will be decided later +Ex01_Regional_GIS: sends an autogenerated GRIDRESOURCE_FAILURE to itself. Clock: 20.918443148412194, resTimeFail: 9.29564320636208 seconds +Ex01_Regional_GIS: sends an autogenerated GRIDRESOURCE_FAILURE to itself. Clock: 20.918443148412194, resTimeFail: 10.226805942007969 seconds +Ex01_Regional_GIS: sends an autogenerated GRIDRESOURCE_FAILURE to itself. Clock: 20.918443148412194, resTimeFail: 9.592465799264474 seconds +Ex01_Regional_GIS: sends a GRIDRESOURCE_FAILURE event to the resource Ex01_Res_1. numMachFailed: 3. Clock: 31.185283368820173. Fail duration: 68.2010926576801 hours. Some machines may still work or may not. +Ex01_Res_1.processFailure(): receives an event GRIDRESOURCE_FAILURE. Clock: 31.205408168820174. There are STILL working machines in this resource. +Ex01_Res_1 - Machine: 0 is set to FAILED +Ex01_Res_1 - Machine: 0 is FAILED +Ex01_Res_1 - Machine: 1 is set to FAILED +Ex01_Res_1 - Machine: 1 is FAILED +Ex01_Res_1 - Machine: 2 is set to FAILED +Ex01_Res_1 - Machine: 2 is FAILED +Ex01_User0: received an SUBMIT_GRIDLET event. Clock: 294.0 +Ex01_User0: resource[0] = 10 +Ex01_User0: resource[1] = 15 +Ex01_User0: resource[2] = 20 +Ex01_User0: Sending Gridlet #0 to Ex01_Res_2 at clock: 374.04012479999994 +Ex01_User0: resource[0] = 10 +Ex01_User0: resource[1] = 15 +Ex01_User0: resource[2] = 20 +Ex01_User0: Sending Gridlet #1 to Ex01_Res_1 at clock: 374.77037439999924 +Ex01_User0: resource[0] = 10 +Ex01_User0: resource[1] = 15 +Ex01_User0: resource[2] = 20 +Ex01_User0: Sending Gridlet #2 to Ex01_Res_2 at clock: 375.50062399999854 +Ex01_User0: resource[0] = 10 +Ex01_User0: resource[1] = 15 +Ex01_User0: resource[2] = 20 +Ex01_User0: Sending Gridlet #3 to Ex01_Res_2 at clock: 376.23087359999784 +Ex01_User0: resource[0] = 10 +Ex01_User0: resource[1] = 15 +Ex01_User0: resource[2] = 20 +Ex01_User0: Sending Gridlet #4 to Ex01_Res_0 at clock: 376.96112319999713 +Ex01_User0: received an GRIDLET_RETURN event. Clock: 1233.4001439999986 +Ex01_User0: Receiving Gridlet #0 with status Success at time = 1233.4001439999986 from resource Ex01_Res_2 +Ex01_User0: received an GRIDLET_RETURN event. Clock: 1234.130393599998 +Ex01_User0: Receiving Gridlet #1 with status Success at time = 1234.130393599998 from resource Ex01_Res_1 +Ex01_User0: received an GRIDLET_RETURN event. Clock: 1234.8606431999972 +Ex01_User0: Receiving Gridlet #2 with status Success at time = 1234.8606431999972 from resource Ex01_Res_2 +Ex01_User0: received an GRIDLET_RETURN event. Clock: 1235.5306431999966 +Ex01_User0: Receiving Gridlet #3 with status Success at time = 1235.5306431999966 from resource Ex01_Res_2 +Ex01_User0: received an GRIDLET_RETURN event. Clock: 1236.3211423999958 +Ex01_User0: Receiving Gridlet #4 with status Success at time = 1236.3211423999958 from resource Ex01_Res_0 +GridInformationService: Notify all GridSim entities for shutting down. +Ex01_Res_1: end of simulation... +Ex01_Res_0: end of simulation... +Ex01_Res_2: end of simulation... +Sim_system: No more future events +Gathering simulation data. + +============== Ex01_User0. Ending simulation... + +============= OUTPUT for Ex01_User0 ========== +Gridlet ID STATUS Resource ID Cost CPU Time Latency + 0 Success 20 2574.0 858.0 859.3600191999986 + 1 Success 15 2574.0 858.0 859.3600191999986 + 2 Success 20 2574.0 858.0 859.3600191999986 + 3 Success 20 2571.809251200002 857.2697504000007 859.2997695999987 + 4 Success 10 2574.0 858.0 859.3600191999986 +================================================= +Simulation completed. + +Finish failure example 1... + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-29 01:09:43
|
Revision: 38 http://gridsim.svn.sourceforge.net/gridsim/?rev=38&view=rev Author: sulistio Date: 2007-08-28 18:09:42 -0700 (Tue, 28 Aug 2007) Log Message: ----------- finalize this example description. Modified Paths: -------------- branches/gridsim4.0-branch1/examples/ResFailureEx01/GridUserFailureEx01.java branches/gridsim4.0-branch1/examples/ResFailureEx01/README.txt branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java Modified: branches/gridsim4.0-branch1/examples/ResFailureEx01/GridUserFailureEx01.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/GridUserFailureEx01.java 2007-08-29 01:01:34 UTC (rev 37) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/GridUserFailureEx01.java 2007-08-29 01:09:42 UTC (rev 38) @@ -94,38 +94,9 @@ gridletLatencyTime = new double[NUM_GRIDLETS]; } - /** - * This function retrieves a list of available resources from the GIS. - * @return an array containing the ids of the resources - */ - private int[] getResList() - { - Object[] resList = super.getLocalResourceList(); - int resourceID[] = null; - - // if we have any resource - if ((resList != null) && (resList.length != 0)) - { - resourceID = new int[resList.length]; - for (int x = 0; x < resList.length; x++) - { - // Resource list contains list of resource IDs - resourceID[x] = ((Integer) resList[x]).intValue(); - - if (trace_flag == true) - { - System.out.println(super.get_name() + - ": resource[" + x + "] = " + resourceID[x]); - } - } - - } - - return resourceID; - } - /** * Handles incoming requests to this entity. + * This method specifies the behaviours and/or scenarios of a user. */ public void body() { @@ -185,6 +156,7 @@ gridletLatencyTime); } // body() + ///////////////////////////////////////////////////////////////////////// /** * This functions process the submission of a gridlet. We have to get the @@ -295,7 +267,6 @@ } // processGridletSubmission - /** * This functions process the return of a gridlet. * We pay attention to the status of the gridlet @@ -733,4 +704,34 @@ } } + /** + * This function retrieves a list of available resources from the GIS. + * @return an array containing the ids of the resources + */ + private int[] getResList() + { + Object[] resList = super.getLocalResourceList(); + int resourceID[] = null; + + // if we have any resource + if ((resList != null) && (resList.length != 0)) + { + resourceID = new int[resList.length]; + for (int x = 0; x < resList.length; x++) + { + // Resource list contains list of resource IDs + resourceID[x] = ((Integer) resList[x]).intValue(); + + if (trace_flag == true) + { + System.out.println(super.get_name() + + ": resource[" + x + "] = " + resourceID[x]); + } + } + + } + + return resourceID; + } + } // end class Modified: branches/gridsim4.0-branch1/examples/ResFailureEx01/README.txt =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/README.txt 2007-08-29 01:01:34 UTC (rev 37) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/README.txt 2007-08-29 01:09:42 UTC (rev 38) @@ -1,68 +1,69 @@ -/* - * Title: GridSim Toolkit - * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation - * of Parallel and Distributed Systems such as Clusters and Grids - * An example of how to use the failure functionality. - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html - * - * Author: Agustin Caminero and Anthony Sulistio - * Organization: UCLM (Spain) - * Created on: August 2007 - */ - -Welcome to the example of how to use the computing resource failure functionality -To compile the example source code: - In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx01.java - In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx01.java - -where $GRIDSIM or %GRIDSIM% is the location of the gridsimtoolkit package. - - -To run the class file: - In Unix/Linux: - java -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx01 network_ex01.txt > file.txt - - In Windows: - java -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx01 network_ex01.txt > file.txt - - -The above command means run the program and output the results into a file -named "file.txt" rather than into screen or standard output. -To prevent from overwriting an existing file, I renamed "file.txt" into -"output.txt" -NOTE: This example uses Java Random class to select a resource and user entity - to communicate to a regional GIS entity. - Hence, when running this example many times, the values will be different. - - -When running the example file, it will produce the following files: - - sim_trace -> created by the SimJava2 package (lower-level) to trace every - events (performed by SimJava and GridSim) during the simulation. - We don't need to worry about this file. Not to important for our - example. - - sim_report -> created by the SimJava2 package (lower-level) of GridSim. - This is a simulation report that contains general information about - running this experiment. We don't need to worry about this file. - Not to important for our example. - - Ex01_Regional_GIS -> contains one line describing each - registering/removing event that takes place at the GIS. Resources will - register at the begining of simulations, and after recovering from a - failure affecting all their machines. Resources will be removed when - they suffer a failure affecting all their machines. - - Ex01_Res_0, Ex01_Res_1, Ex01_Res_2: these files record when a resource suffers a failure - and when it recovers from the failure. They also say how many machines - failed, and the time of the fail/recovery. - - Ex01_User0: contains one line for each event regarding to the gridlets. - These events are the sending/reception of a gridlet, and each line include the status of the gridlet, - time, resource and VO. In this example we only have 1 VO. - - Ex01_User0_Fin: contains one line for each gridlet, showing the resource - it has been executed, its cost, CPU time and total latency. - -NOTE: When you run the program multiple times, all existing files will be overwritten. - +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + +Welcome to the example of how to use the computing resource failure functionality +To compile the example source code: + In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx01.java + In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx01.java + +where $GRIDSIM or %GRIDSIM% is the location of the gridsimtoolkit package. + + +To run the class file: +In Unix/Linux: + java -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx01 network_ex01.txt > file.txt + +In Windows: + java -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx01 network_ex01.txt > file.txt + + +The above command means run the program and output the results into a file +named "file.txt" rather than into screen or standard output. +To prevent from overwriting an existing file, +I renamed "file.txt" into "output.txt" + +NOTE: This example uses probabilistic distributions and random variables. + Hence, when running this example many times, the values will be different. + + +When running the example file, it will produce the following files: + + sim_trace -> created by the SimJava2 package (lower-level) to trace every + events (performed by SimJava and GridSim) during the simulation. + We don't need to worry about this file. Not to important for our + example. + + sim_report -> created by the SimJava2 package (lower-level) of GridSim. + This is a simulation report that contains general information about + running this experiment. We don't need to worry about this file. + Not to important for our example. + + Ex01_Regional_GIS -> contains one line describing each + registering/removing an event that takes place at the GIS. Resources + register in the begining of simulations, and after recovering from a + failure affecting all their machines. Resources will be removed when + they suffer a failure affecting all their machines. + + Ex01_Res_0, Ex01_Res_1, Ex01_Res_2 -> records when the resource + suffers a failure and when it recovers from the failure. It also records + how many machines failed, and the time of the fail/recovery. + + Ex01_User0 -> contains one line for each event regarding to the Gridlets. + These events are the sending/reception of a gridlet, and + each line include the status of the gridlet, + time, resource and VO. In this example we only have 1 VO. + + Ex01_User0_Fin -> contains one line for each gridlet, showing the resource + it has been executed, its cost, CPU time and total latency. + +NOTE: When you run the program multiple times, the new statistics will be + appended at the end of a file. Modified: branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java 2007-08-29 01:01:34 UTC (rev 37) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java 2007-08-29 01:09:42 UTC (rev 38) @@ -39,6 +39,7 @@ return; } + ////////////////////////////////////////// // First step: Initialize the GridSim package. It should be called // before creating any entities. We can't run this example without @@ -55,6 +56,7 @@ GridSim.init(num_user, calendar, trace_flag); trace_flag = true; + ////////////////////////////////////////// // Second step: Builds the network topology among Routers. @@ -99,7 +101,7 @@ // failure message according to these patterns. RegionalGISWithFailure gis = new RegionalGISWithFailure(gisName, link, failureNumResPattern, failureTimePattern, - failureLengthPattern, 0); // TODO: 0 is redundant ? + failureLengthPattern); gis.setTrace(trace_flag); // record this GIS activity // link these GIS to a router @@ -155,6 +157,7 @@ " and registered to " + gis.get_name() ); } + ////////////////////////////////////////// // Fifth step: Creates one GridUserFailure entity, // linked to a router of the topology @@ -245,8 +248,8 @@ * @return a GridResource object */ private static GridResourceWithFailure createGridResource(String name, - double baud_rate, double delay, int MTU, int totalPE, - int totalMachine, int rating, String sched_alg) + double baud_rate, double delay, int MTU, int totalPE, + int totalMachine, int rating, String sched_alg) { // Here are the steps needed to create a Grid resource: // 1. We need to create an object of MachineList to store one or more This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-29 01:01:32
|
Revision: 37 http://gridsim.svn.sourceforge.net/gridsim/?rev=37&view=rev Author: sulistio Date: 2007-08-28 18:01:34 -0700 (Tue, 28 Aug 2007) Log Message: ----------- remove gisID_ attribute, hence fix the constructors. then fix up the writing an event to a file part. Modified Paths: -------------- branches/gridsim4.0-branch1/source/gridsim/resFailure/RegionalGISWithFailure.java Modified: branches/gridsim4.0-branch1/source/gridsim/resFailure/RegionalGISWithFailure.java =================================================================== --- branches/gridsim4.0-branch1/source/gridsim/resFailure/RegionalGISWithFailure.java 2007-08-29 01:00:27 UTC (rev 36) +++ branches/gridsim4.0-branch1/source/gridsim/resFailure/RegionalGISWithFailure.java 2007-08-29 01:01:34 UTC (rev 37) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * Author: Agustin Caminero + * Author: Agustin Caminero and Anthony Sulistio * Organization: Universidad de Castilla La Mancha (UCLM), Spain. * Created on: Nov 2006. */ @@ -36,24 +36,15 @@ * this class and to override {@link #processOtherEvent(Sim_event)} * and/or {@link #registerOtherEntity()} method. * - * @author Agustin Caminero + * @author Agustin Caminero and Anthony Sulistio * @since GridSim Toolkit 4.1 * @see gridsim.index.RegionalGIS */ public class RegionalGISWithFailure extends AbstractGIS { - // for a RegionalGISWithFailure named "RegionalGIS_2", the gisID_ will be 2 - // This is also the number of the VO. - public int gisID_; // TODO: redundant ?? - - - /** This entity ID in <tt>Integer</tt> object. */ protected Integer myID_; - // denotes whether sim has just began or it has been running for some time - private boolean begining; - private ArrayList resList_; // all resources within this region private ArrayList arList_; // AR resources only within this region private ArrayList globalResList_; // all resources outside this region @@ -97,8 +88,11 @@ // a flag to denote whether to record events into a file or not private boolean record_ = false; + // denotes whether sim has just began or it has been running for some time + private boolean begining; + /** * Creates a new regional GIS entity * @param name this regional GIS name @@ -117,11 +111,10 @@ public RegionalGISWithFailure(String name, Link link, DiscreteGenerator failureNumResPattern, DiscreteGenerator failureTimePattern, - DiscreteGenerator failureLengthPattern, int gisID) + DiscreteGenerator failureLengthPattern) throws Exception { super(name, link); - gisID_ = gisID; if (setFailureGenerator(failureNumResPattern, failureTimePattern, failureLengthPattern)) init(); @@ -149,12 +142,10 @@ public RegionalGISWithFailure(String name, Link link, ContinuousGenerator failureNumResPattern, ContinuousGenerator failureTimePattern, - ContinuousGenerator failureLengthPattern, int gisID) + ContinuousGenerator failureLengthPattern) throws Exception { super(name, link); - gisID_ = gisID; - if (setFailureGenerator(failureNumResPattern, failureTimePattern, failureLengthPattern)) init(); @@ -180,13 +171,10 @@ * @post $none */ public RegionalGISWithFailure(String name, Link link, - Variate failureNumResPattern, - Variate failureTimePattern, - Variate failureLengthPattern, int gisID) - throws Exception + Variate failureNumResPattern, Variate failureTimePattern, + Variate failureLengthPattern) throws Exception { super(name, link); - gisID_ = gisID; if (setFailureGenerator(failureNumResPattern, failureTimePattern, failureLengthPattern)) init(); @@ -196,14 +184,19 @@ super.get_name() + " entity"); } - /** + /** * Asks this resource to record its activities. <br> - * NOTE: this method should be called <b>BEFORE</b> the ssimulation starts. + * NOTE: this method should be called <b>BEFORE</b> the simulation starts. + * If an existing file exists, the new activities will be appended at the + * end. The file name is this entity name. + * * @param trace <tt>true</tt> if you want to record this resource's * activities, <tt>false</tt> otherwise */ - public void setTrace(boolean trace) { + public void setTrace(boolean trace) + { record_ = trace; + initializeReportFile(); } /** @@ -563,13 +556,58 @@ /**********/ } + /** + * Initializes the results files (put headers over each column) + */ + private void initializeReportFile() + { + if (record_ == false) { + return; + } + + // Initialize the results file + FileWriter fwriter = null; + try { + fwriter = new FileWriter(super.get_name(), true); + } + catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while opening file " + + super.get_name() + " or " + super.get_name() + "_Fin"); + } + + try { + fwriter.write("Event \t ResourceID \t Clock\n"); + } + catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while writing on file " + + super.get_name() + " or " + super.get_name() + "_Fin"); + } + + try { + fwriter.close(); + } + catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while closing file " + + super.get_name() + " or " + super.get_name() + "_Fin"); + } + } + /** - * Write some data into a results file. - * @param event Values: "Removing" or "Registering" a resource - * @param resID resource id - * @param clock Current time + * Write an event of this entity into a file. + * If an existing file exists, the new event will be appended at the end. + * The file name is this entity name. + * + * @param event Values: "Removing" or "Registering" a resource + * @param resID resource id + * @param clock Current time */ - private void write(String event, int resID, double clock) + protected void write(String event, int resID, double clock) { if (record_ == false) { return; @@ -580,7 +618,8 @@ try { fwriter = new FileWriter(super.get_name(), true); - } catch (Exception ex) + } + catch (Exception ex) { ex.printStackTrace(); System.out.println( @@ -589,9 +628,9 @@ try { - fwriter.write(super.get_name() + " \t " + event + "\t" + resID + - "\t" + clock + "\n"); - } catch (Exception ex) + fwriter.write(event + "\t" + resID + "\t" + clock + "\n"); + } + catch (Exception ex) { ex.printStackTrace(); System.out.println( @@ -601,13 +640,13 @@ try { fwriter.close(); - } catch (Exception ex) + } + catch (Exception ex) { ex.printStackTrace(); System.out.println( "Unwanted errors while closing file " + super.get_name()); } - } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-29 01:00:28
|
Revision: 36 http://gridsim.svn.sourceforge.net/gridsim/?rev=36&view=rev Author: sulistio Date: 2007-08-28 18:00:27 -0700 (Tue, 28 Aug 2007) Log Message: ----------- when record an event to a file, remove putting this entity name. it is redundant. Modified Paths: -------------- branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java Modified: branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java =================================================================== --- branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java 2007-08-28 09:29:09 UTC (rev 35) +++ branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java 2007-08-29 01:00:27 UTC (rev 36) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * Author: Agustin Caminero + * Author: Agustin Caminero and Anthony Sulistio * Organization: Universidad de Castilla La Mancha (UCLM), Spain. * Created on: Nov 2006. */ @@ -31,7 +31,7 @@ * with properties defined in an object of * {@link gridsim.ResourceCharacteristics} class. * - * @author Agustin Caminero + * @author Agustin Caminero and Anthony Sulistio * @since GridSim Toolkit 4.1 * @see gridsim.GridResource * @see gridsim.ResourceCharacteristics @@ -396,12 +396,16 @@ /** * Asks this resource to record its activities. <br> - * NOTE: this method should be called <b>BEFORE</b> the ssimulation starts. + * NOTE: this method should be called <b>BEFORE</b> the simulation starts. + * If an existing file exists, the new activities will be appended at the + * end. The file name is this entity name. + * * @param trace <tt>true</tt> if you want to record this resource's * activities, <tt>false</tt> otherwise */ public void setTrace(boolean trace) { record_ = trace; + initializeReportFile(); } /** @@ -465,9 +469,6 @@ // Below method is for a child class to override registerOtherEntity(); - // Put the headers on each column in the results file - initializeReportFile(); - // Process events until END_OF_SIMULATION is received from the // GridSimShutdown Entity Sim_event ev = new Sim_event(); @@ -1311,7 +1312,7 @@ } try { - fwriter.write("Resource \t Event \t NumMachines \t Clock\n"); + fwriter.write("Event \t NumMachines \t Clock\n"); } catch (Exception ex) { @@ -1332,11 +1333,15 @@ } /** - * Writes some data into a results file. - * @param event Values: "Failure" or "Recovery" of a resource - * @param numMachiens number of machines + * Write an event of this entity into a file. + * If an existing file exists, the new event will be appended at the end. + * The file name is this entity name. + * + * @param event Values: "Removing" or "Registering" a resource + * @param resID resource id + * @param clock Current time */ - private void write(String event, int numMachines) + protected void write(String event, int numMachines) { if (record_ == false) { return; @@ -1348,17 +1353,19 @@ try { fwriter = new FileWriter(this.get_name(), true); - } catch (Exception ex) + } + catch (Exception ex) { ex.printStackTrace(); System.out.println("Unwanted errors while opening file " + this.get_name()); } + try { - fwriter.write(this.get_name() + "\t " + event+ " \t" + numMachines + - " \t" + GridSim.clock() + "\n"); - } catch (Exception ex) + fwriter.write(event+ " \t"+ numMachines+ " \t"+GridSim.clock()+"\n"); + } + catch (Exception ex) { ex.printStackTrace(); System.out.println("Unwanted errors while writing on file " + @@ -1368,7 +1375,8 @@ try { fwriter.close(); - } catch (Exception ex) + } + catch (Exception ex) { ex.printStackTrace(); System.out.println("Unwanted errors while closing file " + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-28 09:29:11
|
Revision: 35 http://gridsim.svn.sourceforge.net/gridsim/?rev=35&view=rev Author: sulistio Date: 2007-08-28 02:29:09 -0700 (Tue, 28 Aug 2007) Log Message: ----------- forgot to link the user entity with a router (mentioned by Agustin). Modified Paths: -------------- branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java Modified: branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java 2007-08-28 06:04:16 UTC (rev 34) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java 2007-08-28 09:29:09 UTC (rev 35) @@ -180,6 +180,9 @@ user.setRegionalGIS(gis); // set the regional GIS entity user.setGridletNumber(totalGridlet); + // link a resource to this router object + linkNetwork(router, user); + System.out.println("Created a USER with name " + userName + " and id = " + user.get_id() + ", connected to " + router.get_name() + ", and with " + totalGridlet + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-28 06:04:23
|
Revision: 34 http://gridsim.svn.sourceforge.net/gridsim/?rev=34&view=rev Author: sulistio Date: 2007-08-27 23:04:16 -0700 (Mon, 27 Aug 2007) Log Message: ----------- initial release. this example was done by Agustin but I did some changes to make it easier to understand. Added Paths: ----------- branches/gridsim4.0-branch1/examples/ResFailureEx01/GridUserFailureEx01.java branches/gridsim4.0-branch1/examples/ResFailureEx01/GridletSubmission.java branches/gridsim4.0-branch1/examples/ResFailureEx01/README.txt branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java branches/gridsim4.0-branch1/examples/ResFailureEx01/network_ex01.txt Added: branches/gridsim4.0-branch1/examples/ResFailureEx01/GridUserFailureEx01.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/GridUserFailureEx01.java (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/GridUserFailureEx01.java 2007-08-28 06:04:16 UTC (rev 34) @@ -0,0 +1,736 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + +import gridsim.*; +import gridsim.index.AbstractGIS; +import gridsim.net.Link; +import java.util.Random; +import java.util.ArrayList; +import java.io.FileWriter; +import gridsim.resFailure.RegionalGISWithFailure; +import eduni.simjava.Sim_system; +import eduni.simjava.Sim_event; + + +/** + * Creates a Grid User that also considers what happens if a resource fails. + * @author Agustin Caminero and Anthony Sulistio + * @since GridSim Toolkit 4.1 + */ +public class GridUserFailureEx01 extends GridUser +{ + // the base for our constants (chosen at random) + private static final int BASE = 440000; + + /** This constant is to tell the user when he should submit a gridlet */ + private static final int SUBMIT_GRIDLET = BASE + 1; + + private ArrayList GridletSubmittedList_; // list of submitted Gridlets + private GridletList GridletReceiveList_; // list of received Gridlets + + private int NUM_GRIDLETS; + private double pollingTime_; + + // The sizes of gridlets + private int gridletLength; + private int gridletInput; + private int gridletOutput; + + // we keep here the time when each gridlet is submitted + private double gridletSubmissionTime []; + private double gridletLatencyTime []; + + // a flag that denotes whether to trace GridSim events or not. + private boolean trace_flag; + + + /** + * Creates a GridUserFailure object + * @param name this entity name + * @param link a network link connecting this entity + * @param pollTime the time between polls + * @param glLength length (MI) for the gridlets of this user + * @param glIn input file size for the gridlets of this user + * @param glOut output file size for the gridlets of this user + * @param trace_flag a flag that denotes whether to trace this user events + * or not. + * @throws java.lang.Exception happens if either name or link is empty + */ + public GridUserFailureEx01(String name, Link link, double pollTime, + int glLength, int glIn, int glOut, boolean trace_flag) + throws Exception + { + super(name, link); + + this.GridletSubmittedList_ = new ArrayList(); + this.GridletReceiveList_ = new GridletList(); + pollingTime_ = pollTime; + + gridletLength = glLength; + gridletInput = glIn; + gridletOutput = glOut; + this.trace_flag = trace_flag; + } + + /** + * Sets the number of gridlets that this user has to submit. + * Also, create the submission and reception times arrays. + * @param gridlet_num the number of gridlets + */ + public void setGridletNumber(int gridlet_num) + { + NUM_GRIDLETS = gridlet_num; + + gridletSubmissionTime = new double[NUM_GRIDLETS]; + gridletLatencyTime = new double[NUM_GRIDLETS]; + } + + /** + * This function retrieves a list of available resources from the GIS. + * @return an array containing the ids of the resources + */ + private int[] getResList() + { + Object[] resList = super.getLocalResourceList(); + int resourceID[] = null; + + // if we have any resource + if ((resList != null) && (resList.length != 0)) + { + resourceID = new int[resList.length]; + for (int x = 0; x < resList.length; x++) + { + // Resource list contains list of resource IDs + resourceID[x] = ((Integer) resList[x]).intValue(); + + if (trace_flag == true) + { + System.out.println(super.get_name() + + ": resource[" + x + "] = " + resourceID[x]); + } + } + + } + + return resourceID; + } + + /** + * Handles incoming requests to this entity. + */ + public void body() + { + initializeResultsFile(); + createGridlet(super.get_id(), NUM_GRIDLETS); + + // schedule the initial sending of gridlets. + // The sending will start in a ramdom time within 5 min + Random random = new Random(); + int init_time = random.nextInt(5*60); + + // sends a reminder to itself + super.send(super.get_id(), init_time, SUBMIT_GRIDLET); + System.out.println(super.get_name() + + ": initial SUBMIT_GRIDLET event will be at clock: " + + init_time + ". Current clock: " + GridSim.clock()); + + + //////////////////////////////////////////////////////////// + // Now, we have the framework of the entity: + while (Sim_system.running()) + { + Sim_event ev = new Sim_event(); + super.sim_get_next(ev); // get the next event in the queue + + switch (ev.get_tag()) + { + // submit a gridlet + case SUBMIT_GRIDLET: + processGridletSubmission(ev); // process the received event + break; + + // Receive a gridlet back + case GridSimTags.GRIDLET_RETURN: + processGridletReturn(ev); + break; + + case GridSimTags.END_OF_SIMULATION: + System.out.println("\n============== " + super.get_name() + + ". Ending simulation..."); + break; + + default: + System.out.println(super.get_name() + + ": Received an event: " + ev.get_tag()); + break; + + } // switch + + } // while + + // remove I/O entities created during construction of this entity + super.terminateIOEntities(); + + // prints the completed gridlets + printGridletList(GridletReceiveList_, super.get_name(), false, + gridletLatencyTime); + } // body() + + + /** + * This functions process the submission of a gridlet. We have to get the + * list of available resources from the RegGIS, choose one of them, and + * submit the gridlet. + * @param ev an incoming event + */ + private void processGridletSubmission(Sim_event ev) + { + if (trace_flag) + { + System.out.println(super.get_name() + + ": received an SUBMIT_GRIDLET event. Clock: " + GridSim.clock()); + } + + /*********** + We have to submit: + - the gridlet whose id comes with the event + - all the gridlets with the "gridletSub.getSubmitted() == false" + + So, set the gridletSub.getSubmitted() to false for the gridlet whose + id comes with the event + ***********/ + + int i = 0; + GridletSubmission gridletSub; + int resourceID[]; + Random random = new Random(5); // a random generator with a random seed + int index; + Gridlet gl; + Integer obj; + int glID; + + // This is because the initial GRIDLET_SUBMIT event, at the beginning + // of sims, does not have any gridlet id. We have to submit + // all the gridlets. + if (ev.get_data() instanceof Integer) + { + obj = (Integer) ev.get_data(); + glID = obj.intValue(); // get the gridlet id. + } + else { + glID = 99; // a value at random, not used at all in this case + } + + while (i < GridletSubmittedList_.size()) + { + gridletSub = (GridletSubmission)GridletSubmittedList_.get(i); + + if ( (gridletSub.getGridlet()).getGridletID() == glID ) + { + // set this gridlet whose id comes with the event as not submitted, + // so that it is submitted as soon as possible. + ((GridletSubmission) GridletSubmittedList_.get(i)).setSubmitted(false); + } + + // Submit the gridlets with the "gridletSub.getSubmitted() == false" + if ( (gridletSub.getSubmitted() == false)) + { + // we have to resubmit this gridlet + gl = ((GridletSubmission) GridletSubmittedList_.get(i)).getGridlet(); + resourceID = getResList(); // Get list of resources from GIS + + // If we have resources in the list + if ((resourceID != null) && (resourceID.length != 0)) + { + index = random.nextInt(resourceID.length); + + // make sure the gridlet will be executed from the begining + resetGridlet(gl); + + // submits this gridlet to a resource + super.gridletSubmit(gl, resourceID[index]); + gridletSubmissionTime[gl.getGridletID()] = GridSim.clock(); + + // set this gridlet as submitted + ((GridletSubmission) GridletSubmittedList_.get(i)).setSubmitted(true); + + if (trace_flag) + { + System.out.println(super.get_name() + + ": Sending Gridlet #" + i + " to " + + GridSim.getEntityName(resourceID[index]) + + " at clock: " + GridSim.clock()); + + // Write into a results file + write(super.get_name(), "Sending", gl.getGridletID(), + GridSim.getEntityName(resourceID[index]), + gl.getGridletStatusString(), GridSim.clock()); + } + + } + // No resources available at this moment, so schedule an event + // in the future. The event wil be in 15 min (900 sec), as + // resource failures may last several hours. + // This event includes the gridletID, so that the user will + // try to submit only this gridlet + else + { + super.send(super.get_id(), GridSimTags.SCHEDULE_NOW + 900, + SUBMIT_GRIDLET, new Integer(gl.getGridletID()) ); + } + + }// if (gridletSub.getSubmitted() == false) + + i++; + } // while (i < GridletSubmittedList_.size()) + + } // processGridletSubmission + + + /** + * This functions process the return of a gridlet. + * We pay attention to the status of the gridlet + * and then decide what we have to do the next + * @param ev an incoming event + */ + private void processGridletReturn(Sim_event ev) + { + if (trace_flag) + { + System.out.println(super.get_name() + + ": received an GRIDLET_RETURN event. Clock: " + GridSim.clock()); + } + + Object obj = (Object) ev.get_data(); + Gridlet gl = null; + Random random = new Random(5); // a random generator with a random seed + + if (obj instanceof Gridlet) + { + gl = (Gridlet) obj; + gridletLatencyTime[gl.getGridletID()] = GridSim.clock(); + + // Write into a results file + if (trace_flag) + { + write(super.get_name(), "Receiving", gl.getGridletID(), + GridSim.getEntityName(gl.getResourceID()), + gl.getGridletStatusString(), GridSim.clock()); + } + + ///////////////////////// Gridlet Success + if (gl.getGridletStatusString().compareTo("Success") == 0) + { + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + " with status Success at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID())); + + this.GridletReceiveList_.add(gl); // add into the received list + gridletLatencyTime[gl.getGridletID()] = + gridletLatencyTime[gl.getGridletID()] - + gridletSubmissionTime[gl.getGridletID()]; + + // We have received all the gridlets. So, finish the simulation. + if (GridletReceiveList_.size() == GridletSubmittedList_.size()) + { + super.finishSimulation(); + } + + } // if (gl.getGridletStatusString() == "Success") + + //////////////////////// Gridlet Failed + else if (gl.getGridletStatusString().compareTo("Failed") == 0) + { + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + " with status Failed at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID())); + + // Send the gridlet as soon as we have resources available. + // This gridlet will be resend as soon as possible, + // in the first loop. + int pos = findGridletInGridletSubmittedList(gl); + if (pos == -1) { + System.out.println(super.get_name() + + ". Gridlet not found in GridletSubmittedList."); + } + else + { + // set this gridlet as submitted, because otherwise + // this gridlet may be submitted several times. + // A gridlet will only be submitted when the event carrying + // its id reaches the user + ((GridletSubmission) GridletSubmittedList_.get(pos)).setSubmitted(true); + + // Now, schedule an event to itself to submit the gridlet + // The gridlet will be sent as soon as possible + Integer glID_Int = new Integer(gl.getGridletID()); + + // This event includes the gridletID, so that the user + // will try to submit only this gridlet + super.send(super.get_id(), GridSimTags.SCHEDULE_NOW, + SUBMIT_GRIDLET, glID_Int); + } + } // if (gl.getGridletStatusString() == "Failed") + + ////////////////////////////// Gridlet Failed_resource + else if (gl.getGridletStatusString().compareTo("Failed_resource_unavailable") == 0) + { + int pos = findGridletInGridletSubmittedList(gl); + if (pos == -1) { + System.out.println(super.get_name() + + ". Gridlet not found in GridletSubmittedList."); + } + else + { + // Now, set its submission time for a random time between + // 1 and the polling time + double resubmissionTime = random.nextDouble() * pollingTime_; + + // this is to prevent the gridlet from being submitted + // before its resubmission time. + // This is different from the FAILED case, because + // in that case, the gridlet should be resubmited as soon + // as possible. As oppossed to that, this gridlet should + // not be resubmited before its resubmission time. + ((GridletSubmission) GridletSubmittedList_.get(pos)).setSubmitted(true); + + + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + + " with status Failed_resource_unavailable at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID()) + + "(resID: " + gl.getResourceID() + + "). Resubmission time will be: " + + resubmissionTime + GridSim.clock()); + + // Now, we have to inform the GIS about this failure, so it + // can keep the list of resources up-to-date. + informGIS(gl.getResourceID()); + + // Now, schedule an event to itself to submit the gridlet + Integer glID_Int = new Integer(gl.getGridletID()); + + // This event includes the gridletID, so that the user + // will try to submit only this gridlet + super.send(super.get_id(), resubmissionTime, + SUBMIT_GRIDLET, glID_Int); + } + } // else if + else + { + System.out.println(super.get_name() + ": Receiving Gridlet #" + + gl.getGridletID() + " with status " + + gl.getGridletStatusString() + " at time = " + + GridSim.clock() + " from resource " + + GridSim.getEntityName(gl.getResourceID()) + + " resID: " + gl.getResourceID()); + } + + } // if (obj instanceof Gridlet) + } + + /** + * Prints the Gridlet objects + * @param list the list of gridlets + * @param name the name of the user + * @param detail if we want the gridlet's history or not + * @param gridletLatencyTime array containing the latencies of gridlets. + * Latencies are from the moment when the gridlet is sent, till + * the moment they are back at the user. + * They take into account the last submission of a gridlet + * (when the gridlet is successfully run) + */ + private static void printGridletList(GridletList list, String name, + boolean detail, double gridletLatencyTime[]) + { + int size = list.size(); + Gridlet gridlet = null; + + String indent = " "; + System.out.println(); + System.out.println("============= OUTPUT for " + name + " =========="); + System.out.println("Gridlet ID" + indent + "STATUS" + indent + + "Resource ID" + indent + "Cost" + indent + + "CPU Time"+ indent + "Latency"); + + // a loop to print the overall result + int i = 0; + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list.get(i); + System.out.print(indent + gridlet.getGridletID() + indent + + indent); + + System.out.print(gridlet.getGridletStatusString()); + + System.out.println(indent + indent + gridlet.getResourceID() + + indent + indent + gridlet.getProcessingCost() + + indent + indent + gridlet.getActualCPUTime()+ + indent + indent + + gridletLatencyTime[gridlet.getGridletID()]); + + writeFin(name, gridlet.getGridletID(), + GridSim.getEntityName(gridlet.getResourceID()), + gridlet.getProcessingCost(), gridlet.getActualCPUTime(), + GridSim.clock()); + + + + } + + + if (detail == true) + { + // a loop to print each Gridlet's history + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list.get(i); + System.out.println(gridlet.getGridletHistory()); + + System.out.print("Gridlet #" + gridlet.getGridletID()); + System.out.println(", length = " + gridlet.getGridletLength() + + ", finished so far = " + + gridlet.getGridletFinishedSoFar()); + System.out.println("======================================\n"); + } + } + + System.out.println("================================================="); + + } + + /** + * This method will show you on how to create Gridlets + * @param userID owner ID of a Gridlet + * @param numGridlet number of Gridlet to be created + */ + private void createGridlet(int userID, int numGridlet) + { + for (int i = 0; i < numGridlet; i++) + { + // Creates a Gridlet + Gridlet gl = new Gridlet(i, gridletLength, gridletInput, gridletOutput); + gl.setUserID(userID); + + // Originally, gridlets are created to be submitted + // as soon as possible (the 0.0 param) + GridletSubmission gst = new GridletSubmission(gl, false); + + // add this gridlet into a list + this.GridletSubmittedList_.add(gst); + } + } + + /** + * Gets a list of received Gridlets + * @return a list of received/completed Gridlets + */ + public GridletList getGridletList() { + return GridletReceiveList_; + } + + /** + * Tells you the possition of this gridlet in the GridletSubmittedList_ + * @param gl the gridlet + * @return the position of this gridlet in the list of submitted gridlets + */ + private int findGridletInGridletSubmittedList(Gridlet gl) + { + Gridlet g = null; + GridletSubmission gst = null; + for (int i = 0; i< GridletSubmittedList_.size(); i++) + { + gst = (GridletSubmission)GridletSubmittedList_.get(i); + g = gst.getGridlet(); + + if ( g.getGridletID() == gl.getGridletID() ) + return i; + } + + return -1; + } + + /** This function resets the gridlet into its original values of + * length and gridletFinishedSoFar + * @param gl the gridlet to be resetted + */ + private void resetGridlet (Gridlet gl) + { + gl.setGridletLength(gridletLength); + gl.setGridletFinishedSoFar(0); + + } + + /** + * Write some data into the final results file. + * @param user user name + * @param glID gridlet id + * @param resName Name of the resource + * @param cost the processing cost of the gridlet + * @param cpu the cpu time + * @param clock Current time + * */ + private static void writeFin(String user, int glID, String resName, + double cost, double cpu, double clock) + { + // Write into a results file + FileWriter fwriter = null; + try + { + fwriter = new FileWriter(user+"_Fin", true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while opening file " + user+"_Fin"); + } + + try + { + fwriter.write(user +"\t "+ glID + "\t" + + resName + "\t" + cost + "\t"+ cpu + "\t" + + clock + "\n"); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while writing on file " + user+"_Fin"); + } + + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while closing file " + user+"_Fin"); + } + + } + + /** + * Write some data into a results file. + * @param user user name + * @param event Values: "Sending" or "Receive" a gridlet + * @param glID gridlet id + * @param resName Name of the resource + * @param status Status of the gridlet + * @param clock Current time + * */ + private void write(String user, String event, int glID, String resName, + String status, double clock) + { + // Write into a results file + FileWriter fwriter = null; + try + { + fwriter = new FileWriter(super.get_name(), true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while opening file " + super.get_name()); + } + + try + { + fwriter.write(user + "\t " + event + "\t" + glID + "\t" + + resName + "\t" + status + "\t\t" + clock + "\t" + "\n"); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while writing on file " + super.get_name()); + } + + + try + { + fwriter.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while closing file " + super.get_name()); + } + + } + + /** + * This function informs the GIS of this user about the failure of a resource + * @param resID the id of the resource which has failed + */ + private void informGIS(int resID) + { + Integer resID_Int = new Integer(resID); + + super.send(super.output, 0.0, AbstractGIS.NOTIFY_GIS_RESOURCE_FAILURE, + new IO_data(resID_Int, Link.DEFAULT_MTU, super.getRegionalGISId()) ); + } + + /** + * Initialize the results files (put headers over each column) + * */ + private void initializeResultsFile() + { + if (trace_flag == false) { + return; + } + + // Initialize the results file + FileWriter fwriter = null; + FileWriter fwriterFin = null; + try + { + fwriter = new FileWriter(super.get_name(), true); + fwriterFin = new FileWriter(super.get_name() + "_Fin", true); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while opening file " + super.get_name() + + " or " + super.get_name()+"_Fin"); + } + + try + { + fwriter.write( + "User \t\t Event \t GridletID \t Resource \t GridletStatus \t\t\t Clock\n"); + fwriterFin.write( + "User \t\t GridletID \t Resource \t Cost \t CPU time \t Latency\n"); + + + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while writing on file " + super.get_name()+ + " or " + super.get_name()+"_Fin"); + } + + try + { + fwriter.close(); + fwriterFin.close(); + } catch (Exception ex) + { + ex.printStackTrace(); + System.out.println( + "Unwanted errors while closing file " + super.get_name()+ + " or " + super.get_name()+"_Fin"); + } + } + +} // end class Added: branches/gridsim4.0-branch1/examples/ResFailureEx01/GridletSubmission.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/GridletSubmission.java (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/GridletSubmission.java 2007-08-28 06:04:16 UTC (rev 34) @@ -0,0 +1,54 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + + +import gridsim.Gridlet; + +/** + * This class is just a wrapper to denote + * whether this gridlet has been already submitted or not + * @author Agustin Caminero and Anthony Sulistio + * @since GridSim Toolkit 4.1 + */ +public class GridletSubmission +{ + private Gridlet gl; + private boolean submitted; + + + public GridletSubmission(Gridlet gl,boolean submitted) + { + this.gl = gl; + this.submitted = submitted; + } + + public Gridlet getGridlet() + { + return gl; + } + + public boolean getSubmitted() + { + return submitted; + } + + public void setGridlet(Gridlet g) + { + this.gl = g; + } + + public void setSubmitted(boolean submitted) + { + this.submitted = submitted; + } + +} // end class Added: branches/gridsim4.0-branch1/examples/ResFailureEx01/README.txt =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/README.txt (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/README.txt 2007-08-28 06:04:16 UTC (rev 34) @@ -0,0 +1,68 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + +Welcome to the example of how to use the computing resource failure functionality +To compile the example source code: + In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx01.java + In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx01.java + +where $GRIDSIM or %GRIDSIM% is the location of the gridsimtoolkit package. + + +To run the class file: + In Unix/Linux: + java -classpath $GRIDSIM/jars/gridsim.jar:. ResFailureEx01 network_ex01.txt > file.txt + + In Windows: + java -classpath %GRIDSIM%\jars\gridsim.jar;. ResFailureEx01 network_ex01.txt > file.txt + + +The above command means run the program and output the results into a file +named "file.txt" rather than into screen or standard output. +To prevent from overwriting an existing file, I renamed "file.txt" into +"output.txt" +NOTE: This example uses Java Random class to select a resource and user entity + to communicate to a regional GIS entity. + Hence, when running this example many times, the values will be different. + + +When running the example file, it will produce the following files: + + sim_trace -> created by the SimJava2 package (lower-level) to trace every + events (performed by SimJava and GridSim) during the simulation. + We don't need to worry about this file. Not to important for our + example. + + sim_report -> created by the SimJava2 package (lower-level) of GridSim. + This is a simulation report that contains general information about + running this experiment. We don't need to worry about this file. + Not to important for our example. + + Ex01_Regional_GIS -> contains one line describing each + registering/removing event that takes place at the GIS. Resources will + register at the begining of simulations, and after recovering from a + failure affecting all their machines. Resources will be removed when + they suffer a failure affecting all their machines. + + Ex01_Res_0, Ex01_Res_1, Ex01_Res_2: these files record when a resource suffers a failure + and when it recovers from the failure. They also say how many machines + failed, and the time of the fail/recovery. + + Ex01_User0: contains one line for each event regarding to the gridlets. + These events are the sending/reception of a gridlet, and each line include the status of the gridlet, + time, resource and VO. In this example we only have 1 VO. + + Ex01_User0_Fin: contains one line for each gridlet, showing the resource + it has been executed, its cost, CPU time and total latency. + +NOTE: When you run the program multiple times, all existing files will be overwritten. + Added: branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/ResFailureEx01.java 2007-08-28 06:04:16 UTC (rev 34) @@ -0,0 +1,322 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * An example of how to use the failure functionality. + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero and Anthony Sulistio + * Organization: UCLM (Spain) + * Created on: August 2007 + */ + +import gridsim.resFailure.*; +import gridsim.*; +import gridsim.net.*; +import java.util.*; +import gridsim.util.NetworkReader; +import gridsim.util.HyperExponential; + + +/** + * This example shows a basic topology with 1 user, 3 resources and 1 GIS. + * All of them are connected by a router. + * There is only one VO in this example. + * @author Agustin Caminero and Anthony Sulistio + * @since GridSim Toolkit 4.1 + */ +public class ResFailureEx01 +{ + public static void main(String[] args) + { + System.out.println("Starting failure example 1..."); + + try + { + if (args.length < 1) + { + System.out.println("Usage: java ResFailureEx01 network_ex01.txt"); + return; + } + + ////////////////////////////////////////// + // First step: 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 a run-time exception + // error. + + // a flag that denotes whether to trace GridSim events or not. + boolean trace_flag = false; // dont use SimJava trace + int num_user = 1; // number of grid users + Calendar calendar = Calendar.getInstance(); + + // Initialize the GridSim package + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + trace_flag = true; + + ////////////////////////////////////////// + // Second step: Builds the network topology among Routers. + + String filename = args[0]; // get the network topology + System.out.println("Reading network from " + filename); + LinkedList routerList = NetworkReader.createFIFO(filename); + + + ////////////////////////////////////////// + // Third step: Creates one RegionalGISWithFailure entity, + // linked to a router in the topology + + Router router = null; + double baud_rate = 100000000; // 100Mbps, i.e. baud rate of links + double propDelay = 10; // propagation delay in milliseconds + int mtu = 1500; // max. transmission unit in byte + int totalMachines = 10; // num of machines each resource has + + String NAME = "Ex01_"; // a common name + String gisName = NAME + "Regional_GIS"; // GIS name + + // a network link attached to this regional GIS entity + Link link = new SimpleLink(gisName + "_link", baud_rate, + propDelay, mtu); + + + // HyperExponential: mean, standard deviation, stream + // how many resources will fail + HyperExponential failureNumResPattern = + new HyperExponential(totalMachines / 2, totalMachines, 4); + + // when they will fail + HyperExponential failureTimePattern = + new HyperExponential(25, 100, 4); + + // how long the failure will be + HyperExponential failureLengthPattern = + new HyperExponential(20, 25, 4); // big test: (20, 100, 4); + + + // creates a new Regional GIS entity that generates a resource + // failure message according to these patterns. + RegionalGISWithFailure gis = new RegionalGISWithFailure(gisName, + link, failureNumResPattern, failureTimePattern, + failureLengthPattern, 0); // TODO: 0 is redundant ? + gis.setTrace(trace_flag); // record this GIS activity + + // link these GIS to a router + router = NetworkReader.getRouter("Router0", routerList); + linkNetwork(router, gis); + + // print some info messages + System.out.println("Created a REGIONAL GIS with name " + gisName + + " and id = " + gis.get_id() + ", connected to " + + router.get_name() ); + + + ////////////////////////////////////////// + // Fourth step: Creates one or more GridResourceWithFailure + // entities, linked to a router in the topology + + String sched_alg = "SPACE"; // use space-shared policy + int totalResource = 3; // number of resources + ArrayList resList = new ArrayList(totalResource); + + // Each resource may have different baud rate, + // totalMachine, rating, allocation policy and the router to + // which it will be connected. However, in this example, we assume + // all have the same properties for simplicity. + int totalPE = 4; // num of PEs each machine has + int rating = 49000; // rating (MIPS) of PEs + int GB = 1000000000; // 1 GB in bits + baud_rate = 2.5 * GB; + + for (int i = 0; i < totalResource; i++) + { + // gets the router object from the list + router = NetworkReader.getRouter("Router0", routerList); + + // creates a new grid resource + String resName = NAME + "Res_" + i; + GridResourceWithFailure res = createGridResource(resName, + baud_rate, propDelay, mtu, totalPE, totalMachines, + rating, sched_alg); + + // add a resource into a list + resList.add(res); + res.setRegionalGIS(gis); // set the regional GIS entity + res.setTrace(trace_flag); // record this resource activity + + // link a resource to this router object + linkNetwork(router, res); + + System.out.println("Created a RESOURCE (" + totalMachines + + " machines, each with " + totalPE + " PEs) with name = " + + resName + " and id = " + res.get_id() + + ", connected to router " + router.get_name() + + " and registered to " + gis.get_name() ); + } + + ////////////////////////////////////////// + // Fifth step: Creates one GridUserFailure entity, + // linked to a router of the topology + + int totalGridlet = 5; // total jobs + double pollTime = 100; // time between polls + int glSize = 100000; // the size of gridlets (input/output) + int glLength = 42000000; // the length (MI) of gridlets + String userName = NAME + "User0"; + + // gets the router object from the list + router = NetworkReader.getRouter("Router0", routerList); + + // a network link attached to this entity + Link link2 = new SimpleLink(userName + "_link", baud_rate, + propDelay, mtu); + + GridUserFailureEx01 user = new GridUserFailureEx01(userName, link2, + pollTime, glLength, glSize, glSize, trace_flag); + // The last parameter is the GIS this user will use to get resources + // for his gridlets + + user.setRegionalGIS(gis); // set the regional GIS entity + user.setGridletNumber(totalGridlet); + + System.out.println("Created a USER with name " + userName + + " and id = " + user.get_id() + ", connected to " + + router.get_name() + ", and with " + totalGridlet + + " gridlets. Registered to " + gis.get_name() ); + System.out.println(); + + + ////////////////////////////////////////// + // Sixth step: Starts the simulation + GridSim.startGridSimulation(); + System.out.println("\nFinish failure example 1... \n"); + } + catch (Exception e) + { + e.printStackTrace(); + System.out.println("Unwanted errors happen"); + } + } + + /** + * Links a particular entity with a given Router. + * + * @param router a Router object + * @param obj a GridSim entity to be attached to the Router + */ + private static void linkNetwork(Router router, GridSimCore obj) throws Exception + { + if (router == null) { + System.out.println("Error - router is NULL."); + return; + } + + // get the baud rate of a link + double baud_rate = obj.getLink().getBaudRate(); + + // create the packet scheduler for this link + PacketScheduler pktObj = new FIFOScheduler(router.get_name() + + "_to_" + obj.get_name() ); + + // attach this GridSim entity to a Router + router.attachHost(obj, pktObj); + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * <p> + * In this simple example, we are simulating one Grid resource with three + * Machines that contains one or more PEs. + * + * @param name a Grid Resource name + * @param baud_rate the bandwidth of this entity + * @param delay the propagation delay + * @param MTU Maximum Transmission Unit + * @param totalPE number of PE per machine + * @param totalMachine number of machines in this resources + * @param rating rating of mahcines in this resource + * @param sched_alg the scheduling algorithm of this resource + * @return a GridResource object + */ + private static GridResourceWithFailure createGridResource(String name, + double baud_rate, double delay, int MTU, int totalPE, + int totalMachine, int rating, String sched_alg) + { + // 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++) + { + // 2. A Machine contains one or more PEs or CPUs. Therefore, should + // create an object of PEList to store these PEs before creating + // a Machine. + PEList peList = new PEList(); + + // 3. Create PEs and add these into an object of PEList. + for (int k = 0; k < totalPE; k++) + { + // need to store PE id and MIPS Rating + peList.add( new PE(k, rating) ); + } + + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, peList) ); + } + + + // 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 = 9.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // we create Space_Shared_failure or Time_Shared_failure schedulers + int scheduling_alg = 0; // space_shared or time_shared + if (sched_alg.equals("SPACE") == true) { + scheduling_alg = ResourceCharacteristics.SPACE_SHARED; + } + else if (sched_alg.equals("TIME") == true) { + scheduling_alg = ResourceCharacteristics.TIME_SHARED; + } + + ResourceCharacteristics resConfig = new ResourceCharacteristics( + arch, os, mList, scheduling_alg, time_zone, cost); + + + // 6. Finally, we need to create a GridResource object. + 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(); + GridResourceWithFailure gridRes = null; + try + { + // creates a GridResource with a link + gridRes = new GridResourceWithFailure(name, + new SimpleLink(name + "_link", baud_rate, delay, MTU), + seed, resConfig, peakLoad, offPeakLoad, holidayLoad, + Weekends, Holidays); + } + catch (Exception e) { + e.printStackTrace(); + } + + return gridRes; + } + +} // end class Added: branches/gridsim4.0-branch1/examples/ResFailureEx01/network_ex01.txt =================================================================== --- branches/gridsim4.0-branch1/examples/ResFailureEx01/network_ex01.txt (rev 0) +++ branches/gridsim4.0-branch1/examples/ResFailureEx01/network_ex01.txt 2007-08-28 06:04:16 UTC (rev 34) @@ -0,0 +1,15 @@ +# The topology of this example is as follows (with 1 user and 1 resource) +# +# user --- Router0 ---- Resource0 +# +# total number of Routers +1 + +# specifies each router name and whether to log its activities or not +# by default no logging is required +Router0 + +# specify the link between two Routers +# The format is: +# Router_name1 Router_name2 baud_rate(GB/s) prop_delay(ms) mtu(byte) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-28 06:02:49
|
Revision: 33 http://gridsim.svn.sourceforge.net/gridsim/?rev=33&view=rev Author: sulistio Date: 2007-08-27 23:02:51 -0700 (Mon, 27 Aug 2007) Log Message: ----------- allowing printing debugging info when the trace option is set to true. Modified Paths: -------------- branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java branches/gridsim4.0-branch1/source/gridsim/resFailure/RegionalGISWithFailure.java Modified: branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java =================================================================== --- branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java 2007-08-28 06:00:14 UTC (rev 32) +++ branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java 2007-08-28 06:02:51 UTC (rev 33) @@ -745,14 +745,14 @@ }catch(Exception e) {} - /********* - //Uncomment this, if you want more info on the progress of sims - System.out.println("################# " + super.get_name() + - ". Received an event from " + GridSim.getEntityName(gl.getUserID()) + - " while the resource was failed. So, event not processed. Event tag: " + - ev.get_tag() + - ". Returning GRIDLET_RETURN to the user."); - *******/ + /***********/ + if (record_ == true) { + System.out.println(super.get_name() + + ": receives an event from " + GridSim.getEntityName(gl.getUserID()) + + " while resource is failed, so not processed. Event tag: " + + ev.get_tag() + ". Returning GRIDLET_RETURN to sender."); + } + /***********/ super.send(super.output, 0, GridSimTags.GRIDLET_RETURN, new IO_data(gl,gl.getGridletOutputSize(),gl.getUserID()) ); @@ -1037,14 +1037,18 @@ AvailabilityInfo resAv = (AvailabilityInfo) ev.get_data(); - /****** // Uncomment this to get more info on the progress of sims - System.out.println("++++++++++ " + super.get_name() + - ". Received a poll request event from "+ + /******* + // Uncomment this to get more info on the progress of sims + // NOTE: this keeps printing at every n seconds interval. + if (record_ == true) { + System.out.println(super.get_name() + + ": receives a poll request event from "+ GridSim.getEntityName(resAv.getSrcID()) +". Clock: " + GridSim.clock() +". Is res failed?: "+ getResourceFailed()); + } *******/ - // if all the mahcines of the resource are out of order or not + // if all the machines of the resource are out of order or not if (getResourceFailed()) { resAv.setAvailability(false); @@ -1103,10 +1107,9 @@ if (record_ == true) { write("Failure", numMachines); - System.out.println("################# " + super.get_name() + - ".processFailure(): " + - "Received an event GRIDRESOURCE_FAILURE. Clock:" + - GridSim.clock() + " which will last until clock:" + + System.out.println(super.get_name() + ".processFailure(): " + + "receives an event GRIDRESOURCE_FAILURE. Clock: " + + GridSim.clock() + " which will last until clock: " + (GridSim.clock() + time) + ". There are NO working machines in this resource."); } @@ -1131,9 +1134,8 @@ if (record_ == true) { write("Failure", numFailedMachines); - System.out.println("################# " + super.get_name() + - ".processFailure(): " + - "Received an event GRIDRESOURCE_FAILURE. Clock:" + + System.out.println(super.get_name() + ".processFailure(): " + + "receives an event GRIDRESOURCE_FAILURE. Clock: " + GridSim.clock() + ". There are STILL working machines in this resource."); } @@ -1187,12 +1189,12 @@ System.out.println(super.get_name() + ": Resource recovered." + " Registering the resource at the regional GIS AGAIN" + - " after the failure at clock:" + GridSim.clock()); + " after the failure at clock: " + GridSim.clock()); } else { System.out.println(super.get_name() + - ": Resource recovered at clock:" + GridSim.clock()); + ": Resource recovered at clock: " + GridSim.clock()); } if (record_ == true) { @@ -1260,30 +1262,31 @@ { Machine mach; - /************ - // Uncomment this if you want more info on the progress of sims + /************/ String status = null; - if (b) - status = "FAILED"; - else - status = "WORKING"; - ************/ + if (record_ == true) { + if (b) + status = "FAILED"; + else + status = "WORKING"; + } + /************/ for(int i = 0; i < numFailedMachines; i++) { mach = resource_.getMachineList().getMachineInPos(i); if (mach != null) { - /************* - // Uncomment htis if you want more info on the progress of sims - System.out.println("$$$$$$ "+ super.get_name() +". Machine: " - + i +": Setting this machine to "+ status+ "..."); - mach.setFailed(super.get_name(), i, b); - *************/ - - mach.setFailed(super.get_name(), b); - } - } + if (record_ == true) { + System.out.println(super.get_name() +" - Machine: " + + i + " is set to " + status); + mach.setFailed(super.get_name(), b); + } + else { + mach.setFailed(b); + } + } // end if + } // end for } /** Modified: branches/gridsim4.0-branch1/source/gridsim/resFailure/RegionalGISWithFailure.java =================================================================== --- branches/gridsim4.0-branch1/source/gridsim/resFailure/RegionalGISWithFailure.java 2007-08-28 06:00:14 UTC (rev 32) +++ branches/gridsim4.0-branch1/source/gridsim/resFailure/RegionalGISWithFailure.java 2007-08-28 06:02:51 UTC (rev 33) @@ -42,22 +42,15 @@ */ public class RegionalGISWithFailure extends AbstractGIS { - // if there is a conflict, we can simply change this number - private static final int GIS_WITH_FAILURE_BASE = 2000; // TODO + // for a RegionalGISWithFailure named "RegionalGIS_2", the gisID_ will be 2 + // This is also the number of the VO. + public int gisID_; // TODO: redundant ?? - /** Denotes that an user has detected the failure of a resource. - * So, the user sends - * this tag to the GIS to make it update its list of resources. - */ - public static final int RESOURCE_FAILED = GIS_WITH_FAILURE_BASE + 1; // TODO: + /** This entity ID in <tt>Integer</tt> object. */ protected Integer myID_; - // for a RegionalGISWithFailure named "RegionalGIS_2", the gisID_ will be 2 - // This is also the number of the VO. - public int gisID_; // TODO: redundant ?? - // denotes whether sim has just began or it has been running for some time private boolean begining; @@ -101,7 +94,11 @@ // defines how GIS should decide how long the resource will be out of order private Variate failureLengthPatternVariate_; + // a flag to denote whether to record events into a file or not + private boolean record_ = false; + + /** * Creates a new regional GIS entity * @param name this regional GIS name @@ -199,6 +196,16 @@ super.get_name() + " entity"); } + /** + * Asks this resource to record its activities. <br> + * NOTE: this method should be called <b>BEFORE</b> the ssimulation starts. + * @param trace <tt>true</tt> if you want to record this resource's + * activities, <tt>false</tt> otherwise + */ + public void setTrace(boolean trace) { + record_ = trace; + } + /** * Initialises all attributes * @pre $none @@ -244,20 +251,20 @@ Integer id = (Integer) obj; list.add(id); result = true; - write("Registering", id.intValue(), GridSim.clock()); - if (list.size() == 1) { // REMOVE !!! - System.out.println(super.get_name() + - ": The list has one resource again. Clock:" + GridSim.clock()); - } + if (record_ == true) { + write("Registering", id.intValue(), GridSim.clock()); + System.out.println(); + System.out.println(super.get_name() + ": registering " + + GridSim.getEntityName(id)); - System.out.println(); - for (int i = 0; i< list.size() ; i++) - { - System.out.println(super.get_name() + ": list("+i+"): " + - GridSim.getEntityName(((Integer)list.get(i)).intValue())); + for (int i = 0; i < list.size() ; i++) + { + System.out.println(super.get_name() + ": list["+ i +"] = " + + GridSim.getEntityName((Integer) list.get(i)) ); + } + System.out.println(); } - System.out.println(); } return result; @@ -307,7 +314,6 @@ ".processRegisterResource(): Warning - can't register " + "a resource ID."); } - } /** @@ -339,12 +345,9 @@ "------- GRIDRESOURCE_FAILURE received at the " + super.get_name() + ", but there is no resources available." + - " So, scheduling a new GRIDRESOURCE_FAILURE to GIS in 2 min."); + " So, scheduling a new GRIDRESOURCE_FAILURE to GIS in 2 mins."); - super.send(super.get_id(), - Math.floor(GridSimTags.SCHEDULE_NOW + 120), - GridSimTags.GRIDRESOURCE_FAILURE); - + super.send(super.get_id(), 120, GridSimTags.GRIDRESOURCE_FAILURE); } // if the sim has just began, then we have to decide how many res // will fail, when and for how long @@ -359,13 +362,13 @@ if (numResFail > resList_.size()) numResFail = resList_.size(); - /**************** - // Uncomment this is you want more info on the progess of sims - System.out.println("################# " + - super.get_name() + ":" + numResFail + + /****************/ + if (record_ == true) { + System.out.println(super.get_name() + ": " + numResFail + " resources will fail in this simulation. " + - "Number of failed machines in each resource will be decided later"); - *****************/ + "Num of failed machines on each resource will be decided later"); + } + /****************/ for (int i = 0; i < numResFail; i++) { @@ -377,22 +380,17 @@ // choose the resource which will fail and how long the failure // will last. Then, it will send the failure signal to the resource. - super.send(super.get_id(), - Math.floor(GridSimTags.SCHEDULE_NOW + resTimeFail), + super.send(super.get_id(), resTimeFail, GridSimTags.GRIDRESOURCE_FAILURE); - /********* - // Uncomment this is you want more info on the progess of sims - System.out.println("################# " + - super.get_name() + - " entity sends an autogenerated GRIDRESOURCE_FAILURE to itself." + - " GridSim.clock(): " + GridSim.clock() + - // ". Calendar + resTimeFail: " + - //((GridSim.getSimulationCalendar().getTimeInMillis() / 1000) + resTimeFail) + " seconds" + - ". resTimeFail: " + - (Math.floor(GridSimTags.SCHEDULE_NOW + resTimeFail)) + - " seconds" + ". super.get_id(): " + super.get_id()); - ********/ + /*********/ + if (record_ == true) { + System.out.println(super.get_name() + + ": sends an autogenerated GRIDRESOURCE_FAILURE to itself." + + " Clock: " + GridSim.clock() + ", resTimeFail: " + + resTimeFail + " seconds"); + } + /*********/ } } // if (begining) @@ -429,9 +427,7 @@ if (resChar == null) { - System.out.println(super.get_name() + - " resChar == null"); - + System.out.println(super.get_name() + " resChar == null"); isWorking = false; } else @@ -449,15 +445,16 @@ GridSimTags.SCHEDULE_NOW + failureLength, GridSimTags.GRIDRESOURCE_RECOVERY, resFailure); - /***************** - // Uncomment this if you want more info on the progress - System.out.println("################# " + super.get_name() + - " sends a GRIDRESOURCE_FAILURE event to the resource " + - GridSim.getEntityName(res_id) + ". numMachFailed: " + - numMachFailed + ". GridSim.clock(): " - + GridSim.clock() + ". Fail duration: " + (failureLength / 3600) + - " hours. Some machines of the resource may still work, or not."); - ******************/ + /*****************/ + if (record_ == true) { + System.out.println(super.get_name() + + ": sends a GRIDRESOURCE_FAILURE event to the resource " + + GridSim.getEntityName(res_id) + ". numMachFailed: " + + numMachFailed + ". Clock: " + GridSim.clock() + + ". Fail duration: " + (failureLength / 3600) + + " hours. Some machines may still work or may not."); + } + /*****************/ // Send the GRIDRESOURCE_FAILURE event to the resource. super.send(super.output, 0.0, ev.get_tag(), @@ -484,14 +481,14 @@ int resource_id = resfail.getRes(); - /*********** - // Uncomment this to get more info on the progress of the sims - System.out.println("################# " + - super.get_name() + - " sends a GRIDRESOURCE_RECOVERY to the resource " + + /***********/ + if (record_ == true) { + System.out.println(super.get_name() + + ": sends a GRIDRESOURCE_RECOVERY to the resource " + GridSim.getEntityName(resource_id) + ". Clock: " + GridSim.clock()); - ***********/ + } + /***********/ // Send the GRIDRESOURCE_RECOVERY event to the resource. super.send(super.output, 0.0, ev.get_tag(), @@ -499,7 +496,6 @@ resource_id)); } // if (obj instanceof FailureMsg) - } @@ -516,11 +512,12 @@ Integer resID_Int = (Integer) ev.get_data(); int resID = resID_Int.intValue(); - // Uncomment this if you want more info on the progress of sims. - System.out.println("+++++++++ " + super.get_name() + - ": received a resource failure information event. Failed resource is " + - GridSim.getEntityName(resID) + ". resID: " + - resID + ". Clock: " + GridSim.clock()); + if (record_ == true) { + System.out.println(super.get_name() + + ": receives a resource failure information event. " + + "Failed resource is " + GridSim.getEntityName(resID) + + ". resID: " + resID + ". Clock: " + GridSim.clock()); + } removeResource(resID); } @@ -539,27 +536,31 @@ if (((Integer) resList_.get(j)).intValue() == resID) { resList_.remove(j); - write("Removing", resID, GridSim.clock()); - if (resList_.size() == 0) // REMOVE !!! - { - System.out.println(super.get_name() + - ": No resources available at this moment. Clock:" + + if (record_ == true) { + write("Removing", resID, GridSim.clock()); + if (resList_.size() == 0) + { + System.out.println(super.get_name() + + ": No resources available at this moment. Clock: " + GridSim.clock()); + } } } } - /*********** - // Uncomment this of you want more info on the progress of sims - System.out.println("Resource list after removing one"); - for (int j = 0; j < resList_.size(); j++) - { - System.out.println( - GridSim.getEntityName( ((Integer)resList_.get(j)).intValue()) ); - + /***********/ + if (record_ == true) { + System.out.println(); + System.out.println(super.get_name() + ": Resource list after removal"); + for (int j = 0; j < resList_.size(); j++) + { + System.out.println(super.get_name() + ": list["+ j +"] = " + + GridSim.getEntityName((Integer)resList_.get(j)) ); + } + System.out.println(); } - **********/ + /**********/ } /** @@ -570,6 +571,10 @@ */ private void write(String event, int resID, double clock) { + if (record_ == false) { + return; + } + // Write into a results file FileWriter fwriter = null; try @@ -641,14 +646,16 @@ res_id = resAv.getResID(); - /* - // Uncomment this if you want more info on the progress of sims. - System.out.println("+++++++++ " + super.get_name() + - ": received a poll response from " + - GridSim.getEntityName(resID) + ". resID: " + resID + + /***************** + // NOTE: this keeps printing at every n seconds interval. + if (record_ == true) { + System.out.println(super.get_name() + + ": receives a poll response from " + + GridSim.getEntityName(res_id) + ". resID: " + res_id + ". Is res available? " + resAv.getAvailability() + ". Clock: " + GridSim.clock()); - */ + } + ****************/ // Find the AvailabilityInfo object corresponding to the resource // which has answered this poll request @@ -665,28 +672,25 @@ removeResource(res_id); } } - } + } // for - } // for (int i = 0; i < resList_.size(); i++) + } // for - /********** - // Uncomment this if you want more info on the progress of sims. - if (resList_.size() == 0) - { - System.out.println("+++++++++++++ " + super.get_name() + - ": After polling, no resource in the GIS. "); + /**********/ + if (record_ == true) { + if (resList_.size() == 0) { + System.out.println(super.get_name() + + ": After polling, no resource in the GIS. "); + } + } + /*********/ - }*/ - // Schedule the following polling event. - super.send(super.get_id(), - Math.floor(GridSimTags.SCHEDULE_NOW + - GridSimTags.POLLING_TIME_GIS), + super.send(super.get_id(), GridSimTags.POLLING_TIME_GIS, GridSimTags.GRIDRESOURCE_POLLING); } - /** * Process an incoming request that uses a user-defined tag. <br> * NOTE: This method can be overridden by its subclasses, provided @@ -718,8 +722,8 @@ processGridResource_Polling(ev); break; - // An user tells the GIS that a resource is out of order - case RESOURCE_FAILED: + // A user tells the GIS that a resource is out of order + case AbstractGIS.NOTIFY_GIS_RESOURCE_FAILURE: processResourceFailed(ev); break; @@ -1044,8 +1048,6 @@ // send a request to a regional GIS super.send( super.output, 0.0, eventTag, new IO_data(myID_, Link.DEFAULT_MTU, obj.intValue()) ); - - } return true; @@ -1232,7 +1234,6 @@ */ protected void registerOtherEntity() { - double resTimeFail = getNextFailureTimeSample(); // the time when we will decide when a resource will fail @@ -1242,23 +1243,20 @@ // will fail and how long the failure will last. // Then, it will send the failure signal // to the resource. - super.send(super.get_id(), - Math.floor(GridSimTags.SCHEDULE_NOW + resTimeFail), - GridSimTags.GRIDRESOURCE_FAILURE); + super.send(super.get_id(), resTimeFail, GridSimTags.GRIDRESOURCE_FAILURE); - /************** - // Uncomment this is you want mor info on the progess of sims - System.out.println("################# " + super.get_name() + - " entity sends an autogenerated GRIDRESOURCE_FAILURE to itself."+ - " GridSim.clock(): " + GridSim.clock() + ". resTimeFail: " + - (Math.floor(GridSimTags.SCHEDULE_NOW + resTimeFail)) + - " seconds" + ". super.get_id(): " + super.get_id()); - ***************/ + /**************/ + if (record_ == true) { + System.out.println(super.get_name() + + ": sends an autogenerated GRIDRESOURCE_FAILURE to itself."+ + " Clock(): " + GridSim.clock() + ". resTimeFail: " + + resTimeFail + " seconds"); + } + /***************/ // Now, we have to start the polling functionality - super.send(super.get_id(), - Math.floor(GridSimTags.SCHEDULE_NOW + GridSimTags.POLLING_TIME_GIS), - GridSimTags.GRIDRESOURCE_POLLING); + super.send(super.get_id(), GridSimTags.POLLING_TIME_GIS, + GridSimTags.GRIDRESOURCE_POLLING); } @@ -1403,7 +1401,7 @@ * discrete or continuous. * @return the sample for the number of resources which will fail */ - public double getNextFailureNumResSample() + protected double getNextFailureNumResSample() { double sample; if (failureNumResPatternDiscrete_ != null) @@ -1432,7 +1430,7 @@ * discrete or continuous. * @return the sample for the time when resources will fail */ - public double getNextFailureTimeSample() { + protected double getNextFailureTimeSample() { double sample; if (failureTimePatternDiscrete_ != null) { @@ -1461,7 +1459,7 @@ * discrete or continuous. * @return the sample for the time when resources will fail */ - public double getNextFailureLengthSample() { + protected double getNextFailureLengthSample() { double sample; if (failureLengthPatternDiscrete_ != null) { @@ -1494,12 +1492,11 @@ * @return the sample for the number of machines which will fail * in a resource */ - public double getNextNumMachinesFailedSample() { + protected double getNextNumMachinesFailedSample() { return getNextFailureNumResSample(); } - /** * Gets a ResourceCharacteristics object for a given GridResource ID. <br> * NOTE: This method returns a reference of ResourceCharacteristics object, @@ -1518,7 +1515,7 @@ * @pre resourceID > 0 * @post $none */ - public ResourceCharacteristics getResourceCharacteristics(int resourceID) + private ResourceCharacteristics getResourceCharacteristics(int resourceID) { // Get Resource Characteristic Info: Send Request and Receive Event/Msg send(super.output, 0.0, GridSimTags.RESOURCE_CHARACTERISTICS, @@ -1544,20 +1541,11 @@ } /** - * Returns the gisID_ attribute of this entity*/ - /*** // TODO: redundant ?? - public int getGisID() - { - return gisID_; - } - ***/ - - /** * This function is to poll the resources in order to check whether * they are failed or not * @return true if everything works well */ - public boolean pollResource(int resID) + protected boolean pollResource(int resID) { if (resID < 0) { @@ -1579,7 +1567,7 @@ * This function is to receive back the polls from the resources * @return a AvailabilityInfo object */ - public AvailabilityInfo pollReturn() + protected AvailabilityInfo pollReturn() { Sim_event ev = new Sim_event(); @@ -1593,13 +1581,15 @@ try { resAv = (AvailabilityInfo) ev.get_data(); - } catch (Sim_exception sim) + } + catch (Sim_exception sim) { System.out.print(super.get_name() + ".pollReturn(): Error - "); System.out.println("exception occurs. See the below message:"); System.out.println(sim.getMessage()); resAv = null; - } catch (Exception e) + } + catch (Exception e) { System.out.print(super.get_name() + ".pollReturn(): Error - "); System.out.println("exception occurs. See the below message:"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-28 06:00:55
|
Revision: 32 http://gridsim.svn.sourceforge.net/gridsim/?rev=32&view=rev Author: sulistio Date: 2007-08-27 23:00:14 -0700 (Mon, 27 Aug 2007) Log Message: ----------- add a new tag regarding to a resource failure functionality Modified Paths: -------------- branches/gridsim4.0-branch1/source/gridsim/index/AbstractGIS.java Modified: branches/gridsim4.0-branch1/source/gridsim/index/AbstractGIS.java =================================================================== --- branches/gridsim4.0-branch1/source/gridsim/index/AbstractGIS.java 2007-08-27 06:48:48 UTC (rev 31) +++ branches/gridsim4.0-branch1/source/gridsim/index/AbstractGIS.java 2007-08-28 06:00:14 UTC (rev 32) @@ -104,7 +104,12 @@ */ public static final int GIS_INQUIRY_RESOURCE_AR_RESULT = GIS_BASE + 12; + /** Denotes an inquiry regarding to a resource failure. + * The user sends this tag to the GIS to update its list of resources. + */ + public static final int NOTIFY_GIS_RESOURCE_FAILURE = GIS_BASE + 13; + /** * Creates a new regional GIS entity * @param name this regional GIS name This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-27 17:41:31
|
Revision: 30 http://gridsim.svn.sourceforge.net/gridsim/?rev=30&view=rev Author: sulistio Date: 2007-08-26 23:22:18 -0700 (Sun, 26 Aug 2007) Log Message: ----------- clean up the code, fix javadoc comments and minor changes to make this class ready for release. Modified Paths: -------------- branches/gridsim4.0-branch1/source/gridsim/resFailure/AllocPolicyWithFailure.java branches/gridsim4.0-branch1/source/gridsim/resFailure/AvailabilityInfo.java branches/gridsim4.0-branch1/source/gridsim/resFailure/FailureMsg.java branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java branches/gridsim4.0-branch1/source/gridsim/resFailure/RegionalGISWithFailure.java branches/gridsim4.0-branch1/source/gridsim/resFailure/SpaceSharedWithFailure.java branches/gridsim4.0-branch1/source/gridsim/resFailure/TimeSharedWithFailure.java branches/gridsim4.0-branch1/source/gridsim/util/HyperExponential.java branches/gridsim4.0-branch1/source/gridsim/util/LCGRandom.java branches/gridsim4.0-branch1/source/gridsim/util/Variate.java branches/gridsim4.0-branch1/source/gridsim/util/Weibull.java Added Paths: ----------- branches/gridsim4.0-branch1/source/gridsim/resFailure/package.html Modified: branches/gridsim4.0-branch1/source/gridsim/resFailure/AllocPolicyWithFailure.java =================================================================== --- branches/gridsim4.0-branch1/source/gridsim/resFailure/AllocPolicyWithFailure.java 2007-08-22 08:08:48 UTC (rev 29) +++ branches/gridsim4.0-branch1/source/gridsim/resFailure/AllocPolicyWithFailure.java 2007-08-27 06:22:18 UTC (rev 30) @@ -1,3 +1,13 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero + * Organization: Universidad de Castilla La Mancha (UCLM), Spain. + * Created on: Nov 2006. + */ package gridsim.resFailure; @@ -2,5 +12,7 @@ /** - * The structure of an allocatoin policy supporting resource failure. - * @author Agustin Caminero, Universidad de Castilla La Mancha (UCLM), Spain. Jan 2007. - * @since GridSim 4.1 + * The structure of an allocation policy supporting resource failure. + * Use this class in addition to {@link gridsim.AllocPolicy} class. + * @author Agustin Caminero + * @since GridSim Toolkit 4.1 + * @see gridsim.AllocPolicy */ @@ -10,15 +22,16 @@ public interface AllocPolicyWithFailure { /** - * This function sets the gridlet status of all the gridlets in thos resource to FAILED. - * Then sends them back to the user, and clean gridlets lists.*/ + * Sets the status of all Gridlets in this resource to <tt>FAILED</tt>. + * Then sends them back to users, and clean up the relevant lists. + */ public abstract void setGridletsFailed(); /** - * This function sets the gridlet status of all the gridlets in a machine to FAILED. - * Then sends them back to the user, and clean gridlets lists. - * @param failedMachID the id of the failed machine */ + * Sets the status of all Gridlets in this machine to <tt>FAILED</tt>. + * Then sends them back to users, and clean up the relevant lists. + * @param failedMachID the id of the failed machine + */ public abstract void setGridletsFailed(int failedMachID); } // end class - Modified: branches/gridsim4.0-branch1/source/gridsim/resFailure/AvailabilityInfo.java =================================================================== --- branches/gridsim4.0-branch1/source/gridsim/resFailure/AvailabilityInfo.java 2007-08-22 08:08:48 UTC (rev 29) +++ branches/gridsim4.0-branch1/source/gridsim/resFailure/AvailabilityInfo.java 2007-08-27 06:22:18 UTC (rev 30) @@ -1,66 +1,89 @@ /* - * Agustin Caminero - * Instituto de Investigacion en Informatica de Albacete - * Universidad de Castilla La Mancha, Spain - * January, 2007. + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * This class implements the way that users know if a resource is working or is totally failed. - * + * Author: Agustin Caminero + * Organization: Universidad de Castilla La Mancha (UCLM), Spain. + * Created on: Nov 2006. */ package gridsim.resFailure; /** - * This class implements the way that users know if a resource is working or is totally failed. - * @author Agustin Caminero, Universidad de Castilla La Mancha (UCLM), Spain. Jan 2007. - * @since GridSim 4.1 + * This class is used by GridSim users to check whether a particular resource + * is working or is totally failed. + * + * @author Agustin Caminero + * @since GridSim Toolkit 4.1 */ public class AvailabilityInfo { + private int resID; + private int srcID; + private boolean availability; - public int resID; - public int srcID; - public boolean availability; - + /** + * Creates a new object of this class + * @param res a resource id + * @param src the sender id + */ public AvailabilityInfo(int res, int src) { resID = res; srcID = src; - availability = true; // by default, true + availability = true; // by default, true } - public int getSrcID() - { + /** + * Gets the source or sender id + * @return sender id + */ + public int getSrcID() { return srcID; } - public int getResID() - { + /** + * Gets the resource id + * @return resource id + */ + public int getResID() { return resID; } - public boolean getAvailability() - { + /** + * Checks the availability of this resource + * @return <tt>true</tt> if available, <tt>false</tt> otherwise + */ + public boolean getAvailability() { return availability; } - public void setSrcID(int src) - { + /** + * Sets the source or sender id + * @param src the sender id + */ + public void setSrcID(int src) { srcID = src; } - public void setResID(int res) - { + /** + * Sets the resource id + * @param res a resource id + */ + public void setResID(int res) { resID = res; } - public void setAvailability(boolean av) - { + /** + * Sets the resource availability + * @param av <tt>true</tt> if available, <tt>false</tt> otherwise + */ + public void setAvailability(boolean av) { availability = av; } - - -} +} // end class Modified: branches/gridsim4.0-branch1/source/gridsim/resFailure/FailureMsg.java =================================================================== --- branches/gridsim4.0-branch1/source/gridsim/resFailure/FailureMsg.java 2007-08-22 08:08:48 UTC (rev 29) +++ branches/gridsim4.0-branch1/source/gridsim/resFailure/FailureMsg.java 2007-08-27 06:22:18 UTC (rev 30) @@ -1,81 +1,103 @@ /* - * Agustin Caminero - * Instituto de Investigacion en Informatica de Albacete - * Universidad de Castilla La Mancha, Spain - * November, 2006. + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * This class implements the way that the (Regional)GIS commnunicates with the - * GridResources to simulate a resource failure. - * + * Author: Agustin Caminero + * Organization: Universidad de Castilla La Mancha (UCLM), Spain. + * Created on: Nov 2006. */ package gridsim.resFailure; /** - * This class implements the way that the RegionalGISWithFailure commnunicates with the - * GridResourcesWithFailure to simulate a resource failure. - * @author Agustin Caminero, Universidad de Castilla La Mancha (UCLM), Spain. Jan 2007. - * @since GridSim 4.1 + * This class is used by + * {@link gridsim.resFailure.RegionalGISWithFailure} to commnunicate with + * {@link gridsim.resFailure.GridResourceWithFailure} + * for simulating a resource failure. + * + * @author Agustin Caminero + * @since GridSim Toolkit 4.1 */ -public class FailureMsg { - /**The time that the failure will last*/ - double time; +public class FailureMsg +{ + /** The time that the failure will last */ + private double time; - /**The id of the resource*/ - int res_id; + /** The id of the resource */ + private int res_id; - /**The number of machines that will fail in this resource*/ - int numMachines; + /** The number of machines that will fail in this resource */ + private int numMachines; - /**@param t the time that the failure will last - * @param rid the resource id */ - public FailureMsg(double t, int rid) { - time = t; + /** + * Creates a new failure message + * @param time the time that the failure will last + * @param rid the resource id + */ + public FailureMsg(double time, int rid) { + this.time = time; res_id = rid; numMachines = 0; } - /**This method sets the time atribute of the ResourceFailure object - * @param t the time that the failure will last*/ - public void setTime(double t) + /** + * This method sets the time atribute of the ResourceFailure object + * @param time the time that the failure will last + */ + public void setTime(double time) { - time = t; + this.time = time; } - /**This method returns the time atribute of the ResourceFailure object */ + /** + * This method returns the time atribute of the ResourceFailure object + * @return time + */ public double getTime() { return time; } - /**This method sets the res_id atribute of the ResourceFailure object - * @param r the resource id of the resource*/ + /** + * This method sets the res_id atribute of the ResourceFailure object + * @param r the resource id of the resource + */ public void setRes(int r) { res_id = r; } - /**This method returns the res_id atribute of the ResourceFailure object */ + /** + * This method returns the res_id atribute of the ResourceFailure object + * @return the resource id + */ public int getRes() { return res_id; } - /**This method sets the numMachines atribute of the ResourceFailure object - * @param n the number of machines which will fail in this resource*/ + /** + * This method sets the numMachines atribute of the ResourceFailure object + * @param n the number of machines which will fail in this resource + */ public void setNumMachines(int n) { numMachines = n; } - /**This method returns the number of machines which will fail in this resource */ + /** + * This method returns the number of machines which will fail + * in this resource + * @return number of failed machines + */ public double getNumMachines() { return numMachines; } - -} +} // end class Modified: branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java =================================================================== --- branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java 2007-08-22 08:08:48 UTC (rev 29) +++ branches/gridsim4.0-branch1/source/gridsim/resFailure/GridResourceWithFailure.java 2007-08-27 06:22:18 UTC (rev 30) @@ -23,32 +23,23 @@ /** - * TODO: write a proper class decription - * Based on existing GridResource class. + * GridResourceWithFailure is based on {@link gridsim.GridResource}, but with + * added failure functionalities. + * GridResourceWithFailure extends the {@link gridsim.GridSimCore} class for + * gaining communication and concurrent entity capabilities. + * An instance of this class stimulates a resource + * with properties defined in an object of + * {@link gridsim.ResourceCharacteristics} class. * * @author Agustin Caminero - * Things added or modified: - * - RESOURCE_NUM_MACHINES event - * - processEvent(...) - * - processFailure(...) - * - processRecovery(...) - * - setMachineFailed(...) - * - processPingRequest(...) -> it's not modifyed any more - * - processPolling(...) - * - * * @since GridSim Toolkit 4.1 - * @see gridsim.GridSimCore + * @see gridsim.GridResource * @see gridsim.ResourceCharacteristics - * @see gridsim.AllocPolicyWithFailure + * @see gridsim.resFailure.AllocPolicyWithFailure * @invariant $none */ public class GridResourceWithFailure extends GridSimCore { - - /**Wether this resource is working properly or it is failed*/ - //private boolean ResourceFailed_; - /** Characteristics of this resource */ protected ResourceCharacteristics resource_; @@ -69,10 +60,13 @@ /** Regional GIS entity name */ protected String regionalGISName_; + // a flag to denote whether to record events into a file or not + private boolean record_ = false; + /** - * Allocates a new GridResourceWithFailure object. When making a different type of - * GridResourceWithFailure object, use + * Allocates a new GridResourceWithFailure object. When making a different + * type of GridResourceWithFailure object, use * {@link #GridResourceWithFailure(String, double, ResourceCharacteristics, * ResourceCalendar, AllocPolicyWithFailure)} * and then overrides {@link #processOtherEvent(Sim_event)}. @@ -101,7 +95,7 @@ * String) * @see gridsim.GridSim#init(int, Calendar, boolean) * @see #GridResourceWithFailure(String, double, - * ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure) + * ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure) * @pre name != null * @pre baud_rate > 0 * @pre resource != null @@ -125,8 +119,8 @@ } /** - * Allocates a new GridResourceWithFailure object. When making a different type of - * GridResourceWithFailure object, use + * Allocates a new GridResourceWithFailure object. When making a different + * type of GridResourceWithFailure object, use * {@link #GridResourceWithFailure(String, double, ResourceCharacteristics, * ResourceCalendar, AllocPolicyWithFailure)} * and then overrides {@link #processOtherEvent(Sim_event)}. @@ -150,7 +144,7 @@ * String) * @see gridsim.GridSim#init(int, Calendar, boolean) * @see #GridResourceWithFailure(String, double, - * ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure) + * ResourceCharacteristics, ResourceCalendar, AllocPolicyWithFailure) * @pre name != null * @pre baud_rate > 0 * @pre resource != null @@ -170,9 +164,9 @@ } /** - * Allocates a new GridResourceWithFailure object. When making a different type of - * GridResourceWithFailure object, use this constructor and then overrides - * {@link #processOtherEvent(Sim_event)}. + * Allocates a new GridResourceWithFailure object. When making a different + * type of GridResourceWithFailure object, use this constructor and then + * overrides {@link #processOtherEvent(Sim_event)}. * * @param name the name to be associated with this entity (as * required by Sim_entity class from simjava package) @@ -195,7 +189,7 @@ * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], * String) * @see gridsim.GridSim#init(int, Calendar, boolean) - * @see gridsim.AllocPolicyWithFailure + * @see gridsim.resFailure.AllocPolicyWithFailure * @pre name != null * @pre baud_rate > 0 * @pre resource != null @@ -209,17 +203,18 @@ { super(name, baud_rate); resource_ = resource; - resCalendar_ = calendar; - policy_ = (AllocPolicy) policy; // the order between policy and init() is important + + // the order between policy and init() is important + policy_ = (AllocPolicy) policy; init(); } //////////////////////////////////////////// /** - * Allocates a new GridResourceWithFailure object. When making a different type of - * GridResourceWithFailure object, use + * Allocates a new GridResourceWithFailure object. When making a different + * type of GridResourceWithFailure object, use * {@link #GridResourceWithFailure(String, Link, ResourceCharacteristics, * ResourceCalendar, AllocPolicyWithFailure)} * and then overrides {@link #processOtherEvent(Sim_event)}. @@ -252,7 +247,7 @@ * @pre resource != null * @post $none */ - public GridResourceWithFailure(String name, Link link, long seed, + public GridResourceWithFailure(String name, Link link, long seed, ResourceCharacteristics resource, double peakLoad, double offPeakLoad, double relativeHolidayLoad, LinkedList weekends, LinkedList holidays) throws Exception @@ -269,8 +264,8 @@ } /** - * Allocates a new GridResourceWithFailure object. When making a different type of - * GridResourceWithFailure object, use + * Allocates a new GridResourceWithFailure object. When making a different + * type of GridResourceWithFailure object, use * {@link #GridResourceWithFailure(String, Link, ResourceCharacteristics, * ResourceCalendar, AllocPolicyWithFailure)} * and then overrides {@link #processOtherEvent(Sim_event)}. @@ -312,9 +307,9 @@ } /** - * Allocates a new GridResourceWithFailure object. When making a different type of - * GridResourceWithFailure object, use this constructor and then overrides - * {@link #processOtherEvent(Sim_event)}. + * Allocates a new GridResourceWithFailure object. When making a different + * type of GridResourceWithFailure object, use this constructor and then + * overrides {@link #processOtherEvent(Sim_event)}. * * @param name the name to be associated with this entity (as * required by Sim_entity class from simjava package) @@ -337,7 +332,7 @@ * </ul> * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], * String) - * @see gridsim.AllocPolicyWithFailure + * @see gridsim.resFailure.AllocPolicyWithFailure * @pre name != null * @pre link != null * @pre resource != null @@ -347,13 +342,14 @@ */ public GridResourceWithFailure(String name, Link link, ResourceCharacteristics resource, ResourceCalendar calendar, - AllocPolicy policy) throws Exception + AllocPolicyWithFailure policy) throws Exception { super(name,link); resource_ = resource; - resCalendar_ = calendar; - policy_ = policy; // the order between policy and init() is important + + // the order between policy and init() is important + policy_ = (AllocPolicy) policy; init(); } @@ -399,9 +395,19 @@ } /** - * Handles external events that are coming to this GridResourceWithFailure entity. - * This method also registers the identity of this GridResourceWithFailure entity to - * <tt>GridInformationService</tt> class. + * Asks this resource to record its activities. <br> + * NOTE: this method should be called <b>BEFORE</b> the ssimulation starts. + * @param trace <tt>true</tt> if you want to record this resource's + * activities, <tt>false</tt> otherwise + */ + public void setTrace(boolean trace) { + record_ = trace; + } + + /** + * Handles external events that are coming to this GridResourceWithFailure + * entity. This method also registers the identity of this + * GridResourceWithFailure entity to <tt>GridInformationService</tt> class. * <p> * The services or tags available for this resource are: * <ul> @@ -460,7 +466,7 @@ registerOtherEntity(); // Put the headers on each column in the results file - initializeResultsFile(); + initializeReportFile(); // Process events until END_OF_SIMULATION is received from the // GridSimShutdown Entity @@ -472,7 +478,7 @@ // if the simulation finishes then exit the loop if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) { - System.out.println(get_name()+ ". Processing end of simulation..."); + System.out.println(get_name()+ ": end of simulation..."); policy_.setEndSimulation(); break; } @@ -485,35 +491,7 @@ super.terminateIOEntities(); } - /** - * As of GridSim 2.2, this method is <b>OBSOLETE</b>. - * Allocates one of the PEs to Gridlet for execution and schedules - * an internal event to be delivered at completion time. - * @param gl a Gridlet to be processed - * @deprecated As of GridSim 2.2, this method is <b>OBSOLETE</b>. - * @pre gl != null - * @post $none - */ - public void SpaceShare_AllocatePEtoGridlet(Gridlet gl) { - this.spaceShared_AllocatePEtoGridlet(gl); - } - /** - * As of GridSim 2.2, this method is <b>OBSOLETE</b>. - * Allocates one of the PEs to Gridlet for execution and schedules - * an internal event to be delivered at completion time. - * @param gl a Gridlet to be processed - * @deprecated As of GridSim 2.2, this method is <b>OBSOLETE</b>. - * @pre gl != null - * @post $none - */ - public void spaceShared_AllocatePEtoGridlet(Gridlet gl) - { - System.out.println("GridResourceWithFailure.spaceShared_AllocatePEtoGridlet()" + - " is OBSOLETE since GridSim 2.2. Don't use this method."); - } - - //////////////////// PROTECTED METHODS /////////////////////////////////// /** @@ -521,7 +499,7 @@ * This method is called by {@link #body()} for incoming unknown tags. * <p> * Another approach is to override the - * {@link gridsim.AllocPolicyWithFailure#processOtherEvent(Sim_event)} method. + * {@link gridsim.AllocPolicy#processOtherEvent(Sim_event)} method. * This approach is desirable if you do not want to create a new type of * grid resource. * @@ -606,10 +584,12 @@ } policy_.init(resource_, resCalendar_, super.output); + record_ = false; } /** - * Processes events or services that are available for this GridResourceWithFailure + * Processes events or services that are available for this + * GridResourceWithFailure * @param ev a Sim_event object * @pre ev != null * @post $none @@ -618,7 +598,8 @@ { int src_id = -1; - // GRIDRESOURCE_RECOVERY and GRIDRESOURCE_FAILURE_INFO (polling request) are ALWAYS processed. + // GRIDRESOURCE_RECOVERY and GRIDRESOURCE_FAILURE_INFO (polling request) + // are ALWAYS processed. if (ev.get_tag() == GridSimTags.GRIDRESOURCE_RECOVERY) { processRecovery(ev); @@ -628,7 +609,8 @@ processPolling(ev); } - if (getResourceFailed() == false) // Only if the resource is not failed, then process other events + // Only if the resource is not failed, then process other events + if (getResourceFailed() == false) { switch (ev.get_tag()) { @@ -637,7 +619,7 @@ case GridSimTags.RESOURCE_CHARACTERISTICS: src_id = ((Integer) ev.get_data()).intValue(); super.send(super.output, 0.0, ev.get_tag(), - new IO_data(resource_, resource_.getByteSize(), src_id)); + new IO_data(resource_, resource_.getByteSize(), src_id)); break; @@ -660,7 +642,7 @@ src_id = ((Integer) ev.get_data()).intValue(); int numFreePE = resource_.getNumFreePE(); super.send(super.output, 0.0, ev.get_tag(), - new IO_data(new Integer(numFreePE), SIZE, src_id)); + new IO_data(new Integer(numFreePE), SIZE, src_id)); break; // New Gridlet arrives @@ -700,12 +682,12 @@ processGridlet(ev, GridSimTags.GRIDLET_RESUME_ACK); break; - // Moves a previously submitted Gridlet to a different resource + // Moves a previously submitted Gridlet to a different res case GridSimTags.GRIDLET_MOVE: processGridletMove(ev, GridSimTags.GRIDLET_MOVE); break; - // Moves a previously submitted Gridlet to a different resource + // Moves a previously submitted Gridlet to a different res case GridSimTags.GRIDLET_MOVE_ACK: processGridletMove(ev, GridSimTags.GRIDLET_MOVE_ACK); break; @@ -725,7 +707,7 @@ break; case GridSimTags.GRIDRESOURCE_RECOVERY: - // Do nothing, as we have already done it in the "if" statement + // Do nothing, as we have done it in the "if" statement break; // Get the total number of machines of this resource @@ -733,12 +715,13 @@ src_id = ((Integer) ev.get_data()).intValue(); int numMachines = resource_.getNumMachines(); super.send(super.output, 0.0, ev.get_tag(), - new IO_data(new Integer(numMachines), SIZE, src_id)); + new IO_data(new Integer(numMachines), SIZE, src_id)); break; case GridSimTags.GRIDRESOURCE_FAILURE_INFO: - // Do nothing, as we have already done it in the "if" statement + // Do nothing, as we have done it in the "if" statement break; + // other unknown tags are processed by this method default: processOtherEvent(ev); @@ -747,7 +730,8 @@ }// if (getResourceFailed() == false) else { - // If we receive an event while the resource is out of order, we have to send the event back. + // If we receive an event while the resource is out of order, + // we have to send the event back. // Otherwise the sender of that event would get stuck. Object obj = ev.get_data(); @@ -757,19 +741,18 @@ try { gl.setGridletStatus(Gridlet.FAILED_RESOURCE_UNAVAILABLE); - gl.setResourceParameter(super.get_id(), resource_.getCostPerSec()); }catch(Exception e) {} - /* + /********* //Uncomment this, if you want more info on the progress of sims System.out.println("################# " + super.get_name() + - ". Received an event from " + GridSim.getEntityName(gl.getUserID()) + - " while the resource was failed. So, event not processed. Event tag: " + - ev.get_tag() + - ". Returning GRIDLET_RETURN to the user."); - */ + ". Received an event from " + GridSim.getEntityName(gl.getUserID()) + + " while the resource was failed. So, event not processed. Event tag: " + + ev.get_tag() + + ". Returning GRIDLET_RETURN to the user."); + *******/ super.send(super.output, 0, GridSimTags.GRIDLET_RETURN, new IO_data(gl,gl.getGridletOutputSize(),gl.getUserID()) ); @@ -783,13 +766,9 @@ src_id = ((Integer) ev.get_data()).intValue(); super.send(super.output, 0.0, ev.get_tag(), - new IO_data(resource_, resource_.getByteSize(), src_id)); + new IO_data(resource_, resource_.getByteSize(), src_id)); } - - } - - } /** @@ -1040,6 +1019,7 @@ new IO_data(pkt, pkt.getSize(), pkt.getSrcID())); } + //////////////////////////////////////////// /** * Processes a polling request. @@ -1052,33 +1032,32 @@ // The resource WILL ALWAYS give a response to the polling requests, // even when all the machines of the resource are out of order. // When all the machines are out of order, - // the resource will wait for a period of time before answering the polling request. + // the resource will wait for a period of time before answering + // the polling request. AvailabilityInfo resAv = (AvailabilityInfo) ev.get_data(); - /*// Uncomment this to get more info on the progress of sims + /****** // Uncomment this to get more info on the progress of sims System.out.println("++++++++++ " + super.get_name() + - ". Received a poll request event from "+ - GridSim.getEntityName(resAv.getSrcID()) +". Clock: " + - GridSim.clock() +". Is res failed?: "+ getResourceFailed());*/ + ". Received a poll request event from "+ + GridSim.getEntityName(resAv.getSrcID()) +". Clock: " + + GridSim.clock() +". Is res failed?: "+ getResourceFailed()); + *******/ - - if (getResourceFailed()) // if all the mahcines of the resource are out of order or not + // if all the mahcines of the resource are out of order or not + if (getResourceFailed()) { resAv.setAvailability(false); - super.sim_pause(GridSimTags.POLLING_TIME_USER); - } else { resAv.setAvailability(true); - } + // sends back to the sender super.send(super.output, 0.0, ev.get_tag(), new IO_data(resAv, Link.DEFAULT_MTU, resAv.getSrcID())); - } @@ -1088,7 +1067,7 @@ * @pre ev != null * @post $none */ - protected void processFailure(Sim_event ev) + private void processFailure(Sim_event ev) { if (ev == null) { @@ -1096,64 +1075,73 @@ "Error - an event is null."); return; } + Object obj = ev.get_data(); if (obj instanceof FailureMsg) { - - //FileWriter fwriter = null; - FailureMsg resFail = (FailureMsg) obj; int numFailedMachines = (int)resFail.getNumMachines(); int numMachines = resource_.getNumMachines(); - // First, we have to set ome of the machines of the resource as out of order. - // Then, we have to set the gridlets to FAILED or FAILED_RESOURCE_UNAVAILABLE - // depending on whether there are still available machines in this resource + // First, we have to set ome of the machines of the resource + // as out of order. + // Then, we have to set the gridlets to FAILED or + // FAILED_RESOURCE_UNAVAILABLE + // depending on whether there are still available machines + // in this resource if (numFailedMachines >= numMachines) { - // This resource will not work, as none of its machines are running - - - + // This resource will not work, as none of its machines + // are running double time; time = resFail.getTime(); - // Uncomment this if you want more info on the progress of sims - System.out.println("################# " + super.get_name() + - ".processFailure(): " + - "Received an event GRIDRESOURCE_FAILURE. Clock:" + - GridSim.clock() + - " which will last until clock:" + - (GridSim.clock() + time) + - ". There are NO working machines in this resource."); + /*****************/ + // Now, we keep the moment of the failure in a results file + // for this res + if (record_ == true) { + write("Failure", numMachines); + System.out.println("################# " + super.get_name() + + ".processFailure(): " + + "Received an event GRIDRESOURCE_FAILURE. Clock:" + + GridSim.clock() + " which will last until clock:" + + (GridSim.clock() + time) + + ". There are NO working machines in this resource."); + } + /******************/ - setMachineFailed(true, numMachines); // set all the machines as failed - + // set all the machines as failed + setMachineFailed(true, numMachines); emptyGridletLists(); - // as all the machines in this resource have failed, all the gridlets - // are lost (the ones running and the ones waiting) - // Now, we keep the moment of the failure in a results file for this res - write ("Failure", numMachines); + // as all the machines in this resource have failed, all + // gridlets are lost (the ones running and the ones waiting) }//if (numFailedMachines >= numMachines) else { - // This resource will still work, as some of its machines are running + // This resource will still work, as some of its machines + // are running + /*****************/ + // Now, we keep the moment of the failure in a results file + // for this res + if (record_ == true) { + write("Failure", numFailedMachines); - // Uncomment this if you want more info on the progress of sims - System.out.println("################# " + super.get_name() + - ".processFailure(): " + - "Received an event GRIDRESOURCE_FAILURE. Clock:" + - GridSim.clock() + - ". There are STILL working machines in this resource."); + System.out.println("################# " + super.get_name() + + ".processFailure(): " + + "Received an event GRIDRESOURCE_FAILURE. Clock:" + + GridSim.clock() + + ". There are STILL working machines in this resource."); + } + /******************/ + // set numFailedMachines machines as failed + setMachineFailed(true, numFailedMachines); - setMachineFailed(true, numFailedMachines); // set numFailedMachines machines as failed - Machine mach; int machID; // empty only the exec list of the machines which has failed @@ -1163,14 +1151,8 @@ machID = mach.getMachineID(); emptyGridletLists(machID); } - - // Now, we keep the moment of the failure in a results file for this res - write ("Failure", numFailedMachines); - } - } - } /** @@ -1181,7 +1163,7 @@ * @pre ev != null * @post $none */ - protected void processRecovery(Sim_event ev) + private void processRecovery(Sim_event ev) { int mach = resource_.getNumMachines(); int failedMach = resource_.getNumFailedMachines(); @@ -1198,30 +1180,34 @@ int gisID = GridSim.getEntityId(regionalGISName_); // send the registration to regGIS - super.send(super.output, GridSimTags.SCHEDULE_NOW, GridSimTags.REGISTER_RESOURCE, + super.send(super.output, GridSimTags.SCHEDULE_NOW, + GridSimTags.REGISTER_RESOURCE, new IO_data(new Integer(super.get_id()), SIZE, gisID)); System.out.println(super.get_name() + ": Resource recovered." + - " Registering the resource at the regional GIS AGAIN" + - " after the failure at clock:" + GridSim.clock()); + " Registering the resource at the regional GIS AGAIN" + + " after the failure at clock:" + GridSim.clock()); } - else - System.out.println(super.get_name() + ": Resource recovered at clock:" + GridSim.clock()); + else { + System.out.println(super.get_name() + + ": Resource recovered at clock:" + GridSim.clock()); + } - - write("Recovery", 0);// Write in the results file - + if (record_ == true) { + write("Recovery", 0); // Write in the results file + } } /** - * This method empties the lists containing gridlets in execution and waiting for execution. + * This method empties the lists containing gridlets in execution + * and waiting for execution. */ - protected void emptyGridletLists() + private void emptyGridletLists() { if (policy_ instanceof AllocPolicyWithFailure) - ((AllocPolicyWithFailure)policy_).setGridletsFailed(); + ((AllocPolicyWithFailure) policy_).setGridletsFailed(); } @@ -1232,18 +1218,20 @@ * @pre ev != null * @post $none */ - protected void emptyGridletLists(int machID) + private void emptyGridletLists(int machID) { if (policy_ instanceof AllocPolicyWithFailure) - ((AllocPolicyWithFailure)policy_).setGridletsFailed(machID); + ((AllocPolicyWithFailure) policy_).setGridletsFailed(machID); } /** - * Returns true if all the machines of the resource are out of order at this moment. + * Checks whether all machines in this resource are failed or not. + * @return <tt>true</tt> if all the machines of the resource + * are out of order at this moment. */ - public boolean getResourceFailed() + private boolean getResourceFailed() { int numMach = resource_.getMachineList().size(); Machine mach; @@ -1260,121 +1248,129 @@ return resFailed; } - /**Set the status of a machine of this resource. - * @param b the new status of the machine. true means the machine is failed, false means the machine is working properly. - * @param numFailedMachines the number of mahicnes whose status were are going to modify + /** + * Set the status of a machine of this resource. + * @param b the new status of the machine. + * <tt>true</tt> means the machine is failed, + * <tt>false</tt> means the machine is working properly. + * @param numFailedMachines the number of failed machines * - * */ - public void setMachineFailed(boolean b, int numFailedMachines) + */ + private void setMachineFailed(boolean b, int numFailedMachines) { Machine mach; - /* - // Uncomment htis if you want more info on the progress of sims - String status = null; + /************ + // Uncomment this if you want more info on the progress of sims + String status = null; if (b) status = "FAILED"; else - status = "WORKING";*/ + status = "WORKING"; + ************/ - for(int i=0; i< numFailedMachines; i++) + for(int i = 0; i < numFailedMachines; i++) { mach = resource_.getMachineList().getMachineInPos(i); - if (mach != null) { + /************* // Uncomment htis if you want more info on the progress of sims - //System.out.println("$$$$$$ "+ super.get_name() +". Machine: "+ i +": Setting this machine to "+ status+ "..."); - //mach.setFailed(super.get_name(), i, b); - mach.setFailed(super.get_name(), b); + System.out.println("$$$$$$ "+ super.get_name() +". Machine: " + + i +": Setting this machine to "+ status+ "..."); + mach.setFailed(super.get_name(), i, b); + *************/ + mach.setFailed(super.get_name(), b); } } } - /** - * Initialize the results files (put headers over each column) - * */ - public void initializeResultsFile() + /** + * Initializes the results files (put headers over each column) + */ + private void initializeReportFile() { - // Initialize the results file - FileWriter fwriter = null; - try - { - fwriter = new FileWriter(super.get_name(), true); + if (record_ == false) { + return; + } - } catch (Exception ex) - { - ex.printStackTrace(); - System.out.println( - "Unwanted errors while opening file " + super.get_name()+" or " + super.get_name()+"_Fin"); - } + // Initialize the results file + FileWriter fwriter = null; + try { + fwriter = new FileWriter(super.get_name(), true); + } + catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while opening file " + + super.get_name() + " or " + super.get_name() + "_Fin"); + } - try - { - fwriter.write( - "Resource \t Event \t NumMachines \t Clock\n"); + try { + fwriter.write("Resource \t Event \t NumMachines \t Clock\n"); + } + catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while writing on file " + + super.get_name() + " or " + super.get_name() + "_Fin"); + } - } catch (Exception ex) - { - ex.printStackTrace(); - System.out.println( - "Unwanted errors while writing on file " + super.get_name()+" or " + super.get_name()+"_Fin"); - } - - try - { - fwriter.close(); - - } catch (Exception ex) - { - ex.printStackTrace(); - System.out.println( - "Unwanted errors while closing file " + super.get_name()+" or " + super.get_name()+"_Fin"); - } + try { + fwriter.close(); + } + catch (Exception ex) + { + ex.printStackTrace(); + System.out.println("Unwanted errors while closing file " + + super.get_name() + " or " + super.get_name() + "_Fin"); + } } /** - * Write some data into a results file. - * @param event Values: "Failure" or "Recovery" a gridlet - * */ - public void write(String event, int numMachines) + * Writes some data into a results file. + * @param event Values: "Failure" or "Recovery" of a resource + * @param numMachiens number of machines + */ + private void write(String event, int numMachines) { - // Write into a results file - // Now, we keep the moment of the failure in a results file for this res - FileWriter fwriter = null; - try - { + if (record_ == false) { + return; + } + + // Write into a results file + // Now, we keep the moment of the failure in a results file for this res + FileWriter fwriter = null; + try + { fwriter = new FileWriter(this.get_name(), true); - } catch (Exception ex) - { + } catch (Exception ex) + { ex.printStackTrace(); System.out.println("Unwanted errors while opening file " + this.get_name()); - } - try - { - fwriter.write(this.get_name() + "\t "+event+ " \t" + numMachines +" \t" + GridSim.clock() + "\n"); - } catch (Exception ex) - { + } + try + { + fwriter.write(this.get_name() + "\t " + event+ " \t" + numMachines + + " \t" + GridSim.clock() + "\n"); + } catch (Exception ex) + { ex.printStackTrace(); System.out.println("Unwanted errors while writing on file " + this.get_name()); - } + } - try - { + try + { fwriter.close(); - } catch (Exception ex) - { + } catch (Exception ex) + { ex.printStackTrace(); System.out.println("Unwanted errors while closing file " + this.get_name()); - } - + } } - - } // end class - Modified: branches/gridsim4.0-branch1/source/gridsim/resFailure/RegionalGISWithFailure.java =================================================================== --- branches/gridsim4.0-branch1/source/gridsim/resFailure/RegionalGISWithFailure.java 2007-08-22 08:08:48 UTC (rev 29) +++ branches/gridsim4.0-branch1/source/gridsim/resFailure/RegionalGISWithFailure.java 2007-08-27 06:22:18 UTC (rev 30) @@ -2,7 +2,12 @@ * Title: GridSim Toolkit * Description: GridSim (Grid Simulation) Toolkit for Modeling and Simulation * of Parallel and Distributed Systems such as Clusters and Grids - */ + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + * Author: Agustin Caminero + * Organization: Universidad de Castilla La Mancha (UCLM), Spain. + * Created on: Nov 2006. + */ package gridsim.resFailure; @@ -15,13 +20,15 @@ import gridsim.resFailure.FailureMsg; import eduni.simjava.distributions.DiscreteGenerator; import eduni.simjava.distributions.ContinuousGenerator; -//import gridsim.resFailure.distributions.Variate; import gridsim.util.Variate; import java.io.FileWriter; /** - * RegionalGISWithFailureis a simple regional GridInformationService (GIS) entity that + * RegionalGISWithFailure is based on {@link gridsim.index.RegionalGIS}, but + * with added failure functionalities. + * RegionalGISWithFailure is a simple regional GridInformationService (GIS) + * entity that * performs basic functionalities, such as storing a list of local resources, * and asking other regional GIS entities for resources. * <p> @@ -29,48 +36,31 @@ * this class and to override {@link #processOtherEvent(Sim_event)} * and/or {@link #registerOtherEntity()} method. * - * @author Agustin Caminero, Universidad de Castilla La Mancha (UCLM), Spain. Nov 2006. - * Based on class RegionalGIS, Anthony Sulistio. - * Things added or modified: - * - failureNumResPattern_, failureResPattern_, failureTimePattern_, - * failureLengthPattern_ all of these cwith ontinuous, discrete and variate versions - * - gisID_ - * - setFailureGenerator(...) - * - init(...) - * - processOtherEvent(...): formerly it was empty - * - registerOtherEntity(...): formerly it was empty - * - failedResList_ -> removed - * - processEndSimulation(...) - * - getResourceCharacteristics(...) - * - pollResource(...) - * - pollReturn(...) - * - processResourceFailed(...) - * - write(...) - * @invariant $none - * @since GridSim 4.1 + * @author Agustin Caminero + * @since GridSim Toolkit 4.1 + * @see gridsim.index.RegionalGIS */ public class RegionalGISWithFailure extends AbstractGIS { - // if there is a conflict, we can simply change this number - private static final int GIS_WITH_FAILURE_BASE = 2000; + private static final int GIS_WITH_FAILURE_BASE = 2000; // TODO - - /** Denotes that an user has detected the failure of a resource. So, the user sends + /** Denotes that an user has detected the failure of a resource. + * So, the user sends * this tag to the GIS to make it update its list of resources. */ - public static final int RESOURCE_FAILED = GIS_WITH_FAILURE_BASE + 1; + public static final int RESOURCE_FAILED = GIS_WITH_FAILURE_BASE + 1; // TODO: /** This entity ID in <tt>Integer</tt> object. */ protected Integer myID_; - public int gisID_; // for a RegionalGISWithFailure named "RegionalGIS_2", the gisID_ will be 2 // This is also the number of the VO. + public int gisID_; // TODO: redundant ?? + // denotes whether sim has just began or it has been running for some time + private boolean begining; - private boolean begining; - // denotes whether the sim has just began or it has been running for some time private ArrayList resList_; // all resources within this region private ArrayList arList_; // AR resources only within this region private ArrayList globalResList_; // all resources outside this region @@ -81,39 +71,45 @@ private int numRes_; // counting for num of GIS entities for res request private int numAR_; // counting for num of GIS entities for res AR request + // defines how GIS should decide how many resource fails + private DiscreteGenerator failureNumResPatternDiscrete_; - // TODO: the best way is to have a generic Object variable then cast it !! + // defines how GIS should decide when the resource will fail + private DiscreteGenerator failureTimePatternDiscrete_; - private DiscreteGenerator failureNumResPatternDiscrete_; - // defines how GIS should decide how many resource fails - private DiscreteGenerator failureTimePatternDiscrete_; - // defines how GIS should decide when the resource will fail + // defines how GIS should decide how long the resource will be out of order private DiscreteGenerator failureLengthPatternDiscrete_; - // defines how GIS should decide how long the resource will be out of order + + // defines how GIS should decide how many resource fails private ContinuousGenerator failureNumResPatternCont_; - // defines how GIS should decide how many resource fails + + // defines how GIS should decide when the resource will fail private ContinuousGenerator failureTimePatternCont_; - // defines how GIS should decide when the resource will fail + + // defines how GIS should decide how long the resource will be out of order private ContinuousGenerator failureLengthPatternCont_; - // defines how GIS should decide how long the resource will be out of order + // New, as some distibutions coming with SimJava2 does not work + // defines how GIS should decide how many resource fails private Variate failureNumResPatternVariate_; - // defines how GIS should decide how many resource fails + + // defines how GIS should decide when the resource will fail private Variate failureTimePatternVariate_; - // defines how GIS should decide when the resource will fail + + // defines how GIS should decide how long the resource will be out of order private Variate failureLengthPatternVariate_; - // defines how GIS should decide how long the resource will be out of order /** * Creates a new regional GIS entity * @param name this regional GIS name * @param link a network link to this entity - * @param failureLengthPattern defines how GIS should decide how long the resource will be out of order - * @param failureNumResPattern defines how GIS should decide how many resource fails - * @param failureTimePattern defines how GIS should decide when the resource will fail + * @param failureLengthPattern defines on how long + * each resource will be out of order + * @param failureNumResPattern defines on how many resource fails + * @param failureTimePattern defines on when each resource will fail * @throws Exception This happens when creating this entity before * initializing GridSim package or this entity name is * <tt>null</tt> or empty @@ -121,9 +117,11 @@ * @pre link != null * @post $none */ - public RegionalGISWithFailure(String name, Link link, DiscreteGenerator failureNumResPattern, - DiscreteGenerator failureTimePattern, - DiscreteGenerator failureLengthPattern, int gisID) throws Exception + public RegionalGISWithFailure(String name, Link link, + DiscreteGenerator failureNumResPattern, + DiscreteGenerator failureTimePattern, + DiscreteGenerator failureLengthPattern, int gisID) + throws Exception { super(name, link); gisID_ = gisID; @@ -133,74 +131,74 @@ else throw new Exception(super.get_name() + " : Problem when setting the failure patterns for the " + - super.get_name() + " entity"); - + super.get_name() + " entity"); } /** - * Creates a new regional GIS entity - * @param name this regional GIS name - * @param link a network link to this entity - * @param failureLengthPattern defines how GIS should decide how long the resource will be out of order - * @param failureNumResPattern defines how GIS should decide how many resource fails - * @param failureTimePattern defines how GIS should decide when the resource will fail - * @throws Exception This happens when creating this entity before - * initializing GridSim package or this entity name is - * <tt>null</tt> or empty - * @pre name != null - * @pre link != null - * @post $none - */ - public RegionalGISWithFailure(String name, Link link, ContinuousGenerator failureNumResPattern, - ContinuousGenerator failureTimePattern, - ContinuousGenerator failureLengthPattern, int gisID) throws Exception - { - super(name, link); - gisID_ = gisID; + * Creates a new regional GIS entity + * @param name this regional GIS name + * @param link a network link to this entity + * @param failureLengthPattern defines on how long + * each resource will be out of order + * @param failureNumResPattern defines on how many resource fails + * @param failureTimePattern defines on when each resource will fail + * @throws Exception This happens when creating this entity before + * initializing GridSim package or this entity name is + * <tt>null</tt> or empty + * @pre name != null + * @pre link != null + * @post $none + */ + public RegionalGISWithFailure(String name, Link link, + ContinuousGenerator failureNumResPattern, + ContinuousGenerator failureTimePattern, + ContinuousGenerator failureLengthPattern, int gisID) + throws Exception + { + super(name, link); + gisID_ = gisID; - if (setFailureGenerator(failureNumResPattern, failureTimePattern, - failureLengthPattern)) - init(); - else - throw new Exception(super.get_name() + - " : Problem when setting the failure patterns for the " + - super.get_name() + " entity"); + if (setFailureGenerator(failureNumResPattern, failureTimePattern, + failureLengthPattern)) + init(); + else + throw new Exception(super.get_name() + + " : Problem when setting the failure patterns for the " + + super.get_name() + " entity"); + } - } + /** + * Creates a new regional GIS entity + * @param name this regional GIS name + * @param link a network link to this entity + * @param failureLengthPattern defines on how long + * each resource will be out of order + * @param failureNumResPattern defines on how many resource fails + * @param failureTimePattern defines on when each resource will fail + * @throws Exception This happens when creating this entity before + * initializing GridSim package or this entity name is + * <tt>null</tt> or empty + * @pre name != null + * @pre link != null + * @post $none + */ + public RegionalGISWithFailure(String name, Link link, + Variate failureNumResPattern, + Variate failureTimePattern, + Variate failureLengthPattern, int gisID) + throws Exception + { + super(name, link); + gisID_ = gisID; + if (setFailureGenerator(failureNumResPattern, failureTimePattern, + failureLengthPattern)) + init(); + else + throw new Exception(super.get_name() + + " : Problem when setting the failure patterns for the " + + super.get_name() + " entity"); + } - /** - * Creates a new regional GIS entity - * @param name this regional GIS name - * @param link a network link to this entity - * @param failureLengthPattern defines how GIS should decide how long the resource will be out of order - * @param failureNumResPattern defines how GIS should decide how many resource fails - * @param failureTimePattern defines how GIS should decide when the resource will fail - * @throws Exception This happens when creating this entity before - * initializing GridSim package or this entity name is - * <tt>null</tt> or empty - * @pre name != null - * @pre link != null - * @post $none - */ - public RegionalGISWithFailure(String name, Link link, - Variate failureNumResPattern, - Variate failureTimePattern, - Variate failureLengthPattern, int gisID) throws - Exception - { - super(name, link); - gisID_ = gisID; - if (setFailureGenerator(failureNumResPattern, failureTimePattern, - failureLengthPattern)) - init(); - else - throw new Exception(super.get_name() + - " : Problem when setting the failure patterns for the " + - super.get_name() + " entity"); - - } - - /** * Initialises all attributes * @pre $none @@ -248,13 +246,16 @@ result = true; write("Registering", id.intValue(), GridSim.clock()); - if (list.size() == 1) // REMOVE !!! - System.out.println(super.get_name() + ": The list has one resource again. Clock:" + GridSim.clock()); + if (list.size() == 1) { // REMOVE !!! + System.out.println(super.get_name() + + ... [truncated message content] |
From: <bro...@us...> - 2007-08-27 16:20:22
|
Revision: 31 http://gridsim.svn.sourceforge.net/gridsim/?rev=31&view=rev Author: brobergj Date: 2007-08-26 23:48:48 -0700 (Sun, 26 Aug 2007) Log Message: ----------- Added tags to support the 5 flow networking variants: INV-LAT, INV-LAT-BOUNDED, INV-RTT, INV-RTT-BOUNDED and MAX-MIN. Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/GridSimTags.java Modified: branches/gridsim4.0-branch2/source/gridsim/GridSimTags.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/GridSimTags.java 2007-08-27 06:22:18 UTC (rev 30) +++ branches/gridsim4.0-branch2/source/gridsim/GridSimTags.java 2007-08-27 06:48:48 UTC (rev 31) @@ -33,9 +33,24 @@ // TODO: new additions public static final int NET_PACKET_LEVEL = NETBASE + 11; + // TODO: NET_FLOW_LEVEL should default to NET_FLOW_LEVEL_INV_RTT_BOUND public static final int NET_FLOW_LEVEL = NETBASE + 12; public static final int NET_BUFFER_PACKET_LEVEL = NETBASE + 13; - + + // TODO: different flow sharing models + // INV-LAT flows are weighted proportionally to the bottleneck latency + public static final int NET_FLOW_LEVEL_INV_LAT = NETBASE + 14; + // INV-LAT-BOUND flows are weighted proportionally to the bottleneck latency + // with bounded bandwidth availability + public static final int NET_FLOW_LEVEL_INV_LAT_BOUND = NETBASE + 15; + // INV-RTT flows are weighted proportionally to the bottleneck RTT + public static final int NET_FLOW_LEVEL_INV_RTT = NETBASE + 16; + // INV-RTT flows are weighted proportionally to the bottleneck RTT + // with bounded bandwidth availability + public static final int NET_FLOW_LEVEL_INV_RTT_BOUND = NETBASE + 17; + // MAX-MIN flows are equally weighted so all flows get equal share + public static final int NET_FLOW_LEVEL_MAX_MIN = NETBASE + 18; + ////////////////////////////////////////////////////////////////////// /** Denotes boolean <tt>true</tt> in <tt>int</tt> value */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sul...@us...> - 2007-08-22 08:08:46
|
Revision: 29 http://gridsim.svn.sourceforge.net/gridsim/?rev=29&view=rev Author: sulistio Date: 2007-08-22 01:08:48 -0700 (Wed, 22 Aug 2007) Log Message: ----------- fix some minor mistakes in the examples/ directory Modified Paths: -------------- trunk/examples/DataGrid/example1/DataExample1.java trunk/examples/DataGrid/example2/DataExample2.java trunk/examples/DataGrid/example3/DataGridletExample.java trunk/examples/DataGrid/tutorial/creatingResources.html trunk/examples/Example10/ARTest.java trunk/examples/Example10/README.txt Modified: trunk/examples/DataGrid/example1/DataExample1.java =================================================================== --- trunk/examples/DataGrid/example1/DataExample1.java 2007-08-22 02:42:56 UTC (rev 28) +++ trunk/examples/DataGrid/example1/DataExample1.java 2007-08-22 08:08:48 UTC (rev 29) @@ -38,7 +38,7 @@ int num_user = 1; // number of grid users Calendar calendar = Calendar.getInstance(); boolean trace_flag = false; // means trace GridSim events - boolean gisFlag = true; // means using DataGIS instead + boolean gisFlag = false; // means using DataGIS instead GridSim.init(num_user, calendar, trace_flag, gisFlag); // set the GIS into DataGIS that handles specifically for data grid Modified: trunk/examples/DataGrid/example2/DataExample2.java =================================================================== --- trunk/examples/DataGrid/example2/DataExample2.java 2007-08-22 02:42:56 UTC (rev 28) +++ trunk/examples/DataGrid/example2/DataExample2.java 2007-08-22 08:08:48 UTC (rev 29) @@ -37,7 +37,7 @@ int num_user = 1; // number of grid users Calendar calendar = Calendar.getInstance(); boolean trace_flag = false; // means trace GridSim events - boolean gisFlag = true; // means using DataGIS instead + boolean gisFlag = false; // means using DataGIS instead GridSim.init(num_user, calendar, trace_flag, gisFlag); // set the GIS into DataGIS that handles specifically for data grid Modified: trunk/examples/DataGrid/example3/DataGridletExample.java =================================================================== --- trunk/examples/DataGrid/example3/DataGridletExample.java 2007-08-22 02:42:56 UTC (rev 28) +++ trunk/examples/DataGrid/example3/DataGridletExample.java 2007-08-22 08:08:48 UTC (rev 29) @@ -27,7 +27,7 @@ * initializes all the entities, which are the same as in the other datagrid * examples. The DataGridlet management is implemented in the class GridletUser. * - * @author Uros Cibej and Anthony Sulistion + * @author Uros Cibej and Anthony Sulistio */ public class DataGridletExample { public static void main(String[] args) { @@ -41,7 +41,7 @@ int num_user = 1; // number of grid users Calendar calendar = Calendar.getInstance(); boolean trace_flag = false; // means trace GridSim events - boolean gisFlag = true; // means using DataGIS instead + boolean gisFlag = false; // means using DataGIS instead GridSim.init(num_user, calendar, trace_flag, gisFlag); // set the GIS into DataGIS that handles specifically for data grid Modified: trunk/examples/DataGrid/tutorial/creatingResources.html =================================================================== --- trunk/examples/DataGrid/tutorial/creatingResources.html 2007-08-22 02:42:56 UTC (rev 28) +++ trunk/examples/DataGrid/tutorial/creatingResources.html 2007-08-22 08:08:48 UTC (rev 29) @@ -166,7 +166,7 @@ - <font color="#000000">gridRes.setLocalRC</font><font color="#000000">()</font><font color="#000000">;<br> + <font color="#000000">gridRes.createLocalRC</font><font color="#000000">()</font><font color="#000000">;<br> </font></code><code><font color="#3f7f5f">//set the higher level</font></code><br> @@ -691,7 +691,8 @@ - <font color="#ffffff"> </font><font color="#000000">gridRes.setLocalRC</font><font color="#000000">()</font><font color="#000000">;</font><br> + <font + color="#ffffff"> </font><font color="#000000">gridRes.createLocalRC</font><font color="#000000">()</font><font color="#000000">;</font><br> Modified: trunk/examples/Example10/ARTest.java =================================================================== --- trunk/examples/Example10/ARTest.java 2007-08-22 02:42:56 UTC (rev 28) +++ trunk/examples/Example10/ARTest.java 2007-08-22 08:08:48 UTC (rev 29) @@ -7,7 +7,7 @@ * * NOTE: The values used from this example are taken from the GridSim paper. * http://www.gridbus.org/gridsim/ - * $Id: ARTest.java,v 1.2 2004/05/31 04:53:33 anthony Exp $ + * $Id: ARTest.java,v 1.3 2007/08/10 02:35:40 anthony Exp $ */ import java.util.*; @@ -27,7 +27,6 @@ { private GridletList list_; // a list containing new Gridlets private GridletList receiveList_; // a list containing completed Gridlets - private double timeZone_; // time zone of this user entity private int failReservation_; // number of reservations failed // time constant values @@ -51,9 +50,8 @@ public ARTest(String name, double baud_rate, double timeZone, int totalJob) throws Exception { - super(name, baud_rate); + super(name, baud_rate, timeZone); this.receiveList_ = new GridletList(); - this.timeZone_ = timeZone; this.failReservation_ = 0; // create Gridlets @@ -196,7 +194,8 @@ time = 0; // immediate reservation } else { - time = cal.getTimeInMillis() + (1*DAY*MILLI_SEC) + duration; + time = cal.getTimeInMillis() + (1*DAY*MILLI_SEC) + + (duration*MILLI_SEC); } // creates a new or immediate reservation @@ -268,6 +267,7 @@ // add the Gridlet into a list list.add(gridlet); + gridlet.setUserID(userID); } return list; Modified: trunk/examples/Example10/README.txt =================================================================== --- trunk/examples/Example10/README.txt 2007-08-22 02:42:56 UTC (rev 28) +++ trunk/examples/Example10/README.txt 2007-08-22 08:08:48 UTC (rev 29) @@ -2,7 +2,7 @@ /** * Author: Anthony Sulistio * Date: May 2004 - * $Id: README.txt,v 1.3 2004/11/01 02:10:39 anthony Exp $ + * $Id: README.txt,v 1.4 2007/08/10 02:35:23 anthony Exp $ */ Welcome to the 10th Example of how to use GridSim package. @@ -15,32 +15,23 @@ To run the class file: In Unix/Linux: - java -classpath $GRIDSIM/jars/gridsim.jar:. Example10 + java -classpath $GRIDSIM/jars/gridsim.jar:. Example10 In Windows: java -classpath %GRIDSIM%\jars\gridsim.jar;. Example10 - -NOTE: This example uses Java Random class to select a resource entity to + +NOTE: This example uses Java Random class to select a resource entity to process a Gridlet. Hence, when running this example many times, the values are different. When running the example file, it will produce the following files: - stat.txt -> created by GridSim 2.1, now being replaced by GridSim_stat.txt - - GridSim_stat.txt -> created by the GridSim verson 2.2 onwards - during GridSim.init() to create - GridStatistics object for statistical purposes. In this example, we - recorded the event of receiving ResourceCharacteristics object, as well - as sending/receiving Gridlets. - For more detailed explanations, please read this file. - tracefile -> created by SimJava 1.2, now being replaced by sim_trace NOTE: GridSim 2.1 uses SimJava 1.2 package GridSim 2.2 onwards use SimJava2 package - + sim_trace -> created by the SimJava2 package (lower-level) to trace every events (performed by SimJava and GridSim) during the simulation. We don't need to worry about this file. Not to important for our @@ -51,7 +42,6 @@ running this experiment. We don't need to worry about this file. Not to important for our example. -NOTE: When you run the program multiple times, new data generated from - simulation will be appended at the end of "GridSim_stat.txt". - However, "sim_trace" and "sim_report" file will be overwritten. +NOTE: When you run the program multiple times, + "sim_trace" and "sim_report" file will be overwritten. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |