From: <mar...@us...> - 2007-09-14 07:21:35
|
Revision: 57 http://gridsim.svn.sourceforge.net/gridsim/?rev=57&view=rev Author: marcos_dias Date: 2007-09-14 00:21:38 -0700 (Fri, 14 Sep 2007) Log Message: ----------- I have deleted the files to include GridSim Express. Removed Paths: ------------- branches/gridsim4.0-branch3/build.xml branches/gridsim4.0-branch3/examples/ branches/gridsim4.0-branch3/jars/ branches/gridsim4.0-branch3/javadoc.sh branches/gridsim4.0-branch3/source/ branches/gridsim4.0-branch3/testing/ Deleted: branches/gridsim4.0-branch3/build.xml =================================================================== --- branches/gridsim4.0-branch3/build.xml 2007-09-02 07:34:45 UTC (rev 56) +++ branches/gridsim4.0-branch3/build.xml 2007-09-14 07:21:38 UTC (rev 57) @@ -1,68 +0,0 @@ -<?xml version="1.0"?> - -<!-- September 2004 -Build file or Makefile for GridSim. -NOTE: Make sure you have installed 'ant' and put the location of it into - your path so you can access it anywhere. - 'ant' can be downloadable from http://ant.apache.org/ - -Usage: -* type 'ant' to compile all gridsim source files and put them into - classes/ directory -* type 'ant makejar' to compile the source files (if necessary) and to create - a jar file into jar/ directory - -NOTE: rule for javadoc is not included yet. Use javadoc.sh script instead under - Unix/Linux environment. - -Acknowledgement: Thank to Uros Cibej for providing this file and instruction on - how to use it. ---> - - -<project name="GridSim" basedir="." default="build"> - <description> - This is the build file for GridSim - </description> - - <!-- location to store Java classes --> - <property name="class.dir" location="./classes" /> - - <!-- location to store GridSim source files --> - <property name="src.dir" location="./source/gridsim" /> - - <!-- location to store jar files --> - <property name="jar.dir" location="./jars" /> - - <!-- location to store Javadoc files --> - <property name="doc.dir" location="./doc" /> - - <!-- location to use SimJava libraries --> - <property name="classpath" location="${jar.dir}/simjava2.jar" /> - - - - <target name="prepare"> - <mkdir dir="${class.dir}" /> - </target> - - <!-- rule to compile GridSim source files --> - <target name="build" depends="prepare"> - <javac srcdir="${src.dir}" destdir="${class.dir}" classpath="${classpath}" /> - </target> - - <!-- rule for making a jar file. - NOTE: - * The new jar file is named as "new_gridsim.jar" to avoid overriding - the existing jar file. - * The new jar file only contains gridsim classes NOT SimJava2. - --> - <target name="makejar" depends="build"> - <echo>Compiling a new jar file, named: "new_gridsim.jar".</echo> - <echo>This jar file only contains GridSim classes but not SimJava2.</echo> - <jar destfile="${jar.dir}/new_gridsim.jar" basedir="${class.dir}" /> - </target> - -</project> - - Deleted: branches/gridsim4.0-branch3/javadoc.sh =================================================================== --- branches/gridsim4.0-branch3/javadoc.sh 2007-09-02 07:34:45 UTC (rev 56) +++ branches/gridsim4.0-branch3/javadoc.sh 2007-09-14 07:21:38 UTC (rev 57) @@ -1,35 +0,0 @@ - -## A script to run javadoc (Anthony Sept 2004). - -year="2007" # year -ver="v4.0-branch1" # version number - -dir=./source # source directory that contains Java files -doc=./doc # output directory - -mkdir doc - -# 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/auction/*.java \ - $dir/gridsim/datagrid/*.java \ - $dir/gridsim/datagrid/filter/*.java \ - $dir/gridsim/datagrid/index/*.java \ - $dir/gridsim/datagrid/storage/*.java \ - $dir/gridsim/resFailure/*.java - -echo "javadoc is done ...." - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-09-14 07:33:31
|
Revision: 58 http://gridsim.svn.sourceforge.net/gridsim/?rev=58&view=rev Author: marcos_dias Date: 2007-09-14 00:33:33 -0700 (Fri, 14 Sep 2007) Log Message: ----------- Alpha version of GridSim Turbo Added Paths: ----------- branches/gridsim4.0-branch3/.classpath branches/gridsim4.0-branch3/.project branches/gridsim4.0-branch3/examples/ branches/gridsim4.0-branch3/examples/examples/ branches/gridsim4.0-branch3/examples/examples/workload/ branches/gridsim4.0-branch3/examples/examples/workload/parallel/ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java branches/gridsim4.0-branch3/source/ branches/gridsim4.0-branch3/source/eduni/ branches/gridsim4.0-branch3/source/eduni/simdiag/ branches/gridsim4.0-branch3/source/eduni/simdiag/GraphClearObject.java branches/gridsim4.0-branch3/source/eduni/simdiag/GraphData.java branches/gridsim4.0-branch3/source/eduni/simdiag/GraphDiagram.java branches/gridsim4.0-branch3/source/eduni/simdiag/GraphDisplay.java branches/gridsim4.0-branch3/source/eduni/simdiag/GraphEqn.java branches/gridsim4.0-branch3/source/eduni/simdiag/GraphEventObject.java branches/gridsim4.0-branch3/source/eduni/simdiag/GraphListener.java branches/gridsim4.0-branch3/source/eduni/simdiag/GraphLoader.java branches/gridsim4.0-branch3/source/eduni/simdiag/GraphSetAxes.java branches/gridsim4.0-branch3/source/eduni/simdiag/GraphSetScale.java branches/gridsim4.0-branch3/source/eduni/simdiag/GraphWindow.java branches/gridsim4.0-branch3/source/eduni/simdiag/TimingDiagram.java branches/gridsim4.0-branch3/source/eduni/simdiag/TimingWindow.java branches/gridsim4.0-branch3/source/eduni/simdiag/TraceEventObject.java branches/gridsim4.0-branch3/source/eduni/simdiag/TraceListener.java branches/gridsim4.0-branch3/source/eduni/simdiag/TraceLoader.java branches/gridsim4.0-branch3/source/eduni/simdiag/TraceSaver.java branches/gridsim4.0-branch3/source/eduni/simdiag/Traceable.java branches/gridsim4.0-branch3/source/eduni/simdiag/package.html branches/gridsim4.0-branch3/source/eduni/simjava/ branches/gridsim4.0-branch3/source/eduni/simjava/Evqueue.java branches/gridsim4.0-branch3/source/eduni/simjava/Semaphore.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_accum.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_any_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_event.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_exception.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_from_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_none_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_not_from_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_not_type_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_outfile.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_output.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_port.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_predicate.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_reporter.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_reportfile.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_stat.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_stat_exception.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_system.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_type_p.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/ branches/gridsim4.0-branch3/source/eduni/simjava/distributions/ContinuousGenerator.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/DiscreteGenerator.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Generator.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_bernoulli_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_beta_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_betaprime_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_binomial_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_cauchy_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_chisquare_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_erlang_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_f_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_gamma_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_geometric_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_invgamma_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_logistic_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_lognormal_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_negexp_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_normal_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_parameter_exception.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_pareto_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_pascal_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_poisson_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_random_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_tstudent_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_uniform_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/Sim_weibull_obj.java branches/gridsim4.0-branch3/source/eduni/simjava/distributions/package.html branches/gridsim4.0-branch3/source/eduni/simjava/package.html branches/gridsim4.0-branch3/source/gridsim/ branches/gridsim4.0-branch3/source/gridsim/ARGridResource.java branches/gridsim4.0-branch3/source/gridsim/ARObject.java branches/gridsim4.0-branch3/source/gridsim/ARPolicy.java branches/gridsim4.0-branch3/source/gridsim/ARSimpleSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/Accumulator.java branches/gridsim4.0-branch3/source/gridsim/AdvanceReservation.java branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/GridInformationService.java branches/gridsim4.0-branch3/source/gridsim/GridResource.java branches/gridsim4.0-branch3/source/gridsim/GridSim.java branches/gridsim4.0-branch3/source/gridsim/GridSimCore.java branches/gridsim4.0-branch3/source/gridsim/GridSimRandom.java branches/gridsim4.0-branch3/source/gridsim/GridSimShutdown.java branches/gridsim4.0-branch3/source/gridsim/GridSimStandardPE.java branches/gridsim4.0-branch3/source/gridsim/GridSimTags.java branches/gridsim4.0-branch3/source/gridsim/GridStatistics.java branches/gridsim4.0-branch3/source/gridsim/GridUser.java branches/gridsim4.0-branch3/source/gridsim/Gridlet.java branches/gridsim4.0-branch3/source/gridsim/GridletList.java branches/gridsim4.0-branch3/source/gridsim/IO_data.java branches/gridsim4.0-branch3/source/gridsim/Machine.java branches/gridsim4.0-branch3/source/gridsim/MachineList.java branches/gridsim4.0-branch3/source/gridsim/PERange.java branches/gridsim4.0-branch3/source/gridsim/PERangeList.java branches/gridsim4.0-branch3/source/gridsim/ParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/ParameterException.java branches/gridsim4.0-branch3/source/gridsim/ResGridlet.java branches/gridsim4.0-branch3/source/gridsim/ResGridletList.java branches/gridsim4.0-branch3/source/gridsim/ResourceCalendar.java branches/gridsim4.0-branch3/source/gridsim/ResourceCharacteristics.java branches/gridsim4.0-branch3/source/gridsim/ResourceUserList.java branches/gridsim4.0-branch3/source/gridsim/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/Sim_from_port.java branches/gridsim4.0-branch3/source/gridsim/SpaceShared.java branches/gridsim4.0-branch3/source/gridsim/Stat.java branches/gridsim4.0-branch3/source/gridsim/TimeShared.java branches/gridsim4.0-branch3/source/gridsim/auction/ branches/gridsim4.0-branch3/source/gridsim/auction/Auction.java branches/gridsim4.0-branch3/source/gridsim/auction/AuctionObserver.java branches/gridsim4.0-branch3/source/gridsim/auction/AuctionTags.java branches/gridsim4.0-branch3/source/gridsim/auction/Auctioneer.java branches/gridsim4.0-branch3/source/gridsim/auction/ContinuousDoubleAuction.java branches/gridsim4.0-branch3/source/gridsim/auction/DoubleAuction.java branches/gridsim4.0-branch3/source/gridsim/auction/DutchAuction.java branches/gridsim4.0-branch3/source/gridsim/auction/EnglishAuction.java branches/gridsim4.0-branch3/source/gridsim/auction/FirstPriceSealedBidAuction.java branches/gridsim4.0-branch3/source/gridsim/auction/Message.java branches/gridsim4.0-branch3/source/gridsim/auction/MessageAsk.java branches/gridsim4.0-branch3/source/gridsim/auction/MessageBid.java branches/gridsim4.0-branch3/source/gridsim/auction/MessageCallForBids.java branches/gridsim4.0-branch3/source/gridsim/auction/MessageInformOutcome.java branches/gridsim4.0-branch3/source/gridsim/auction/MessageInformStart.java branches/gridsim4.0-branch3/source/gridsim/auction/MessageRejectBid.java branches/gridsim4.0-branch3/source/gridsim/auction/MessageRejectCallForBid.java branches/gridsim4.0-branch3/source/gridsim/auction/OneSidedAuction.java branches/gridsim4.0-branch3/source/gridsim/auction/Responder.java branches/gridsim4.0-branch3/source/gridsim/auction/ReverseDutchAuction.java branches/gridsim4.0-branch3/source/gridsim/auction/ReverseEnglishAuction.java branches/gridsim4.0-branch3/source/gridsim/auction/ReverseFirstPriceSealedBidAuction.java branches/gridsim4.0-branch3/source/gridsim/auction/package.html branches/gridsim4.0-branch3/source/gridsim/datagrid/ branches/gridsim4.0-branch3/source/gridsim/datagrid/DataGridResource.java branches/gridsim4.0-branch3/source/gridsim/datagrid/DataGridTags.java branches/gridsim4.0-branch3/source/gridsim/datagrid/DataGridUser.java branches/gridsim4.0-branch3/source/gridsim/datagrid/DataGridlet.java branches/gridsim4.0-branch3/source/gridsim/datagrid/File.java branches/gridsim4.0-branch3/source/gridsim/datagrid/FileAttribute.java branches/gridsim4.0-branch3/source/gridsim/datagrid/ReplicaManager.java branches/gridsim4.0-branch3/source/gridsim/datagrid/SimpleReplicaManager.java branches/gridsim4.0-branch3/source/gridsim/datagrid/filter/ branches/gridsim4.0-branch3/source/gridsim/datagrid/filter/FileNameFilter.java branches/gridsim4.0-branch3/source/gridsim/datagrid/filter/Filter.java branches/gridsim4.0-branch3/source/gridsim/datagrid/filter/FilterDataResult.java branches/gridsim4.0-branch3/source/gridsim/datagrid/filter/package.html branches/gridsim4.0-branch3/source/gridsim/datagrid/index/ branches/gridsim4.0-branch3/source/gridsim/datagrid/index/AbstractRC.java branches/gridsim4.0-branch3/source/gridsim/datagrid/index/DataGIS.java branches/gridsim4.0-branch3/source/gridsim/datagrid/index/DataRegionalGIS.java branches/gridsim4.0-branch3/source/gridsim/datagrid/index/RegionalRC.java branches/gridsim4.0-branch3/source/gridsim/datagrid/index/TopRegionalRC.java branches/gridsim4.0-branch3/source/gridsim/datagrid/index/package.html branches/gridsim4.0-branch3/source/gridsim/datagrid/package.html branches/gridsim4.0-branch3/source/gridsim/datagrid/storage/ branches/gridsim4.0-branch3/source/gridsim/datagrid/storage/HarddriveStorage.java branches/gridsim4.0-branch3/source/gridsim/datagrid/storage/Storage.java branches/gridsim4.0-branch3/source/gridsim/datagrid/storage/TapeStorage.java branches/gridsim4.0-branch3/source/gridsim/datagrid/storage/package.html branches/gridsim4.0-branch3/source/gridsim/filter/ branches/gridsim4.0-branch3/source/gridsim/filter/FilterCreateAR.java branches/gridsim4.0-branch3/source/gridsim/filter/FilterGridlet.java branches/gridsim4.0-branch3/source/gridsim/filter/FilterQueryTimeAR.java branches/gridsim4.0-branch3/source/gridsim/filter/FilterResult.java branches/gridsim4.0-branch3/source/gridsim/filter/package.html branches/gridsim4.0-branch3/source/gridsim/gui/ branches/gridsim4.0-branch3/source/gridsim/gui/AllocationAction.java branches/gridsim4.0-branch3/source/gridsim/gui/AllocationListener.java branches/gridsim4.0-branch3/source/gridsim/gui/AllocationSubject.java branches/gridsim4.0-branch3/source/gridsim/gui/DetachedMagnifyingGlass.java branches/gridsim4.0-branch3/source/gridsim/gui/GridSimVisualizer.java branches/gridsim4.0-branch3/source/gridsim/gui/GridletPanel.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/index/ branches/gridsim4.0-branch3/source/gridsim/index/AbstractGIS.java branches/gridsim4.0-branch3/source/gridsim/index/RegionalGIS.java branches/gridsim4.0-branch3/source/gridsim/index/package.html branches/gridsim4.0-branch3/source/gridsim/net/ branches/gridsim4.0-branch3/source/gridsim/net/BusLink.java branches/gridsim4.0-branch3/source/gridsim/net/FIFOScheduler.java branches/gridsim4.0-branch3/source/gridsim/net/FloodAdPack.java branches/gridsim4.0-branch3/source/gridsim/net/FloodingRouter.java branches/gridsim4.0-branch3/source/gridsim/net/InfoPacket.java branches/gridsim4.0-branch3/source/gridsim/net/Input.java branches/gridsim4.0-branch3/source/gridsim/net/Link.java branches/gridsim4.0-branch3/source/gridsim/net/NetPacket.java branches/gridsim4.0-branch3/source/gridsim/net/Output.java branches/gridsim4.0-branch3/source/gridsim/net/Packet.java branches/gridsim4.0-branch3/source/gridsim/net/PacketScheduler.java branches/gridsim4.0-branch3/source/gridsim/net/RIPAdPack.java branches/gridsim4.0-branch3/source/gridsim/net/RIPRouter.java branches/gridsim4.0-branch3/source/gridsim/net/RateControlledRouter.java branches/gridsim4.0-branch3/source/gridsim/net/RateControlledScheduler.java branches/gridsim4.0-branch3/source/gridsim/net/Router.java branches/gridsim4.0-branch3/source/gridsim/net/SCFQScheduler.java branches/gridsim4.0-branch3/source/gridsim/net/SimpleLink.java branches/gridsim4.0-branch3/source/gridsim/net/package.html branches/gridsim4.0-branch3/source/gridsim/package.html branches/gridsim4.0-branch3/source/gridsim/services/ branches/gridsim4.0-branch3/source/gridsim/services/AcquisitionPolicy.java branches/gridsim4.0-branch3/source/gridsim/services/MessageBody.java branches/gridsim4.0-branch3/source/gridsim/services/Negotiation.java branches/gridsim4.0-branch3/source/gridsim/services/NegotiationList.java branches/gridsim4.0-branch3/source/gridsim/services/NegotiationMessage.java branches/gridsim4.0-branch3/source/gridsim/services/NegotiationPolicy.java branches/gridsim4.0-branch3/source/gridsim/services/Provider.java branches/gridsim4.0-branch3/source/gridsim/services/ProviderCalendar.java branches/gridsim4.0-branch3/source/gridsim/services/ProviderCharacteristics.java branches/gridsim4.0-branch3/source/gridsim/services/ProvisioningPolicy.java branches/gridsim4.0-branch3/source/gridsim/services/Service.java branches/gridsim4.0-branch3/source/gridsim/services/ServiceAttributes.java branches/gridsim4.0-branch3/source/gridsim/services/ServiceGridTags.java branches/gridsim4.0-branch3/source/gridsim/services/ServiceGridlet.java branches/gridsim4.0-branch3/source/gridsim/services/ServiceList.java branches/gridsim4.0-branch3/source/gridsim/services/ServiceRequest.java branches/gridsim4.0-branch3/source/gridsim/services/ServiceRequestList.java branches/gridsim4.0-branch3/source/gridsim/services/ServiceRequestWorkload.java branches/gridsim4.0-branch3/source/gridsim/services/ServiceRequestWorkloadList.java branches/gridsim4.0-branch3/source/gridsim/services/ServiceRequester.java branches/gridsim4.0-branch3/source/gridsim/services/ServiceRequirement.java branches/gridsim4.0-branch3/source/gridsim/services/ServiceRequirementList.java branches/gridsim4.0-branch3/source/gridsim/services/ServiceWorkload.java branches/gridsim4.0-branch3/source/gridsim/services/ServiceWorkloadItem.java branches/gridsim4.0-branch3/source/gridsim/services/SimpleAcquisitionPolicy.java branches/gridsim4.0-branch3/source/gridsim/services/SimpleProvisionPolicy.java branches/gridsim4.0-branch3/source/gridsim/services/filter/ branches/gridsim4.0-branch3/source/gridsim/services/filter/ServiceFilter.java branches/gridsim4.0-branch3/source/gridsim/services/filter/ServiceNameFilter.java branches/gridsim4.0-branch3/source/gridsim/services/filter/ServiceNameTypeFilter.java branches/gridsim4.0-branch3/source/gridsim/services/filter/ServiceTypeFilter.java branches/gridsim4.0-branch3/source/gridsim/services/index/ branches/gridsim4.0-branch3/source/gridsim/services/index/GridServiceRepository.java branches/gridsim4.0-branch3/source/gridsim/services/index/RegionalGSR.java branches/gridsim4.0-branch3/source/gridsim/util/ branches/gridsim4.0-branch3/source/gridsim/util/NetworkReader.java branches/gridsim4.0-branch3/source/gridsim/util/Poisson.java branches/gridsim4.0-branch3/source/gridsim/util/SimReport.java branches/gridsim4.0-branch3/source/gridsim/util/TrafficGenerator.java branches/gridsim4.0-branch3/source/gridsim/util/Workload.java branches/gridsim4.0-branch3/source/gridsim/util/package.html Added: branches/gridsim4.0-branch3/.classpath =================================================================== --- branches/gridsim4.0-branch3/.classpath (rev 0) +++ branches/gridsim4.0-branch3/.classpath 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="source"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="src" path="examples"/> + <classpathentry kind="output" path="bin"/> +</classpath> Added: branches/gridsim4.0-branch3/.project =================================================================== --- branches/gridsim4.0-branch3/.project (rev 0) +++ branches/gridsim4.0-branch3/.project 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>gridsim-sf</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,176 @@ + +package examples.workload.parallel; + +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example + */ +public class TurboExample01 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + String fileName = args[0]; + // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf + + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) + { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode + GridSim.startGridSimulation(true); + + // Start the simulation in normal mode +// GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + ResourceCharacteristics resConfig = new ResourceCharacteristics( + arch, os, mList, ResourceCharacteristics.PARALLEL_SPACE_SHARED, + time_zone, cost); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList Weekends = new LinkedList(); + Weekends.add(new Integer(Calendar.SATURDAY)); + Weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList Holidays = new LinkedList(); + GridResource gridRes = null; + try { + gridRes = new GridResource(name, baud_rate, seed, + resConfig, peakLoad, offPeakLoad, holidayLoad, Weekends, + Holidays); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + Added: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphClearObject.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simdiag/GraphClearObject.java (rev 0) +++ branches/gridsim4.0-branch3/source/eduni/simdiag/GraphClearObject.java 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,7 @@ +package eduni.simdiag; + +/** Clears graph */ +public class GraphClearObject extends GraphEventObject { + public GraphClearObject(Object src) { super(src); } + public void doit(GraphDiagram d) { d.clear(); } +} Property changes on: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphClearObject.java ___________________________________________________________________ Name: svn:executable + * Added: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphData.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simdiag/GraphData.java (rev 0) +++ branches/gridsim4.0-branch3/source/eduni/simdiag/GraphData.java 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,39 @@ +package eduni.simdiag; + +import java.util.StringTokenizer; + +/** Stores a single data point. + * + * Each data point has a line name and X and Y coordinates. + */ +public class GraphData extends GraphEventObject { + public String linename; + public double x,y; + + /** Constructs data elem from a single text line + * Format: linename x y + * e.g. "total_time 10 123.45" + */ + public GraphData(Object src, String l) { + super(src); + StringTokenizer st = new StringTokenizer(l, " "); + try { + linename = st.nextToken(); + x = (Double.valueOf(st.nextToken())).doubleValue(); + y = (Double.valueOf(st.nextToken())).doubleValue(); + } catch( Exception e) { + System.out.println("Graphdata Couldn't parse "+l); + } + } + + /** Constructs data elem from linename, x and y + */ + public GraphData(Object src, String linename, double x, double y){ + super(src); + this.linename = linename; + this.x = x; this.y = y; + } + + /** Called by recipient to implement command */ + public void doit(GraphDiagram d) { d.data(linename,x,y); } +} Property changes on: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphData.java ___________________________________________________________________ Name: svn:executable + * Added: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphDiagram.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simdiag/GraphDiagram.java (rev 0) +++ branches/gridsim4.0-branch3/source/eduni/simdiag/GraphDiagram.java 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,353 @@ +/** + * GraphDiagram.java + * simjava graph + */ + +package eduni.simdiag; + +import java.util.List; +import java.util.ArrayList; +import java.awt.Panel; +import java.awt.Graphics; +import java.awt.Dimension; +import java.awt.Image; +import java.awt.Color; +import java.awt.GridLayout; +import java.awt.Frame; +import java.applet.Applet; + +class DPoint { + public double x,y; + public DPoint(double xx, double yy) {x=xx;y=yy;} +} + +class Linedata { + String name; + List points = new ArrayList();// list of points + public Linedata(String n) { name = n; } + public void add(double x, double y) { + points.add(new DPoint(x,y)); + } + public DPoint getDPoint(int i) { return (DPoint)points.get(i); } + public String getName() { return name; } + Color valtocol(int v) { + if (v==0) return Color.blue; + if (v==1) return Color.red; + if (v==2) return Color.darkGray; + if (v==3) return Color.gray; + if (v==4) return Color.green; + if (v==5) return Color.lightGray; + if (v==6) return Color.magenta; + if (v==7) return Color.orange; + if (v==8) return Color.pink; + if (v==9) return Color.cyan; + return valtocol(v%10); + } + + public void draw(Graphics g, int i, GraphPanel p) { + g.setColor(valtocol(i)); + // Join points. + for (int j=0; j<points.size()-1; j++) { + DPoint p1 = (DPoint)points.get(j); + DPoint p2 = (DPoint)points.get(j+1); + g.drawLine(p.xscale(p1.x),p.yscale(p1.y), + p.xscale(p2.x),p.yscale(p2.y)); + } + + int sz = 2; // Cross size. + for (int j=0; j<points.size(); j++) { + DPoint p1 = (DPoint)points.get(j); + int ix = p.xscale(p1.x); + int iy = p.yscale(p1.y); + g.drawLine(ix-sz,iy-sz,ix+sz,iy+sz); + g.drawLine(ix+sz,iy-sz,ix-sz,iy+sz); + } + + // Draw Key (tr) + int kyspc = 20; int kx = p.getSize().width - 100; + int ky = (i+2) * kyspc; + g.drawLine(kx,ky,kx+10,ky); + g.drawString(name,kx+10,ky); + } +} + +class GraphPanel extends Panel { + String xax="X",yax="Y"; + List data = new ArrayList(); // List of Linedata + double xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0; + // Offset of axes + int xoff = 40; + int yoff = 40; + + /** Return linedata given line name, or null if not found */ + Linedata getLine(String n) { + for (int i=0; i<data.size(); i++) { + Linedata ld = (Linedata)data.get(i); + if (n.compareTo(ld.getName())==0) + return ld; + } + return null; + } + GraphPanel() { + super(); + resetScale(); + } + void resetScale() { + xmin=0.0; + xmax=1.0; + ymin=0.0; + ymax=1.0; + } + + public int xscale(double x) { + int w = getSize().width; + return (int)(((x-xmin)/(xmax-xmin)) * (w-xoff)) + xoff; + } + public int yscale(double y) { + int h = getSize().height; + return h-((int)(((y-ymin)/(ymax-ymin)) * (h-yoff)) + yoff); + } + public void clear() { + data.clear(); + resetScale(); + } + + public void setAxes(String xax, String yax) { + this.xax = xax; this.yax = yax; + } + + public void setScale(double xmin,double xmax, double ymin, double ymax) { + this.xmin = xmin; + this.xmax = xmax; + this.ymin = ymin; + this.ymax = ymax; + } + + public void data(String linename, double x, double y) { + Linedata ld = getLine(linename); + if (ld==null) { + ld = new Linedata(linename); + data.add(ld); + } + ld.add(x,y); + if (x > xmax) xmax = x; + if (y > ymax) ymax = y; + if (x < xmin) xmin = x; + if (y < ymin) ymin = y; + } + + public void display() { + repaint(); + } + + double log10(double d) { + return Math.log(d)/Math.log(10); + } + + void drawNotches(Graphics g, int x1, int y1, int x2, int y2, + double v1, double v2) { + boolean isXaxis = (y1==y2); + double tsize = v2 - v1; // e.g. 17.2 + double tgaplog = log10( (double) tsize ); // e.g. 1.2ish + int tgaprounded = (int)tgaplog; // e.g. 1 + double tgapfinal = Math.pow( 10.0, (double) tgaprounded ); // e.g.10.0 + // Change to 0 5 10 etc? + if (tsize/tgapfinal < 3.0) { tgapfinal /= 2.0; } + + // Get first point + double div = 0.5 + (v1 / tgapfinal); + int idiv = (int) div; + double firstt1 = idiv * tgapfinal; + + // Draw major notches + if (isXaxis) { + int notchHeight = yoff/10; + for (double t=firstt1; t<=v2; t+=tgapfinal ) { + int xp = xscale(t); + String s = Double.toString(t); + g.setColor(Color.blue); + g.drawLine(xp,y1,xp,notchHeight+y1); + int w = g.getFontMetrics().stringWidth(s); + int h = g.getFontMetrics().getHeight(); + g.drawString(s,xp-w/2,y1+notchHeight+h); + + g.setColor(Color.gray.brighter()); + g.drawLine(xp,y1,xp,0); + } + } else { + int notchHeight = xoff/10; + for (double t=firstt1; t<=v2; t+=tgapfinal ) { + int yp = yscale(t); + String s = Double.toString(t); + g.setColor(Color.blue); + g.drawLine(x1,yp,x1-notchHeight,yp); + int sw = g.getFontMetrics().stringWidth(s); + int sh = g.getFontMetrics().getHeight(); + g.drawString(s,x1-sw-notchHeight,yp+sh/2); + + g.setColor(Color.gray.brighter()); + g.drawLine(x1,yp,getSize().width,yp ); + } + } + + } + + void drawAxes(Graphics g ) { + int w = getSize().width; + int h = getSize().height; + + g.setColor(Color.blue); + g.drawLine(xoff, h-yoff, w, h-yoff); + g.drawLine(xoff, h-yoff, xoff, 0); + g.drawString(xax,w/2,h-yoff/3); + g.drawString(yax,xoff/3,h/2); + + // Draw notches + drawNotches(g,xoff, h-yoff, w, h-yoff,xmin,xmax); + drawNotches(g,xoff, h-yoff, xoff, 0 ,ymin,ymax); + + g.setColor(Color.blue.brighter()); + g.drawLine(xoff, h-yoff+1, w, h-yoff+1); + g.drawLine(xoff+1, h-yoff, xoff+1, 0); + } + + + Image offscreen; + Dimension offscreensize=new Dimension(); + Graphics offg; + + /** Plot the graph */ + public void paint(Graphics g) { + Dimension d = getSize(); + if ((offscreen == null) || (d.width != offscreensize.width) || (d.height != offscreensize.height)) { + offscreen = createImage(d.width, d.height); + offscreensize = d; + offg = offscreen.getGraphics(); + } + + int w = getSize().width; + int h = getSize().height; + System.out.println("Painting "+w+" "+h); + offg.setColor(Color.lightGray.darker()); + offg.fillRect(0,0,w,h); + offg.setColor(Color.lightGray); + offg.fillRect(xoff,0,w,h-yoff); + drawAxes(offg); + + for (int i=0; i<data.size(); i++) { + Linedata ld = (Linedata)data.get(i); + ld.draw(offg,i,this); + } + g.drawImage(offscreen, 0, 0, null); + } +} + +/** + * This class represents the graph application. + * @version 1.0, July 1997 + * @author Fred Howell + */ +public class GraphDiagram extends Applet implements GraphListener, Runnable { + transient Thread thread; + + GraphPanel diag; + + /** Constructs a graph which runs in its own thread. + */ + public GraphDiagram() { + super(); + thread = new Thread(this); + thread.start(); + } + + /** Draws graph */ + public void run() { + init(); + } + /** Graph beans event interface */ + private List graphListeners = new ArrayList(); + + /** Adds a graph listener to the output. */ + public synchronized void addGraphListener(GraphListener l) { + graphListeners.add(l); + } + /** Removes a graph listener from the output. */ + public synchronized void removeGraphListener(GraphListener l) { + graphListeners.remove(l); + } + /** Deals with incoming graph events */ + public void handleGraph(GraphEventObject e) { + e.doit(this); + forwardGraph(e); + } + /** Sends graph events to any listeners */ + public void forwardGraph(GraphEventObject e) { + List l; + synchronized(this) { l = (List)((ArrayList)graphListeners).clone(); } + // GraphEventObject teo = new GraphEventObject(this,e); + // Not bothering to clone the object, make sure sender doesn't change + // it. + for (int i=0; i<l.size(); i++) { + GraphListener tl = (GraphListener) l.get(i); + tl.handleGraph(e); + } + } + + /** Sets up graph diagram display */ + public void init() { + setLayout(new GridLayout(1,1)); + diag = new GraphPanel(); + add(diag); + } + + /** Returns the panel associated with this graph */ + public GraphPanel get_diag() { return diag; } + + /** Clears the graph */ + public void clear() { + diag.clear(); + diag.repaint(); + } + + /** Sets the axes labels */ + public void setAxes(String xax, String yax) { + System.out.println("Setting axes to "+xax+" "+yax); + diag.setAxes(xax,yax); + } + + /** Sets the scale */ + public void setScale(double xmin,double xmax, double ymin, double ymax) { + diag.setScale(xmin,xmax,ymin,ymax); + } + + /** Adds a data element */ + public void data(String linename, double x, double y) { + System.out.println("Data "+linename+" "+x+" "+y); + diag.data(linename,x,y); + } + + /** Displays the graph */ + public void display() { + diag.repaint(); + } + + + /** Constructs an example using the graph, by connecting a + * GraphEqn object to its input to display sine waves. + */ + public static void main(String args[]) { + Frame f = new Frame("Graph Diagram Example"); + GraphDiagram ex1 = new GraphDiagram(); + // GraphLoader tl = new GraphLoader("file:/home/fwh/export/tmp.graph"); + // tl.addGraphListener(ex1); + // tl.startLoading(); + GraphEqn ge = new GraphEqn(); + ge.addGraphListener(ex1); + ge.startRunning(); + + f.add("Center", ex1); + f.pack(); + f.setSize(600,300); + f.show(); + } +} Property changes on: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphDiagram.java ___________________________________________________________________ Name: svn:executable + * Added: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphDisplay.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simdiag/GraphDisplay.java (rev 0) +++ branches/gridsim4.0-branch3/source/eduni/simdiag/GraphDisplay.java 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,10 @@ +package eduni.simdiag; + +/** Displays graph. Required to update the display after + * a set of <a href="eduni.simdiag.GraphData.html">GraphData</a> commands. + * see also <a href="../design_doc/index.html#twodgraphs">the design document</a>. + */ +public class GraphDisplay extends GraphEventObject { + public GraphDisplay(Object src) { super(src); } + public void doit(GraphDiagram d) { d.display(); } +} Property changes on: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphDisplay.java ___________________________________________________________________ Name: svn:executable + * Added: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphEqn.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simdiag/GraphEqn.java (rev 0) +++ branches/gridsim4.0-branch3/source/eduni/simdiag/GraphEqn.java 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,76 @@ +package eduni.simdiag; + +import java.util.List; +import java.util.ArrayList; +import java.applet.Applet; + +/** + * Generates sin/cos graph from equation. + * The output format is a stream of + * GraphEventObjects which can be read and displayed by + * a GraphDiagram. + * This class may be useful as an example of how to + * generate a graph from user simulations: + * see the <a href="../../eduni/simdiag/GraphEqn.java">source code</a> + */ + +public class GraphEqn implements Runnable { + + transient Thread thread; + + /** Creates a graph generator (Sine, Cos) */ + public GraphEqn() { + } + + /** Called after output has been wired */ + public void startRunning() { + thread = new Thread(this); + thread.start(); + } + + /** Generates the graph */ + public void run() { + double delta = 0.1; + // while (true) { + forwardGraph( new GraphClearObject(this) ); + + forwardGraph( new GraphSetAxes(this,"X","Y") ); + + for (double x = 0.0; x<20; x+=0.1) { + forwardGraph( new GraphData(this,"sin",x,Math.sin(x+delta)) ); + forwardGraph( new GraphData(this,"cos",x,Math.cos(x+delta)) ); + + forwardGraph( new GraphDisplay(this) ); + try { thread.sleep(100); } catch (Exception e) {} + } + + forwardGraph( new GraphDisplay(this) ); + delta += 0.1; + // try { thread.sleep(1000); } catch (Exception e) {} + // } + } + + /** Javabeans graph event output: List of + * event listeners. + */ + private List graphListeners = new ArrayList(); + /** Adds a graph listener */ + public synchronized void addGraphListener(GraphListener l) { + graphListeners.add(l); + } + /** Removes a graph listener */ + public synchronized void removeGraphListener(GraphListener l) { + graphListeners.remove(l); + } + /** Forwards a graph event to anyone listening. + */ + public void forwardGraph(GraphEventObject e) { + List l; + // GraphEventObject weo = new GraphEventObject(this,e); + synchronized(this) { l = (List)((ArrayList)graphListeners).clone(); } + for (int i=0; i<l.size(); i++) { + GraphListener wl = (GraphListener) l.get(i); + wl.handleGraph(e); + } + } +} Property changes on: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphEqn.java ___________________________________________________________________ Name: svn:executable + * Added: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphEventObject.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simdiag/GraphEventObject.java (rev 0) +++ branches/gridsim4.0-branch3/source/eduni/simdiag/GraphEventObject.java 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,26 @@ +package eduni.simdiag; + +import java.util.EventObject; + +/** + * The basic graph event class. + * All graph commands are derived from this and override + * the doit() method. + * @see eduni.simdiag.GraphData + * @see eduni.simdiag.GraphDisplay + * @see eduni.simdiag.GraphSetAxes + * @see eduni.simdiag.GraphSetScale + * @see eduni.simdiag.GraphClearObject + */ + +public class GraphEventObject extends EventObject { + public GraphEventObject(Object src) { + super(src); + } + /** Implements graph commands. + * The graph commands override this to do their biz. + */ + public void doit(GraphDiagram d) { + System.out.println("Executing a basic command\n"); + } +} Property changes on: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphEventObject.java ___________________________________________________________________ Name: svn:executable + * Added: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphListener.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simdiag/GraphListener.java (rev 0) +++ branches/gridsim4.0-branch3/source/eduni/simdiag/GraphListener.java 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,14 @@ +package eduni.simdiag; + +import java.util.EventListener; + +/** + * Graph event listener interface. <p> + * Implemented by graph drawing routine. + * @see eduni.simdiag.GraphDiagram + */ + +public interface GraphListener extends EventListener { + /** Responds to a single graph event */ + void handleGraph(GraphEventObject teo); +} Property changes on: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphListener.java ___________________________________________________________________ Name: svn:executable + * Added: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphLoader.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simdiag/GraphLoader.java (rev 0) +++ branches/gridsim4.0-branch3/source/eduni/simdiag/GraphLoader.java 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,99 @@ +/* GraphLoader.java */ + +package eduni.simdiag; + +import java.util.List; +import java.util.ArrayList; +import java.util.EventListener; +import java.applet.Applet; +import java.io.BufferedReader; +import java.io.DataInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; + +/** + * Converts graph from URL to GraphEventListener format. + */ +public class GraphLoader implements Runnable { + + transient Thread thread; + String urlName; + + + /** Create a graph loader with the given url */ + public GraphLoader(String urlName) { + this.urlName = urlName; + thread = new Thread(this); + } + + /** Called after output has been wired */ + public void startLoading() { + thread.start(); + } + + protected String nextLine(BufferedReader r) { + try { + String l = r.readLine(); + return l; + } catch (Exception e) { + return null; + } + } + + public void run() { + URL u; + try { + u = new URL(urlName); + } catch (Exception e) { + System.out.println("Can't open URL "+urlName); + return; + } + + DataInputStream file; + try { + file = new DataInputStream(u.openStream()); + } catch (IOException ioe) { + System.out.println("Couldn't open URL\n"); + return; + } + BufferedReader in = new BufferedReader(new InputStreamReader(file)); + String l; + + int numevents = 0; + + forwardGraph( new GraphClearObject(this) ); + // File fmt: + // axis names, data. + // mem speed\n time\n sys1 10 123.4 etc + String xax = nextLine(in); + String yax = nextLine(in); + forwardGraph( new GraphSetAxes(this,xax,yax) ); + while ((l = nextLine(in))!=null) { + forwardGraph( new GraphData(this,l) ); + numevents += 1; + } + + forwardGraph( new GraphDisplay(this) ); + + System.out.println("Read in "+numevents+" lines"); + } + + /* Javabeans graph event output */ + private List graphListeners = new ArrayList(); + public synchronized void addGraphListener(GraphListener l) { + graphListeners.add(l); + } + public synchronized void removeGraphListener(GraphListener l) { + graphListeners.remove(l); + } + public void forwardGraph(GraphEventObject e) { + List l; + // GraphEventObject weo = new GraphEventObject(this,e); + synchronized(this) { l = (List)((ArrayList)graphListeners).clone(); } + for (int i=0; i<l.size(); i++) { + GraphListener wl = (GraphListener) l.get(i); + wl.handleGraph(e); + } + } +} Property changes on: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphLoader.java ___________________________________________________________________ Name: svn:executable + * Added: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphSetAxes.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simdiag/GraphSetAxes.java (rev 0) +++ branches/gridsim4.0-branch3/source/eduni/simdiag/GraphSetAxes.java 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,21 @@ +package eduni.simdiag; + +/** Stores a command to set the axes labels for this graph. + * + */ +public class GraphSetAxes extends GraphEventObject { + String xax,yax; + /** Constructs a setaxes command. + * @param xax The label of the X axis. + * @param yax The label of the Y axis. + */ + + public GraphSetAxes(Object src, String xax, String yax){ + super(src); + this.xax = xax; this.yax=yax; + } + /** Sets the axes labels of the given diagram. + * Called by the recipient of the command. + */ + public void doit(GraphDiagram d) { d.setAxes(xax,yax); } +} Property changes on: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphSetAxes.java ___________________________________________________________________ Name: svn:executable + * Added: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphSetScale.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simdiag/GraphSetScale.java (rev 0) +++ branches/gridsim4.0-branch3/source/eduni/simdiag/GraphSetScale.java 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,14 @@ +package eduni.simdiag; + +/** Sets scale */ +public class GraphSetScale extends GraphEventObject { + double xmin,xmax,ymin,ymax; + public GraphSetScale(Object src, double xmin,double xmax, double ymin, double ymax) { + super(src); + this.xmin = xmin; + this.xmax = xmax; + this.ymin = ymin; + this.ymax = ymax; + } + public void doit(GraphDiagram d) { d.setScale(xmin,xmax,ymin,ymax); } +} Property changes on: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphSetScale.java ___________________________________________________________________ Name: svn:executable + * Added: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphWindow.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simdiag/GraphWindow.java (rev 0) +++ branches/gridsim4.0-branch3/source/eduni/simdiag/GraphWindow.java 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,33 @@ +package eduni.simdiag; + +import java.awt.Frame; + +/** A graph diagram in a separate window (and thread). + * <b>Note</b> that it is the GraphDiagram which listens + * to graph event objects, not the GraphWindow. + * + * Usage (from a class which generates GraphObjects) + * <pre> + * GraphWindow gw = new GraphWindow(); + * addGraphListener( gw.getDiag()); + * gw.start(); + * </pre> + */ +public class GraphWindow extends Thread { + Frame f; + GraphDiagram td; + + public GraphWindow() { + f = new Frame("Graph Diagram"); + td = new GraphDiagram(); + } + /** Displays the window */ + public void run() { + // td.init(); + f.add(td); + f.pack(); + f.setVisible(true); + } + /** Returns the graph diagram for this window */ + public GraphDiagram getDiag() { return td; } +} Property changes on: branches/gridsim4.0-branch3/source/eduni/simdiag/GraphWindow.java ___________________________________________________________________ Name: svn:executable + * Added: branches/gridsim4.0-branch3/source/eduni/simdiag/TimingDiagram.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simdiag/TimingDiagram.java (rev 0) +++ branches/gridsim4.0-branch3/source/eduni/simdiag/TimingDiagram.java 2007-09-14 07:33:33 UTC (rev 58) @@ -0,0 +1,806 @@ +/** + * TimingDiagram.java + * simjava timing diagram + * Adapted from a C++/Motif version + * 31 Jan 1998 - making it run in its own thread (so it + * doesn't need its own window). + */ + +package eduni.simdiag; + +import java.util.List; +import java.util.ArrayList; +import java.util.StringTokenizer; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Panel; +import java.awt.Button; +import java.awt.Image; +import java.awt.Dimension; +import java.awt.Scrollbar; +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; +import java.awt.Frame; +import java.awt.Font; +import java.applet.Applet; +import java.awt.event.InputEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseMotionListener; +import java.awt.event.MouseListener; +import java.awt.event.AdjustmentListener; +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; +import java.awt.event.AdjustmentEvent; + +class StringVector { + protected List v; + StringVector() { v = new ArrayList(); } + List getV() { return v; } + void add(String s) { v.add(s); } + String get( int i ) { return (String)v.get(i); } + int find( String s ) { + String found = null, curr; + int foundi = 0; + int v_size = v.size(); + for (int i=0; i < v_size; i++) { + curr = (String)v.get(i); + if(s.compareTo(curr) == 0) { + found = curr; + foundi = i; + } + } + return foundi; + } +} + +/** + * This class represents a data type to be displayed in + * The timing diagram. + * @version 1.0, June 1997 + * @author Fred Howell + */ +class TypeParam { + String typename; + protected StringVector labels; + TypeParam(String buff) { + labels = new StringVector(); + StringTokenizer st = new StringTokenizer(buff, " "); + typename = st.nextToken(); + while (st.hasMoreTokens()) + labels.add(st.nextToken()); + } + String getLabel(int i) { return labels.get(i); } + int get_index(String l) { return labels.find(l); } + + Color valtocol(int v) { + if (v==0) return Color.blue; + if (v==1) return Color.cyan; + if (v==2) return Color.darkGray; + if (v==3) return Color.gray; + if (v==4) return Color.green; + if (v==5) return Color.lightGray; + if (v==6) return Color.magenta; + if (v==7) return Color.orange; + if (v==8) return Color.pink; + if (v==9) return Color.red; + if (v==10) return Color.white; + return valtocol(v%10); + } + void drawKey(Graphics g, int x, int y, int w, int h) { + g.setColor(Color.black); + g.drawString(typename,x,y+h); + + // Draw blocks for labels too + String curr; + int blksize = 20; + List labelsV = labels.getV(); + int labelsV_size = labelsV.size(); + for (int i=0; i < labelsV_size; i++) { + int keywidth = w / (labelsV_size+1); + curr = (String)labelsV.get(i); + g.setColor(Color.black); + g.drawString(curr,x + (i+1)*keywidth, y+h); + g.setColor(valtocol(i)); + g.fillRect(x + (i+1)*keywidth, y , keywidth, h/2); + } + } +} + +class Types { + protected List types; + Types() { types = new ArrayList(); } + void add(TypeParam tp) { types.add(tp); } + TypeParam find( String s ) { + TypeParam found = null, curr; + int foundi = 0; + int types_size = types.size(); + for (int i=0; i < types_size; i++) { + curr = (TypeParam)types.get(i); + if(s.compareTo(curr.typename) == 0) { + found = curr; + } + } + return found; + } + void drawKeys(Graphics g, int w, int h) { + TypeParam curr; + int types_size = types.size(); + for (int i=0; i < types_size; i++) { + int keyheight = h / types_size; + curr = (TypeParam)types.get(i); + curr.drawKey(g,0,i * keyheight, w, (int)(keyheight*0.7)); + } + } + List getV() { return types; } +} + +class Event { + double time; + int stateno; + Event() { time = -1; stateno = 0; } + Event(double t, int s) { time = t; stateno = s; } + boolean isblank() { return (time==-1); } +} + + +/** + * This class represents an entry on the diagram + * including all data. + * @version 1.0, June 1997 + * @author Fred Howell + */ +class Entry { + + protected String name; + protected List events; + protected TypeParam tp; + int x,y,w,h; + double startt, endt; + + Entry(String n, TypeParam tp) { + name = n; + events = new ArrayList(); + this.tp = tp; + x = 0; y = 0; w = 100; h = 100; + } + + TypeParam getType() { return tp; } + void add(Event e) { events.add(e); } + void setPosition(int x, int y, int w, int h) { + this.x = x; + this.y = y; + this.w = w; + this.h = h; + } + + int ttox(double t ) { + return (int)((w) * (t-startt)/(endt-startt)); + } + + Color valtocol(int v) { + return tp.valtocol(v); + } + + void drawLabel(Graphics g, int x, int y) { + // Draw label + g.setColor(Color.black); + g.drawString(name,x,y); + } + + // draw all events from t1 to t2. + void draw(Graphics g, double t1, double t2) { + startt = t1; endt = t2; + + // System.out.println("Drawing from "+t1+" to "+t2); + + // Get last event before starttime + int ptri=0, previ=0; + boolean found = false; + int i=0; + for (i=0; i<events.size() && !found; i++) { + if (((Event)events.get(i)).time > t1) { + found = true; + ptri = i; + previ = ptri-1; if (previ<0) previ=0; + } + } + + // System.out.println("Found start at index "+previ+" out of "+events.size()); + + boolean reachedend = false; + for (; previ<events.size() && !reachedend; previ++) { + double time1=t1,time2=t2; + int val = 0; + + ptri = previ+1; + + Event prevevent = (Event)events.get(previ); + Event ptr; + if (ptri<events.size()) + ptr = (Event)events.get(ptri); + else ptr = new Event(); + + if (!prevevent.isblank()) { + time1 = prevevent.time; + val = prevevent.stateno; + } + if (!ptr.isblank()) time2 = ptr.time; + + if (time2 > t2) time2 = t2; + if (time1 > t2) time1 = t2; + + //System.out.println("Drawing: "+ttox(time1)+" "+ttox(time2-time1)+" v="+val+" t="+time1+" - "+time2); + + g.setColor(valtocol(val)); + g.fillRect(ttox(time1),y, ttox(time2)-ttox(time1),h); + + if (prevevent.time > t2) reachedend = true; + } + + } +} + + +/** + * This class loads and stores all data entries + * @version 1.0, June 1997 + * @author Fred Howell + */ + +class Entries { + protected List entries; + protected Types types; + + double starttime, endtime; + + Entries() { + entries = new ArrayList(); + types = new Types(); + starttime = 0.0; + endtime = 1.0; + } + + /* External commands */ + void reset() { + entries.clear(); + types.getV().clear(); + starttime = 0.0; + endtime = 1.0; + } + + /** Add a single trace line + * return 1 if successful + */ + final int TYPES = 0; + final int BARS = 1; + final int EVENTS = 2; + int section = TYPES; + int addTrace(String l) { + int success = 1; + if (l.startsWith("$")) { + // System.out.println("Changing section\n"); + if ("$types".compareTo(l) == 0) section = TYPES; + else if ("$bars".compareTo(l) == 0) section = BARS; + else if ("$events".compareTo(l) == 0) section = EVENTS; + else { + System.out.println("Couldn't read section name "+l); + success = 0; + } + } else if (section==TYPES) { + // Format: typename flag1 flag2 ... + types.add(new TypeParam(l)); + } else if (section==BARS) { + // Format: barname bartype + StringTokenizer st = new StringTokenizer(l); + String barname, bartype; + if (st.hasMoreTokens()) { + barname = st.nextToken(); + if (st.hasMoreTokens()) { + bartype = st.nextToken(); + TypeParam btp = types.find(bartype); + if (btp!=null) { + entries.add(new Entry(barname, btp)); + } else { + System.out.println("Couldn't find type "+bartype); + success = 0; + } + } + } + } else if (section==EVENTS) { + StringTokenizer st = new StringTokenizer(l, ": \n\r\t"); + if(st.nextToken().charAt(0) != 'u') + ;//System.out.println("Error: Only do 'u:' traces"); + else { + String barname = st.nextToken(); + Entry e = find(barname); + if (e==null) + ;// System.out.println("Couldn't find bar:"+barname); + else { + st.nextToken(); // skip 'at' + double timestamp = + (Double.valu... [truncated message content] |
From: <mar...@us...> - 2007-09-14 07:34:31
|
Revision: 59 http://gridsim.svn.sourceforge.net/gridsim/?rev=59&view=rev Author: marcos_dias Date: 2007-09-14 00:34:35 -0700 (Fri, 14 Sep 2007) Log Message: ----------- Workload used in the example. Added Paths: ----------- branches/gridsim4.0-branch3/workloads/ branches/gridsim4.0-branch3/workloads/sdsc_blue_2000.swf Added: branches/gridsim4.0-branch3/workloads/sdsc_blue_2000.swf =================================================================== --- branches/gridsim4.0-branch3/workloads/sdsc_blue_2000.swf (rev 0) +++ branches/gridsim4.0-branch3/workloads/sdsc_blue_2000.swf 2007-09-14 07:34:35 UTC (rev 59) @@ -0,0 +1,1574 @@ + 31466 28 1 180 -1 -1 -1 16 1800 -1 5 55 -1 -1 0 -1 -1 -1 + 31472 743 10 -1 -1 -1 -1 16 600 -1 5 28 -1 -1 3 -1 -1 -1 + 31473 1293 35 45 -1 -1 -1 24 1800 -1 5 213 -1 -1 0 -1 -1 -1 + 31476 1616 22749 23 8 -1 -1 8 21600 -1 1 242 -1 -1 4 -1 -1 -1 + 31478 1902 131750 64398 32 32153 -1 32 64800 -1 1 171 -1 -1 3 -1 -1 -1 + 31480 2215 85592 17655 32 8719 -1 32 18000 -1 1 178 -1 -1 4 -1 -1 -1 + 31481 2276 85692 15489 32 7639 -1 32 18000 -1 1 178 -1 -1 4 -1 -1 -1 + 31482 3051 1421 -1 -1 -1 -1 64 86400 -1 5 266 -1 -1 3 -1 -1 -1 + 31483 3160 0 65 8 -1 -1 8 1800 -1 1 266 -1 -1 0 -1 -1 -1 + 31485 3909 0 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31486 4109 1 180 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31489 4619 1 180 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31490 4955 59374 -1 -1 -1 -1 80 86400 -1 5 266 -1 -1 2 -1 -1 -1 + 31493 6709 1 180 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31494 6913 0 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31495 7253 0 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31497 7400 0 180 -1 -1 -1 8 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31498 8148 0 180 -1 -1 -1 8 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31499 9402 407486 64848 128 31090 -1 128 64800 -1 5 90 -1 -1 3 -1 -1 -1 + 31500 9417 1 183 -1 -1 -1 8 1800 -1 5 11 -1 -1 0 -1 -1 -1 + 31501 10817 1 183 -1 -1 -1 8 1800 -1 5 39 -1 -1 0 -1 -1 -1 + 31502 11056 19650 7246 32 5430 -1 32 7200 -1 5 39 -1 -1 2 -1 -1 -1 + 31504 14701 9586 29 8 -1 -1 8 600 -1 1 11 -1 -1 3 -1 -1 -1 + 31505 15922 1 180 -1 -1 -1 16 1800 -1 5 156 -1 -1 0 -1 -1 -1 + 31508 19359 1 180 -1 -1 -1 16 1800 -1 5 156 -1 -1 0 -1 -1 -1 + 31509 19961 1 180 -1 -1 -1 16 1800 -1 5 156 -1 -1 0 -1 -1 -1 + 31510 23552 374714 18617 128 9248 -1 128 28800 -1 1 95 -1 -1 3 -1 -1 -1 + 31511 27021 105479 16597 512 7784 -1 512 27000 -1 5 93 -1 -1 3 -1 -1 -1 + 31512 27971 2929 1774 128 1158 -1 128 5400 -1 1 261 -1 -1 3 -1 -1 -1 + 31513 29458 1 114 8 -1 -1 8 1800 -1 1 108 -1 -1 0 -1 -1 -1 + 31514 55528 167528 72706 256 -1 -1 256 28800 -1 5 99 -1 -1 4 -1 -1 -1 + 31520 56746 239219 43773 128 21782 -1 128 50400 -1 1 118 -1 -1 3 -1 -1 -1 + 31521 57093 34589 9902 16 9791 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31522 57114 31289 9834 16 9731 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31523 57130 26472 9891 16 9793 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31527 58638 11306 31 8 -1 -1 8 21600 -1 1 242 -1 -1 4 -1 -1 -1 + 31530 60144 26 3648 40 1347 -1 40 3600 -1 5 231 -1 -1 3 -1 -1 -1 + 31532 60556 33 3026 8 2970 -1 8 3000 -1 5 250 -1 -1 3 -1 -1 -1 + 31533 60679 25 3026 8 2984 -1 8 3000 -1 5 250 -1 -1 3 -1 -1 -1 + 31534 60688 16 2859 8 2815 -1 8 3000 -1 1 250 -1 -1 3 -1 -1 -1 + 31541 61832 2254 6923 16 6857 -1 16 10800 -1 5 273 -1 -1 3 -1 -1 -1 + 31543 61914 897 -1 -1 -1 -1 256 15300 -1 5 95 -1 -1 3 -1 -1 -1 + 31547 62819 268319 6966 256 3434 -1 256 15300 -1 5 95 -1 -1 3 -1 -1 -1 + 31548 63530 31710 4201 64 4099 -1 64 7200 -1 1 132 -1 -1 3 -1 -1 -1 + 31549 63693 155425 43257 56 33571 -1 56 43200 -1 5 225 -1 -1 2 -1 -1 -1 + 31550 64194 727 2653 8 2593 -1 8 3000 -1 1 250 -1 -1 3 -1 -1 -1 + 31551 64242 3357 2621 8 2574 -1 8 3000 -1 1 250 -1 -1 3 -1 -1 -1 + 31552 64252 5692 2593 8 2539 -1 8 3000 -1 1 250 -1 -1 3 -1 -1 -1 + 31553 64302 284898 -1 -1 -1 -1 80 86400 -1 5 266 -1 -1 2 -1 -1 -1 + 31555 65016 187 -1 -1 -1 -1 80 86400 -1 5 266 -1 -1 2 -1 -1 -1 + 31556 65458 283504 -1 -1 -1 -1 80 86400 -1 5 266 -1 -1 2 -1 -1 -1 + 31557 66089 1 43 8 -1 -1 8 1800 -1 1 30 -1 -1 0 -1 -1 -1 + 31558 66093 32507 55893 8 55611 -1 8 64800 -1 1 143 -1 -1 3 -1 -1 -1 + 31559 66230 67423 35322 8 35181 -1 8 64800 -1 1 143 -1 -1 3 -1 -1 -1 + 31560 66359 1140 -1 -1 -1 -1 8 1800 -1 5 37 -1 -1 1 -1 -1 -1 + 31561 66423 67345 43329 8 43129 -1 8 64800 -1 1 143 -1 -1 3 -1 -1 -1 + 31563 67552 1 41 8 -1 -1 8 1800 -1 1 30 -1 -1 0 -1 -1 -1 + 31564 67670 348 -1 -1 -1 -1 16 300 -1 5 111 -1 -1 3 -1 -1 -1 + 31565 67967 2 50 16 -1 -1 16 1800 -1 1 111 -1 -1 0 -1 -1 -1 + 31569 69771 143186 64898 256 64436 -1 256 64800 -1 5 273 -1 -1 3 -1 -1 -1 + 31570 70473 2 86 8 -1 -1 8 1800 -1 1 49 -1 -1 0 -1 -1 -1 + 31571 70554 306534 86455 256 86069 -1 256 86400 -1 5 273 -1 -1 3 -1 -1 -1 + 31572 70629 1 751 8 -1 -1 8 1800 -1 1 49 -1 -1 0 -1 -1 -1 + 31573 71050 5451 7247 16 7156 -1 16 7200 -1 5 273 -1 -1 3 -1 -1 -1 + 31574 71130 1 74 16 -1 -1 16 1800 -1 1 111 -1 -1 0 -1 -1 -1 + 31583 73128 754 -1 -1 -1 -1 72 12600 -1 5 14 -1 -1 2 -1 -1 -1 + 31584 73239 41 21621 8 2623 -1 8 21600 -1 5 242 -1 -1 4 -1 -1 -1 + 31588 75370 69 -1 -1 -1 -1 32 7200 -1 5 39 -1 -1 2 -1 -1 -1 + 31589 75467 3595 -1 -1 -1 -1 32 7200 -1 5 39 -1 -1 2 -1 -1 -1 + 31590 76964 2 67 8 -1 -1 8 1800 -1 1 39 -1 -1 0 -1 -1 -1 + 31592 77409 2 180 -1 -1 -1 32 1800 -1 5 39 -1 -1 0 -1 -1 -1 + 31593 77628 1 45 8 -1 -1 8 1800 -1 5 39 -1 -1 0 -1 -1 -1 + 31594 77686 2713 2629 8 2581 -1 8 3000 -1 1 250 -1 -1 3 -1 -1 -1 + 31595 77739 2699 2584 8 2539 -1 8 3000 -1 1 250 -1 -1 3 -1 -1 -1 + 31596 77785 1 44 8 -1 -1 8 1800 -1 5 39 -1 -1 0 -1 -1 -1 + 31600 79165 8884 3277 32 1239 -1 32 7200 -1 5 39 -1 -1 2 -1 -1 -1 + 31601 79506 22477 1670 128 1152 -1 128 5400 -1 1 261 -1 -1 3 -1 -1 -1 + 31602 80063 198168 417 256 -1 -1 256 64560 -1 5 264 -1 -1 3 -1 -1 -1 + 31603 81259 317009 3853 256 3793 -1 256 64800 -1 5 273 -1 -1 3 -1 -1 -1 + 31606 83734 335 2577 8 2531 -1 8 3000 -1 1 250 -1 -1 3 -1 -1 -1 + 31607 83912 276 1707 8 1668 -1 8 3000 -1 1 250 -1 -1 3 -1 -1 -1 + 31609 83944 2361 1604 8 1561 -1 8 3000 -1 1 250 -1 -1 3 -1 -1 -1 + 31610 83962 3016 1494 8 1456 -1 8 3000 -1 1 250 -1 -1 3 -1 -1 -1 + 31611 84220 2 181 -1 -1 -1 8 1800 -1 5 37 -1 -1 0 -1 -1 -1 + 31616 84688 1 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31617 84891 1 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31622 87069 2 185 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31626 88443 2 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31628 88587 1 181 -1 -1 -1 64 1800 -1 5 264 -1 -1 0 -1 -1 -1 + 31633 89296 1 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31636 89497 1 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31637 89553 69581 22485 336 11102 -1 336 25200 -1 1 138 -1 -1 3 -1 -1 -1 + 31650 91280 2 40 8 -1 -1 8 1800 -1 1 39 -1 -1 0 -1 -1 -1 + 31653 92080 2 180 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31655 92275 1 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31661 95253 306884 18599 256 9262 -1 256 64800 -1 1 119 -1 -1 3 -1 -1 -1 + 31662 96562 306772 64852 256 32372 -1 256 64800 -1 5 119 -1 -1 3 -1 -1 -1 + 31664 97397 47875 56698 8 7081 -1 8 72000 -1 1 242 -1 -1 4 -1 -1 -1 + 31665 98077 1 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31666 98314 1 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31667 98515 3 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31668 98828 2 180 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31670 105594 192 4193 64 4092 -1 64 7200 -1 1 132 -1 -1 3 -1 -1 -1 + 31671 105941 362259 43441 128 21643 -1 128 64800 -1 1 246 -1 -1 3 -1 -1 -1 + 31672 106544 18089 7503 640 -1 -1 640 41400 -1 5 93 -1 -1 3 -1 -1 -1 + 31673 108737 1588 9854 16 9747 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31674 108746 1579 9851 16 9743 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31675 108755 1570 9838 16 9724 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31676 108765 1639 9811 16 9716 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31677 108779 5580 9868 16 9737 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31678 108789 5532 9903 16 9767 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31679 108800 5559 9862 16 9735 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31680 108810 5511 9810 16 9707 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31681 108822 35 -1 -1 -1 -1 16 10800 -1 5 144 -1 -1 4 -1 -1 -1 + 31682 108870 5490 10844 16 10726 -1 16 10800 -1 5 144 -1 -1 4 -1 -1 -1 + 31683 108879 5442 9886 16 9766 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31684 109916 239067 -1 -1 -1 -1 96 86400 -1 5 266 -1 -1 2 -1 -1 -1 + 31685 110187 4134 9853 16 9735 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31686 110201 4120 9860 16 9737 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31687 110212 4148 9859 16 9732 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31688 110223 4137 9839 16 9719 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31689 110234 4125 9844 16 9724 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31690 110246 4114 9863 16 9736 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31691 110258 4346 9835 16 9738 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31692 110268 4168 10042 16 9910 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31693 110278 4119 9841 16 9733 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31694 110298 4023 9850 16 9725 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31696 139232 6043 4233 64 4107 -1 64 7200 -1 1 132 -1 -1 3 -1 -1 -1 + 31697 148214 17 -1 -1 -1 -1 112 86400 -1 5 266 -1 -1 3 -1 -1 -1 + 31698 148408 200794 -1 -1 -1 -1 112 86400 -1 5 266 -1 -1 2 -1 -1 -1 + 31699 151792 17 9881 16 9762 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31700 152823 14 9874 16 9746 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31701 152838 43 9866 16 9705 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31702 152860 21 9850 16 9714 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31703 152873 50 9890 16 9741 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31704 152899 22 9927 16 9779 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31705 152920 38 9871 16 9750 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31706 152944 53 9826 16 9704 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31707 152964 5732 9897 16 9741 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31708 152988 5710 9944 16 9745 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31709 153481 253227 -1 -1 -1 -1 256 86400 -1 5 273 -1 -1 3 -1 -1 -1 + 31710 153669 774 7249 16 7168 -1 16 7200 -1 5 273 -1 -1 3 -1 -1 -1 + 31711 154095 4603 9974 16 9805 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31712 154117 7932 9809 16 9702 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31713 154133 8925 9829 16 9713 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31714 154152 7944 9896 16 9757 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31715 154169 9088 9832 16 9730 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31716 154192 8866 9858 16 9720 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31717 154218 14679 9831 16 9718 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31718 154238 12502 9885 16 9776 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31719 154257 12528 9856 16 9726 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31720 154274 12511 9846 16 9727 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31721 154913 8225 9900 16 9792 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31722 154936 8202 9842 16 9736 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31723 154950 11835 9827 16 9705 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31724 154964 11862 9820 16 9713 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31725 154982 8196 9842 16 9724 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31726 154997 8181 9849 16 9734 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31727 155013 11635 9826 16 9706 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31728 155029 11667 10752 16 10626 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31729 155041 11655 9818 16 9695 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31730 155054 11686 9836 16 9723 -1 16 10800 -1 1 144 -1 -1 4 -1 -1 -1 + 31731 155382 123569 449 256 -1 -1 256 9000 -1 5 116 -1 -1 3 -1 -1 -1 + 31733 158923 239344 5024 256 2460 -1 256 15300 -1 1 95 -1 -1 3 -1 -1 -1 + 31734 158938 261816 18847 128 9374 -1 128 28800 -1 1 95 -1 -1 3 -1 -1 -1 + 31736 161061 17954 59369 8 59008 -1 8 64800 -1 1 143 -1 -1 3 -1 -1 -1 + 31737 161141 153739 -1 -1 -1 -1 256 9000 -1 5 116 -1 -1 3 -1 -1 -1 + 31738 161218 8277 9073 200 4453 -1 200 9000 -1 5 116 -1 -1 3 -1 -1 -1 + 31741 162242 2 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31742 162386 93 7233 8 1794 -1 8 7200 -1 5 144 -1 -1 4 -1 -1 -1 + 31744 162440 3 180 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31745 162676 2 180 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31746 162813 16302 9695 640 -1 -1 640 41400 -1 5 93 -1 -1 4 -1 -1 -1 + 31747 162964 3 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31748 163165 3 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31750 163960 2 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31751 164198 2 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31752 165623 3 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31753 167867 79340 48628 56 -1 -1 56 43200 -1 5 225 -1 -1 3 -1 -1 -1 + 31754 169151 54312 78382 56 -1 -1 56 43200 -1 5 225 -1 -1 2 -1 -1 -1 + 31765 174709 186100 15159 256 7478 -1 256 64320 -1 1 59 -1 -1 2 -1 -1 -1 + 31766 174794 115086 24831 64 -1 -1 64 63600 -1 5 264 -1 -1 2 -1 -1 -1 + 31770 178180 24352 16550 64 -1 -1 64 18000 -1 5 132 -1 -1 3 -1 -1 -1 + 31771 178181 10612 11603 32 -1 -1 32 9000 -1 5 116 -1 -1 3 -1 -1 -1 + 31773 178313 10475 19623 128 -1 -1 128 9000 -1 5 116 -1 -1 3 -1 -1 -1 + 31774 179006 9780 -1 -1 -1 -1 16 1200 -1 5 116 -1 -1 3 -1 -1 -1 + 31775 180196 347320 18725 128 9304 -1 128 28800 -1 1 95 -1 -1 3 -1 -1 -1 + 31777 180418 2 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31778 180646 3 180 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31779 188696 28 11665 24 -1 -1 24 1800 -1 5 213 -1 -1 0 -1 -1 -1 + 31780 188720 270 13704 24 -1 -1 24 60 -1 5 213 -1 -1 2 -1 -1 -1 + 31781 201475 113404 -1 -1 -1 -1 128 3600 -1 5 261 -1 -1 3 -1 -1 -1 + 31782 202488 6058 56669 8 7078 -1 8 72000 -1 1 242 -1 -1 4 -1 -1 -1 + 31783 202518 147 196 8 -1 -1 8 21600 -1 5 144 -1 -1 4 -1 -1 -1 + 31784 222098 925 16587 64 16431 -1 64 21600 -1 1 132 -1 -1 3 -1 -1 -1 + 31785 223030 283435 47129 128 46859 -1 128 57600 -1 1 132 -1 -1 3 -1 -1 -1 + 31793 232617 116367 -1 -1 -1 -1 80 86400 -1 5 266 -1 -1 2 -1 -1 -1 + 31795 236042 3 88 8 -1 -1 8 1800 -1 1 111 -1 -1 0 -1 -1 -1 + 31796 236096 4 64 -1 -1 -1 32 1800 -1 5 111 -1 -1 0 -1 -1 -1 + 31798 240340 74542 5319 128 2629 -1 128 5400 -1 5 116 -1 -1 3 -1 -1 -1 + 31803 243586 105398 -1 -1 -1 -1 64 86400 -1 5 266 -1 -1 2 -1 -1 -1 + 31807 246931 4 181 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 31808 247147 3 181 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 31809 247406 3 181 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 31810 247450 42 54306 8 54030 -1 8 64800 -1 1 143 -1 -1 3 -1 -1 -1 + 31811 247615 35 37331 8 37074 -1 8 64800 -1 1 143 -1 -1 3 -1 -1 -1 + 31812 247673 4 181 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 31813 247808 14902 42195 8 41932 -1 8 64800 -1 1 143 -1 -1 3 -1 -1 -1 + 31814 247927 5 181 -1 -1 -1 24 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 31816 248414 4 181 -1 -1 -1 24 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 31817 248627 3 181 -1 -1 -1 24 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 31818 249185 5 1857 24 1409 -1 24 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 31819 249414 455309 9402 128 4636 -1 128 28800 -1 1 95 -1 -1 3 -1 -1 -1 + 31823 251294 4 181 -1 -1 -1 24 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 31824 251541 3 181 -1 -1 -1 24 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 31825 251758 3 181 -1 -1 -1 24 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 31826 252007 62872 24427 64 17285 -1 64 43200 -1 5 225 -1 -1 2 -1 -1 -1 + 31828 252602 5 181 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 31829 252811 3 181 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 31830 253226 167529 11391 56 6821 -1 56 43200 -1 5 225 -1 -1 3 -1 -1 -1 + 31831 253316 61564 30270 64 23779 -1 64 43200 -1 5 225 -1 -1 2 -1 -1 -1 + 31832 255550 59664 27093 64 13484 -1 64 32400 -1 1 73 -1 -1 4 -1 -1 -1 + 31833 267574 13 56685 8 7080 -1 8 72000 -1 1 242 -1 -1 4 -1 -1 -1 + 31834 272193 42989 16503 64 16387 -1 64 21600 -1 1 132 -1 -1 3 -1 -1 -1 + 31835 272397 4 181 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 31837 295761 63 10 -1 -1 -1 32 1800 -1 5 213 -1 -1 0 -1 -1 -1 + 31839 314896 286 -1 -1 -1 -1 8 14400 -1 5 99 -1 -1 4 -1 -1 -1 + 31840 315290 37 9778 8 9606 -1 8 14400 -1 1 99 -1 -1 4 -1 -1 -1 + 31841 316154 1709 7241 16 7147 -1 16 7200 -1 5 273 -1 -1 3 -1 -1 -1 + 31842 316587 1391 10632 128 10458 -1 128 28800 -1 5 99 -1 -1 4 -1 -1 -1 + 31843 318185 28 21627 8 5398 -1 8 21600 -1 5 144 -1 -1 4 -1 -1 -1 + 31844 320510 14 4278 128 2100 -1 128 7200 -1 1 128 -1 -1 3 -1 -1 -1 + 31845 320528 30 1429 16 1369 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31846 321247 18 1433 16 1372 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31847 321254 11 1435 16 1376 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31848 321262 44 1435 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31849 321269 38 1989 16 1922 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31850 321277 31 1462 16 1393 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31851 321288 21 1439 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31852 321325 22 1434 16 1372 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31853 321334 13 1435 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31854 321343 44 1435 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31855 321393 971 1432 16 1373 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31856 321404 1641 1435 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31857 321411 1592 1474 16 1372 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31858 321421 1665 1433 16 1373 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31860 323657 31 1517 8 1483 -1 8 3000 -1 1 250 -1 -1 3 -1 -1 -1 + 31861 323843 5 4796 8 4746 -1 8 5400 -1 1 250 -1 -1 3 -1 -1 -1 + 31862 323987 22 5425 8 5377 -1 8 5400 -1 5 250 -1 -1 3 -1 -1 -1 + 31863 324112 1095 12653 128 6282 -1 128 12600 -1 5 116 -1 -1 3 -1 -1 -1 + 31864 324114 63 -1 -1 -1 -1 16 64800 -1 5 27 -1 -1 2 -1 -1 -1 + 31865 324157 20 -1 -1 -1 -1 16 64800 -1 5 27 -1 -1 2 -1 -1 -1 + 31866 324283 37997 64845 16 32367 -1 16 64800 -1 5 27 -1 -1 2 -1 -1 -1 + 31867 324368 22 -1 -1 -1 -1 8 64800 -1 5 27 -1 -1 3 -1 -1 -1 + 31869 325443 34 13325 32 6618 -1 32 18000 -1 1 178 -1 -1 4 -1 -1 -1 + 31870 325585 10 7247 16 7169 -1 16 7200 -1 5 273 -1 -1 3 -1 -1 -1 + 31872 327566 1 200 16 -1 -1 16 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 31873 327697 11 4929 32 4368 -1 32 7200 -1 1 261 -1 -1 3 -1 -1 -1 + 31875 327887 0 46 16 -1 -1 16 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 31878 328169 1 362 16 -1 -1 16 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 31879 328306 31 1444 16 1378 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31880 328317 20 1447 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31881 328327 12 1447 16 1380 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31882 328339 40 1442 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31883 328350 29 1442 16 1377 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31884 328361 18 1441 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31885 328371 576 1437 16 1375 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31887 328750 1 85 16 -1 -1 16 1800 -1 1 111 -1 -1 0 -1 -1 -1 + 31893 330806 373921 21570 128 10711 -1 128 28800 -1 1 95 -1 -1 3 -1 -1 -1 + 31895 331559 220003 2788 200 1300 -1 200 54000 -1 1 271 -1 -1 2 -1 -1 -1 + 31898 332887 13 4799 8 4748 -1 8 5400 -1 1 250 -1 -1 3 -1 -1 -1 + 31899 332901 38 4002 8 3958 -1 8 5400 -1 1 250 -1 -1 3 -1 -1 -1 + 31900 333015 44 1431 16 1370 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31901 333028 31 1432 16 1372 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31903 333073 27 1440 16 1377 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31904 333084 17 1434 16 1370 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31905 333094 7 1440 16 1375 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31906 333105 1 72 8 -1 -1 8 1800 -1 1 28 -1 -1 0 -1 -1 -1 + 31907 333106 35 1439 16 1376 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31908 333115 27 1445 16 1381 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31909 333146 35 1438 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31910 333155 27 1443 16 1379 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31911 333166 16 1437 16 1373 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31912 333189 34 1437 16 1376 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31913 333200 64 1440 16 1378 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31915 333276 451 1444 16 1380 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31916 333499 1 50 8 -1 -1 8 1800 -1 1 213 -1 -1 0 -1 -1 -1 + 31919 333845 630416 48425 64 48153 -1 64 64800 -1 1 132 -1 -1 3 -1 -1 -1 + 31920 334037 774 1432 16 1370 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31921 334051 799 1441 16 1377 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31922 334060 830 1440 16 1376 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31923 334069 864 1438 16 1372 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31924 334080 894 1438 16 1372 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31925 334092 923 1440 16 1376 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31926 334102 872 1441 16 1376 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31927 334416 129169 20993 512 10445 -1 512 27000 -1 1 93 -1 -1 4 -1 -1 -1 + 31928 334591 45014 18648 640 9280 -1 640 41400 -1 1 93 -1 -1 4 -1 -1 -1 + 31929 334668 149956 21619 512 10730 -1 512 27000 -1 1 93 -1 -1 4 -1 -1 -1 + 31932 335070 1 54 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 31934 335172 0 39 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 31935 335405 0 56 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 31936 335587 30002 21646 16 21526 -1 16 21600 -1 5 273 -1 -1 3 -1 -1 -1 + 31942 336701 1 85 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 31943 336872 95286 17857 64 17748 -1 64 21600 -1 1 132 -1 -1 3 -1 -1 -1 + 31945 337040 0 52 8 -1 -1 8 1800 -1 1 213 -1 -1 0 -1 -1 -1 + 31949 337276 0 46 8 -1 -1 8 1800 -1 1 213 -1 -1 0 -1 -1 -1 + 31950 337371 1 72 8 -1 -1 8 1800 -1 1 213 -1 -1 0 -1 -1 -1 + 31952 337554 1 44 16 -1 -1 16 1800 -1 1 213 -1 -1 0 -1 -1 -1 + 31954 337807 33 4504 128 1693 -1 128 7200 -1 5 128 -1 -1 3 -1 -1 -1 + 31957 338280 33 4998 8 4922 -1 8 7200 -1 1 250 -1 -1 3 -1 -1 -1 + 31958 338290 23 4146 8 4095 -1 8 7200 -1 1 250 -1 -1 3 -1 -1 -1 + 31959 338393 40 1437 16 1370 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31960 338406 27 1447 16 1382 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31961 338421 13 1438 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31962 338457 17 1437 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31963 338469 47 1437 16 1373 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31965 338484 32 1441 16 1373 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31966 338495 21 1438 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31969 339010 47 1437 16 1369 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31970 339021 36 1442 16 1372 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31971 339030 27 1440 16 1372 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31972 339039 18 2282 16 2209 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31973 339051 47 1442 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31974 339062 36 1440 16 1372 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31975 339075 23 1448 16 1376 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31976 339097 43 1439 16 1369 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31977 339109 31 1445 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31978 339120 23 1450 16 1382 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31979 339129 13 24 8 -1 -1 8 1800 -1 5 28 -1 -1 8 -1 -1 -1 + 31980 339131 12 1447 16 1380 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31981 339337 17 1435 16 1371 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31982 339347 51 1446 16 1381 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31983 339355 43 1448 16 1383 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 31984 339474 81281 43247 64 30763 -1 64 43200 -1 5 225 -1 -1 2 -1 -1 -1 + 31987 339967 28 25 8 -1 -1 8 1800 -1 1 21 -1 -1 8 -1 -1 -1 + 31988 340118 624145 21789 128 10821 -1 128 28800 -1 1 95 -1 -1 3 -1 -1 -1 + 31991 340529 45670 19055 40 9393 -1 40 21600 -1 1 277 -1 -1 3 -1 -1 -1 + 31999 341363 1 49 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32002 342122 164337 64854 256 32371 -1 256 64800 -1 5 119 -1 -1 2 -1 -1 -1 + 32003 342201 1 55 8 -1 -1 8 1800 -1 1 156 -1 -1 0 -1 -1 -1 + 32007 342496 0 38 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32009 342634 1 59 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32010 342830 0 71 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32011 343084 1 56 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32012 343094 29481 13615 32 6762 -1 32 18000 -1 1 178 -1 -1 4 -1 -1 -1 + 32017 343444 61847 12984 32 6451 -1 32 18000 -1 1 178 -1 -1 4 -1 -1 -1 + 32022 343991 16817 16246 128 8075 -1 128 16200 -1 5 116 -1 -1 3 -1 -1 -1 + 32023 344210 1 73 8 -1 -1 8 1800 -1 1 156 -1 -1 0 -1 -1 -1 + 32030 344923 17 1449 16 1376 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32031 344933 7 1451 16 1376 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32032 344944 37 1466 16 1387 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32033 344955 26 1456 16 1376 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32034 344965 16 1454 16 1373 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32035 344976 47 1442 16 1376 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32036 344987 36 1441 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32065 346093 16971 23081 8 5760 -1 8 36000 -1 1 144 -1 -1 4 -1 -1 -1 + 32066 346156 16908 1436 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32067 346166 15443 1433 16 1371 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32068 346178 16886 1437 16 1375 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32069 346189 14619 1439 16 1377 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32070 346210 15399 1441 16 1379 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32071 346230 15379 1436 16 1374 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32072 346252 15357 1442 16 1380 -1 16 7200 -1 1 144 -1 -1 4 -1 -1 -1 + 32073 346465 1 84 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32078 347397 207059 17732 64 9383 -1 64 64800 -1 1 169 -1 -1 2 -1 -1 -1 + 32081 347798 401870 41057 64 21913 -1 64 64800 -1 1 169 -1 -1 2 -1 -1 -1 + 32085 349167 400501 3651 80 1774 -1 80 64800 -1 1 266 -1 -1 2 -1 -1 -1 + 32086 349248 657854 -1 -1 -1 -1 96 64800 -1 5 266 -1 -1 2 -1 -1 -1 + 32095 350866 6721 21654 512 10763 -1 512 21600 -1 5 37 -1 -1 2 -1 -1 -1 + 32097 352152 86 -1 -1 -1 -1 1024 600 -1 5 28 -1 -1 3 -1 -1 -1 + 32100 362590 0 84 8 -1 -1 8 1800 -1 1 108 -1 -1 0 -1 -1 -1 + 32103 365706 122205 9049 256 4488 -1 256 9000 -1 5 116 -1 -1 3 -1 -1 -1 + 32105 370566 0 43 8 -1 -1 8 1800 -1 1 157 -1 -1 0 -1 -1 -1 + 32106 371591 24 22 8 -1 -1 8 3600 -1 1 157 -1 -1 3 -1 -1 -1 + 32107 372003 16 22 8 -1 -1 8 3600 -1 1 157 -1 -1 3 -1 -1 -1 + 32108 372293 21 22 8 -1 -1 8 3600 -1 1 157 -1 -1 4 -1 -1 -1 + 32109 375878 92324 4128 128 2016 -1 128 10800 -1 1 128 -1 -1 3 -1 -1 -1 + 32110 377889 1717 4966 32 4395 -1 32 7200 -1 1 261 -1 -1 3 -1 -1 -1 + 32111 379970 55883 -1 -1 -1 -1 640 46200 -1 5 93 -1 -1 4 -1 -1 -1 + 32112 388056 18 7246 32 6435 -1 32 7200 -1 5 261 -1 -1 3 -1 -1 -1 + 32113 395216 132892 27987 64 13933 -1 64 32400 -1 1 73 -1 -1 4 -1 -1 -1 + 32114 398879 350782 44854 128 22366 -1 128 50400 -1 1 118 -1 -1 3 -1 -1 -1 + 32115 401106 38514 3647 128 1455 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32116 401109 42181 3647 128 1515 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32117 401113 45845 3647 128 1489 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32118 401120 49524 3647 128 1454 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32119 401124 53633 3648 128 1360 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32120 401127 99559 3654 128 1351 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32121 401131 95865 3359 128 1130 -1 128 3600 -1 1 58 -1 -1 3 -1 -1 -1 + 32122 401134 106894 3303 128 1101 -1 128 3600 -1 1 58 -1 -1 3 -1 -1 -1 + 32124 401142 110643 3665 128 1460 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32125 401145 53234 3647 128 1472 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32126 401149 110214 3650 128 1502 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32127 401152 95844 3646 128 1429 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32128 401156 110590 3651 128 1394 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32129 401160 74717 3648 128 1439 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32130 401163 106902 3649 128 1419 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32132 401171 83042 3653 128 1385 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32133 401175 80602 3650 128 1352 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32135 401182 79340 3649 128 1413 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32136 401185 75653 3649 128 1462 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32137 401188 57235 3643 128 1388 -1 128 3600 -1 5 58 -1 -1 3 -1 -1 -1 + 32138 401192 71154 3507 128 1379 -1 128 3600 -1 1 58 -1 -1 3 -1 -1 -1 + 32140 401497 6 11690 16 11607 -1 16 36000 -1 1 144 -1 -1 4 -1 -1 -1 + 32141 401928 0 49 16 -1 -1 16 1800 -1 1 41 -1 -1 0 -1 -1 -1 + 32142 402011 0 46 16 -1 -1 16 1800 -1 1 41 -1 -1 0 -1 -1 -1 + 32143 402051 0 98 16 -1 -1 16 1800 -1 1 41 -1 -1 0 -1 -1 -1 + 32144 402205 3086 11744 16 11650 -1 16 36000 -1 1 144 -1 -1 4 -1 -1 -1 + 32145 402214 16934 -1 -1 -1 -1 16 36000 -1 5 144 -1 -1 4 -1 -1 -1 + 32146 402221 16934 -1 -1 -1 -1 16 36000 -1 5 144 -1 -1 4 -1 -1 -1 + 32147 402226 16935 -1 -1 -1 -1 16 36000 -1 5 144 -1 -1 4 -1 -1 -1 + 32148 402229 0 105 16 -1 -1 16 1800 -1 1 41 -1 -1 0 -1 -1 -1 + 32149 402234 16935 -1 -1 -1 -1 16 36000 -1 5 144 -1 -1 4 -1 -1 -1 + 32150 402240 16936 -1 -1 -1 -1 16 36000 -1 5 144 -1 -1 4 -1 -1 -1 + 32151 402364 0 119 16 -1 -1 16 1800 -1 1 41 -1 -1 0 -1 -1 -1 + 32152 402654 0 48 16 -1 -1 16 1800 -1 1 41 -1 -1 0 -1 -1 -1 + 32153 402828 0 50 8 -1 -1 8 1800 -1 1 41 -1 -1 0 -1 -1 -1 + 32154 402941 0 42 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32156 403136 0 41 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32157 403367 0 36 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32158 404343 1 31 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32161 407522 174029 64857 256 64529 -1 256 64800 -1 5 273 -1 -1 3 -1 -1 -1 + 32162 407701 152029 43245 64 33840 -1 64 43200 -1 5 225 -1 -1 2 -1 -1 -1 + 32163 408460 14643 6756 32 3346 -1 32 7200 -1 1 128 -1 -1 3 -1 -1 -1 + 32166 409264 117911 64836 32 32373 -1 32 64800 -1 5 171 -1 -1 3 -1 -1 -1 + 32173 411053 2239 55909 8 55651 -1 8 64800 -1 1 143 -1 -1 3 -1 -1 -1 + 32174 411204 2088 35012 8 34840 -1 8 64800 -1 1 143 -1 -1 3 -1 -1 -1 + 32175 411435 11668 42331 8 42117 -1 8 64800 -1 1 143 -1 -1 3 -1 -1 -1 + 32178 412775 0 58 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32179 412890 0 84 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32180 413165 0 83 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32184 414060 0 47 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32185 414136 1 45 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32186 414370 0 41 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32187 414389 2686 7246 16 7169 -1 16 7200 -1 5 273 -1 -1 3 -1 -1 -1 + 32188 414425 0 54 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32193 414950 420 -1 -1 -1 -1 16 600 -1 5 273 -1 -1 3 -1 -1 -1 + 32194 415011 156352 64381 256 31124 -1 256 64320 -1 5 59 -1 -1 2 -1 -1 -1 + 32196 415399 159996 64377 256 31892 -1 256 64320 -1 5 59 -1 -1 2 -1 -1 -1 + 32198 416070 8281 7247 16 7170 -1 16 7200 -1 5 273 -1 -1 3 -1 -1 -1 + 32204 417719 0 66 8 -1 -1 8 1800 -1 1 49 -1 -1 0 -1 -1 -1 + 32205 417776 1 37 8 -1 -1 8 1800 -1 1 49 -1 -1 0 -1 -1 -1 + 32207 417901 0 84 8 -1 -1 8 1800 -1 1 9 -1 -1 0 -1 -1 -1 + 32209 418148 0 42 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32210 418333 475 -1 -1 -1 -1 64 1200 -1 5 127 -1 -1 3 -1 -1 -1 + 32212 418881 3228 -1 -1 -1 -1 32 1200 -1 5 127 -1 -1 3 -1 -1 -1 + 32213 419030 11227 11708 16 11605 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32214 419073 18579 11738 16 11633 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32215 419190 0 60 8 -1 -1 8 1800 -1 1 268 -1 -1 0 -1 -1 -1 + 32216 419191 22838 11771 16 11667 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32217 419199 25686 11721 16 11606 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32218 419206 39329 11769 16 11653 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32219 419213 39322 11780 16 11657 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32220 419227 37417 11721 16 11603 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32225 420193 544068 5122 256 2510 -1 256 15300 -1 5 95 -1 -1 3 -1 -1 -1 + 32228 420333 135909 25273 336 12576 -1 336 25200 -1 5 138 -1 -1 3 -1 -1 -1 + 32229 420363 0 180 -1 -1 -1 64 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 32232 421497 105832 28864 336 14359 -1 336 28800 -1 5 138 -1 -1 2 -1 -1 -1 + 32237 423136 16633 18003 40 8902 -1 40 21600 -1 1 277 -1 -1 3 -1 -1 -1 + 32240 424167 2963 21645 16 21504 -1 16 21600 -1 5 273 -1 -1 3 -1 -1 -1 + 32242 424991 5038 21646 16 21530 -1 16 21600 -1 5 273 -1 -1 3 -1 -1 -1 + 32245 425903 0 33 8 -1 -1 8 1800 -1 1 9 -1 -1 0 -1 -1 -1 + 32248 427037 0 49 8 -1 -1 8 1800 -1 1 39 -1 -1 0 -1 -1 -1 + 32250 427098 0 64 8 -1 -1 8 1800 -1 1 39 -1 -1 0 -1 -1 -1 + 32257 429643 1 33 8 -1 -1 8 1800 -1 1 97 -1 -1 0 -1 -1 -1 + 32259 429870 161 -1 -1 -1 -1 8 3600 -1 5 73 -1 -1 4 -1 -1 -1 + 32266 430532 151016 43248 56 22760 -1 56 43200 -1 5 225 -1 -1 2 -1 -1 -1 + 32268 430578 0 180 -1 -1 -1 8 1800 -1 5 157 -1 -1 0 -1 -1 -1 + 32272 430929 212 -1 -1 -1 -1 8 1800 -1 5 73 -1 -1 1 -1 -1 -1 + 32276 432225 368603 43247 56 25177 -1 56 43200 -1 5 225 -1 -1 3 -1 -1 -1 + 32279 433312 0 49 8 -1 -1 8 1800 -1 1 39 -1 -1 0 -1 -1 -1 + 32280 433356 316312 64845 64 32362 -1 64 64800 -1 5 27 -1 -1 2 -1 -1 -1 + 32281 433379 0 56 8 -1 -1 8 1800 -1 1 39 -1 -1 0 -1 -1 -1 + 32286 434261 0 41 8 -1 -1 8 1800 -1 1 37 -1 -1 0 -1 -1 -1 + 32287 434394 1 180 -1 -1 -1 64 1800 -1 5 264 -1 -1 0 -1 -1 -1 + 32291 434927 1 180 -1 -1 -1 16 1800 -1 5 59 -1 -1 0 -1 -1 -1 + 32297 436294 0 180 -1 -1 -1 64 1800 -1 5 264 -1 -1 0 -1 -1 -1 + 32298 436486 0 180 -1 -1 -1 64 1800 -1 5 264 -1 -1 0 -1 -1 -1 + 32305 437604 1 37 8 -1 -1 8 1800 -1 1 157 -1 -1 0 -1 -1 -1 + 32306 437643 1 1834 32 1264 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32307 437675 0 41 8 -1 -1 8 1800 -1 1 157 -1 -1 0 -1 -1 -1 + 32308 437954 0 57 8 -1 -1 8 1800 -1 1 157 -1 -1 0 -1 -1 -1 + 32309 438125 0 180 -1 -1 -1 32 1800 -1 5 246 -1 -1 0 -1 -1 -1 + 32311 438767 0 181 -1 -1 -1 32 1800 -1 5 246 -1 -1 0 -1 -1 -1 + 32312 438869 0 35 8 -1 -1 8 1800 -1 1 157 -1 -1 0 -1 -1 -1 + 32313 439055 157 5529 16 2735 -1 16 7200 -1 1 128 -1 -1 3 -1 -1 -1 + 32314 439071 0 180 -1 -1 -1 32 1800 -1 5 246 -1 -1 0 -1 -1 -1 + 32316 439323 0 181 -1 -1 -1 32 1800 -1 5 246 -1 -1 0 -1 -1 -1 + 32319 439871 0 180 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32320 439873 1 180 -1 -1 -1 32 1800 -1 5 246 -1 -1 0 -1 -1 -1 + 32321 440121 0 180 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32322 440417 0 180 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32323 440497 0 63 -1 -1 -1 8 1800 -1 5 72 -1 -1 0 -1 -1 -1 + 32324 440662 0 180 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32325 440675 1317 22 8 -1 -1 8 120 -1 1 37 -1 -1 1 -1 -1 -1 + 32326 440859 0 180 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32327 441146 0 180 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32328 441370 0 180 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32329 441605 1 180 -1 -1 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32330 442083 276 -1 -1 -1 -1 192 64140 -1 5 59 -1 -1 2 -1 -1 -1 + 32331 442668 86330 -1 -1 -1 -1 192 64140 -1 5 264 -1 -1 2 -1 -1 -1 + 32333 443421 0 180 -1 -1 -1 32 1800 -1 5 246 -1 -1 0 -1 -1 -1 + 32334 443789 0 180 -1 -1 -1 32 1800 -1 5 246 -1 -1 0 -1 -1 -1 + 32338 451835 12173 10652 32 2941 -1 32 16200 -1 1 111 -1 -1 4 -1 -1 -1 + 32340 453212 8879 11738 16 11635 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32341 453220 16288 11727 16 11637 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32342 453231 10852 11679 16 11594 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32343 453239 10844 11697 16 11611 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32346 463575 11 180 -1 -1 -1 32 1800 -1 5 246 -1 -1 0 -1 -1 -1 + 32351 476961 2599 8635 32 7475 -1 32 10800 -1 1 261 -1 -1 3 -1 -1 -1 + 32352 480099 8103 17827 64 17712 -1 64 21600 -1 1 132 -1 -1 3 -1 -1 -1 + 32353 481222 34262 6486 128 2580 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32354 482063 36756 7250 128 3060 -1 128 7200 -1 5 58 -1 -1 3 -1 -1 -1 + 32355 482067 180871 6767 128 2779 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32356 482071 38570 6483 128 2575 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32357 482075 71715 5807 128 2237 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32358 482078 77771 4305 128 1524 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32360 482086 64182 3233 128 1101 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32363 484620 19756 3592 128 1758 -1 128 7200 -1 1 128 -1 -1 3 -1 -1 -1 + 32365 488856 480546 43247 64 30158 -1 64 43200 -1 5 225 -1 -1 2 -1 -1 -1 + 32366 488902 1 1857 32 1254 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32368 489725 17 21649 16 21491 -1 16 21600 -1 5 273 -1 -1 3 -1 -1 -1 + 32369 489772 16693 21637 16 21481 -1 16 21600 -1 5 273 -1 -1 3 -1 -1 -1 + 32370 491145 0 1858 32 1270 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32373 493244 0 1855 32 1250 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32374 493261 14106 11737 16 11635 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32375 493268 15360 11744 16 11624 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32376 493275 15353 11736 16 11607 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32377 493283 15571 11716 16 11611 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32378 493291 15563 11765 16 11666 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32379 493297 15557 11733 16 11623 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32380 493305 15549 11743 16 11641 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32381 495344 0 1850 32 1252 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32382 498261 439 -1 -1 -1 -1 8 1200 -1 5 37 -1 -1 1 -1 -1 -1 + 32393 499869 7 -1 -1 -1 -1 8 1800 -1 5 9 -1 -1 2 -1 -1 -1 + 32404 501701 23930 2436 48 1392 -1 48 36000 -1 1 60 -1 -1 2 -1 -1 -1 + 32409 502808 1 180 -1 -1 -1 32 1800 -1 5 246 -1 -1 0 -1 -1 -1 + 32417 505478 0 267 8 -1 -1 8 1800 -1 1 37 -1 -1 0 -1 -1 -1 + 32418 506022 5337 53903 8 53682 -1 8 64800 -1 1 143 -1 -1 3 -1 -1 -1 + 32419 506159 5239 36690 8 36487 -1 8 64800 -1 1 143 -1 -1 3 -1 -1 -1 + 32420 506343 5055 44331 8 44004 -1 8 64800 -1 1 143 -1 -1 3 -1 -1 -1 + 32423 506797 256042 37631 256 18666 -1 256 64800 -1 1 119 -1 -1 3 -1 -1 -1 + 32427 507156 1660 17768 64 17637 -1 64 21600 -1 1 132 -1 -1 3 -1 -1 -1 + 32429 507260 0 57 8 -1 -1 8 1800 -1 1 11 -1 -1 0 -1 -1 -1 + 32432 507970 1 180 -1 -1 -1 16 1800 -1 5 37 -1 -1 0 -1 -1 -1 + 32433 508121 1 41 8 -1 -1 8 1800 -1 1 240 -1 -1 0 -1 -1 -1 + 32434 508307 0 44 8 -1 -1 8 1800 -1 1 240 -1 -1 0 -1 -1 -1 + 32436 508546 0 34 8 -1 -1 8 1800 -1 1 240 -1 -1 0 -1 -1 -1 + 32437 508675 0 85 32 -1 -1 32 1800 -1 1 37 -1 -1 0 -1 -1 -1 + 32439 508937 0 53 8 -1 -1 8 1800 -1 1 240 -1 -1 0 -1 -1 -1 + 32440 509127 0 57 8 -1 -1 8 1800 -1 1 240 -1 -1 0 -1 -1 -1 + 32442 509293 1 84 32 -1 -1 32 1800 -1 1 225 -1 -1 0 -1 -1 -1 + 32447 509692 1 60 8 -1 -1 8 1800 -1 1 11 -1 -1 0 -1 -1 -1 + 32448 509705 1 1845 32 1248 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32449 509791 0 36 8 -1 -1 8 1800 -1 1 11 -1 -1 0 -1 -1 -1 + 32450 509851 0 50 8 -1 -1 8 1800 -1 1 11 -1 -1 0 -1 -1 -1 + 32451 509916 0 59 8 -1 -1 8 1800 -1 1 11 -1 -1 0 -1 -1 -1 + 32453 510006 1 45 8 -1 -1 8 1800 -1 1 11 -1 -1 0 -1 -1 -1 + 32454 510063 1 63 8 -1 -1 8 1800 -1 1 11 -1 -1 0 -1 -1 -1 + 32456 510133 0 31 8 -1 -1 8 1800 -1 1 11 -1 -1 0 -1 -1 -1 + 32460 510807 16529 11763 16 11604 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32461 510815 16558 11753 16 11630 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32462 510822 17321 11687 16 11598 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32464 510828 17465 11749 16 11636 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32465 510837 28344 11718 16 11617 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32466 510845 28298 11736 16 11614 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32467 510857 28995 11692 16 11601 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32468 510858 4661 1247 64 1183 -1 64 1200 -1 5 127 -1 -1 3 -1 -1 -1 + 32469 510990 459188 43249 64 28067 -1 64 43200 -1 5 225 -1 -1 2 -1 -1 -1 + 32470 511029 0 56 8 -1 -1 8 1800 -1 1 73 -1 -1 0 -1 -1 -1 + 32474 511716 15620 21628 16 21448 -1 16 21600 -1 5 273 -1 -1 3 -1 -1 -1 + 32475 511783 1 1859 32 1253 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32478 512561 1 37 8 -1 -1 8 1800 -1 1 240 -1 -1 0 -1 -1 -1 + 32489 514975 11628 1678 16 1615 -1 16 64800 -1 1 37 -1 -1 2 -1 -1 -1 + 32490 515127 1 180 -1 -1 -1 64 1800 -1 5 264 -1 -1 0 -1 -1 -1 + 32494 515811 1 180 -1 -1 -1 64 1800 -1 5 264 -1 -1 0 -1 -1 -1 + 32495 516009 0 180 -1 -1 -1 64 1800 -1 5 264 -1 -1 0 -1 -1 -1 + 32499 516408 0 191 8 -1 -1 8 1800 -1 1 246 -1 -1 0 -1 -1 -1 + 32502 517169 1 72 8 -1 -1 8 1800 -1 1 157 -1 -1 0 -1 -1 -1 + 32504 517573 20 4847 64 4768 -1 64 4800 -1 5 127 -1 -1 3 -1 -1 -1 + 32512 518876 14 326 8 -1 -1 8 300 -1 5 111 -1 -1 3 -1 -1 -1 + 32513 519060 1 180 -1 -1 -1 64 1800 -1 5 264 -1 -1 0 -1 -1 -1 + 32514 519304 0 181 -1 -1 -1 64 1800 -1 5 264 -1 -1 0 -1 -1 -1 + 32515 519541 1 180 -1 -1 -1 64 1800 -1 5 264 -1 -1 0 -1 -1 -1 + 32516 519729 1 64 8 -1 -1 8 1800 -1 1 157 -1 -1 0 -1 -1 -1 + 32519 519897 1 53 8 -1 -1 8 1800 -1 1 157 -1 -1 0 -1 -1 -1 + 32531 522520 102226 12224 40 9601 -1 40 28800 -1 5 87 -1 -1 4 -1 -1 -1 + 32537 522884 36843 13517 32 6714 -1 32 18000 -1 1 178 -1 -1 4 -1 -1 -1 + 32539 523314 1 49 8 -1 -1 8 1800 -1 1 79 -1 -1 0 -1 -1 -1 + 32547 523881 1 41 8 -1 -1 8 1800 -1 1 9 -1 -1 0 -1 -1 -1 + 32563 526266 1 180 -1 -1 -1 8 1800 -1 5 79 -1 -1 0 -1 -1 -1 + 32566 527407 1 180 -1 -1 -1 8 1800 -1 5 11 -1 -1 0 -1 -1 -1 + 32567 527452 2 125 -1 -1 -1 8 1800 -1 5 79 -1 -1 0 -1 -1 -1 + 32568 527562 248373 7323 192 3579 -1 192 64080 -1 1 264 -1 -1 2 -1 -1 -1 + 32569 527665 1 63 -1 -1 -1 8 1800 -1 5 79 -1 -1 0 -1 -1 -1 + 32570 527765 0 34 8 -1 -1 8 1800 -1 1 11 -1 -1 0 -1 -1 -1 + 32571 527805 0 84 8 -1 -1 8 1800 -1 1 11 -1 -1 0 -1 -1 -1 + 32572 527983 0 181 -1 -1 -1 32 1800 -1 5 246 -1 -1 0 -1 -1 -1 + 32573 528487 254847 64158 192 31779 -1 192 64080 -1 5 264 -1 -1 2 -1 -1 -1 + 32574 528828 11250 11715 16 11612 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32575 528836 26916 11740 16 11634 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32576 528845 22975 11783 16 11679 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32577 528854 30996 11838 16 11702 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32578 528860 38646 11722 16 11613 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32579 528870 30980 11747 16 11626 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32580 528878 30972 11819 16 11692 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32581 528946 265613 39857 192 19622 -1 192 64140 -1 1 59 -1 -1 2 -1 -1 -1 + 32583 530039 9065 23 8 -1 -1 8 600 -1 1 11 -1 -1 3 -1 -1 -1 + 32584 530282 180115 -1 -1 -1 -1 336 36000 -1 5 138 -1 -1 3 -1 -1 -1 + 32585 530534 174253 -1 -1 -1 -1 336 36000 -1 5 138 -1 -1 3 -1 -1 -1 + 32586 534758 68360 17752 64 17615 -1 64 21600 -1 1 132 -1 -1 3 -1 -1 -1 + 32587 535009 521876 56617 64 56351 -1 64 64800 -1 1 132 -1 -1 3 -1 -1 -1 + 32588 538170 108271 16263 256 8068 -1 256 16200 -1 5 116 -1 -1 3 -1 -1 -1 + 32589 542148 17702 11776 16 11649 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32590 542159 23143 11688 16 11593 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32591 542167 39381 11697 16 11603 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32592 542174 17676 11789 16 11658 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32593 542181 21436 11755 16 11638 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32594 542187 51268 11721 16 11597 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32595 542196 52210 11741 16 11633 -1 16 16200 -1 1 144 -1 -1 4 -1 -1 -1 + 32597 559669 450274 46903 128 46722 -1 128 57600 -1 1 132 -1 -1 3 -1 -1 -1 + 32598 559992 52039 12706 64 10887 -1 64 14400 -1 1 261 -1 -1 3 -1 -1 -1 + 32599 567494 95444 6826 128 2791 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32600 567498 102251 6661 128 2703 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32601 567503 382743 6341 128 2570 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32602 567509 102279 5256 128 2019 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32604 567520 110275 8675 128 -1 -1 128 7200 -1 5 58 -1 -1 3 -1 -1 -1 + 32605 567525 234405 3830 128 1476 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32606 567529 396732 3877 128 1469 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32607 567534 396727 7247 128 2790 -1 128 7200 -1 5 58 -1 -1 3 -1 -1 -1 + 32608 567538 396723 7247 128 2769 -1 128 7200 -1 5 58 -1 -1 3 -1 -1 -1 + 32609 567543 235495 6105 128 2300 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32610 567548 238255 5881 128 2360 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32612 567557 376899 4313 128 1657 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32613 567561 376894 3645 128 1444 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32614 567566 400637 2970 128 1177 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32615 567570 539453 3354 128 1261 -1 128 7200 -1 1 58 -1 -1 3 -1 -1 -1 + 32617 575593 0 1849 32 1251 -1 32 1800 -1 5 225 -1 -1 0 -1 -1 -1 + 32618 575930 363052 -1 -1 -1 -1 128 57600 ... [truncated message content] |
From: <mar...@us...> - 2007-09-18 04:17:23
|
Revision: 61 http://gridsim.svn.sourceforge.net/gridsim/?rev=61&view=rev Author: marcos_dias Date: 2007-09-17 21:17:27 -0700 (Mon, 17 Sep 2007) Log Message: ----------- SOME OPTIMISATIONS AND BUG FIXES: + gridlets now share entries in the availability profile. This reduces the number of entries in the profile, improves simulation speed and minimises the use of memory. + cancellation of gridlets. Gridlets can now be cancelled and the remaining part of the queue is compressed. The compression of the queue is described in an IEEE Transactions paper described in the header of the class. The compression avoids reschedule and is faster as the first time estimation is always respected as the gridlets are considered according to the order that they were put in the queue. + Some changes in the availability, GUI, and PE ranges related classes. + One example of cancellation has been included. LIMITATIONS/KNOWN ISSUES: + AllocPolicy does not set the status of the Gridlet to CANCELED when it is sent to the user. + In fact, I do not know why the Gridlet is sent back to the user when it is cancelled. + TThe interface does not show the cancelled Gridlets properly YET. When ready, the cancelled Gridlets will appear in red right before they disappear from the panel. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java branches/gridsim4.0-branch3/source/gridsim/ARPolicy.java branches/gridsim4.0-branch3/source/gridsim/GridSim.java branches/gridsim4.0-branch3/source/gridsim/PERangeList.java branches/gridsim4.0-branch3/source/gridsim/ParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/gui/AllocationAction.java branches/gridsim4.0-branch3/source/gridsim/gui/GridSimVisualizer.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/util/Workload.java Added Paths: ----------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2007-09-14 23:23:03 UTC (rev 60) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2007-09-18 04:17:27 UTC (rev 61) @@ -86,10 +86,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode - GridSim.startGridSimulation(true); +// GridSim.startGridSimulation(true); // Start the simulation in normal mode -// GridSim.startGridSimulation(); + GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2007-09-18 04:17:27 UTC (rev 61) @@ -0,0 +1,173 @@ + +package examples.workload.parallel; + +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCharacteristics; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example + */ +public class TurboExampleWithCancellation01 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + String fileName = args[0]; + // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf + + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialise the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initialising GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialise the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) + { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + WorkloadWithCancellation workload = new WorkloadWithCancellation("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode + GridSim.startGridSimulation(true); + + // Start the simulation in normal mode +// GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + ResourceCharacteristics resConfig = new ResourceCharacteristics( + arch, os, mList, ResourceCharacteristics.PARALLEL_SPACE_SHARED, + time_zone, cost); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList Weekends = new LinkedList(); + Weekends.add(new Integer(Calendar.SATURDAY)); + Weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList Holidays = new LinkedList(); + GridResource gridRes = null; + try { + gridRes = new GridResource(name, baud_rate, seed, + resConfig, peakLoad, offPeakLoad, holidayLoad, Weekends, + Holidays); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java 2007-09-18 04:17:27 UTC (rev 61) @@ -0,0 +1,250 @@ +/* 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 + */ + +package examples.workload.parallel; + +import eduni.simjava.Sim_event; +import eduni.simjava.Sim_system; +import gridsim.GridSimTags; +import gridsim.Gridlet; +import gridsim.IO_data; +import gridsim.ParameterException; +import gridsim.net.Link; +import gridsim.util.Workload; + +import java.util.ArrayList; + +/** + * This class is an extended version of @link{Workload}. This class + * cancels some gridlets submitted. + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see Workload + */ +public class WorkloadWithCancellation extends Workload { + private final int NUM_GRIDLETS_BETWEEN_CANCELLATIONS = 50; + // value of 1, means that the cancellation will be sent + // at the gridlet's submission time + (gridlet duration * 1) + private final double TIME_CANCELLATION = 0.5; + + /** + * Create a new @link{WorkloadWithCancellation} object <b>without</b> using + * the network extension. This means this entity directly sends Gridlets + * to a resource destination without going through a wired network. <br> + * <tt>NOTE:</tt> + * You can not use this constructor in an experiment that uses a wired + * network topology. + * + * @param name this entity name + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithCancellation(String name, String fileName, String resourceName, + int rating) throws ParameterException, Exception { + + super(name, fileName, resourceName, rating); + } + + /** + * Create a new @link{WorkloadWithCancellation} object <b>with</b> the network extension. + * This means this entity directly sends Gridlets to a destination resource + * through a link. The link is automatically created by this constructor. + * + * @param name this entity name + * @param baudRate baud rate of this link (bits/s) + * @param propDelay Propagation delay of the Link in milliseconds + * @param MTU Maximum Transmission Unit of the Link in bytes. + * Packets which are larger than the MTU should be split + * up into MTU size units. + * For example, a 1024 byte packet trying to cross a 576 + * byte MTU link should get split into 2 packets of 576 + * bytes and 448 bytes. + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li> baudRate <= 0 + * <li> propDelay <= 0 + * <li> MTU <= 0 + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre baudRate > 0 + * @pre propDelay > 0 + * @pre MTU > 0 + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithCancellation(String name, double baudRate, double propDelay, int MTU, + String fileName, String resourceName, int rating) + throws ParameterException, Exception { + + super( name, baudRate, propDelay, MTU, fileName, resourceName, rating ); + } + + /** + * Create a new Workload object <b>with</b> the network extension. + * This means this entity directly sends Gridlets to a destination resource + * through a link. The link is automatically created by this constructor. + * + * @param name this entity name + * @param link the link that will be used to connect this Workload + * to another entity or a Router. + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li>the link is empty + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre link != null + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithCancellation(String name, Link link, String fileName, + String resourceName, int rating) + throws ParameterException, Exception { + + super(name, link, fileName, resourceName, rating); + } + + //////////////////////// PRIVATE METHODS /////////////////////// + + /** + * Collects Gridlets sent and stores them into a list. + * @pre $none + * @post $none + */ + protected void collectGridlet() { + System.out.println(super.get_name() + ": Collecting Gridlets ..."); + list_ = new ArrayList(gridletID_ + 1); + + Object data = null; + Gridlet gl = null; + + int counter = 1; // starts at 1, since gridletID_ starts at 1 too + Sim_event ev = new Sim_event(); + while ( Sim_system.running() ) { + + super.sim_get_next(ev); // get the next available event + data = ev.get_data(); // get the event's data + + // handle ping request + if (ev.get_tag() == GridSimTags.INFOPKT_SUBMIT) { + processPingRequest(ev); + continue; + } + + // get the Gridlet data + if (data != null && data instanceof Gridlet) { + gl = (Gridlet) data; + + if(gl.getGridletStatus() == Gridlet.FAILED) + System.out.println("Gridlet failed"); + + if(gl.getGridletStatus() == Gridlet.CANCELED) + System.out.println("Gridlet cancelled"); + + list_.add(gl); + counter++; + } + + // if all the Gridlets have been collected + if (counter == gridletID_) { + break; + } + } + } + + /** + * Creates a Gridlet with the given information, then submit it to a + * resource + * @param id a Gridlet ID + * @param submitTime Gridlet's submit time + * @param runTime Gridlet's run time + * @param numProc number of processors + * @pre id >= 0 + * @pre submitTime >= 0 + * @pre runTime >= 0 + * @pre numProc > 0 + * @post $none + */ + protected void submitGridlet(int id, long submitTime, int runTime, int numProc) { + + // create the gridlet + int len = runTime * rating_; // calculate a job length for each PE + Gridlet gl = new Gridlet(id, len, size_, size_); + gl.setUserID( super.get_id() ); // set the owner ID + gl.setNumPE(numProc); // set the requested num of proc + + // printing to inform user + if (gridletID_ == 1 || gridletID_ % INTERVAL == 0) { + System.out.println(super.get_name() + ": Submitting Gridlets to " + + resName_ + " ..."); + } + + // check the submit time + if (submitTime < 0) { + submitTime = 0; + } + + gridletID_++; // increment the counter + + // submit a gridlet to resource + super.send(super.output, submitTime, GridSimTags.GRIDLET_SUBMIT, + new IO_data(gl, gl.getGridletFileSize(), resID_) ); + + // check whether a cancellation has to be scheduled or not + int result = gridletID_ % NUM_GRIDLETS_BETWEEN_CANCELLATIONS; + if(result == 0) { + super.send(super.output, (submitTime + (TIME_CANCELLATION * runTime)), GridSimTags.GRIDLET_CANCEL, + new IO_data(gl, 0, resID_) ); + gridletID_++; + } + } + +} // end class + Modified: branches/gridsim4.0-branch3/source/gridsim/ARPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/ARPolicy.java 2007-09-14 23:23:03 UTC (rev 60) +++ branches/gridsim4.0-branch3/source/gridsim/ARPolicy.java 2007-09-18 04:17:27 UTC (rev 61) @@ -488,9 +488,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: branches/gridsim4.0-branch3/source/gridsim/GridSim.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/GridSim.java 2007-09-14 23:23:03 UTC (rev 60) +++ branches/gridsim4.0-branch3/source/gridsim/GridSim.java 2007-09-18 04:17:27 UTC (rev 61) @@ -449,7 +449,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 @@ -459,7 +459,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: branches/gridsim4.0-branch3/source/gridsim/PERangeList.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/PERangeList.java 2007-09-14 23:23:03 UTC (rev 60) +++ branches/gridsim4.0-branch3/source/gridsim/PERangeList.java 2007-09-18 04:17:27 UTC (rev 61) @@ -51,25 +51,28 @@ } /** - * Consolidate PE ranges: e.g. 3-5,5-8,10-20 => 3-8,10-20. - * @pre assumes that the ranges are in order. + * Merges PE ranges: e.g. 3-5,5-8,10-20 => 3-8,10-20. */ - public void consolidatePERanges(){ - PERange currentRange; - PERange nextRange; + public void mergePERanges() { + if(this.size() < 2) // there is nothing to be consolidated + return; + + PERange currentRange; + PERange nextRange; - sortRanges(); - - for(int i=0 ; i<this.size()-1; i++) { - currentRange = this.get(i); - nextRange = this.get(i+1); - - if( currentRange.getEnd() == nextRange.getBeginning() || - (nextRange.getBeginning() - currentRange.getEnd()) == 1 ){ - currentRange.setEnd(nextRange.getEnd()); - this.remove(i+1); - } - } + sortRanges(); // sorts the ranges before + int index = 0; + while(index < super.size()-1){ + currentRange = super.get(index); + nextRange = super.get(index+1); + if( (nextRange.getBeginning() - currentRange.getEnd()) == 1 ){ + currentRange.setEnd(nextRange.getEnd()); + super.remove(index+1); + } + else{ + index++; + } + } } /** @@ -89,7 +92,8 @@ * of the ranges */ public void sortRanges(){ - Collections.sort(this,comparator_); + if(super.size() > 1) + Collections.sort(this, comparator_); } /** @@ -197,8 +201,13 @@ } } } - rIntersec.consolidatePERanges(); - return rIntersec.size() == 0 ? null : rIntersec; + + if( rIntersec.size() == 0) + return null; + else{ + rIntersec.mergePERanges(); + return rIntersec; + } } /** @@ -285,14 +294,12 @@ return null; } - PERangeList query = lista; - query.sortRanges(); + PERangeList difference = lista.clone(); + difference.mergePERanges(); PERangeList universe = listb; universe.sortRanges(); - - PERangeList difference = query.clone(); - + boolean finished = false; while(!finished){ finished = true; @@ -321,7 +328,7 @@ return null; } else{ - difference.consolidatePERanges(); + difference.mergePERanges(); return difference; } } @@ -453,7 +460,7 @@ return null; } else{ - universe.consolidatePERanges(); + universe.mergePERanges(); return universe; } } @@ -502,4 +509,22 @@ return begA.compareTo(begB); } } + + + // FOR DEBUGGING PURPOSES ONLY... + public static void main(String args[]){ + + PERange ra = new PERange(0, 10); + PERange rd = new PERange(31, 50); + PERange rb = new PERange(11, 20); + PERange rc = new PERange(21, 30); + + PERangeList list = new PERangeList(); + list.add(ra); list.add(rb); + list.add(rc); list.add(rd); + + list.mergePERanges(); + + System.out.println("Consolidated# " + list); + } } Modified: branches/gridsim4.0-branch3/source/gridsim/ParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/ParallelSpaceShared.java 2007-09-14 23:23:03 UTC (rev 60) +++ branches/gridsim4.0-branch3/source/gridsim/ParallelSpaceShared.java 2007-09-18 04:17:27 UTC (rev 61) @@ -16,38 +16,48 @@ import java.util.ArrayList; import java.util.Calendar; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.Iterator; import java.util.LinkedList; /** * @link{ParallelSpaceShared} class is an allocation policy for * @link{GridResource} that behaves exactly like First Come First Serve (FCFS) * with conservative backfilling. The policy is based on the conservative - * backfilling algorithm described in: + * backfilling algorithm described in the following papers: * <p> * Dror G. Feitelson and Ahuva Mu'alem Weil, Utilization and Predictability * in Scheduling the IBM SP2 with Backfilling, in Proceedings of the 12th * International Parallel Processing Symposium on International * Parallel Processing Symposium (IPPS 1998), pp. 542-546. * <p> + * Ahuva W. Mu'alem and Dror G. Feitelson, Utilization, Predictability, + * Workloads, and User Runtime Estimates in Scheduling the IBM SP2 with Backfilling. + * IEEE Transactions on Parallel and Distributed Systems, 12:(6), pp. 529-543, 2001. + * <p> * <b>LIMITATIONS:</b><br> * <ul> * <li> The list of machines comprising this resource must be homogeneous. - * <li> Local load is not considered. - * <li> Gridlets cannot be neither paused nor migrated. + * <li> Local load is not considered. If would like to simulate this, you have to + * model the local load as gridlets. It is more precise and faster. + * <li> Gridlets cannot be paused nor migrated. * </ul> - * + * * @author Marcos Dias de Assuncao * @since GridSim Turbo Alpha 0.1 + * * @see gridsim.GridSim * @see gridsim.ResourceCharacteristics * @see gridsim.AllocPolicy + * @see gridsim.PERange + * @see gridsim.PERangeList */ public class ParallelSpaceShared extends AllocPolicy { - private LinkedList<SSGridlet> queuedGridlets_; // Queue of queued Gridlets + private LinkedList<SSGridlet> queuedGridlets_; // Queue of waiting Gridlets private LinkedList<SSGridlet> runningGridlets_; // Queue of running Gridlets private int numPE_; // The total number of PEs in the resource private int ratingPE_; // The rating of one PE @@ -56,8 +66,8 @@ // FOR DEBUGGING PURPOSES ONLY... private ArrayList<AllocationListener> listeners_; // the listeners interested in this policy - private boolean hasListener_; - private double currentTime_; + private boolean hasListener_; // indicates whether there are listeners registered + private double lastActionTime_; // Keep the time of last relevant allocation action /** * Allocates a new @link{ParallelSpaceShared} object @@ -87,7 +97,7 @@ queuedGridlets_ = new LinkedList<SSGridlet>(); availProfile_ = new AvailabilityProfile(); freePERanges_ = new PERangeList(); - currentTime_ = 0.0D; + lastActionTime_ = 0.0D; numPE_ = 0; ratingPE_ = 0; listeners_ = null; @@ -98,8 +108,7 @@ * Handles internal events that come to this entity. */ public void body(){ - - // Gets the information on number of PEs and rating + // Gets the information on number of PEs and rating // of one PE assuming that the machines are homogeneous MachineList list = resource_.getMachineList(); int numMachine = list.size(); @@ -114,8 +123,7 @@ // a loop that is looking for internal events only Sim_event ev = new Sim_event(); - while ( Sim_system.running() ) - { + while ( Sim_system.running() ) { super.sim_get_next(ev); // if the simulation finishes then exit the loop @@ -126,7 +134,7 @@ // Internal Event if the event source is this entity if (ev.get_src() == super.myId_) { - updateSchedule(); + updateSchedule(); } } @@ -145,15 +153,20 @@ * @param ack an acknowledgement, i.e. <tt>true</tt> if the user wants to know * whether this operation is success or not, <tt>false</tt> otherwise. */ - public void gridletSubmit(Gridlet gridlet, boolean ack){ - + public void gridletSubmit(Gridlet gridlet, boolean ack) { int reqPE = gridlet.getNumPE(); double currentTime = GridSim.clock(); + lastActionTime_ = currentTime; try{ // reject the Gridlet if it requires more PEs than the resource // is able to provide if(reqPE > numPE_){ + String userName = GridSim.getEntityName( gridlet.getUserID() ); + System.out.println(super.get_name() + ".gridletSubmit(): " + + " Gridlet #" + gridlet.getGridletID() + " from " + userName + + " user requires " + gridlet.getNumPE() + " PEs."); + System.out.println("--> The resource has only " + numPE_ + " PEs."); gridlet.setGridletStatus(Gridlet.FAILED); super.sendFinishGridlet(gridlet); return; @@ -164,57 +177,44 @@ ": Exception on submission of a Gridlet"); } - SSGridlet rgl = new SSGridlet(gridlet); + // Create a resource Gridlet + SSGridlet sgl = new SSGridlet(gridlet); /////////////// FOR DEBUGGING PURPOSES ONLY //////// if(GridSim.DEBUG_SIMULATION){ - if(hasListener_){ - AllocationAction action = - new AllocationAction(AllocationAction.GRIDLET_ARRIVED, currentTime_); - LinkedList<SSGridlet> list = new LinkedList<SSGridlet>(); - list.add(rgl); - action.setSSGridlet(list); - notifyListeners(action); - } + LinkedList<SSGridlet> list = new LinkedList<SSGridlet>(); + list.add(sgl); + notifyListeners(AllocationAction.GRIDLET_ARRIVED, true, lastActionTime_, list); } ///////////////////////////////////////////////////// - // If there are no jobs in the queue list, then check if - // there are enough PEs to process the job + // there are enough PEs to process the job immediately boolean success = false; int freePE = (freePERanges_ == null) ? 0 : freePERanges_.getNumPE(); if( reqPE <= freePE ){ - success = scheduleJobImmediately(rgl); + success = scheduleGridletImmediately(sgl); } // if the job could not be scheduled immediately, then // find the anchor point where the job can be put if(!success){ - findAnchorPoint(rgl); + findAnchorPoint(sgl); + // add this Gridlet into waiting list + queuedGridlets_.add(sgl); } /////////////// FOR DEBUGGING PURPOSES ONLY //////// + // Notifies the listeners that a Gridlet has been either scheduled + // to run immediately or put in the waiting queue if(GridSim.DEBUG_SIMULATION){ - if(hasListener_){ - AllocationAction action = - new AllocationAction(AllocationAction.GRIDLET_SCHEDULED, currentTime_); - LinkedList<SSGridlet> list = new LinkedList<SSGridlet>(); - list.add(rgl); - action.setSSGridlet(list); - notifyListeners(action); - - if(GridSim.STEP_BY_STEP_SIMULATION){ - GridSim.pauseSimulation(); - } - else if(GridSim.SLOW_MOTION_SIMULATION){ - GridSim.smallPause(); - } - } + LinkedList<SSGridlet> list = new LinkedList<SSGridlet>(); + list.add(sgl); + notifyListeners(AllocationAction.GRIDLET_SCHEDULED, true, lastActionTime_, list); } ///////////////////////////////////////////////////// @@ -226,7 +226,161 @@ ); } } + + /** + * Finds the status of a specified @link{Gridlet}. + * @param gridletId a Gridlet ID + * @param userId the user or owner's ID of this Gridlet + * @return the Gridlet status or <tt>-1</tt> if not found + * @see gridsim.Gridlet + * @pre gridletId > 0 + * @pre userId > 0 + * @post $none + */ + public int gridletStatus(int gridletId,int userId){ + SSGridlet sgl = null; + + // Look for the Gridlet in the running queue + int index = findSSGridlet(runningGridlets_, gridletId, userId); + if (index >= 0) { + // Get the Gridlet from the execution list + sgl = runningGridlets_.get(index); + return sgl.getGridletStatus(); + } + + // Look for the gridlet in the waiting queue + index = findSSGridlet(queuedGridlets_, gridletId, userId); + if (index >= 0) { + // Get the Gridlet from the execution list + sgl = queuedGridlets_.get(index); + return sgl.getGridletStatus(); + } + + // if not found in all lists then report the Gridlet has not found + return -1; + } + + /** + * Cancels a Gridlet running or in the waiting queue. + * This method will search the running and waiting queues. + * The User ID is important as many users might have the same + * Gridlet ID in the lists. If a Gridlet is cancelled, the availability + * profile is shifted forward. This process ensures that the Gridlets + * will not have an expected completion time worse than the one + * initially stipulated for the Gridlet. This process if known + * as the compression of the schedule. For more details please look + * at the references provided at the initial part of this documentation.<br> + * <b>NOTE:</b> + * <ul> + * <li> Before cancelling a Gridlet, this method updates when the expected + * completion time of the Gridlet is. If the completion time is smaller + * than the current time, then the Gridlet is considered to be + * <tt>finished</tt>. Therefore the Gridlet cannot be cancelled. + * + * <li> Once a Gridlet has been cancelled, it cannot be resumed to + * execute again since this method will pass the Gridlet back to + * sender, i.e. the <tt>userId</tt>. + * + * <li> If a Gridlet cannot be found in both execution and paused list, + * then a <tt>null</tt> Gridlet will be send back to sender, + * i.e. the <tt>userId</tt>. + * + * <li> Once a Gridlet is cancelled, the availability profile is swept + * and Gridlets are moved forwards. The entries in the profile incurred + * by each Gridlet are updated and the new anchor for the Gridlet is found + * again. This process is repeated for each Gridlet. This guarantees that + * Gridlets will not have a time completion worse than those initially + * provided. + * </ul> + * + * @param gridletId a Gridlet ID + * @param userId the user or owner's ID of this Gridlet + * @pre gridletId > 0 + * @pre userId > 0 + * @post $none + */ + public void gridletCancel(int gridletId, int userId){ + double currentTime = GridSim.clock(); + lastActionTime_ = currentTime; // set the time of the last allocation action + SSGridlet sgl = null; // stores the gridlet if found + boolean found = false; + + // Look for the Gridlet in the running queue + int index = findSSGridlet(runningGridlets_, gridletId, userId); + if (index >= 0) { + found = true; + + // Get the Gridlet from the execution list + sgl = runningGridlets_.get(index); + + // if the Gridlet's finish time is smaller than the current + // time or the status is FINISHED, it means that the Gridlet + // has finished and will be but has not been removed from + // the running queue yet. It will probably be done shortly, + // so just send a null to the user. + if(sgl.getGridletStatus() == Gridlet.SUCCESS || + sgl.getGridletFinishTime() <= currentTime){ + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, null, gridletId, userId); + return; // return as it is impossible to cancel the Gridlet + } + else{ + // remove from the queue before compressing the schedule + runningGridlets_.remove(index); + } + } + + if(!found){ + // Look for the gridlet in the waiting queue + index = findSSGridlet(queuedGridlets_, gridletId, userId); + if (index >= 0) { + found = true; + + // Get the Gridlet from the waiting queue and + // remove from the queue before compressing the schedule + sgl = queuedGridlets_.remove(index); + } + } + + // If the Gridlet could not be found in neither queue, then send a null + // Gridlet to the user and return because there is no need to + // compress the schedule + if(!found){ + System.out.println(super.resName_ + ".ParallelSpaceShared.gridletCancel():" + + " Cannot find Gridlet #" + gridletId + " for User #" + userId); + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, null, gridletId, userId); + return; + } + ////////////////////////// USED FOR DEBUGGING PURPOSES ONLY /////////////////////// + + if(GridSim.DEBUG_SIMULATION){ + // If a gridlet has been cancelled, then inform the listeners about it + LinkedList<SSGridlet> gridletsCancelled = new LinkedList<SSGridlet>(); + gridletsCancelled.add(sgl); + this.notifyListeners(AllocationAction.GRIDLET_CANCELLED, true, lastActionTime_, gridletsCancelled); + } + + /////////////////////////////////////////////////////////////////////////////////// + + // compress the schedule, that is, moves the gridlets forwards + compressSchedule(sgl); + + ////////////////////////// USED FOR DEBUGGING PURPOSES ONLY /////////////////////// + + if(GridSim.DEBUG_SIMULATION){ + // If a gridlet has been cancelled, then inform the listeners about it + this.notifyListeners(AllocationAction.SCHEDULE_CHANGED, true, lastActionTime_, null); + } + + /////////////////////////////////////////////////////////////////////////////////// + + // sends the Gridlet back to user + sgl.finalizeGridlet(); + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, sgl.getGridlet(), gridletId, userId); + } + + // -------------------- PRIVATE METHODS ---------------------------- + /** * Update the information about the jobs scheduled * @param rgl the resource gridlet @@ -235,48 +389,51 @@ int reqPE = sgl.getNumPE(); // calculate the execution time of the Gridlet - double executionTime = - forecastExecutionTime(ratingPE_, sgl.getRemainingGridletLength()) + 1; + double executionTime = forecastExecutionTime(ratingPE_, sgl.getRemainingGridletLength()); + lastActionTime_ = GridSim.clock(); // keep the time of the last allocation action - this.currentTime_ = GridSim.clock(); + double startTime = -1; // keeps the potential start time of the gridlet + double finishTime = -1; // stores the gridlet's expected finish time + int anchorIndex = -1; // the anchor index, the entry in the profile where the gridlet will be placed + int tailIndex = -1; // insert index represents the position in the profile where + // the entry corresponding to the gridlet's finish time will be placed + ProfileEntry tailEntry = null; // a pointer to the last entry analysed while scanning the profile + ProfileEntry anchorEntry = null; // a pointer to the anchor entry - double startTime = -1; - double finishTime = -1; - int anchorIndex = -1; - int tailIndex = -1; - ProfileEntry tailEntry = null; - ProfileEntry anchorEntry = null; - - AvailabilityProfile clonedProfile = availProfile_.clone(); PERangeList intersectList = null; - - for(ProfileEntry entry : availProfile_){ + int length = availProfile_.size(); + + Iterator<ProfileEntry> iterProfile = availProfile_.iterator(); + while(iterProfile.hasNext()){ + ProfileEntry entry = iterProfile.next(); anchorEntry = entry; anchorIndex = availProfile_.indexOf(anchorEntry); tailEntry = entry; - startTime = entry.getTime(); - finishTime = startTime + executionTime; + startTime = entry.getTime(); // sets the start time as the time of the entry + finishTime = startTime + executionTime; // calculates when the finish time would be if + // the gridlet is put in this position - if(entry.getNumPE() < reqPE) { + // scan the profile until an entry with enough PEs is found + if(entry.getNumPE() < reqPE) { continue; } else { + // if an entry with enough PEs is found, then scan the profile from + // that point onwards analysing the intersection of the ranges available + // in the entries until the gridlet expected completion time intersectList = entry.getPERanges(); - int length = clonedProfile.size(); // Look for the intersection of available ranges from // the anchor until the end of the profile or until // the entries and further than the expected completion time for(int i=anchorIndex+1; i<length; i++){ - ProfileEntry nextEntry = clonedProfile.get(i); + ProfileEntry nextEntry = availProfile_.get(i); if(nextEntry.getTime() > finishTime){ break; } else{ - intersectList = - PERangeList.intersection(intersectList, nextEntry.getPERanges()); - + intersectList = PERangeList.intersection(intersectList, nextEntry.getPERanges()); if(intersectList == null || intersectList.getNumPE() < reqPE){ break; } @@ -285,40 +442,52 @@ } } } - // If a time slot with enough PEs has been found, - // then stop the search + // If a time slot with enough PEs has been found, then stop the search if(intersectList != null && intersectList.getNumPE() >= reqPE){ break; } } } + // Increase the number of gridlets that rely on the anchor point to + // either mark their termination time or anchor + anchorEntry.increaseGridlet(); + anchorIndex = availProfile_.indexOf(anchorEntry); tailIndex = availProfile_.indexOf(tailEntry); // Selects a range to be used by the Gridlet PERangeList selected = selectPERangeList(reqPE, intersectList); - // Creates a new entry to be added to the profile - ProfileEntry newEntry = new ProfileEntry(finishTime); - newEntry.setPERangeList(tailEntry.getPERanges().clone()); - availProfile_.add(tailIndex+1, newEntry); + // If the time of the last entry analysed is equals to the Gridlet + // expected finish time, then a new entry is not needed. + if(tailEntry.getTime() < finishTime){ + // Creates a new entry to be added to the profile + ProfileEntry newEntry = new ProfileEntry(finishTime); + newEntry.setPERangeList(tailEntry.getPERanges().clone()); + availProfile_.add(tailIndex+1, newEntry); + } + else{ + // increase the number of gridlets that use this gridlet to + // mark their completion time + tailEntry.increaseGridlet(); + } // updates the entries between anchor and tail for(int index=anchorIndex; index<=tailIndex; index++){ ProfileEntry entry = availProfile_.get(index); + if(entry.getTime() == finishTime){ + break; + } PERangeList updList = PERangeList.difference(entry.getPERanges(), selected); entry.setPERangeList(updList); } - // add this Gridlet into execution list - this.queuedGridlets_.add(sgl); - // Sets the list of ranges used by the gridlet sgl.setPERangeList(selected); // change Gridlet status - sgl.setGridletStatus(Gridlet.QUEUED); + sgl.setGridletStatus(Gridlet.QUEUED); sgl.setGridletPotentialStartTime(startTime); sgl.setFinishTime(finishTime); @@ -333,7 +502,7 @@ * @pre rgl != null * @post $none */ - private boolean scheduleJobImmediately(SSGridlet sgl) { + private boolean scheduleGridletImmediately(SSGridlet sgl) { int reqPE = sgl.getNumPE(); // calculate the execution time of the Gridlet @@ -342,45 +511,51 @@ // calculates how much ahead to look into the availability profile double currentTime = GridSim.clock() ; - double finishTime = currentTime + executionTime; + double finishTime = currentTime + executionTime; // the Gridlet's expected finish time + lastActionTime_ = currentTime; // keep the time of the last allocation action - this.currentTime_ = currentTime; + // freePERanges_ does not need to be clonned here as the + // PERangeList.intersection() method will create a new list of ranges + // with the intersection anyway + PERangeList intersectList = freePERanges_; + ProfileEntry closeGrlTail = null; + int insertIndex = -1; // this denotes where the new entry (if needed) will be added - PERangeList intersectList = freePERanges_.clone(); - ProfileEntry closeGrlTail = null; - int tailIndex = -1; - + // scan the availability profile until the expected termination + // of the Gridlet to check whether enough resources will be available + // for the Gridlet. Stop the search if not enough resources are available for(ProfileEntry entry : availProfile_){ double entryTime = entry.getTime(); if(entryTime < currentTime) { continue; } - else if(entryTime >= finishTime) { + else if(entryTime > finishTime) { break; } else{ closeGrlTail = entry; - tailIndex = availProfile_.indexOf(entry); + insertIndex = availProfile_.indexOf(entry); PERangeList listEntry = entry.getPERanges(); intersectList = PERangeList.intersection(listEntry, intersectList); } } - - tailIndex++; - - // if the number of PEs available over the time slot is smaller + + // if the number of PEs available over the time slot is smaller // than the number of PEs required, then the gridlet cannot be started if(intersectList == null || intersectList.getNumPE() < reqPE){ return false; } - // Selects a list of ranges to be used by the Gridlet + // increment the index. That is, last entry before finish time + 1 + insertIndex++; + + // Select a list of ranges to be used by the Gridlet PERangeList selected = selectPERangeList(reqPE, intersectList); - if(selected.size() == 0){ + if(selected.getNumPE() < reqPE){ return false; } - - // add the information to the usageProfile + + // Gathers the information should be added in the insertIndex PERangeList listCloseGrlTail = null; if(closeGrlTail == null){ listCloseGrlTail = freePERanges_.clone(); @@ -388,28 +563,45 @@ else{ listCloseGrlTail = closeGrlTail.getPERanges().clone(); } - + + // if the time of the entry at insertIndex - 1 is equals to + // the gridlet finish time, then a new entry in the profile + // is not needed. In this case, the entry at insertIndex - 1 + // is updated to show that one more gridlet relies on the entry + // to represent its completion time. This reduces the number of + // entries in the availability profile + boolean addNewEntry = true; + // Updates entries in the profile - for(int index=0; index<tailIndex; index++){ + for(int index=0; index<insertIndex; index++){ ProfileEntry entry = availProfile_.get(index); if(entry.getTime() < currentTime){ continue; } + // if an entry whose time is equals to the gridlet's completion + // is found, then stop the update and sets addNewEntry to true + else if(entry.getTime() == finishTime){ + entry.increaseGridlet(); + addNewEntry = false; + break; + } PERangeList uptList = PERangeList.difference(entry.getPERanges(), selected); entry.setPERangeList(uptList); } - - // subtracts the selected ranges from the free ranges + + // subtracts the selected ranges from the free ranges freePERanges_ = PERangeList.difference(freePERanges_, selected); - - // Creates a new entry to be added to the profile - ProfileEntry newEntry = new ProfileEntry(finishTime); - newEntry.setPERangeList(listCloseGrlTail); - availProfile_.add(tailIndex, newEntry); - + // If a new entry is required, then add it. + if(addNewEntry){ + // Creates a new entry to be added to the profile + ProfileEntry newEntry = new ProfileEntry(finishTime); + newEntry.setPERangeList(listCloseGrlTail); + availProfile_.add(insertIndex, newEntry); + } + // add this Gridlet into execution list - this.runningGridlets_.add(sgl); + runningGridlets_.add(sgl); sgl.setGridletPotentialStartTime(currentTime); sgl.setFinishTime(finishTime); @@ -432,29 +624,30 @@ * availability profile. */ private void updateSchedule(){ + double currentTime = GridSim.clock(); - this.currentTime_ = currentTime; + lastActionTime_ = currentTime; // removes all Gridlets that have already completed from // the queue of running Gridlets PERangeList releasedRanges = new PERangeList(); - LinkedList<SSGridlet> completedGridlets = new LinkedList<SSGridlet>(); + LinkedList<SSGridlet> grlsCompleted = new LinkedList<SSGridlet>(); for(SSGridlet gridlet : runningGridlets_){ - if(gridlet.getGridletFinishTime() <= currentTime && - gridlet.getGridletStatus() != Gridlet.SUCCESS && - gridlet.getGridletStatus() != Gridlet.FAILED){ + // as gridlets are removed from running queue once they finish + // time is smaller than current time, then testing the time + // is enough. There's no need to check status + if(gridlet.getGridletFinishTime() <= currentTime) { // Update the list of ranges released releasedRanges.addAll(gridlet.getPERangeList().clone()); - completedGridlets.add(gridlet); + grlsCompleted.add(gridlet); gridletFinish(gridlet, Gridlet.SUCCESS); } } -// runningGridlets_.removeAll(grlToRemove); - - freePERanges_ = (freePERanges_ == null) ? new PERangeList() : freePERanges_.clone(); + + if(freePERanges_ == null) + freePERanges_ = new PERangeList(); freePERanges_.addAll(releasedRanges); - freePERanges_.sortRanges(); - freePERanges_.consolidatePERanges(); + freePERanges_.mergePERanges(); // Updates the usage profile LinkedList<ProfileEntry> entToRemove = new LinkedList<ProfileEntry>(); @@ -471,13 +664,13 @@ // Start the execution of Gridlets that are queued and whose // potential start execution time is smaller than current time PERangeList allocatedRanges = new PERangeList(); - LinkedList<SSGridlet> grlToRemove = new LinkedList<SSGridlet>(); + LinkedList<SSGridlet> grlsToStart = new LinkedList<SSGridlet>(); for(SSGridlet gridlet : queuedGridlets_){ if(gridlet.getGridletPotentialStartTime() <= currentTime){ // Update the list of ranges allocated allocatedRanges.addAll(gridlet.getPERangeList()); runningGridlets_.add(gridlet); - grlToRemove.add(gridlet); + grlsToStart.add(gridlet); // change Gridlet status gridlet.setGridletStatus(Gridlet.INEXEC); @@ -485,28 +678,24 @@ super.sendInternalEvent(roundUpTime); } } - queuedGridlets_.removeAll(grlToRemove); - freePERanges_ = PERangeList.difference(freePERanges_.clone(), allocatedRanges); + queuedGridlets_.removeAll(grlsToStart); + freePERanges_ = PERangeList.difference(freePERanges_, allocatedRanges); ////////////////////////// USED FOR DEBUGGING PURPOSES ONLY /////////////////////// if(GridSim.DEBUG_SIMULATION){ - if(hasListener_){ - AllocationAction action = - new AllocationAction(AllocationAction.GRIDLET_COMPLETED, currentTime_); - action.setSSGridlet(completedGridlets); - notifyListeners(action); - - if(GridSim.STEP_BY_STEP_SIMULATION){ - GridSim.pauseSimulation(); - } - else if(GridSim.SLOW_MOTION_SIMULATION){ - GridSim.smallPause(); - } + // If a gridlet has started execution or one has finished, + // then inform the listeners + if(grlsToStart.size() > 0 || grlsCompleted.size() > 0){ + notifyListeners(AllocationAction.GRIDLET_COMPLETED, true, lastActionTime_, grlsCompleted); } } - + /////////////////////////////////////////////////////////////////////////////////// + + // finally, remove the gridlets from the running queue + runningGridlets_.removeAll(grlsCompleted); + } /** @@ -516,7 +705,7 @@ * @param status the Gridlet status */ private void gridletFinish(SSGridlet sgl, int status) { - // the order is important! Set the status first then finalize + // the order is important! Set the status first then finalise // due to timing issues in SSGridlet class sgl.setGridletStatus(status); sgl.finalizeGridlet(); @@ -534,25 +723,25 @@ private PERangeList selectPERangeList(int reqPE, PERangeList freeList){ PERangeList selected = new PERangeList(); try{ - freeList.sortRanges(); + freeList.sortRanges(); - for(PERange range: freeList){ - if(range.getNumPE() >= reqPE){ - int beginning = range.getBeginning(); - int end = beginning + reqPE - 1; - selected.add(new PERange(beginning, end)); - break; - } - else{ - selected.add(range); - reqPE -= range.getNumPE(); - } - } - } + for(PERange range: freeList){ + if(range.getNumPE() >= reqPE){ + int beginning = range.getBeginning(); + int end = beginning + reqPE - 1; + selected.add(new PERange(beginning, end)); + break; + } + else{ + selected.add(range.clone()); + reqPE -= range.getNumPE(); + } + } + } catch(NullPointerException ex){ ex.printStackTrace(); - System.out.println("selectPERangeList(): Exception. Number of PEs required = " + reqPE); - System.out.println(availProfile_); + System.out.println("selectPERangeList(): Exception. Number of PEs required# " + reqPE + + "\n Profile# " + availProfile_); } return selected; } @@ -582,34 +771,223 @@ /** * Notifies the listeners about the action performed - * @param action the action performed + * @param allocationAction the action performed + * @param shouldPause indicates whether the simulation should be paused after + * notifying the listeners. <tt>true</tt> indicates that it should pause and + * <tt>false</tt> means that it should not. + * @param time the time when the action took place + * @param gridletList the list of gridlets to provide to the listeners + * + * @see AllocationAction#GRIDLET_ARRIVED + * @see AllocationAction#GRIDLET_SCHEDULED + * @see AllocationAction#GRIDLET_CANCELLED + * @see AllocationAction#GRIDLET_COMPLETED + * @see AllocationAction#SCHEDULE_CHANGED */ - private void notifyListeners(AllocationAction action){ - for(AllocationListener listener : listeners_){ - listener.allocationActionPerformed(action); + private void notifyListeners(int allocationAction, boolean shouldPause, + double time, LinkedList<SSGridlet> gridletList){ + + if(hasListener_){ + AllocationAction action = new AllocationAction(allocationAction, time); + + if(gridletList != null) + action.setSSGridlet(gridletList); + + for(AllocationListener listener : listeners_){ + listener.allocationActionPerformed(action); + } + + if(shouldPause){ + if(GridSim.STEP_BY_STEP_SIMULATION){ + GridSim.pauseSimulation(); + } + else if(GridSim.SLOW_MOTION_SIMULATION){ + GridSim.smallPause(); + } + } } } /** - * Finds the status of a specified @link{Gridlet}. - * @param gridletId a Gridlet ID - * @param userId the user or owner's ID of this Gridlet - * @return the Gridlet status or <tt>-1</tt> if not found - * @see gridsim.Gridlet + * Finds a Gridlet inside a given list. This method needs a combinati... [truncated message content] |
From: <mar...@us...> - 2007-10-04 06:03:36
|
Revision: 64 http://gridsim.svn.sourceforge.net/gridsim/?rev=64&view=rev Author: marcos_dias Date: 2007-10-03 23:03:39 -0700 (Wed, 03 Oct 2007) Log Message: ----------- This version contains many changes and bug fixes: + Some classes have been moved to gridsim.turbo package. + The ParallelSpaceShared policy has been changed substantially and some bugs have been fixed. For example, the policy was not compressing the schedule properly when cancelling a gridlet. This could also lead to finding the wrong anchor for a job when the completion of a job matched the completion of another job and there was a big job starting at this completion time. + Some advance reservation features have been provided, but they are still being tested. + Improvements in the graphical user interface have been made. + Some changes in SimJava classes have been made to remove the animation and log capabilities that are not used by GridSim. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_event.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_port.java branches/gridsim4.0-branch3/source/gridsim/ARPolicy.java branches/gridsim4.0-branch3/source/gridsim/ARSimpleSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/GridResource.java branches/gridsim4.0-branch3/source/gridsim/GridSim.java branches/gridsim4.0-branch3/source/gridsim/GridSimTags.java branches/gridsim4.0-branch3/source/gridsim/Gridlet.java branches/gridsim4.0-branch3/source/gridsim/MachineList.java branches/gridsim4.0-branch3/source/gridsim/ResGridletList.java branches/gridsim4.0-branch3/source/gridsim/SpaceShared.java branches/gridsim4.0-branch3/source/gridsim/TimeShared.java branches/gridsim4.0-branch3/source/gridsim/gui/AllocationAction.java branches/gridsim4.0-branch3/source/gridsim/gui/AllocationListener.java branches/gridsim4.0-branch3/source/gridsim/gui/AllocationSubject.java branches/gridsim4.0-branch3/source/gridsim/gui/GridSimVisualizer.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/net/BusLink.java branches/gridsim4.0-branch3/source/gridsim/net/Output.java branches/gridsim4.0-branch3/source/gridsim/services/MessageBody.java branches/gridsim4.0-branch3/source/gridsim/services/Negotiation.java branches/gridsim4.0-branch3/source/gridsim/services/NegotiationList.java branches/gridsim4.0-branch3/source/gridsim/services/NegotiationMessage.java branches/gridsim4.0-branch3/source/gridsim/services/index/GridServiceRepository.java branches/gridsim4.0-branch3/source/gridsim/services/index/RegionalGSR.java Added Paths: ----------- branches/gridsim4.0-branch3/examples/examples/ar/ branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java branches/gridsim4.0-branch3/source/gridsim/gui/ItemPanel.java branches/gridsim4.0-branch3/source/gridsim/gui/ScheduleItem.java branches/gridsim4.0-branch3/source/gridsim/turbo/ branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/FilterARMessage.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java branches/gridsim4.0-branch3/source/gridsim/turbo/ParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java Removed Paths: ------------- branches/gridsim4.0-branch3/examples/examples/ar/Example10.java branches/gridsim4.0-branch3/examples/examples/ar/README.txt branches/gridsim4.0-branch3/source/eduni/simdiag/ branches/gridsim4.0-branch3/source/eduni/simjava/Sim_accum.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_reporter.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_reportfile.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_stat.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_stat_exception.java branches/gridsim4.0-branch3/source/eduni/simjava/package.html branches/gridsim4.0-branch3/source/gridsim/PERange.java branches/gridsim4.0-branch3/source/gridsim/PERangeList.java branches/gridsim4.0-branch3/source/gridsim/ParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/gui/DetachedMagnifyingGlass.java branches/gridsim4.0-branch3/source/gridsim/gui/GridletPanel.java Copied: branches/gridsim4.0-branch3/examples/examples/ar (from rev 53, trunk/examples/Example10) Modified: branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java =================================================================== --- trunk/examples/Example10/ARTest.java 2007-09-01 02:48:15 UTC (rev 53) +++ branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2007-10-04 06:03:39 UTC (rev 64) @@ -1,19 +1,24 @@ /* - * Author Anthony Sulistio - * Date: May 2004 + * Author Marcos Dias de Assuncao + * Date: September 2007 * Description: A simple program to demonstrate of how to use basic * advanced reservation functionalities, such as create, commit * and status. - * - * NOTE: The values used from this example are taken from the GridSim paper. - * http://www.gridbus.org/gridsim/ - * $Id: ARTest.java,v 1.3 2007/08/10 02:35:40 anthony Exp $ */ -import java.util.*; -import gridsim.*; -import eduni.simjava.*; +package examples.ar; +import gridsim.GridSim; +import gridsim.Gridlet; +import gridsim.GridletList; +import gridsim.turbo.Reservation; +import gridsim.turbo.ReservationRequester; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + /** * A user entity that reserves a resource in advance. * In this example, only explore some functionalities, such as: @@ -23,11 +28,10 @@ * - commits an accepted reservation * - checks the status of a reservation */ -public class ARTest extends AdvanceReservation -{ +public class ARTest extends ReservationRequester { private GridletList list_; // a list containing new Gridlets private GridletList receiveList_; // a list containing completed Gridlets - private int failReservation_; // number of reservations failed + private int failReservation_; // number of reservations failed // time constant values private final int SEC = 1; // 1 second @@ -40,7 +44,6 @@ * Creates a new grid user entity * @param name the Entity name of this object * @param baud_rate the communication speed - * @param timeZone user's local time zone * @param totalJob number of Gridlets to be created * @throws Exception This happens when creating this entity before * initializing GridSim package or the entity name is @@ -48,9 +51,8 @@ * @see gridsim.GridSim#init(int, Calendar, boolean) */ public ARTest(String name, double baud_rate, double timeZone, - int totalJob) throws Exception - { - super(name, baud_rate, timeZone); + int totalJob) throws Exception { + super(name, baud_rate); this.receiveList_ = new GridletList(); this.failReservation_ = 0; @@ -65,8 +67,7 @@ /** * The core method that handles communications among GridSim entities. */ - public void body() - { + public void body() { LinkedList resList; // waiting to get list of resources. Since GridSim package uses @@ -74,8 +75,7 @@ // before one or more grid resource entities manage to register // themselves to GridInformationService (GIS) entity. // Therefore, it's better to wait in the first place - while (true) - { + while (true) { // need to pause for a while to wait GridResources finish // registering to GIS super.gridSimHold(2*SEC); // wait for 2 seconds @@ -124,11 +124,10 @@ } //---------------------------------------------------- - // sends one or more reservations to a gridresource entity + // sends one or more reservations to a grid resource entity sendReservation(resARList, resNameList); - try - { + try { // then get the results or Gridlets back int size = list_.size() - failReservation_; for (i = 0; i < size; i++) @@ -154,23 +153,17 @@ * One reservation only reserves 1 PE. At the moment, GridSim is only * able to execute 1 Gridlet on a single PE. */ - private void sendReservation(ArrayList resARList, ArrayList resNameList) - { + private void sendReservation(ArrayList resARList, ArrayList resNameList) { // total reservation made. 1 reservation reserves 1 PE. - int totalPE = 1; + int totalPE = 2; int totalReservation = list_.size(); // total number of Gridlets - // gets the init simulation time - Calendar cal = GridSim.getSimulationCalendar(); - // wants to reserve 1 day after the init simulation time - int MILLI_SEC = 1000; - long time = cal.getTimeInMillis() + (1 * DAY * MILLI_SEC); + long time = 1 * DAY; // each reservation requires around 10 minutes int duration = 10 * MIN; - String result = null; Gridlet gl = null; int val = 0; int resID = 0; // a resource ID @@ -179,8 +172,7 @@ Random randObj = new Random(time); - for (int i = 0; i < totalReservation; i++) - { + for (int i = 0; i < totalReservation; i++) { duration += 5 * MIN; // duration of a reservation // gets the resource ID and name @@ -194,50 +186,38 @@ time = 0; // immediate reservation } else { - time = cal.getTimeInMillis() + (1*DAY*MILLI_SEC) - + (duration*MILLI_SEC); + time = 1 * HOUR + duration; } // creates a new or immediate reservation - result = super.createReservation(time, duration, totalPE, resID); - System.out.println(super.get_name() + ": reservation result from "+ - resName + " = " + result + " at time = " + GridSim.clock()); - - // queries the status of this reservation - val = super.queryReservation(result); - System.out.println(super.get_name() + ": query result = " + - AdvanceReservation.getQueryResult(val) ); + Reservation reservation = null; + boolean success = false; - // if a reservation fails, then continue the next Gridlet - if (val == GridSimTags.AR_STATUS_ERROR || - val == GridSimTags.AR_STATUS_ERROR_INVALID_BOOKING_ID) - { + reservation = super.createReservation(time, duration, totalPE, resID); + if(reservation != null) { + System.out.println(super.get_name() + ": reservation has been returned from "+ + resName + " at time = " + GridSim.clock()); + } + else { + System.out.println(super.get_name() + ": no reservation has been returned from "+ + resName + " at time = " + GridSim.clock()); failReservation_++; - System.out.println("=========================="); - continue; } - // for a reservation with an even number, commits straightaway - // without sending any Gridlets yet - if (i % 2 == 0) - { - val = super.commitReservation(result); - System.out.println(super.get_name() + - ": commit only with result = " + - AdvanceReservation.getCommitResult(val) ); + if(reservation != null) { + // for a reservation with an even number, commits straightaway + // without sending any Gridlets yet + success = super.commitReservation(reservation.getID()); + + if(success) { + System.out.println("Reservation # "+ reservation.getID() + + " has been committed successfully."); + } + else { + System.out.println("Reservation # "+ reservation.getID() + + " has NOT been committed successfully."); + } } - - // a reservation only needs to reserve 1 PE. - gl = (Gridlet) list_.get(i); - val = super.commitReservation(result, gl); - System.out.println(super.get_name() + ": commit result = " + - AdvanceReservation.getCommitResult(val) ); - - // queries the status of this reservation - val = super.queryReservation(result); - System.out.println(super.get_name() + ": query result = " + - AdvanceReservation.getQueryResult(val) ); - System.out.println("=========================="); } } @@ -255,16 +235,15 @@ * GridSimRandom class. * @return a GridletList object */ - private GridletList createGridlet(int size, int userID) - { + private GridletList createGridlet(int size, int userID) { // Creates a container to store Gridlets GridletList list = new GridletList(); int length = 5000; - for (int i = 0; i < size; i++) - { + for (int i = 0; i < size; i++) { // creates a new Gridlet object Gridlet gridlet = new Gridlet(i, length, 1000, 5000); + // add the Gridlet into a list list.add(gridlet); gridlet.setUserID(userID); Deleted: branches/gridsim4.0-branch3/examples/examples/ar/Example10.java =================================================================== --- trunk/examples/Example10/Example10.java 2007-09-01 02:48:15 UTC (rev 53) +++ branches/gridsim4.0-branch3/examples/examples/ar/Example10.java 2007-10-04 06:03:39 UTC (rev 64) @@ -1,263 +0,0 @@ -/* - * Author Anthony Sulistio - * Date: May 2004 - * Description: A simple program to demonstrate of how to use basic - * advanced reservation functionalities, such as create, commit - * and status. - * - * NOTE: The values used from this example are taken from the GridSim paper. - * http://www.gridbus.org/gridsim/ - * $Id: Example10.java,v 1.2 2004/05/31 04:53:33 anthony Exp $ - */ - -import java.util.*; -import gridsim.*; - -/** - * This is the main class to run the example. - */ -public class Example10 -{ - /** - * A main method that initializes GridSim, creating user and grid - * resource entities before running the simulation. - */ - public static void main(String[] args) - { - System.out.println("Starting Example10"); - try - { - // 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 run-time exception - // error. - int num_user = 5; // number of user entities - - // Gets the current time as the init simulation time. - // The time plays a very important role in determining start - // and end time of a reservation. Both start and end time must - // be greater than the init simulation time. - Calendar calendar = Calendar.getInstance(); - System.out.println("Init simulation time = " + calendar.getTime()); - - boolean trace_flag = false; // true means trace GridSim events - - // Since GridSim 3.0, there are different ways to initialize the - // GridSim package. One of them is below without the need to - // have GridStatistics entity. Therefore, removing any redundant - // entities. - GridSim.init(num_user, calendar, trace_flag); - - //------------------------------------------------ - // Second step: Creates one or more GridResource objects - // given resource name, total PE, number of Machine, time zone - // and MIPS Rating. - - // R0: vpac Compaq AlphaServer - ARGridResource resource0 = createGridResource("Resource_0", - 4, 1, 10.0, 515); - - // R1: Manjra Linux PC - ARGridResource resource1 = createGridResource("Resource_1", - 13, 1, 10.0, 684); - - // R2: Germany - ARGridResource resource2 = createGridResource("Resource_2", - 16, 1, 1.0, 410); - - // R3: Czech - ARGridResource resource3 = createGridResource("Resource_3", - 6, 1, 1.0, 410); - - // R4: Chichago - ARGridResource resource4 = createGridResource("Resource_4", - 8, 1, -6.0, 377); - - //------------------------------------------------ - // Third step: Creates grid users - ARTest[] userList = new ARTest[num_user]; - ARTest user = null; // a user entity - double bandwidth = 1000; // bandwidth of this user - double timeZone = 0.0; // user's time zone - int totalJob = 0; // total Gridlets owned - int i = 0; - - // a loop that creates a user entity - for (i = 0; i < num_user; i++) - { - // users with an even number have their time zone to GMT+8 - if (i % 2 == 0) - { - timeZone = 8.0; // with respect to GMT or UTC - totalJob = 4; - } - - // users with an odd number have their time zone to GMT-3 - else - { - timeZone = -3.0; // with respect to GMT or UTC - totalJob = 5; - } - - // creates a user entity - user = new ARTest("User_" + i, bandwidth, timeZone, totalJob); - - // put the entity into an array - userList[i] = user; - } - - //------------------------------------------------ - // Fourth step: Starts the simulation - GridSim.startGridSimulation(); - - //------------------------------------------------ - // Final step: Prints the Gridlets when this simulation is over - GridletList newList = null; - for (i = 0; i < num_user; i++) - { - user = (ARTest) userList[i]; - newList = user.getGridletList(); - printGridletList( newList, user.get_name() ); - } - - System.out.println("Finish Example10"); - } - catch (Exception e) - { - System.out.println("Error ...... EXCEPTION"); - e.printStackTrace(); - } - - } - - /** - * Creates a GridResource entity that supports advanced reservation - * functionalities. - */ - private static ARGridResource createGridResource(String name, int totalPE, - int totalMachine, double timeZone, int rating) - { - // 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 zone and its price - String arch = "Sun Ultra"; // system architecture - String os = "Solaris"; // operating system - double cost = 3.0; // the cost of using this resource (G$/PE) - - // NOTE: allocation policy in here is set to - // ResourceCharacteristics.ADVANCE_RESERVATION not SPACE_SHARED nor - // TIME_SHARED. - ResourceCharacteristics resConfig = new ResourceCharacteristics( - arch, os, mList, ResourceCharacteristics.ADVANCE_RESERVATION, - timeZone, cost); - - // 6. Finally, we need to create a GridResource object. - double baud_rate = 1000.0; // communication speed - long seed = 11L*13*17*19*23+1; - double peakLoad = 0.0; // the resource load during peak hour - double offPeakLoad = 0.0; // the resource load during off-peak hr - double holidayLoad = 0.0; // the resource load during holiday - - // incorporates weekends so the grid resource is on 7 days a week - LinkedList Weekends = new LinkedList(); - Weekends.add(new Integer(Calendar.SATURDAY)); - Weekends.add(new Integer(Calendar.SUNDAY)); - - // incorporates holidays. However, no holidays are set in this example - LinkedList Holidays = new LinkedList(); - ARGridResource gridRes = null; - - // creates a resource calendar that handles different loads - ResourceCalendar cal = new ResourceCalendar( - resConfig.getResourceTimeZone(), peakLoad, offPeakLoad, - holidayLoad, Weekends, Holidays, seed); - - try - { - // use this AR scheduling algorithm. The name of this entity - // will be name_scheduler, e.g. Resource0_scheduler. - String scheduler = "scheduler"; - ARSimpleSpaceShared policy =new ARSimpleSpaceShared(name,scheduler); - - // then creates a grid resource entity. - // NOTE: You need to use a grid resource entity that supports - // advanced reservation functionalities. In this case, the entity - // is called ARGridResource. - gridRes = new ARGridResource(name,baud_rate,resConfig,cal,policy); - } - catch (Exception e) { - e.printStackTrace(); - } - - System.out.println("Creates one Grid resource with name = " + name); - return gridRes; - } - - /** - * Prints the Gridlet objects - * @param list list of Gridlets - */ - private static void printGridletList(GridletList list, String name) - { - String indent = " "; - System.out.println(); - System.out.println("========== OUTPUT for " + name + " =========="); - System.out.println("Gridlet ID" + indent + "STATUS" + indent + - "Resource ID" + indent + "Cost"); - - int size = list.size(); - int i = 0; - Gridlet gridlet = null; - String status; - - // for each user entity, prints out the results. Prints out the - // table of summary - for (i = 0; i < size; i++) - { - gridlet = (Gridlet) list.get(i); - System.out.print(indent + gridlet.getGridletID() + indent - + indent); - - status = gridlet.getGridletStatusString(); - System.out.print(status); - - System.out.println( indent + indent + gridlet.getResourceID() + - indent + indent + gridlet.getProcessingCost() ); - } - - // for each Gridlet, prints out its detailed operation / report - /***** NOTE: Not recommended for many Gridlets as each Gridlet - // report is pretty long - System.out.println(); - for (i = 0; i < size; i++) - { - gridlet = (Gridlet) list.get(i); - System.out.println( gridlet.getGridletHistory() ); - } - *********/ - } - -} // end class - Deleted: branches/gridsim4.0-branch3/examples/examples/ar/README.txt =================================================================== --- trunk/examples/Example10/README.txt 2007-09-01 02:48:15 UTC (rev 53) +++ branches/gridsim4.0-branch3/examples/examples/ar/README.txt 2007-10-04 06:03:39 UTC (rev 64) @@ -1,47 +0,0 @@ - -/** - * Author: Anthony Sulistio - * Date: May 2004 - * $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. -To compile the example source code: - In Unix/Linux: javac -classpath $GRIDSIM/jars/gridsim.jar:. Example10.java - In Windows: javac -classpath %GRIDSIM%\jars\gridsim.jar;. Example10.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:. Example10 - - In Windows: - java -classpath %GRIDSIM%\jars\gridsim.jar;. Example10 - - -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: - - 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 - 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. - -NOTE: When you run the program multiple times, - "sim_trace" and "sim_report" file will be overwritten. - Added: branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java 2007-10-04 06:03:39 UTC (rev 64) @@ -0,0 +1,245 @@ +/* + * Author: Marcos Dias de Assuncao + * Date: September 2007 + * Description: A simple program to demonstrate of how to use basic + * advanced reservation functionalities, such as create, commit + * and status. + */ + +package examples.ar; + +import java.util.*; +import gridsim.*; +import gridsim.turbo.ARParallelSpaceShared; +import gridsim.turbo.ARTGridResource; +import gridsim.turbo.TResourceCharacteristics; + +/** + * This is the main class to run the example. + */ +public class SimpleARExample01 { + + /** + * A main method that initialises GridSim, creating user and grid + * resource entities before running the simulation. + */ + public static void main(String[] args) { + System.out.println("SimpleARExample01"); + try { + // First step: Initialises the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initialising GridSim first. We will get run-time exception + // error. + int num_user = 1; // number of user entities + + // Gets the current time as the init simulation time. + // The time plays a very important role in determining start + // and end time of a reservation. Both start and end time must + // be greater than the init simulation time. + Calendar calendar = Calendar.getInstance(); + System.out.println("Init simulation time = " + calendar.getTime()); + + boolean trace_flag = false; // true means trace GridSim events + + // Since GridSim 3.0, there are different ways to initialize the + // GridSim package. One of them is below without the need to + // have GridStatistics entity. Therefore, removing any redundant + // entities. + GridSim.init(num_user, calendar, trace_flag); + + //------------------------------------------------ + // Second step: Creates one or more GridResource objects + // given resource name, total PE, number of Machine, time zone + // and MIPS Rating. + +// // R0: vpac Compaq AlphaServer +// ARTGridResource resource0 = +// createGridResource("Resource_0", 4, 1, 10.0, 515); + + // R1: Manjra Linux PC + ARTGridResource resource1 = + createGridResource("Resource_1", 13, 1, 10.0, 684); + +// // R2: Germany +// ARTGridResource resource2 = +// createGridResource("Resource_2", 16, 1, 1.0, 410); +// +// // R3: Czech +// ARTGridResource resource3 = +// createGridResource("Resource_3", 6, 1, 1.0, 410); +// +// // R4: Chichago +// ARTGridResource resource4 = +// createGridResource("Resource_4", 8, 1, -6.0, 377); + + //------------------------------------------------ + // Third step: Creates grid users + ARTest[] userList = new ARTest[num_user]; + ARTest user = null; // a user entity + double bandwidth = 1000; // bandwidth of this user + double timeZone = 0.0; // user's time zone + int totalJob = 0; // total Gridlets owned + int i = 0; + + // a loop that creates a user entity + for (i = 0; i < num_user; i++) { + // users with an even number have their time zone to GMT+8 + if (i % 2 == 0) { + timeZone = 8.0; // with respect to GMT or UTC + totalJob = 4; + } + + // users with an odd number have their time zone to GMT-3 + else { + timeZone = -3.0; // with respect to GMT or UTC + totalJob = 5; + } + + // creates a user entity + user = new ARTest("User_" + i, bandwidth, timeZone, totalJob); + + // put the entity into an array + userList[i] = user; + } + + //------------------------------------------------ + // Fourth step: Starts the simulation +// GridSim.startGridSimulation(); + + GridSim.startGridSimulation(true); + + //------------------------------------------------ + // Final step: Prints the Gridlets when this simulation is over + GridletList newList = null; + for (i = 0; i < num_user; i++) { + user = (ARTest) userList[i]; + newList = user.getGridletList(); + printGridletList( newList, user.get_name() ); + } + + System.out.println("Finish SimpleARExample01"); + } + catch (Exception e) { + System.out.println("Error ...... EXCEPTION"); + e.printStackTrace(); + } + + } + + /** + * Creates a GridResource entity that supports advanced reservation + * functionalities. + */ + private static ARTGridResource createGridResource(String name, int totalPE, + int totalMachine, double timeZone, int rating) { + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, rating) ); + } + + // 2. Create a TResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy, time zone and its price + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double cost = 3.0; // the cost of using this resource (G$/PE) + + // NOTE: allocation policy in here is set to + // TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED not SPACE_SHARED nor + // TIME_SHARED. + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED, + timeZone, cost); + + // 6. Finally, we need to create a GridResource object. + double baud_rate = 1000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList Weekends = new LinkedList(); + Weekends.add(new Integer(Calendar.SATURDAY)); + Weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList Holidays = new LinkedList(); + ARTGridResource gridRes = null; + + // creates a resource calendar that handles different loads + ResourceCalendar cal = new ResourceCalendar( + resConfig.getResourceTimeZone(), peakLoad, offPeakLoad, + holidayLoad, Weekends, Holidays, seed); + + try { + // use this AR scheduling algorithm. The name of this entity + // will be name_scheduler, e.g. Resource0_scheduler. + String scheduler = "scheduler"; + ARParallelSpaceShared policy = new ARParallelSpaceShared(name, scheduler); + + // then creates a grid resource entity. + // NOTE: You need to use a grid resource entity that supports + // advanced reservation functionalities. In this case, the entity + // is called ARGridResource. + gridRes = new ARTGridResource(name,baud_rate,resConfig,cal,policy); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } + + /** + * Prints the Gridlet objects + * @param list list of Gridlets + */ + private static void printGridletList(GridletList list, String name) { + String indent = " "; + System.out.println(); + System.out.println("========== OUTPUT for " + name + " =========="); + System.out.println("Gridlet ID" + indent + "STATUS" + indent + + "Resource ID" + indent + "Cost"); + + int size = list.size(); + int i = 0; + Gridlet gridlet = null; + String status; + + // for each user entity, prints out the results. Prints out the + // table of summary + for (i = 0; i < size; i++) { + gridlet = (Gridlet) list.get(i); + System.out.print(indent + gridlet.getGridletID() + indent + + indent); + + status = gridlet.getGridletStatusString(); + System.out.print(status); + + System.out.println( indent + indent + gridlet.getResourceID() + + indent + indent + gridlet.getProcessingCost() ); + } + + // for each Gridlet, prints out its detailed operation / report + /***** NOTE: Not recommended for many Gridlets as each Gridlet + // report is pretty long + System.out.println(); + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list.get(i); + System.out.println( gridlet.getGridletHistory() ); + } + *********/ + } + +} // end class + Added: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java 2007-10-04 06:03:39 UTC (rev 64) @@ -0,0 +1,179 @@ + +package examples.workload.ar; + +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.turbo.ARTGridResource; +import gridsim.turbo.TResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example + */ +public class TurboARExample01 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + String fileName = args[0]; + // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf + + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) + { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode + GridSim.startGridSimulation(true); + + // Start the simulation in normal mode +// GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED, + time_zone, cost); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + ResourceCalendar calendar = new ResourceCalendar(time_zone, peakLoad, + offPeakLoad, holidayLoad, weekends, holidays, seed); + + ARTGridResource gridRes = null; + try { + gridRes = new ARTGridResource(name, baud_rate, resConfig, calendar, null); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2007-09-22 22:44:03 UTC (rev 63) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2007-10-04 06:03:39 UTC (rev 64) @@ -5,7 +5,7 @@ import gridsim.GridSim; import gridsim.Machine; import gridsim.MachineList; -import gridsim.ResourceCharacteristics; +import gridsim.turbo.TResourceCharacteristics; import gridsim.util.Workload; import java.util.ArrayList; @@ -66,8 +66,7 @@ int i = 0; String[] resArray = new String[totalResource]; - for (i = 0; i < totalResource; i++) - { + for (i = 0; i < totalResource; i++) { String resName = "Res_" + i; GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); resources.add(resource); @@ -86,10 +85,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over @@ -140,8 +139,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource - ResourceCharacteristics resConfig = new ResourceCharacteristics( - arch, os, mList, ResourceCharacteristics.PARALLEL_SPACE_SHARED, + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.PARALLEL_SPACE_SHARED, time_zone, cost); ////////////////////////////////////////// @@ -153,17 +152,17 @@ 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)); + 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(); + LinkedList holidays = new LinkedList(); GridResource gridRes = null; try { gridRes = new GridResource(name, baud_rate, seed, - resConfig, peakLoad, offPeakLoad, holidayLoad, Weekends, - Holidays); + resConfig, peakLoad, offPeakLoad, holidayLoad, weekends, + holidays); } catch (Exception e) { e.printStackTrace(); Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2007-09-22 22:44:03 UTC (rev 63) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2007-10-04 06:03:39 UTC (rev 64) @@ -5,7 +5,7 @@ import gridsim.GridSim; import gridsim.Machine; import gridsim.MachineList; -import gridsim.ResourceCharacteristics; +import gridsim.turbo.TResourceCharacteristics; import java.util.ArrayList; import java.util.Calendar; @@ -137,8 +137,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource - ResourceCharacteristics resConfig = new ResourceCharacteristics( - arch, os, mList, ResourceCharacteristics.PARALLEL_SPACE_SHARED, + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.PARALLEL_SPACE_SHARED, time_zone, cost); ////////////////////////////////////////// @@ -150,17 +150,17 @@ 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)); + 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(); + LinkedList holidays = new LinkedList(); GridResource gridRes = null; try { gridRes = new GridResource(name, baud_rate, seed, - resConfig, peakLoad, offPeakLoad, holidayLoad, Weekends, - Holidays); + resConfig, peakLoad, offPeakLoad, holidayLoad, weekends, + holidays); } catch (Exception e) { e.printStackTrace(); Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java 2007-09-22 22:44:03 UTC (rev 63) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java 2007-10-04 06:03:39 UTC (rev 64) @@ -18,7 +18,7 @@ import java.util.ArrayList; /** - * This class is an extended version of @link{Workload}. This class + * This class is an extended version of {@link Workload}. This class * cancels some gridlets submitted. * * @author Marcos Dias de Assuncao @@ -33,7 +33,7 @@ private final double TIME_CANCELLATION = 0.5; /** - * Create a new @link{WorkloadWithCancellation} object <b>without</b> using + * Create a new {@link WorkloadWithCancellation} object <b>without</b> using * the network extension. This means this entity directly sends Gridlets * to a resource destination without going through a wired network. <br> * <tt>NOTE:</tt> @@ -68,7 +68,7 @@ } /** - * Create a new @link{WorkloadWithCancellation} object <b>with</b> the network extension. + * Create a new {@link WorkloadWithCancellation} object <b>with</b> the network extension. * This means this entity directly sends Gridlets to a destination resource * through a link. The link is automatically created by this constructor. * @@ -182,12 +182,12 @@ if (data != null && data instanceof Gridlet) { gl = (Gridlet) data; - if(gl.getGridletStatus() == Gridlet.FAILED) - System.out.println("Gridlet failed"); +// if(gl.getGridletStatus() == Gridlet.FAILED) +// System.out.println("Gridlet failed"); +// +// if(gl.getGridletStatus() == Gridlet.CANCELED) +// System.out.println("Gridlet cancelled"); - if(gl.getGridletStatus() == Gridlet.CANCELED) - System.out.println("Gridlet cancelled"); - list_.add(gl); counter++; } Deleted: branches/gridsim4.0-branch3/source/eduni/simjava/Sim_accum.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simjava/Sim_accum.java 2007-09-22 22:44:03 UTC (rev 63) +++ branches/gridsim4.0-branch3/source/eduni/simjava/Sim_accum.java 2007-10-04 06:03:39 UTC (rev 64) @@ -1,134 +0,0 @@ -/* Sim_accum.java */ - -package eduni.simjava; - -import java.util.ArrayList; -import java.util.List; - -/** - * A class for collecting basic statistical data during simulations. - * <p> - * This class can be used to manually calculate measurements of - * interest for state-based, non-continuous measures (see the - * <a href="http://www.dcs.ed.ac.uk/home/simjava/tutorial/index.html#6">SimJava Tutorial</a> for details). - * This is a primitive class that is still present in the API for compatibility with existing - * simulations. Simulations written with the SimJava version 2.0 should make use of <code>Sim_stat</code> - * instances for their entities if statistics are required. - * @see eduni.simjava.Sim_stat - * @version 1.0, 4 September 1996 - * @version 1.1, 29 May 1997 fwh corrected update() bug. - * @author Ross McNab - */ -public class Sim_accum { - private List intervals; - private List values; - - /** - * Allocate a new instance of the class. - */ - public Sim_accum() { - intervals = new ArrayList(); - values = new ArrayList(); - } - - /** - * Allocate a new, named, instance of the class. The name is - * supplied for <code>SIM++</code> compatibility. - * @param name The name to be associated with the instance (currently ignored) - */ - public Sim_accum(String name) { // For SIM++ compatibility - new Sim_accum(); - } - - /** - * Add a new record to the statistics collected so far. - * @param interval How long the value was held - * @param value The value to record - */ - public void update(double interval, double value) { - intervals.add(new Double(interval)); - values.add(new Double(value)); - } - - /** - * Find the minimum value recorded so far - * @return The minimum value recorded so far or 0.0 if no values have been recorded - */ - public double min(){ - double ret, val; - if (intervals.size() == 0) - ret = 0.0; - else { - ret = ((Double)values.get(0)).doubleValue(); - int values_size = values.size(); - for (int i=0; i < values_size; i++) { - val = ((Double)values.get(i)).doubleValue(); - if (val<ret) ret = val; - } - } - return ret; - } - - - /** - * Find the maximum value recorded so far - * @return The maximum value recorded so far or 0.0 if no values have been recorded - */ - public double max() { - double ret, val; - if (intervals.size() == 0) - ret = 0.0; - else { - ret = ((Double)values.get(0)).doubleValue(); - int values_size = values.size(); - for (int i=0; i < values_size; i++) { - val = ((Double)values.get(i)).doubleValue(); - if (val>ret) ret = val; - } - } - return ret; - } - - /** - * Calculates the average value held over the total - * interval recorded. - * i.e. <code>Sum_for_all_i(value[i]*interval[i])/total_interval</code> - * @return The average value - */ - public double avg() { - double ret, val, inter; - if (intervals.size() == 0) - ret = 0.0; - else { - ret = 0.0; - int intervals_size = intervals.size(); - for (int i=0; i < intervals_size; i++) { - val = ((Double)values.get(i)).doubleValue(); - inter = ((Double)intervals.get(i)).doubleValue(); - ret += val * inter; - } - ret = ret / interval_sum(); - } - return ret; - } - - /** - * Sums all the intervals recorded so far. - * @return The sum of the intervals - */ - public double interval_sum() { - double ret, val; - if (intervals.size() == 0) - ret = 0.0; - else { - ret = 0.0; - int intervals_size = intervals.size(); - for (int i=0; i < intervals_size; i++) { - val = ((Double)intervals.get(i)).doubleValue(); - ret += val; - } - } - return ret; - } -} - Modified: branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java =================================================================== --- branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java 2007-09-22 22:44:03 UTC (rev 63) +++ branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java 2007-10-04 06:03:39 UTC (rev 64) @@ -14,8 +14,6 @@ * behaviour. Methods beginning with the prefix <code>sim_</code> are runtime * methods to be called within <code>body()</code>. * <p> - * Since version 2.0, entities don't need to check transient or termination - * conditions. These are all maintained and checked by <code>Sim_system</code>. * To check whether the termination condition has been satisfied, entities * should use the <code>Sim_system.running()</code> method. As such. entities * that exhibit a continuous, looping behaviour should have a <code>body()</code> @@ -54,79 +52,12 @@ * when the entity is considered to be busy processing. * </ul> * <p> - * In order to collect statistical measurements from entities a <code>Sim_stat</code> object needs - * to be defined for the entity. This is the object in charge of collecting observations and - * calculating measurements. Measures of interest could be default of custom. Default measures are - * those which can be considered in most simulations and whose update can be automatically carried - * out without user effort. Custom measures on the other hand... [truncated message content] |
From: <mar...@us...> - 2007-10-12 09:02:46
|
Revision: 68 http://gridsim.svn.sourceforge.net/gridsim/?rev=68&view=rev Author: marcos_dias Date: 2007-10-12 02:02:49 -0700 (Fri, 12 Oct 2007) Log Message: ----------- This commit includes the advance reservation framework and some improvements in the graphical user interface. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/GridInformationService.java branches/gridsim4.0-branch3/source/gridsim/Gridlet.java branches/gridsim4.0-branch3/source/gridsim/gui/AllocationAction.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java branches/gridsim4.0-branch3/source/gridsim/turbo/ParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/util/Workload.java Added Paths: ----------- branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java branches/gridsim4.0-branch3/source/eduni/simjava/Evqueue.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_system.java branches/gridsim4.0-branch3/source/gridsim/ResourceCharacteristics.java branches/gridsim4.0-branch3/source/gridsim/filter/FilterCreateAR.java branches/gridsim4.0-branch3/source/gridsim/turbo/OrderGridletbyStartTime.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java Removed Paths: ------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java branches/gridsim4.0-branch3/source/gridsim/gui/ItemPanel.java branches/gridsim4.0-branch3/source/gridsim/gui/ScheduleItem.java Copied: branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java (from rev 64, branches/gridsim4.0-branch3/examples/examples/workload/parallel/WorkloadWithCancellation.java) =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java 2007-10-12 09:02:49 UTC (rev 68) @@ -0,0 +1,250 @@ +/* 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 + */ + +package examples; + +import eduni.simjava.Sim_event; +import eduni.simjava.Sim_system; +import gridsim.GridSimTags; +import gridsim.Gridlet; +import gridsim.IO_data; +import gridsim.ParameterException; +import gridsim.net.Link; +import gridsim.util.Workload; + +import java.util.ArrayList; + +/** + * This class is an extended version of {@link Workload}. This class + * cancels some gridlets submitted. + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see Workload + */ +public class WorkloadWithCancellation extends Workload { + private final int NUM_GRIDLETS_BETWEEN_CANCELLATIONS = 50; + // value of 1, means that the cancellation will be sent + // at the gridlet's submission time + (gridlet duration * 1) + private final double TIME_CANCELLATION = 0.5; + + /** + * Create a new {@link WorkloadWithCancellation} object <b>without</b> using + * the network extension. This means this entity directly sends Gridlets + * to a resource destination without going through a wired network. <br> + * <tt>NOTE:</tt> + * You can not use this constructor in an experiment that uses a wired + * network topology. + * + * @param name this entity name + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithCancellation(String name, String fileName, String resourceName, + int rating) throws ParameterException, Exception { + + super(name, fileName, resourceName, rating); + } + + /** + * Create a new {@link WorkloadWithCancellation} object <b>with</b> the network extension. + * This means this entity directly sends Gridlets to a destination resource + * through a link. The link is automatically created by this constructor. + * + * @param name this entity name + * @param baudRate baud rate of this link (bits/s) + * @param propDelay Propagation delay of the Link in milliseconds + * @param MTU Maximum Transmission Unit of the Link in bytes. + * Packets which are larger than the MTU should be split + * up into MTU size units. + * For example, a 1024 byte packet trying to cross a 576 + * byte MTU link should get split into 2 packets of 576 + * bytes and 448 bytes. + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li> baudRate <= 0 + * <li> propDelay <= 0 + * <li> MTU <= 0 + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre baudRate > 0 + * @pre propDelay > 0 + * @pre MTU > 0 + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithCancellation(String name, double baudRate, double propDelay, int MTU, + String fileName, String resourceName, int rating) + throws ParameterException, Exception { + + super( name, baudRate, propDelay, MTU, fileName, resourceName, rating ); + } + + /** + * Create a new Workload object <b>with</b> the network extension. + * This means this entity directly sends Gridlets to a destination resource + * through a link. The link is automatically created by this constructor. + * + * @param name this entity name + * @param link the link that will be used to connect this Workload + * to another entity or a Router. + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li>the link is empty + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre link != null + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithCancellation(String name, Link link, String fileName, + String resourceName, int rating) + throws ParameterException, Exception { + + super(name, link, fileName, resourceName, rating); + } + + //////////////////////// PRIVATE METHODS /////////////////////// + + /** + * Collects Gridlets sent and stores them into a list. + * @pre $none + * @post $none + */ + protected void collectGridlet() { + System.out.println(super.get_name() + ": Collecting Gridlets ..."); + list_ = new ArrayList(gridletID_ + 1); + + Object data = null; + Gridlet gl = null; + + int counter = 1; // starts at 1, since gridletID_ starts at 1 too + Sim_event ev = new Sim_event(); + while ( Sim_system.running() ) { + + super.sim_get_next(ev); // get the next available event + data = ev.get_data(); // get the event's data + + // handle ping request + if (ev.get_tag() == GridSimTags.INFOPKT_SUBMIT) { + processPingRequest(ev); + continue; + } + + // get the Gridlet data + if (data != null && data instanceof Gridlet) { + gl = (Gridlet) data; + +// if(gl.getGridletStatus() == Gridlet.FAILED) +// System.out.println("Gridlet failed"); +// +// if(gl.getGridletStatus() == Gridlet.CANCELED) +// System.out.println("Gridlet cancelled"); + + list_.add(gl); + counter++; + } + + // if all the Gridlets have been collected + if (counter == gridletID_) { + break; + } + } + } + + /** + * Creates a Gridlet with the given information, then submit it to a + * resource + * @param id a Gridlet ID + * @param submitTime Gridlet's submit time + * @param runTime Gridlet's run time + * @param numProc number of processors + * @pre id >= 0 + * @pre submitTime >= 0 + * @pre runTime >= 0 + * @pre numProc > 0 + * @post $none + */ + protected void submitGridlet(int id, long submitTime, int runTime, int numProc) { + + // create the gridlet + int len = runTime * rating_; // calculate a job length for each PE + Gridlet gl = new Gridlet(id, len, size_, size_); + gl.setUserID( super.get_id() ); // set the owner ID + gl.setNumPE(numProc); // set the requested num of proc + + // printing to inform user + if (gridletID_ == 1 || gridletID_ % INTERVAL == 0) { + System.out.println(super.get_name() + ": Submitting Gridlets to " + + resName_ + " ..."); + } + + // check the submit time + if (submitTime < 0) { + submitTime = 0; + } + + gridletID_++; // increment the counter + + // submit a gridlet to resource + super.send(super.output, submitTime, GridSimTags.GRIDLET_SUBMIT, + new IO_data(gl, gl.getGridletFileSize(), resID_) ); + + // check whether a cancellation has to be scheduled or not + int result = gridletID_ % NUM_GRIDLETS_BETWEEN_CANCELLATIONS; + if(result == 0) { + super.send(super.output, (submitTime + (TIME_CANCELLATION * runTime)), GridSimTags.GRIDLET_CANCEL, + new IO_data(gl, 0, resID_) ); + gridletID_++; + } + } + +} // end class + Added: branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java 2007-10-12 09:02:49 UTC (rev 68) @@ -0,0 +1,1077 @@ +/* + * 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 + * + */ + +package examples; + +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Enumeration; +import java.util.Random; +import java.util.zip.GZIPInputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import eduni.simjava.Sim_event; +import eduni.simjava.Sim_system; + +import gridsim.GridSim; +import gridsim.GridSimTags; +import gridsim.Gridlet; +import gridsim.IO_data; +import gridsim.ParameterException; +import gridsim.net.InfoPacket; +import gridsim.net.Link; +import gridsim.net.SimpleLink; +import gridsim.turbo.Reservation; +import gridsim.turbo.ReservationRequester; + +/** + * The main purpose of this class is to create a realistic simulation + * environment where your jobs or Gridlets are competing with others. + * In other words, the grid resource might not be available at certain times. + * In addition, the arrival time of jobs are also captured in the trace file. + * <p> + * This workload class has been modified to simulate advance reservations. + * Some parameters where included to indicate the frequency in which + * advance reservations are made. Additionally, it is possible to specify how + * long in advance the advance reservations are made. + * <p> + * This class is responsible for reading resource traces from a file and + * sends Gridlets to only <tt>one</tt> destinated resource. <br> + * <b>NOTE:</b> + * <ul> + * <li> This class can only take <tt>one</tt> trace file of the following + * format: <i>ASCII text, zip, gz.</i> + * <li> This class can be classified as <b>one grid user entity</b>. + * Hence, you need to incorporate this entity into <tt>numUser</tt> + * during {@link gridsim.GridSim#init(int, Calendar, boolean)} + * <li> If you need to use multiple trace files to submit Gridlets to + * same or different resources, then you need to create multiple + * instances of this class <tt>each with a unique entity name</tt>. + * <li> If size of the trace file is huge or contains lots of traces + * please increase the JVM heap size accordingly by using + * <tt>java -Xmx</tt> option when running the simulation. + * <li> If you are running an experiment using the network extension, + * i.e. the gridsim.net package, then you need to use + * {@link #Workload(String, double, double, int, String, String, int)} + * instead. + * <li> The default job file size for sending to and receiving from + * a resource is {@link gridsim.net.Link#DEFAULT_MTU}. + * However, you can specify + * the file size by using {@link #setGridletFileSize(int)}. + * <li> A job run time is only for 1 PE <tt>not</tt> the total number of + * allocated PEs. + * Therefore, a Gridlet length is also calculated for 1 PE.<br> + * For example, job #1 in the trace has a run time of 100 seconds + * for 2 processors. This means each processor runs + * job #1 for 100 seconds, if the processors have the same + * specification. + * </ul> + * <p> + * By default, this class follows the standard workload format as specified + * in <a href="http://www.cs.huji.ac.il/labs/parallel/workload/"> + * http://www.cs.huji.ac.il/labs/parallel/workload/</a> <br> + * However, you can use other format by calling the below methods before + * running the simulation: + * <ul> + * <li> {@link #setComment(String)} + * <li> {@link #setField(int, int, int, int, int)} + * </ul> + * + * @see gridsim.GridSim#init(int, Calendar, boolean) + * @author Marcos Dias de Assuncao (the most of the code came + * from {@link Workload} class) + * @since GridSim Turbo Alpha 0.1 + * @invariant $none + */ + +public class WorkloadWithReservation extends ReservationRequester { + + protected String fileName_; // file name + protected String resName_; // resource name + protected int resID_; // resource ID + protected int rating_; // a PE rating + protected int gridletID_; // gridletID + protected int size_; // job size for sending it through a network + protected ArrayList list_; // a list for getting all the Gridlets + + // constant + private int JOB_NUM; // job number + private int SUBMIT_TIME; // submit time of a Gridlet + private int RUN_TIME; // running time of a Gridlet + private int NUM_PROC; // number of processors needed for a Gridlet + private int REQ_NUM_PROC; // required number of processors + private int REQ_RUN_TIME; // required running time + private int MAX_FIELD; // max number of field in the trace file + private String COMMENT; // a string that denotes the start of a comment + private final int IRRELEVANT = -1; // irrelevant number + protected final int INTERVAL = 10; // number of intervals + private String[] fieldArray_; // a temp array storing all the fields + + // ADVANCE RESERVATION PROPERTIES + private double reservProbability_; + private double timeInAdvance_; + private Random numGen_; + private long seed_ = 11L*13*17*19*23+1; + + // TAGS FOR INTERNAL EVENTS + private final int GRIDLET_SUBMIT = 10; + private final int RESERVE_RESOURCES = 11; + + /** + * Create a new Workload object <b>without</b> using the network extension. + * This means this entity directly sends Gridlets to a destination resource + * without going through a wired network. <br> + * <tt>NOTE:</tt> + * You can not use this constructor in an experiment that uses a wired + * network topology. + * + * @param name this entity name + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithReservation(String name, String fileName, String resourceName, + int rating) throws ParameterException, Exception { + super(name, GridSimTags.DEFAULT_BAUD_RATE); + + // check the input parameters first + String msg = name + "(): Error - "; + if (fileName == null || fileName.length() == 0) { + throw new ParameterException(msg + "invalid trace file name."); + } + else if (resourceName == null || resourceName.length() == 0) { + throw new ParameterException(msg + "invalid resource name."); + } + else if (rating <= 0) { + throw new ParameterException(msg+"resource PE rating must be > 0."); + } + + System.out.println(name + ": Creating a workload object ..."); + init(fileName, resourceName, rating); + } + + /** + * Create a new Workload object <b>with</b> the network extension. + * This means this entity directly sends Gridlets to a destination resource + * through a link. The link is automatically created by this constructor. + * + * @param name this entity name + * @param baudRate baud rate of this link (bits/s) + * @param propDelay Propagation delay of the Link in milliseconds + * @param MTU Maximum Transmission Unit of the Link in bytes. + * Packets which are larger than the MTU should be split + * up into MTU size units. + * For example, a 1024 byte packet trying to cross a 576 + * byte MTU link should get split into 2 packets of 576 + * bytes and 448 bytes. + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li> baudRate <= 0 + * <li> propDelay <= 0 + * <li> MTU <= 0 + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre baudRate > 0 + * @pre propDelay > 0 + * @pre MTU > 0 + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithReservation(String name, double baudRate, double propDelay, int MTU, + String fileName, String resourceName, int rating) + throws ParameterException, Exception { + super( name, new SimpleLink(name+"_link", baudRate, propDelay, MTU) ); + + // check the input parameters first + String msg = name + "(): Error - "; + if (fileName == null || fileName.length() == 0) { + throw new ParameterException(msg + "invalid trace file name."); + } + else if (resourceName == null || resourceName.length() == 0) { + throw new ParameterException(msg + "invalid resource name."); + } + else if (rating <= 0) { + throw new ParameterException(msg+"resource PE rating must be > 0."); + } + + System.out.println(name + ": Creating a workload object ..."); + init(fileName, resourceName, rating); + } + + /** + * Create a new Workload object <b>with</b> the network extension. + * This means this entity directly sends Gridlets to a destination resource + * through a link. The link is automatically created by this constructor. + * + * @param name this entity name + * @param link the link that will be used to connect this Workload + * to another entity or a Router. + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li>the link is empty + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre link != null + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithReservation(String name, Link link, String fileName, + String resourceName, int rating) + throws ParameterException, Exception { + super(name, link); + + // check the input parameters first + String msg = name + "(): Error - "; + if (fileName == null || fileName.length() == 0) { + throw new ParameterException(msg + "invalid trace file name."); + } + else if (resourceName == null || resourceName.length() == 0) { + throw new ParameterException(msg + "invalid resource name."); + } + else if (rating <= 0) { + throw new ParameterException(msg+"resource PE rating must be > 0."); + } + + System.out.println(name + ": Creating a workload object ..."); + init(fileName, resourceName, rating); + } + + /** + * Gets the probability of a job in the workload + * be an advance reservation + * @return the reservation probability + */ + public double getReservationProbability() { + return reservProbability_; + } + + /** + * Sets the probability of a job in the workload + * be an advance reservation + * @param probability the reservation probability + */ + public void setReservationProbability(double probability) { + reservProbability_ = probability; + } + + /** + * Gets how long in advance an advance reservation has to + * be made. The time in advance is how long in advance to + * the submission time included in the log the reservation + * has to be made + * @return the time in advance + */ + public double getARTimeInAdvance() { + return timeInAdvance_; + } + + /** + * Sets how long in advance an advance reservation has to + * be made. The time in advance is how long in advance to + * the submission time included in the log the reservation + * has to be made + * @param time the time in advance + */ + public void setARTimeInAdvance(double time) { + timeInAdvance_ = time; + } + + /** + * Initialises all the attributes + * @param fileName trace file name + * @param resourceName resource entity name + * @param rating resource PE rating + * @pre $none + * @post $none + */ + private void init(String fileName, String resourceName, int rating) + { + fileName_ = fileName; + resName_ = resourceName; + resID_ = GridSim.getEntityId(resName_); + rating_ = rating; + gridletID_ = 1; // starts at 1 to make it the same as in a trace file + list_ = null; + size_ = Link.DEFAULT_MTU; + + timeInAdvance_ = 60 * 60; // one hour + reservProbability_ = 0D; + numGen_ = new Random(seed_); + + // if using Standard Workload Format -- don't forget to substract by 1 + // since an array starts at 0, but the field in a trace starts at 1 + JOB_NUM = 1 - 1; + SUBMIT_TIME = 2 - 1; + RUN_TIME = 4 - 1; + NUM_PROC = 5 - 1; + REQ_NUM_PROC = 8 - 1; + REQ_RUN_TIME = 9 - 1; + + COMMENT = ";"; // semicolon means the start of a comment + MAX_FIELD = 18; // standard workload format has 18 fields + fieldArray_ = null; + } + + /** + * Sets a Gridlet file size (in byte) for sending to/from a resource. + * @param size a Gridlet file size (in byte) + * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise + * @pre size > 0 + * @post $none + */ + public boolean setGridletFileSize(int size) { + if (size < 0) { + return false; + } + + size_ = size; + return true; + } + + /** + * Identifies the start of a comment line. Hence, a line that starts + * with a given comment will be ignored. + * @param comment a character that denotes the start of a comment, + * e.g. ";" or "#" + * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise + * @pre comment != null + * @post $none + */ + public boolean setComment(String comment) + { + boolean success = false; + if (comment != null && comment.length() > 0) + { + COMMENT = comment; + success = true; + } + return success; + } + + /** + * Tells this class what to look in the trace file. + * This method should be called before the start of the simulation. + * <p> + * By default, this class follows the standard workload format as specified + * in <a href="http://www.cs.huji.ac.il/labs/parallel/workload/"> + * http://www.cs.huji.ac.il/labs/parallel/workload/</a> <br> + * However, you can use other format by calling this method. + * <p> + * The parameters must be a positive integer number starting from 1. + * A special case is where <tt>jobNum == -1</tt>, meaning the job or + * gridlet ID starts at 1. + * + * @param maxField max. number of field/column in one row + * @param jobNum field/column number for locating the job ID + * @param submitTime field/column number for locating the job submit time + * @param runTime field/column number for locating the job run time + * @param numProc field/column number for locating the number of PEs + * required to run a job + * @return <tt>true</tt> if successful, <tt>false</tt> otherwise + * @pre maxField > 0 + * @pre submitTime > 0 + * @pre runTime > 0 + * @pre numProc > 0 + * @post $none + */ + public boolean setField(int maxField, int jobNum, int submitTime, + int runTime, int numProc) + { + // need to substract by 1 since array starts at 0. Need to convert, + // position in a field into the index of the array + if (jobNum > 0) { + JOB_NUM = jobNum - 1; + } + else if (jobNum == 0) + { + System.out.println(super.get_name() + + ".setField(): Invalid job number field."); + return false; + } + else { + JOB_NUM = -1; + } + + // get the max. number of field + if (maxField > 0) { + MAX_FIELD = maxField; + } + else + { + System.out.println(super.get_name() + + ".setField(): Invalid max. number of field."); + return false; + } + + // get the submit time field + if (submitTime > 0) { + SUBMIT_TIME = submitTime - 1; + } + else + { + System.out.println(super.get_name() + + ".setField(): Invalid submit time field."); + return false; + } + + // get the run time field + if (runTime > 0) { + REQ_RUN_TIME = runTime - 1; + } + else + { + System.out.println(super.get_name() + + ".setField(): Invalid run time field."); + return false; + } + + // get the number of processors field + if (numProc > 0) { + REQ_NUM_PROC = numProc - 1; + } + else + { + System.out.println(super.get_name() + + ".setField(): Invalid number of processors field."); + return false; + } + + return true; + } + + /** + * Gets a list of completed Gridlets + * @return a list of Gridlets + * @pre $none + * @post $none + */ + public ArrayList getGridletList() { + return list_; + } + + /** + * Prints the Gridlet objects + * @param history <tt>true</tt> means printing each Gridlet's history, + * <tt>false</tt> otherwise + * @pre $none + * @post $none + */ + public void printGridletList(boolean history) + { + String name = super.get_name(); + int size = list_.size(); + Gridlet gridlet; + + String indent = " "; + System.out.println(); + System.out.println("========== OUTPUT for " + name + " =========="); + System.out.println("Gridlet_ID" + indent + "STATUS" + indent + + "Resource_ID" + indent + "Cost"); + + int i = 0; + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list_.get(i); + System.out.print(indent + gridlet.getGridletID() + indent + + indent); + + // get the status of a Gridlet + System.out.print( gridlet.getGridletStatusString() ); + System.out.println( indent + indent + gridlet.getResourceID() + + indent + indent + gridlet.getProcessingCost() ); + } + + System.out.println(); + if (history == true) + { + // a loop to print each Gridlet's history + System.out.println(); + 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("========================================="); + System.out.println(); + } + } + } + + /** + * Reads from a given file when the simulation starts running. + * Then submits Gridlets to a resource and collects them before exiting. + * To collect the completed Gridlets, use {@link #getGridletList()} + * @pre $none + * @post $none + */ + public void body() { + System.out.println(); + System.out.println(super.get_name() + ".body() :%%%% Start ..."); + + // create a temp array + fieldArray_ = new String[MAX_FIELD]; + + // get the resource id + if (resID_ < 0) + { + System.out.println(super.get_name() + + ".body(): Error - invalid resource name: " + resName_); + return; + } + + boolean success = false; + + // read the gz file + if (fileName_.endsWith(".gz") == true) { + success = readGZIPFile(fileName_); + } + // read the zip file + else if (fileName_.endsWith(".zip") == true) { + success = readZipFile(fileName_); + } + // read from uncompressed file as well + else { + success = readFile(fileName_); + } + + // if all the gridlets have been submitted + if (!success ) { + System.out.println(super.get_name() + + ".body(): Error - unable to parse from a file."); + return; + } + + System.out.println(super.get_name() + ": Collecting Gridlets ..."); + list_ = new ArrayList(gridletID_ + 1); + + Object data = null; + Gridlet gl = null; + + int counter = 1; // starts at 1, since gridletID_ starts at 1 too + Sim_event ev = new Sim_event(); + Object[] reservObj = null; + + while ( Sim_system.running() + && counter < gridletID_ ) { + + super.sim_get_next(ev); // get the next available event + data = ev.get_data(); // get the event's data + + // handle ping request + if (ev.get_tag() == GridSimTags.INFOPKT_SUBMIT) { + processPingRequest(ev); + continue; + } + else if (ev.get_tag() == RESERVE_RESOURCES) { + + reservObj = (Object[])ev.get_data(); + + double startTime = (Double)reservObj[0]; + int duration = (Integer)reservObj[1]; + Gridlet resGl = (Gridlet)reservObj[2]; + + // creates a new reservation + Reservation reservation = null; + reservation = super.createReservation(startTime, duration, resGl.getNumPE(), resID_); + + success = true; + if(reservation == null) { + success = false; + } + + // commit the reservation + if(success) { + // for a reservation with an even number, commits straightaway + // without sending any Gridlets yet + success = super.commitReservation(reservation.getID()); + + // submit the gridlet if success + if(success) { + + // sets the reservation id of this gridlet + resGl.setReservationID(reservation.getID()); + + // submit the gridlet to the resource + super.send(super.output, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, + new IO_data(resGl, resGl.getGridletFileSize(), resID_) ); + } + // if the reservation fails, then sets the status of the + // gridlet to failed and adds the gridlet to the list + else { + try { + resGl.setGridletStatus(Gridlet.FAILED); + } + catch(Exception ex) { + + } + list_.add(resGl); + } + } + counter++; + } + + // get the Gridlet data + else if (data != null && data instanceof Gridlet) { + gl = (Gridlet) data; + list_.add(gl); + counter++; + } + + // if all the Gridlets have been collected + if (counter == gridletID_) { + break; + } + } + + // shut down all the entities, including GridStatistics entity since + // we used it to record certain events. + shutdownGridStatisticsEntity(); + shutdownUserEntity(); + terminateIOEntities(); + + System.out.println(super.get_name() + ".body() : %%%% Exit ..."); + } + + //////////////////////// PROTECTED METHODS /////////////////////// + + /** + * Processes a ping request. + * @param ev a Sim_event object + * @pre ev != null + * @post $none + */ + protected void processPingRequest(Sim_event ev) + { + InfoPacket pkt = (InfoPacket) ev.get_data(); + pkt.setTag(GridSimTags.INFOPKT_RETURN); + pkt.setDestID( pkt.getSrcID() ); + + // sends back to the sender + super.send(super.output, GridSimTags.SCHEDULE_NOW, + GridSimTags.INFOPKT_RETURN, + new IO_data(pkt, pkt.getSize(), pkt.getSrcID()) ); + } + + //////////////////////// PRIVATE METHODS /////////////////////// + + /** + * Breaks a line of string into many fields. + * @param line a line of string + * @param lineNum a line number + * @pre line != null + * @pre lineNum > 0 + * @post $none + */ + private void parseValue(String line, int lineNum) + { + // skip a comment line + if (line.startsWith(COMMENT) == true) { + return; + } + + String[] sp = line.split("\\s+"); // split the fields based on a space + int i; // a counter + int len = 0; // length of a string + int index = 0; // the index of an array + + // check for each field in the array + for (i = 0; i < sp.length; i++) + { + len = sp[i].length(); // get the length of a string + + // if it is empty then ignore + if (len == 0) { + continue; + } + // if not, then put into the array + else + { + fieldArray_[index] = sp[i]; + index++; + } + } + + if (index == MAX_FIELD) { + extractField(fieldArray_, lineNum); + } + } + + /** + * Extracts relevant information from a given array + * @param array an array of String + * @param line a line number + * @pre array != null + * @pre line > 0 + */ + private void extractField(String[] array, int line) + { + try + { + Integer obj = null; + + // get the job number + int id = 0; + if (JOB_NUM == IRRELEVANT) { + id = gridletID_; + } + else + { + obj = new Integer( array[JOB_NUM].trim() ); + id = obj.intValue(); + } + + // get the submit time + Long l = new Long( array[SUBMIT_TIME].trim() ); + long submitTime = l.intValue(); + + // get the run time + obj = new Integer( array[REQ_RUN_TIME].trim() ); + int runTime = obj.intValue(); + + // if the required run time field is ignored, then use + // the actual run time + if (runTime == IRRELEVANT) + { + obj = new Integer( array[RUN_TIME].trim() ); + runTime = obj.intValue(); + } + + // according to the SWF manual, runtime of 0 is possible due + // to rounding down. E.g. runtime is 0.4 seconds -> runtime = 0 + if (runTime == 0) { + runTime = 1; // change to 1 second + } + + // get the number of allocated processors + obj = new Integer( array[REQ_NUM_PROC].trim() ); + int numProc = obj.intValue(); + + // if the required num of allocated processors field is ignored + // or zero, then use the actual field + if (numProc == IRRELEVANT || numProc == 0) + { + obj = new Integer( array[NUM_PROC].trim() ); + numProc = obj.intValue(); + } + + // finally, check if the num of PEs required is valid or not + if (numProc <= 0) + { + System.out.println(super.get_name() + ": Warning - job #" + + id + " at line " + line + " requires " + numProc + + " CPU. Change to 1 CPU."); + numProc = 1; + } + + // creates a submission/reservation event + submitGridlet(id, submitTime, runTime, numProc); + } + catch (Exception e) + { + System.out.println(super.get_name() + + ": Exception in reading file at line #" + line); + e.printStackTrace(); + } + } + + /** + * Creates a Gridlet with the given information, then submit it to a + * resource + * @param id a Gridlet ID + * @param submitTime Gridlet's submit time + * @param runTime Gridlet's run time + * @param numProc number of processors + * @pre id >= 0 + * @pre submitTime >= 0 + * @pre runTime >= 0 + * @pre numProc > 0 + * @post $none + */ + protected void submitGridlet(int id, long submitTime, int runTime, int numProc) { + // create the gridlet + int len = runTime * rating_; // calculate a job length for each PE + Gridlet gridlet = new Gridlet(id, len, size_, size_); + gridlet.setUserID( super.get_id() ); // set the owner ID + gridlet.setNumPE(numProc); // set the requested num of proc + + // check the probability of creating an advance reservation + double probAR = Math.abs(numGen_.nextDouble()); + + // check the submit time + if (submitTime < 0) { + submitTime = 0; + } + + if(probAR <= reservProbability_) { + + // calculate how long in advance the reservation is made + double timeInAdvance = timeInAdvance_ * numGen_.nextDouble(); + + // convert to seconds + double timeToReserve = submitTime - timeInAdvance; + + // if the time the reservation would be done has already + // past, then consider now as the submission time + if(timeToReserve <= 0.0D) { + timeToReserve = GridSimTags.SCHEDULE_NOW; + } + + //TODO To check the duration of the advance reservation later + Object[] reservObj = new Object[3]; + reservObj[0] = new Double(submitTime); // start time of the reservation + reservObj[1] = (int) runTime + 1; // the advance reservation duration + reservObj[2] = gridlet; // the gridlet to be submitted + + // submit an internal event to create a reservation for this gridlet + super.send(super.get_id(), timeToReserve, RESERVE_RESOURCES, reservObj); + } + else { + // printing to inform user + if (gridletID_ == 1 || gridletID_ % INTERVAL == 0) { + System.out.println(super.get_name() + ": Submitting Gridlets to " + + resName_ + " ..."); + } + + // submit a gridlet to resource + super.send(super.output, submitTime, GridSimTags.GRIDLET_SUBMIT, + new IO_data(gridlet, gridlet.getGridletFileSize(), resID_) ); + } + + gridletID_++; // increment the counter + } + + /** + * Reads a text file one line at the time + * @param fileName a file name + * @return <tt>true</tt> if reading a file is successful, <tt>false</tt> + * otherwise. + * @pre fileName != null + * @post $none + */ + private boolean readFile(String fileName) + { + boolean success = false; + BufferedReader reader = null; + try + { + FileInputStream file = new FileInputStream(fileName); + InputStreamReader input = new InputStreamReader(file); + reader = new BufferedReader(input); + + // read one line at the time + int line = 1; + while ( reader.ready() ) + { + parseValue(reader.readLine(), line); + line++; + } + + reader.close(); // close the file + success = true; + } + catch (FileNotFoundException f) + { + System.out.println(super.get_name() + + ": Error - the file was not found: " + f.getMessage()); + } + catch (IOException e) + { + System.out.println(super.get_name() + + ": Error - an IOException occurred: " + e.getMessage()); + } + finally + { + if (reader != null) + { + try { + reader.close(); // close the file + } + catch (IOException e) + { + System.out.println(super.get_name() + + ": Error - an IOException occurred: " + e.getMessage()); + } + } + } + + return success; + } + + /** + * Reads a gzip file one line at the time + * @param fileName a gzip file name + * @return <tt>true</tt> if reading a file is successful, <tt>false</tt> + * otherwise. + * @pre fileName != null + * @post $none + */ + private boolean readGZIPFile(String fileName) + { + boolean success = false; + BufferedReader reader = null; + try + { + FileInputStream file = new FileInputStream(fileName); + GZIPInputStream gz = new GZIPInputStream(file); + InputStreamReader input = new InputStreamReader(gz); + reader = new BufferedReader(input); + + // read one line at the time + int line = 1; + while ( reader.ready() ) + { + parseValue(reader.readLine(), line); + line++; + } + + reader.close(); // close the file + success = true; + } + catch (FileNotFoundException f) + { + System.out.println(super.get_name() + + ": Error - the file was not found: " + f.getMessage()); + } + catch (IOException e) + { + System.out.println(super.get_name() + + ": Error - an IOException occurred: " + e.getMessage()); + } + finally + { + if (reader != null) + { + try { + reader.close(); // close the file + } + catch (IOException e) + { + System.out.println(super.get_name() + + ": Error - an IOException occurred: " + e.getMessage()); + } + } + } + + return success; + } + + /** + * Reads a Zip file. Iterating through each entry and reading it one line + * at the time. + * @param fileName a zip file name + * @return <tt>true</tt> if reading a file is successful, <tt>false</tt> + * otherwise. + * @pre fileName != null + * @post $none + */ + private boolean readZipFile(String fileName) + { + boolean success = false; + ZipFile zipFile = null; + try + { + InputStreamReader input = null; + BufferedReader reader = null; + + // ZipFile offers an Enumeration of all the files in the Zip file + zipFile = new ZipFile(fileName); + for (Enumeration e = zipFile.entries(); e.hasMoreElements();) + { + success = false; // reset the value again + ZipEntry zipEntry = (ZipEntry) e.nextElement(); + + input = new InputStreamReader(zipFile.getInputStream(zipEntry)); + reader = new BufferedReader(input); + + // read one line at the time + int line = 1; + while ( reader.ready() ) + { + parseValue(reader.readLine(), line); + line++; + } + + reader.close(); // close the file + success = true; + } + } + catch (IOException e) + { + System.out.println(super.get_name() + + ": Error - an IOException occurred: " + e.getMessage()); + } + finally + { + if (zipFile != null) + { + try { + zipFile.close(); // close the file + } + catch (IOException e) + { + System.out.println(super.get_name() + + ": Error - an IOException occurred: " + e.getMessage()); + } + } + } + + return success; + } +} Modified: branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2007-10-04 06:05:40 UTC (rev 67) +++ branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2007-10-12 09:02:49 UTC (rev 68) @@ -50,8 +50,7 @@ * <tt>null</tt> or empty * @see gridsim.GridSim#init(int, Calendar, boolean) */ - public ARTest(String name, double baud_rate, double timeZone, - int totalJob) throws Exception { + public ARTest(String name, double baud_rate, int totalJob) throws Exception { super(name, baud_rate); this.receiveList_ = new GridletList(); this.failReservation_ = 0; @@ -108,8 +107,7 @@ // double check whether a resource supports AR or not. // In this example, all resources support AR. - if (GridSim.resourceSupportAR(intObj) == true) - { + if (GridSim.resourceSupportAR(intObj) == true) { // gets the name of a resource name = GridSim.getEntityName( intObj.intValue() ); @@ -155,11 +153,11 @@ */ private void sendReservation(ArrayList resARList, ArrayList resNameList) { // total reservation made. 1 reservation reserves 1 PE. - int totalPE = 2; - int totalReservation = list_.size(); // total number of Gridlets + int totalPE = 3; + int totalReservation = list_.size() + 2; // total number of Gridlets - // wants to reserve 1 day after the init simulation time - long time = 1 * DAY; + // wants to reserve 1 hour after the init simulation time + long time = 1 * HOUR; // each reservation requires around 10 minutes int duration = 10 * MIN; @@ -189,22 +187,25 @@ time = 1 * HOUR + duration; } - // creates a new or immediate reservation + // creates a new reservation Reservation reservation = null; boolean success = false; reservation = super.createReservation(time, duration, totalPE, resID); if(reservation != null) { - System.out.println(super.get_name() + ": reservation has been returned from "+ + System.out.println(super.get_name() + ": reservation has been accepted by "+ resName + " at time = " + GridSim.clock()); + success = true; } else { - System.out.println(super.get_name() + ": no reservation has been returned from "+ + System.out.println(super.get_name() + ": reservation has not been accepted by "+ resName + " at time = " + GridSim.clock()); failReservation_++; + success = false; } - if(reservation != null) { + // commit the reservation + if(success) { // for a reservation with an even number, commits straightaway // without sending any Gridlets yet success = super.commitReservation(reservation.getID()); @@ -218,6 +219,13 @@ " has NOT been committed successfully."); } } + + if(success && i<list_.size()) { + // then sends a gridlet to use the reservation + Gridlet grl = this.list_.get(i); + grl.setReservationID(reservation.getID()); + super.gridletSubmit(grl, resID); + } } } @@ -238,7 +246,7 @@ private GridletList createGridlet(int size, int userID) { // Creates a container to store Gridlets GridletList list = new GridletList(); - int length = 5000; + int length = 500000; for (int i = 0; i < size; i++) { // creates a new Gridlet object Gridlet gridlet = new Gridlet(i, length, 1000, 5000); Modified: branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java 2007-10-04 06:05:40 UTC (rev 67) +++ branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java 2007-10-12 09:02:49 UTC (rev 68) @@ -51,33 +51,14 @@ // Second step: Creates one or more GridResource objects // given resource name, total PE, number of Machine, time zone // and MIPS Rating. - -// // R0: vpac Compaq AlphaServer -// ARTGridResource resource0 = -// createGridResource("Resource_0", 4, 1, 10.0, 515); - - // R1: Manjra Linux PC ARTGridResource resource1 = createGridResource("Resource_1", 13, 1, 10.0, 684); -// // R2: Germany -// ARTGridResource resource2 = -// createGridResource("Resource_2", 16, 1, 1.0, 410); -// -// // R3: Czech -// ARTGridResource resource3 = -// createGridResource("Resource_3", 6, 1, 1.0, 410); -// -// // R4: Chichago -// ARTGridResource resource4 = -// createGridResource("Resource_4", 8, 1, -6.0, 377); - //------------------------------------------------ // Third step: Creates grid users ARTest[] userList = new ARTest[num_user]; ARTest user = null; // a user entity double bandwidth = 1000; // bandwidth of this user - double timeZone = 0.0; // user's time zone int totalJob = 0; // total Gridlets owned int i = 0; @@ -85,18 +66,16 @@ for (i = 0; i < num_user; i++) { // users with an even number have their time zone to GMT+8 if (i % 2 == 0) { - timeZone = 8.0; // with respect to GMT or UTC totalJob = 4; } // users with an odd number have their time zone to GMT-3 else { - timeZone = -3.0; // with respect to GMT or UTC totalJob = 5; } // creates a user entity - user = new ARTest("User_" + i, bandwidth, timeZone, totalJob); + user = new ARTest("User_" + i, bandwidth, totalJob); // put the entity into an array userList[i] = user; Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java 2007-10-04 06:05:40 UTC (rev 67) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java 2007-10-12 09:02:49 UTC (rev 68) @@ -17,7 +17,8 @@ /** - * Test Driver class for this example + * Test Driver class for this example. This example just tests + * the same features provided by the ParallelSpaceShared policy */ public class TurboAREx... [truncated message content] |
From: <mar...@us...> - 2007-10-16 07:12:50
|
Revision: 70 http://gridsim.svn.sourceforge.net/gridsim/?rev=70&view=rev Author: marcos_dias Date: 2007-10-16 00:12:49 -0700 (Tue, 16 Oct 2007) Log Message: ----------- This update contains: + Support for querying the availability of processing elements (PEs) at a Grid resource able to handle advance reservations. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java Added Paths: ----------- branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java Modified: branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2007-10-14 23:06:27 UTC (rev 69) +++ branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2007-10-16 07:12:49 UTC (rev 70) @@ -13,6 +13,7 @@ import gridsim.GridletList; import gridsim.turbo.Reservation; import gridsim.turbo.ReservationRequester; +import gridsim.turbo.TimeSlotList; import java.util.ArrayList; import java.util.Calendar; @@ -177,7 +178,15 @@ val = randObj.nextInt(totalResource); resID = ( (Integer) resARList.get(val) ).intValue(); resName = (String) resNameList.get(val); - + + // queries the availability of the Grid resource + TimeSlotList availability = + super.queryFreeTime(GridSim.clock(), Integer.MAX_VALUE, resID); + + System.out.println("Availability information returned by the " + + "Grid resource # " + resID + " at time # " + GridSim.clock() + + " is as follows: \n " + availability); + // try immediate reservation, where starting time is 0 meaning // use current time as the start time if (val == i) { @@ -186,6 +195,10 @@ else { time = 1 * HOUR + duration; } + + double potStartTime = availability.getPotentialStartTime(duration, totalPE); + System.out.println("The reservation requiring " + totalPE + " PEs could " + + "be served by Grid resource # " + resID + " at time # " + potStartTime); // creates a new reservation Reservation reservation = null; @@ -206,6 +219,12 @@ // commit the reservation if(success) { + + // query the status of the reservation + int status = super.queryReservation(reservation.getID()); + System.out.println("The status of reservation # " + reservation.getID() + + " is # " + Reservation.getStatusString(status)); + // for a reservation with an even number, commits straightaway // without sending any Gridlets yet success = super.commitReservation(reservation.getID()); @@ -218,6 +237,11 @@ System.out.println("Reservation # "+ reservation.getID() + " has NOT been committed successfully."); } + + // query the status of the reservation again + status = super.queryReservation(reservation.getID()); + System.out.println("The status of reservation # " + reservation.getID() + + " is # " + Reservation.getStatusString(status)); } if(success && i<list_.size()) { Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2007-10-14 23:06:27 UTC (rev 69) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2007-10-16 07:12:49 UTC (rev 70) @@ -85,10 +85,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode - GridSim.startGridSimulation(true); +// GridSim.startGridSimulation(true); // Start the simulation in normal mode -// GridSim.startGridSimulation(); + GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java 2007-10-14 23:06:27 UTC (rev 69) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java 2007-10-16 07:12:49 UTC (rev 70) @@ -27,8 +27,16 @@ private int msgType_; // the type of this message private int errorCode_; // an error code associated with the operation required private Reservation reservation_; // the negotiation this message is about - private double price_; // the price associate with this message + + // If a Grid resource cannot make a reservation, it may provide options + // by informing the reservation requester when resource will be available to + // fulfil the reservation. This attribute contains the list of PEs + // available at a set of simulation times + private TimeSlotList resOptions_; + // the price associate with this message + private double price_; + // starting constant value for the tags to avoid conflicts // with the GridSim tags and other tags private static final int BASE = 5000; @@ -105,6 +113,7 @@ msgType_ = TYPE_UNKNOWN; errorCode_ = EC_NO_ERROR; reservation_ = null; + resOptions_ = null; } /** @@ -152,6 +161,7 @@ msgId_ = ARMessage.createUniqueID(); reservation_ = reservation; errorCode_ = EC_NO_ERROR; + resOptions_ = null; } /** @@ -367,6 +377,22 @@ public double getPrice() { return price_; } + + /** + * Gets the reservation options given by the Grid resource + * @return the reservation options + */ + public TimeSlotList getReservationOptions() { + return resOptions_; + } + + /** + * Sets the reservation options given by the Grid resource + * @param resOptions the reservation options object + */ + public void setReservationOptions(TimeSlotList resOptions) { + resOptions_ = resOptions; + } /** * Returns the size in bytes for this message. @@ -391,7 +417,6 @@ ARMessage newMessage = new ARMessage(dstId_, srcId_, reservation_); newMessage.msgType_ = msgType_; newMessage.price_ = price_; - newMessage.reservation_ = reservation_; return newMessage; } catch (Exception ex) { Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2007-10-14 23:06:27 UTC (rev 69) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2007-10-16 07:12:49 UTC (rev 70) @@ -83,7 +83,7 @@ * <li> cancel a reservation * <li> commit a reservation * <li> process a reservation status query - * <li> list free time over a certain period of time (under development) + * <li> list free time over a certain period of time * </ul> * <p> * <b>LIMITATIONS:</b><br> @@ -639,12 +639,34 @@ } /** - * Handles a query free time request (NOTE: <b>NOT YET SUPPORTED</b>). + * Handles a query free time request. * @param message the advance reservation message received. */ public void handleQueryFreeTime(ARMessage message) { - System.out.println(super.get_name() + - ".handleQueryFreeTime(): not supported at the moment."); + + double currentTime = GridSim.clock(); + + // stores the last action time for debugging purposes + lastActionTime_ = currentTime; + + // gets the reservation id of the message + Reservation reservation = message.getReservation(); + + // creates a response message to be sent to the requester + ARMessage response = message.createResponse(); + + // gets the start time and finish time the user is interested in + double startTime = reservation.getStartTime(); + int duration = reservation.getDurationTime(); + + // gets the availability information from the availability profile + TimeSlotList availability = getAvailabilityInfo(startTime, duration); + + // sets the options as the availability over the requested period + response.setReservationOptions(availability); + + // Sends the response back to the user + super.sendARMessage(response); } /** @@ -2313,4 +2335,96 @@ availProfile_.add(tailInsertPos, newEntryAfterTail); } } + + /** + * This method returns a list that corresponds to the free time slots + * in the scheduling queue managed by this scheduler or + * resource allocation policy. + * @param startTime the start time in which the requester is interested. + * @param finishTime the finish time in which the requester is interested. + * @return the list of free time slots. The list is actually a list of + * entries that correspond to the availability profile between the times + * specified by the requester. + */ + private TimeSlotList getAvailabilityInfo(double startTime, int duration) { + + TimeSlotList list = new TimeSlotList(); + int anchorIndex = -1; + + // if the user specified the start time as 0, it means that the + // user is interested to know the availability starting from the + // current time, or the time when the resource received this request + if(startTime == 0) { + startTime = GridSim.clock(); + } + + list.setStartTime(startTime); + + // calculate the reservation's finish time + double finishTime = startTime + duration; + list.setFinishTime(finishTime); + + // a pointer to the anchor entry (described above) + AvailabilityProfileEntry anchorEntry = null; + int length = availProfile_.size(); + TimeSlotEntry firstEntry = null; + + double entryTime; + + Iterator<AvailabilityProfileEntry> iterProfile = + availProfile_.iterator(); + while(iterProfile.hasNext()) { + AvailabilityProfileEntry entry = iterProfile.next(); + entryTime = entry.getTime(); + if(entryTime > startTime) { + break; + } + else { + anchorEntry = entry; + } + } + + // if the entry is null, then it means that the reservation is + // before the first entry of the profile, so the intersection list + // has to start with the ranges of PEs currently available + if (anchorEntry == null) { + firstEntry = + new TimeSlotEntry(startTime, resource_.getFreePERanges().clone()); + } + else { + PERangeList newList = anchorEntry.getPERanges(); + if(newList != null) { + newList = newList.clone(); + } + firstEntry = new TimeSlotEntry(startTime, newList); + anchorIndex = availProfile_.indexOf(anchorEntry); + } + + list.add(firstEntry); + + // Iterates the availability profile and adds all the entries + // whose times are between start and finish time in the list + // to be returned. It removes duplicated entries + AvailabilityProfileEntry previousEntry = null; + for(int i=anchorIndex+1; i<length; i++) { + AvailabilityProfileEntry nextEntry = availProfile_.get(i); + if(nextEntry.getTime() > finishTime){ + break; + } + else { + if( !(previousEntry != null && previousEntry.hasSamePERanges(nextEntry)) ) { + PERangeList peList = nextEntry.getPERanges(); + if(peList != null) { + peList = peList.clone(); + } + TimeSlotEntry tsEntry = + new TimeSlotEntry(nextEntry.getTime(), peList.clone()); + list.add(tsEntry); + } + previousEntry = nextEntry; + } + } + + return list; + } } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2007-10-14 23:06:27 UTC (rev 69) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2007-10-16 07:12:49 UTC (rev 70) @@ -25,7 +25,7 @@ /** * Creates a new @link{AvailabilityProfile} object. */ - public AvailabilityProfile(){ + public AvailabilityProfile() { super(); } @@ -34,7 +34,7 @@ * <b>NOTE:</b> this method does not clone the entries * @return the cloned object */ - public AvailabilityProfile clone(){ + public AvailabilityProfile clone() { AvailabilityProfile clone = new AvailabilityProfile(); for(AvailabilityProfileEntry entry : this){ clone.add(entry); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java 2007-10-14 23:06:27 UTC (rev 69) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java 2007-10-16 07:12:49 UTC (rev 70) @@ -106,6 +106,23 @@ } /** + * Returns <tt>true</tt> if this entry has the same list of ranges of PEs + * as the entry provided. + * @param entry the entry whose ranges have to be compared + * @return <tt>true</tt> if the ranges are the same or false otherwise. + */ + public boolean hasSamePERanges(AvailabilityProfileEntry entry) { + boolean result = false; + if(ranges_ == null && entry.ranges_ == null) { + result = true; + } + else if(ranges_ != null) { + result = ranges_.equals(entry.ranges_); + } + return result; + } + + /** * Creates a string representation of this entry */ public String toString(){ Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java 2007-10-14 23:06:27 UTC (rev 69) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java 2007-10-16 07:12:49 UTC (rev 70) @@ -128,6 +128,11 @@ * @return <tt>true</tt> if they are equals or <tt>false</tt> otherwise. */ public boolean equals(PERangeList list) { + + if(list == null) { + return false; + } + if(super.size() != list.size()) { return false; } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java 2007-10-14 23:06:27 UTC (rev 69) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java 2007-10-16 07:12:49 UTC (rev 70) @@ -10,9 +10,6 @@ package gridsim.turbo; import gridsim.GridSim; -import gridsim.gui.GridSimVisualizer; - -import java.text.DecimalFormat; import java.util.Calendar; /** Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java 2007-10-14 23:06:27 UTC (rev 69) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java 2007-10-16 07:12:49 UTC (rev 70) @@ -105,7 +105,7 @@ int numPE, int resID) { // check all the values first - boolean success = validateValue(startTime, duration, numPE, resID); + boolean success = validateValue(startTime, duration, numPE); if (!success) { return null; } @@ -187,7 +187,7 @@ int resId = currReservation.getResourceID(); // check all the values first - boolean success = validateValue(startTime, duration, numPE, resId); + boolean success = validateValue(startTime, duration, numPE); if (!success) { return null; } @@ -297,26 +297,84 @@ } /** - * Querys to a resource regarding to list of free time during a period of - * time. Each object inside ArrayList is <tt>long array[3]</tt>, with: + * Queries to a resource regarding to list of free time during a period of + * time. This method returns a list that contains the availability + * of PEs at simulation times between the start and end time. Each entry + * contains: * <ul> - * <li> array[0] = start time - * <li> array[1] = duration time - * <li> array[2] = number of PEs + * <li> time of the entry + * <li> list of ranges of PEs available at that particular time * </ul> * - * @param resourceID a resource ID - * @param from starting time in milliseconds - * @param to ending time in milliseconds - * @return ArrayList object or <tt>null</tt> if error occurs + * @param resID a resource ID + * @param startTime the simulation start time in which + * the requester is interested + * @param duration duration time in seconds + * @return a list of entries that describe the ranges of PEs + * available at simulation time between the requested time * @pre resourceID > 0 - * @pre from > 0 - * @pre to > 0 - * @post $none + * @pre startTime >= 0 + * @pre finishTime > 0 */ - public ArrayList queryFreeTime(int resourceID, long from, long to) { - // TODO: To find a nice way to do it. - return null; + public TimeSlotList queryFreeTime(double startTime, + int duration, int resID) { + + // check all the values first + boolean success = validateValue(startTime, duration, 1); + if (!success) { + return null; + } + + TimeSlotList resOptions = null; + try { + + // create the reservation itself + Reservation reservation = new Reservation(super.get_id()); + reservation.setStartTime(startTime); + reservation.setDurationTime(duration); + reservation.setResourceID(resID); + + // creates the message to be sent to the grid resource + ARMessage message = new ARMessage(super.get_id(), resID, reservation); + message.setMessageType(ARMessage.TYPE_AR_LIST_FREE_TIME); + + // sends the message to the grid resource + sendARMessage(message); + + // wait for feedback whether the reservation has been accepted or not + FilterARMessage tagObj = + new FilterARMessage(reservation.getID(), + ARMessage.TYPE_AR_LIST_FREE_TIME); + + // only look for this type of ack for same reservation ID + Sim_event ev = new Sim_event(); + super.sim_get_next(tagObj, ev); + + // gets the reply from the grid resource + ARMessage reply = (ARMessage)ev.get_data(); + + // gets the error code. If the error code is EC_NO_ERROR + // it means that the reservation has been successful. + // Otherwise, print the error message + int error = reply.getErrorCode(); + if(error == ARMessage.EC_NO_ERROR) { + resOptions = reply.getReservationOptions(); + } + else { + System.out.println(super.get_name() + ": Resource # " + resID + + " could not inform the availability at time " + GridSim.clock()); + resOptions = null; + } + } + + catch (Exception ex) { + System.out.println(super.get_name() + ": Resource # " + resID + + " could not inform the availability at time " + GridSim.clock()); + ex.printStackTrace(); + resOptions = null; + } + + return resOptions; } /** @@ -450,8 +508,7 @@ * @param resID a resource ID * @return <tt>true</tt> if they are valid or <tt>false</tt> otherwise. */ - private boolean validateValue(double startTime, - int duration, int numPE, int resID) { + private boolean validateValue(double startTime, int duration, int numPE) { // current time = simulation time double currentTime = GridSim.clock(); Added: branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java 2007-10-16 07:12:49 UTC (rev 70) @@ -0,0 +1,129 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + */ + +package gridsim.turbo; + +/** + * The {@link TimeSlotEntry} class represents an entry in a list of + * time slots available, which can be allocated to a user. This is used + * in return to a query for free time slots in an advance reservation + * based allocation policy. + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see ARTPolicy + * @see PERange + * @see PERangeList + * @see TimeSlotList + * @see ARParallelSpaceShared + * @see ARParallelSpaceShared#handleQueryFreeTime(ARMessage) + */ + +public class TimeSlotEntry implements Comparable <TimeSlotEntry> { + + private double time_; + private PERangeList availRanges_; + + /** + * Creates a new instance of {@link TimeSlotEntry} + * @time the time associated with this entry + */ + public TimeSlotEntry(double time) { + time_ = time; + availRanges_ = null; + } + + /** + * Creates a new instance of {@link TimeSlotEntry} + * @time the time associated with this entry + * @ranges the list of ranges of PEs available + */ + public TimeSlotEntry(double time, PERangeList ranges) { + time_ = time; + availRanges_ = ranges; + } + + /** + * Gets the time associated with this entry + * @return the time associated with this entry + */ + public double getTime() { + return time_; + } + + /** + * Sets the time associated with this entry + * @param time the time associated with this entry + * @return <tt>true</tt> if the time has been set successfully or + * <tt>false</tt> otherwise. + */ + public boolean setTime(double time) { + if(time < 0) + return false; + + time_ = time; + return true; + } + + /** + * Returns the list of ranges available at this entry + * @return the list of ranges available + */ + public PERangeList getAvailRanges() { + return availRanges_; + } + + /** + * Sets the ranges of PEs available at this entry + * @param availRanges the list of ranges of PEs available + */ + public void setAvailRanges(PERangeList availRanges) { + availRanges_ = availRanges; + } + + /** + * Compares this object with the specified object for order. + * Returns a negative integer, zero, or a positive integer + * as this object is less than, equal to, or greater + * than the specified object. + * @param entry the entry to be compared. + * @return a negative integer, zero, or a positive integer as + * this entry is less than, equal to, or greater + * than the specified entry. + */ + public int compareTo(TimeSlotEntry entry) { + int result = 0; + if(time_ < entry.time_) { + result = -1; + } + else if(time_ > entry.time_) { + result = 1; + } + return result; + } + + /** + * Gets the number of PEs associated with this entry + * @return the number of PEs + */ + public int getNumPE(){ + if(availRanges_ == null) + return 0; + else + return availRanges_.getNumPE(); + } + + /** + * Creates a string representation of this entry + * @return a representation of this entry + */ + public String toString(){ + return "{time="+ time_ + "; " + + ( (availRanges_!=null) ? availRanges_ : "{[]}") + "}"; + } +} Added: branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java 2007-10-16 07:12:49 UTC (rev 70) @@ -0,0 +1,314 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + */ + +package gridsim.turbo; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; + +/** + * The {@link TimeSlotList} class represents a list of time slots + * that are available and can be allocated to a user. This is used + * in return to a query for free time slots in an advance reservation + * based allocation policy. + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see ARTPolicy + * @see PERange + * @see PERangeList + * @see ARParallelSpaceShared + * @see ARParallelSpaceShared#handleQueryFreeTime(ARMessage) + */ + +public class TimeSlotList { + + private static final long serialVersionUID = -3951650752024908016L; + + private ArrayList<TimeSlotEntry> list_; + private double startTime_; + private double finishTime_; + + private static final int UNKNOWN = -1; + + /** + * Default constructor. + */ + public TimeSlotList() { + list_ = new ArrayList<TimeSlotEntry>(); + startTime_ = UNKNOWN; + finishTime_ = UNKNOWN; + } + + /** + * Returns the start time of this list. That is, + * the time of the first element of this list + * @return the start time + */ + public double getStartTime() { + return startTime_; + } + + /** + * Returns the end time of this list. + * @return the end time + */ + public double getEndTime() { + return finishTime_; + } + + /** + * Sets the start time of this list. + * @param startTime the start time + */ + public void setStartTime(double startTime) { + startTime_ = startTime; + } + + /** + * Sets the end time of this list. + * @param finishTime the end time + */ + public void setFinishTime(double finishTime) { + finishTime_ = finishTime; + } + + /** + * Adds the specified element to this list. + * @param entry the entry to be added to this list + * @return <tt>true + */ + public boolean add(TimeSlotEntry entry) { + if(entry == null) { + return false; + } + else { + double entryTime = entry.getTime(); + int size = list_.size(); + int index = 0; + for (index=0; index<size; index++) { + if(list_.get(index).getTime() > entryTime) { + break; + } + } + list_.add(index, entry); + } + return true; + } + + /** + * Adds all of the elements in the specified Collection to this list, + * The behaviour of this operation is undefined if the specified + * Collection is modified while the operation is in progress. + * (This implies that the behaviour of this call is undefined if the + * specified Collection is this list, and this list is nonempty.) + * @param collection the collection to be included in this list + * @return <tt>true<tt> if the collection has been added successfully + * or <tt>false</tt> otherwise. + */ + public boolean addAll(Collection<? extends TimeSlotEntry> collection) { + boolean result = true; + + // adds the collection to the list and sets the start + // and finish time again + if(collection != null && !collection.isEmpty()) { + list_.addAll(collection); + Collections.sort(list_); + } + return result; + } + + /** + * Removes all elements from the list. + */ + public void clear() { + list_.clear(); + } + + /** + * Returns a shallow copy of this list. + * (The elements themselves are not copied.) + */ + public Object clone() { + return list_.clone(); + } + + /** + * Returns <tt>true</tt> if this list contains the specified element. + * @param entry the entry whose presence in this List is to be tested. + * @return <tt>true</tt> if the specified element is present; + * <tt>false</tt> otherwise. + */ + public boolean contains(Object entry) { + return list_.contains(entry); + } + + /** + * Returns the element at the specified position in this list. + * @param index the index of the element to return + * @return the element at the specified position in this list. + */ + public TimeSlotEntry get(int index) { + return list_.get(index); + } + + /** + * Searches for the first occurence of the given argument, + * testing for equality using the equals method. + * @param entry the entry whose index is to be returned + * @return the index of the first occurrence of the argument + * in this list; returns <tt>-1</tt> if the object is not found. + */ + public int indexOf(Object entry) { + return list_.indexOf(entry); + } + + /** + * Tests if this list has no elements. + * @return <tt>true</tt> if the list has no elements. + */ + public boolean isEmpty() { + return list_.isEmpty(); + } + + /** + * Returns an iterator over the elements in this list in proper sequence. + * @return the iterator. + */ + public Iterator<TimeSlotEntry> iterator() { + return list_.iterator(); + } + + /** + * Removes the element at a given index + * @param index the index of the element to be removed + * @return the removed element. + */ + public TimeSlotEntry remove(int index) { + return list_.remove(index); + } + + /** + * Removes a given element from the list. + * @param entry the entry to be removed + * @return <tt>true</tt> if the collection contained the + * specified entry. + */ + public boolean remove(Object entry) { + return list_.remove(entry); + } + + /** + * Returns the size of this list. + * @return the size of this list + */ + public int size() { + return list_.size(); + } + + /** + * Scans the entries in a list and returns the first time frame over + * which a request with the characteristics provided can be scheduled + * @param duration the duration of the request + * @param numPE the number of PEs required + * @return the start time or <tt>-1</tt> if not found + */ + public double getPotentialStartTime(int duration, int reqPE) { + + // the anchor index, the entry in the profile where + // the request would be placed OR the closest entry to the + // point where the anchor of the request would be placed + int anchorIndex = -1; + + // a pointer to the anchor entry (described above) + TimeSlotEntry anchorEntry = null; + + // the list of selected ranges + PERangeList intersectList = null; + + double potStartTime = -1; // keep the potential start time of the request + double potFinishTime = -1; // store the gridlet's expected finish time + + intersectList = null; + int length = list_.size(); + + Iterator<TimeSlotEntry> iterProfile = list_.iterator(); + while(iterProfile.hasNext()) { + + TimeSlotEntry entry = iterProfile.next(); + anchorEntry = entry; + anchorIndex = list_.indexOf(anchorEntry); + + // sets the start time as the time of the entry + potStartTime = entry.getTime(); + // calculates when the finish time will be if + // the gridlet is put at this position + potFinishTime = potStartTime + duration; + + // scan the profile until an entry with enough PEs is found + if(entry.getNumPE() < reqPE) { + continue; + } + else { + // if an entry with enough PEs is found, then scan the list + // from that point onwards analysing the intersection of + // the ranges available in the entries until the + // request expected completion time + intersectList = entry.getAvailRanges().clone(); + + // Look for the intersection of available ranges from + // the anchor until the end of the profile or until + // the entries are further than the expected completion time + for(int i=anchorIndex+1; i<length; i++){ + TimeSlotEntry nextEntry = list_.get(i); + if(nextEntry.getTime() > potFinishTime){ + break; + } + else{ + // if the finish time is equals to the entry time, so there + // is no need to check the intersection + if(nextEntry.getTime() < potFinishTime) { + intersectList = PERangeList.intersection(intersectList, + nextEntry.getAvailRanges()); + if(intersectList == null || intersectList.getNumPE() < reqPE) { + break; + } + } + } + } + // If a time slot with enough PEs has been found, then stop the search + if(intersectList != null && intersectList.getNumPE() >= reqPE) { + break; + } + } + } + + // if the potential finish time is larger than the end time of + // this list, then the request cannot be scheduled + if(potFinishTime > finishTime_) { + potStartTime = UNKNOWN; + } + + return potStartTime; + } + + /** + * Creates a string representation of the list + * @return a string representation + */ + public String toString() { + String result = "Availability={\n"; + for(TimeSlotEntry entry : list_){ + result += entry + "\n"; + } + result += "}"; + return result; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-10-17 01:14:29
|
Revision: 71 http://gridsim.svn.sourceforge.net/gridsim/?rev=71&view=rev Author: marcos_dias Date: 2007-10-16 18:14:31 -0700 (Tue, 16 Oct 2007) Log Message: ----------- This update is only to clear the lists and tables created by the allocation policies. I want to implement restart of a simulation and this will be required. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/ParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2007-10-16 07:12:49 UTC (rev 70) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2007-10-17 01:14:31 UTC (rev 71) @@ -85,10 +85,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2007-10-16 07:12:49 UTC (rev 70) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2007-10-17 01:14:31 UTC (rev 71) @@ -276,6 +276,13 @@ System.out.println(super.get_name() + ".body(): ignore internal events"); } + + queuedGridlets_.clear(); + runningGridlets_.clear(); + orderStartTime_ = null; + reservTable_.clear(); + expiryTable_.clear(); + availProfile_.clear(); } //---------------- RESERVATION RELATED PUBLIC METHODS --------------------- Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ParallelSpaceShared.java 2007-10-16 07:12:49 UTC (rev 70) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ParallelSpaceShared.java 2007-10-17 01:14:31 UTC (rev 71) @@ -196,6 +196,11 @@ super.sim_get_next(ev); System.out.println(super.get_name() + ".body(): ignore internal events"); } + + queuedGridlets_.clear(); + runningGridlets_.clear(); + orderStartTime_ = null; + availProfile_.clear(); } /** Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java 2007-10-16 07:12:49 UTC (rev 70) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java 2007-10-17 01:14:31 UTC (rev 71) @@ -13,7 +13,6 @@ import gridsim.GridSimTags; import gridsim.net.Link; -import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java 2007-10-16 07:12:49 UTC (rev 70) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java 2007-10-17 01:14:31 UTC (rev 71) @@ -23,7 +23,7 @@ * @since GridSim Turbo Alpha 0.1 */ -public class SSReservation implements ScheduleItem{ +public class SSReservation implements ScheduleItem { // the Reservation that this SSReservation represents private Reservation reservation_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-02-15 04:12:54
|
Revision: 103 http://gridsim.svn.sourceforge.net/gridsim/?rev=103&view=rev Author: marcos_dias Date: 2008-02-14 20:13:00 -0800 (Thu, 14 Feb 2008) Log Message: ----------- Stable version of the multiple queue aggressive backfilling policy. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java Added Paths: ----------- branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartitionPredicate.java Removed Paths: ------------- branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePredicate.java Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java 2008-02-14 12:00:22 UTC (rev 102) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java 2008-02-15 04:13:00 UTC (rev 103) @@ -145,16 +145,9 @@ // this resource will use an aggressive backfilling policy (EASY) TResourceCharacteristics resConfig = new TResourceCharacteristics( - arch, os, mList, TResourceCharacteristics.EB_PARALLEL_SPACE_SHARED, + arch, os, mList, TResourceCharacteristics.MULTIPLE_EASY_BACKFILLING_QUEUES, time_zone, cost); - MultipleEasyBackfillingQueues policy = null; - try { - policy = new MultipleEasyBackfillingQueues(name, "Policy", 1); - } catch (Exception e1) { - e1.printStackTrace(); - } - ////////////////////////////////////////// // 6. Finally, we need to create a GridResource object. double baud_rate = 10000.0; // communication speed @@ -172,13 +165,10 @@ LinkedList holidays = new LinkedList(); GridResource gridRes = null; - ResourceCalendar resCalendar = new ResourceCalendar(time_zone, - peakLoad, offPeakLoad, holidayLoad, weekends, - holidays, seed); - try { - gridRes = new GridResource(name, baud_rate, resConfig, - resCalendar, policy); + gridRes = new GridResource(name, baud_rate, seed, + resConfig, peakLoad, offPeakLoad, holidayLoad, weekends, + holidays); } catch (Exception e) { e.printStackTrace(); Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java 2008-02-14 12:00:22 UTC (rev 102) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java 2008-02-15 04:13:00 UTC (rev 103) @@ -7,7 +7,7 @@ import gridsim.MachineList; import gridsim.ResourceCalendar; import gridsim.turbo.MultipleEasyBackfillingQueues; -import gridsim.turbo.QueuePredicate; +import gridsim.turbo.QueuePartitionPredicate; import gridsim.turbo.SSGridlet; import gridsim.turbo.TResourceCharacteristics; import gridsim.util.Workload; @@ -145,7 +145,7 @@ // this resource will use an aggressive backfilling policy (EASY) TResourceCharacteristics resConfig = new TResourceCharacteristics( - arch, os, mList, TResourceCharacteristics.EB_PARALLEL_SPACE_SHARED, + arch, os, mList, TResourceCharacteristics.MULTIPLE_EASY_BACKFILLING_QUEUES, time_zone, cost); MultipleEasyBackfillingQueues policy = null; @@ -160,8 +160,8 @@ QueuePredicateExample pred1 = new QueuePredicateExample(0, 10000, peRating); QueuePredicateExample pred2 = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); - policy.createQueue(0, resConfig.getNumPE() / 2, pred1); - policy.createQueue(1, resConfig.getNumPE() / 2, pred2); + policy.createPartition(0, resConfig.getNumPE() / 2, pred1); + policy.createPartition(1, resConfig.getNumPE() / 2, pred2); ////////////////////////////////////////// // 6. Finally, we need to create a GridResource object. @@ -197,7 +197,7 @@ } } // end class -class QueuePredicateExample implements QueuePredicate { +class QueuePredicateExample implements QueuePartitionPredicate { int minRuntime_; int maxRuntime_; int resRating_; Modified: branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java 2008-02-14 12:00:22 UTC (rev 102) +++ branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java 2008-02-15 04:13:00 UTC (rev 103) @@ -14,9 +14,12 @@ import gridsim.ResourceCharacteristics; import java.awt.BorderLayout; +import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -76,6 +79,7 @@ private JButton btChangePause_; private JTextField tfRunUntil_; + private JLabel status_; private JList jlResource_; private JTextArea jlResourceInfo_; @@ -197,11 +201,38 @@ mainPanel.add(simulationPanel); mainPanel.add(resourceInfoPanel); + JPanel statusPanel = new JPanel(); + statusPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); + status_ = new JLabel("Current simulation time is " + GridSim.clock() + " seconds."); + statusPanel.add(status_); + + /* to show simulation time when mouse cursor passing over buttons */ + MouseListener mouseListener = new MouseListener() { + + public void mouseEntered(MouseEvent e) { + status_.setText("Current simulation time is " + GridSim.clock() + " seconds."); + } + + public void mouseExited(MouseEvent e) { + status_.setText(" "); + } + + public void mouseClicked(MouseEvent e) { } + public void mousePressed(MouseEvent e) { } + public void mouseReleased(MouseEvent e) { } + }; + + btChangePause_.addMouseListener(mouseListener); + btRun_.addMouseListener(mouseListener); + btSlowMotion_.addMouseListener(mouseListener); + btStep_.addMouseListener(mouseListener); + createMenuBar(); firstClick_ = true; super.setLocation(0, 0); super.getContentPane().add(mainPanel, BorderLayout.CENTER); + super.getContentPane().add(statusPanel, BorderLayout.SOUTH); super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Creates a thread that will be responsible for starting the simulation @@ -248,7 +279,7 @@ /** * Handles the events generated by this frame */ - public void actionPerformed(ActionEvent e){ + public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if(e.getSource() == btChangePause_) { @@ -313,7 +344,7 @@ * Informs all the listeners about the change in the * simulation time */ - private static void informListenersAboutTime() { + private void informListenersAboutTime() { settings_.setTimeSpan(GridSim.clock()); Iterator<AllocationListener> iterListener = listeners_.values().iterator(); while(iterListener.hasNext()) { @@ -322,6 +353,7 @@ new AllocationAction(AllocationAction.SIMULATION_TIME_CHANGED); listener.allocationActionPerformed(action); } + status_.setText("Current simulation time is " + GridSim.clock() + " seconds."); } /** Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-02-14 12:00:22 UTC (rev 102) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-02-15 04:13:00 UTC (rev 103) @@ -279,7 +279,7 @@ * @pre userId > 0 * @post $none */ - public int gridletStatus(int gridletId,int userId){ + public int gridletStatus(int gridletId,int userId) { SSGridlet sgl = null; // Look for the Gridlet in the running queue Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java 2008-02-14 12:00:22 UTC (rev 102) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java 2008-02-15 04:13:00 UTC (rev 103) @@ -23,15 +23,50 @@ import java.util.LinkedList; /** - * Under development... - * + * This class implements a non-FCFS policy to schedule parallel jobs. The + * policy is based on aggressive (EASY) backfilling. This policy can use + * multiple partitions or queues and the jobs can be directed to these partitions + * using a partition predicate ({@link QueuePartitionPredicate}. A partition + * can borrow resources from another when it requires and the resources are + * not being used by the other partition. The implementation of this policy is + * based on the following paper: + * <p> + * <ul> + * <li> Barry G. Lawson and Evgenia Smirni, Multiple-Queue Backfilling + * Scheduling with Priorities and Reservations for Parallel Systems, + * 2002 Workshop on Job Scheduling Strategies for Parallel + * Processing (JSSPP), pp. 72-87, 2002. + * </ul> + * <br> + * We use an availability profile to store the availability of processing + * elements. In order to represent the pivots (i.e. the first jobs in the + * partitions), we schedule them creating the entries in the availability + * profile. This way, we do not need to store the pivots' start times + * (or shadow times) and extra nodes in different variables. It also makes + * the search for available resources for a new pivot easier. + * <p> + * <b>LIMITATIONS:</b><br> + * <ul> + * <li> The list of machines comprising this resource must be + * homogeneous. + * <li> Local load is not considered. If you would like to simulate this, + * you have to model the local load as gridlets. It is more precise + * and faster. To do so, please check {@link Lublin99Workload}. + * <li> Gridlets cannot be paused nor migrated. This could be + * easily done, but due to time constraints, I could not + * implement these features. + * <li> This policy still neither supports priorities nor advance + * reservation. + * </ul> + * * @author Marcos Dias de Assuncao * @since GridSim Turbo Alpha 0.1 * * @see gridsim.GridSim * @see gridsim.ResourceCharacteristics * @see gridsim.turbo.TAllocPolicy - * @see gridsim.turbo.CBParallelSpaceShared + * @see gridsim.turbo.EBParallelSpaceShared + * @see gridsim.turbo.QueuePartitionPredicate * @see gridsim.turbo.PERange * @see gridsim.turbo.PERangeList */ @@ -39,10 +74,10 @@ public class MultipleEasyBackfillingQueues extends TAllocPolicy { // Queue of running Gridlets - protected LinkedList<MQGridlet> runningGridlets_; + protected LinkedList<SSGridlet> runningGridlets_; // Queue of Gridlets waiting in this queue - protected LinkedList<MQGridlet> queuedGridlets_; + protected LinkedList<SSGridlet> queuedGridlets_; // The rating of one PE protected int ratingPE_; @@ -51,10 +86,10 @@ protected TResourceCharacteristics resource_; // The availability profile - protected Profile profile_; + protected MultiPartitionProfile profile_; - // the number of queues in this scheduler - private int numQueues_; + // the number of partitions or queues in this scheduler + private int numPartitions_; // the last time when the schedule updated was called private double lastScheduleUpdate_; @@ -66,12 +101,14 @@ private static final int UNKNOWN = -1; /** - * Allocates a new <tt>EBParallelSpaceShared</tt> object + * Allocates a new <tt>MultiEasyBackfillingQueues</tt> object. + * If the policy is create with only one partition, it will then work as + * a normal aggressive (EASY) backfilling scheduler. * * @param resourceName the <tt>GridResource</tt> entity name that will * contain this allocation policy * @param entityName this object entity name - * @param numQueues The number of queues in the scheduler + * @param numPartitions The number of partitions of the scheduling queue * @throws Exception This happens when one of the following scenarios occur: * <ul> * <li> Creating this entity before initialising GridSim package @@ -87,28 +124,55 @@ * String[], String[], String) */ public MultipleEasyBackfillingQueues(String resourceName, - String entityName, int numQueues) throws Exception { + String entityName, int numPartitions) throws Exception { super(resourceName, entityName); // makes sure that the scheduler has at least one queue - if(numQueues <= 0) { - throw new ParameterException("Number of queues" + + if(numPartitions <= 0) { + throw new ParameterException("Number of partitions " + "should be larger than 1"); } // initialises local data structure - runningGridlets_ = new LinkedList<MQGridlet>(); - queuedGridlets_ = new LinkedList<MQGridlet>(); - numQueues_ = numQueues; - profile_ = new Profile(); + runningGridlets_ = new LinkedList<SSGridlet>(); + queuedGridlets_ = new LinkedList<SSGridlet>(); + numPartitions_ = numPartitions; + profile_ = new MultiPartitionProfile(); lastScheduleUpdate_ = 0.0D; ratingPE_ = 0; } - - public boolean createQueue(int queueId, int numPE, QueuePredicate predicate) { - EasyBackFillingQueue queue = new EasyBackFillingQueue(queueId, numPE, predicate); - profile_.addQueue(queue); + /** + * Creates a new partition in this scheduler. + * @param queueId the id of the partition + * @param numPE the number of PEs in this partition + * @param predicate the predicate to be used to select + * gridlets for this partition. + * @return <tt>true</tt> if the partition has been set + * correctly or <tt>false</tt> otherwise. + */ + public boolean createPartition(int queueId, int numPE, + QueuePartitionPredicate predicate) { + if(numPE < 0) { + System.out.println(super.get_name() + ".createPartition(): " + + "Error, the number of PEs should be > 0"); + return false; + } + else if(predicate == null) { + System.out.println(super.get_name() + ".createPartition(): " + + "Error, you have provided an invalid predicate"); + return false; + } + else if(profile_.queues_.size() == numPartitions_ + && !profile_.queues_.containsKey(queueId) ) { + System.out.println(super.get_name() + ".createPartition(): " + + "Error, you have already specified all the " + + numPartitions_ + " partitions."); + return false; + } + + QueuePartition partition = new QueuePartition(queueId, numPE, predicate); + profile_.queues_.put(queueId, partition); return true; } @@ -124,47 +188,45 @@ // of one PE assuming that the machines are homogeneous ratingPE_ = resource_.getMIPSRatingOfOnePE(); - if(numQueues_ > 1 && profile_.getNumberOfQueues() != numQueues_) { + int partInProfile = profile_.queues_.size(); + if(numPartitions_ > 1 && partInProfile != numPartitions_) { System.out.println(super.get_name() + ".body(): The scheduler" + - " is expected to have " + numQueues_ + " queues. However," + - " only " + profile_.getNumberOfQueues() + " have been defined"); + " is expected to have " + numPartitions_ + " queues. However," + + " only " + partInProfile + " have been defined"); return; } + else if (profile_.getNumberOfAssignedPEs() > resource_.getNumPE()) { + System.out.println(super.get_name() + ".body(): " + + "Error, you have assigned more PEs to the queues than available "+ + "at the resource"); + return; + } - //TODO: To validate the processing elements assigned to the queues - - // if the user has not specified the queues and the scheduler is - // expected to have only one queue, then creates the queue and - // includes it in the list. - if(profile_.getNumberOfQueues() == 0 && numQueues_ == 1) { - // creates the accept all predicate - QueuePredicate predicate = new QueuePredicate() { + // if the user has not specified the partitions and the scheduler is + // expected to have only one partition. So, it creates the partition and + // assigns an accept-all predicate to it. + if(partInProfile == 0 && numPartitions_ == 1) { + QueuePartitionPredicate predicate = new QueuePartitionPredicate() { public boolean match(SSGridlet gridlet) { return true; } }; - EasyBackFillingQueue queue = - new EasyBackFillingQueue(0, resource_.getNumPE(), predicate); - queue.idlePERanges_ = resource_.getFreePERanges().clone(); - profile_.addQueue(queue); + QueuePartition partition = + new QueuePartition(0, resource_.getNumPE(), predicate); + + partition.idlePERanges_ = resource_.getFreePERanges().clone(); + profile_.queues_.put(partition.partitionId_, partition); } - // assigns the PEs to the queues + // divides the PEs and assigns them to the partitions else { int allocPE = 0; PERangeList freeRanges = resource_.getFreePERanges().clone(); - for(EasyBackFillingQueue queue : profile_.queues_.values()) { - allocPE += queue.initialNumPEs_; - - if(allocPE > resource_.getNumPE()) { - System.out.println(super.get_name() + ".body(): The scheduler" + - " cannot allocate PEs to all queues because there are not" + - " anough PEs"); - return; - } - - PERangeList selected = super.selectPERangeList(queue.initialNumPEs_, freeRanges); - queue.idlePERanges_ = selected; + for(QueuePartition partition : profile_.queues_.values()) { + allocPE += partition.initialNumPEs_; + PERangeList selected = + super.selectPERangeList(partition.initialNumPEs_, freeRanges); + partition.idlePERanges_ = selected; freeRanges = PERangeList.difference(freeRanges, selected); } } @@ -192,10 +254,17 @@ } // reset variables to default values - runningGridlets_.clear(); + runningGridlets_.clear(); + queuedGridlets_.clear(); + profile_.clear(); lastScheduleUpdate_ = 0.0D; ratingPE_ = 0; resource_.resetFreePERanges(); + + for(QueuePartition partition : profile_.queues_.values()) { + partition.idlePERanges_ = null; + partition.pivot_ = null; + } } /** @@ -230,7 +299,7 @@ } // Create a resource Gridlet - MQGridlet sgl = new MQGridlet(gridlet); + SSGridlet sgl = new SSGridlet(gridlet); //-------------- FOR DEBUGGING PURPOSES ONLY -------------- @@ -258,7 +327,7 @@ return; } - sgl.setQueueID(queueId); + sgl.setPartitionID(queueId); // If there are no jobs in the queue list, then check if // there are enough PEs to process the job immediately @@ -270,9 +339,6 @@ queuedGridlets_.add(sgl); } -// System.out.println("\nFree Ranges=" + profile_.getIdlePEsPerQueue()); -// System.out.println(profile_); - //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- // Notifies the listeners that a Gridlet has been either scheduled @@ -362,32 +428,33 @@ // -------------------- PRIVATE METHODS ---------------------------- /** - * + * Tries to start a gridlet if there are enough processing elements + * available at the current simulation time. + * @param sgl the gridlet to be started */ - private boolean startGridlet(MQGridlet sgl) { + private boolean startGridlet(SSGridlet sgl) { int reqPE = sgl.getNumPE(); if(reqPE > resource_.getNumFreePE()) return false; - boolean success = false; // to test various conditions - int queueId = sgl.getQueueID(); + boolean success = false; // to test a few conditions + int queueId = sgl.getPartitionID(); - // calculate the execution time of the Gridlet double executionTime = super.forecastExecutionTime(ratingPE_, sgl.getRemainingLength()); + + double currentTime = GridSim.clock() ; // calculates how much ahead to look into the availability profile - double currentTime = GridSim.clock() ; - // the Gridlet's expected finish time if it starts now double finishTime = currentTime + executionTime; + // checks the availability of PEs in the selected partition PERangeList ranges = profile_.getImmediateAvailability(queueId, executionTime); - - // if the above method returns null, it means that there are not enough - // PEs to serve the reservation or Gridlet + + // if there are enough PEs in the queue, then allocate them if(ranges.getNumPE() >= reqPE) { ranges = super.selectPERangeList(reqPE, ranges); profile_.allocateImmediateRanges(queueId, finishTime, ranges); @@ -395,34 +462,27 @@ } // If the queue to which the gridlet is assigned does not have the - // required PEs, then try to borrow the additional PEs from other queues. + // required PEs, then tries to borrow the additional PEs from other queues if(!success) { + // gets all available PEs during given time interval PERangeList overallAvailPEs = profile_.getImmediateAvailability(executionTime); // additional PEs required int addRequired = reqPE - ranges.getNumPE(); + // removes PEs already obtained from selected partition PERangeList addRanges = PERangeList.difference(overallAvailPEs, ranges); if(addRanges != null && addRanges.getNumPE() >= addRequired) { - // subtracts the ranges already obtained from the gridlet's queue - -// System.out.println("\nRanges to Add to queue " + queueId +" = " + -// addRanges + "\noverall = " + overallAvailPEs + -// "\n overall num available = " + overallAvailPEs.getNumPE() + -// "\n free PEs = " + resource_.getNumFreePE() + -// "\n free PEs profile = " + profile_.getNumFreePEs() + -// "\n PEs from the queue = " + ranges.getNumPE() + -// "\n req PEs = " + reqPE); - - // borrows the ranges from the queues and adds it into the - // specified queue + + // borrows the additional PEs required from the partitions + // and adds them into the specified queue addRanges = super.selectPERangeList(addRequired, addRanges); profile_.transferPEs(queueId, addRanges, currentTime, finishTime); - // allocate the ranges to the job + // allocates the ranges to the gridlet ranges.addAll(addRanges); profile_.allocateImmediateRanges(queueId, finishTime, ranges); success = true; @@ -430,7 +490,7 @@ } if(!success) - return false; + return false; // it was not possible to schedule the gridlet // sets the PEs to busy at resource class. This is just to provide // information to other classes that may query it @@ -462,13 +522,17 @@ } /** + * Tries to schedule a gridlet. Only the first job in the waiting queue + * for a given partition is scheduled. If a pivot for that partition already + * exists, them the method returns <tt>null</tt> * @param sgl the resource gridlet + * return <tt>true</tt> if gridlet was scheduled; <tt>false</tt> otherwise. */ - private boolean scheduleGridlet(MQGridlet sgl) { + private boolean scheduleGridlet(SSGridlet sgl) { int reqPE = sgl.getNumPE(); - int queueId = sgl.getQueueID(); + int queueId = sgl.getPartitionID(); - EasyBackFillingQueue queue = profile_.getQueue(queueId); + QueuePartition queue = profile_.getQueue(queueId); // if queue has a pivot already, then just add // the job to the waiting queue @@ -485,10 +549,13 @@ double startTime = -1; // keep the potential start time of the gridlet double finishTime = -1; // store the gridlet's expected finish time - // check whether there are PEs available over the time interval requested + // check when enough PEs to handle the gridlet will be available at + // the partition without borrowing PEs Object[] availObjQueue = profile_.checkPERangesAvailability(queueId, reqPE, executionTime); + // check when enough PEs to handle the gridlet will be available + // considering all the partitions Object[] availObj = profile_.checkPERangesAvailability(reqPE, executionTime); @@ -501,11 +568,12 @@ startTimeQueue=profile_.get(anchor).getTime(); } -// System.out.println(profile_); - anchor = (Integer)availObj[0]; double startTimeAll = profile_.get(anchor).getTime(); + // if the time if the selected partition is smaller or the same as + // considering all the partitions, so that means that we can select + // resources from the selected partition if(startTimeQueue <= startTimeAll) { ranges = (PERangeList)availObjQueue[2]; ranges = super.selectPERangeList(reqPE, ranges); @@ -524,7 +592,8 @@ else { PERangeList addRanges = (PERangeList)availObj[2]; - // the anchor index, the entry in the profile where the gridlet will be placed + // the anchor index, the entry in the profile where + // the gridlet will be placed int anchorIndex = (Integer)availObj[0]; // insert index represents the position after which the entry // corresponding to the gridlet's finish time will be placed @@ -534,16 +603,19 @@ startTime = startTimeAll; finishTime = startTime + executionTime; + // checks what PEs from those selected already belong + // to the gridlet's partition availObjQueue = profile_.checkPERangesAvailability(queueId, startTime, executionTime); - ranges = availObjQueue == null ? new PERangeList() : (PERangeList)availObjQueue[2]; - addRanges = availObjQueue == null ? addRanges : PERangeList.difference(addRanges, ranges); + ranges = availObjQueue == null ? new PERangeList() : + (PERangeList)availObjQueue[2]; + + addRanges = availObjQueue == null ? addRanges : + PERangeList.difference(addRanges, ranges); + addRanges = super.selectPERangeList(reqPE - ranges.getNumPE(), addRanges); -// System.out.println("\nRanges to transfer to queue " + queueId +" = " + -// addRanges + " from " + startTime + " to " + finishTime); - // borrows the ranges from the queues and adds it into the // specified queue profile_.transferPEs(queueId, addRanges, startTime, finishTime); @@ -647,9 +719,9 @@ int itemsFinished = 0; // iterates the list to check what has finished - Iterator<MQGridlet> iter = runningGridlets_.iterator(); + Iterator<SSGridlet> iter = runningGridlets_.iterator(); while (iter.hasNext()) { - MQGridlet gridlet = iter.next(); + SSGridlet gridlet = iter.next(); // as gridlets are removed from running queue once they finish // time is smaller than current time, then testing the time // is enough. There's no need to check status @@ -675,7 +747,7 @@ // first checks whether the pivots can be started // checks the pivots first - for(EasyBackFillingQueue queue : profile_.queues_.values()) { + for(QueuePartition queue : profile_.queues_.values()) { if(queue.pivot_ != null && queue.pivot_.getStartTime() <= currentTime) { runningGridlets_.add(queue.pivot_); queuedGridlets_.remove(queue.pivot_); @@ -691,9 +763,9 @@ // Start the execution of Gridlets that are queued and whose // potential start execution time is smaller than reference time - Iterator<MQGridlet> iter = queuedGridlets_.iterator(); + Iterator<SSGridlet> iter = queuedGridlets_.iterator(); while (iter.hasNext()) { - MQGridlet gridlet = iter.next(); + SSGridlet gridlet = iter.next(); if(gridlet.getStartTime() < 0) { boolean success = startGridlet(gridlet); @@ -725,73 +797,53 @@ super.sendFinishGridlet( sgl.getGridlet() ); } - - private class EasyBackFillingQueue { - int queueId_; // this queue's identifier + // ---------------------- PRIVATE CLASSES ------------------------ + + /** + * This class represents a partition in this scheduler. It only + * stores a few variables used to control the partition. + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + */ + private class QueuePartition { + int partitionId_; // this partition's identifier int initialNumPEs_; // the initial number of PEs allocated - PERangeList idlePERanges_; // idle resources in this queue - MQGridlet pivot_; // the first job of this queue in the general waiting queue + PERangeList idlePERanges_; // idle resources in this partition + SSGridlet pivot_; // the first job of this queue in the general waiting queue // to check whether a gridlet can be scheduled in this queue - QueuePredicate predicate_; + QueuePartitionPredicate predicate_; - protected EasyBackFillingQueue(int queueId, - int numPE, QueuePredicate predicate) { - this.queueId_ = queueId; + protected QueuePartition(int queueId, + int numPE, QueuePartitionPredicate predicate) { + this.partitionId_ = queueId; initialNumPEs_ = numPE; predicate_ = predicate; pivot_ = null; } - - protected int getNumIdlePEs() { - return (idlePERanges_ == null) ? 0 : idlePERanges_.getNumPE(); - } } - private class MQGridlet extends SSGridlet { - private int queueId_; - private int priority_; - - public MQGridlet(Gridlet gridlet) { - super(gridlet); - queueId_ = UNKNOWN; - } - - public void setQueueID(int queueId) { - queueId_ = queueId; - } - - public int getQueueID() { - return queueId_; - } - - public int getPriority() { - return priority_; - } - - public void setPriority(int priority) { - this.priority_ = priority; - } - } - /** - * This class represents an entry in the usage profile. There is an entry + * This class represents an entry in the profile. There is an entry * at most in the usage profile for each job scheduled by this policy. * * @author Marcos Dias de Assuncao * @since GridSim Turbo Alpha 0.1 */ private class ProfileEntry { + // the ranges available + private HashMap <Integer, PERangeList> ranges_; + // the time when the ranges will be available + private double time_; + // number of gridlets that rely on this entry + // to mark their completion time or anchor point + private int numGridlets_ = 1; - private HashMap <Integer, PERangeList> ranges_; // the ranges available - private double time_; // the time when the ranges will be available - private int numGridlets_ = 1; // number of gridlets that rely on this entry - // to mark their completion time or anchor point /** * Creates an instance of @link{ProfileEntry}. * @param time the time associated with this event */ - public ProfileEntry(double time) { + protected ProfileEntry(double time) { time_ = time; ranges_ = new HashMap<Integer, PERangeList>(); } @@ -801,11 +853,15 @@ * @param queue the queue whose ranges should be obtained * @return the ranges of free PEs associated with this entry */ - public PERangeList getPERanges(int queue) { + protected PERangeList getPERanges(int queue) { return ranges_.get(queue); } - - public PERangeList getPERanges() { + + /** + * Returns the general ranges of free PEs associated with this entry + * @return the ranges of free PEs associated with this entry + */ + protected PERangeList getPERanges() { PERangeList result = new PERangeList(); for(PERangeList list : ranges_.values()) { if(list.getNumPE() > 0) @@ -819,12 +875,13 @@ * @param queue the queue whose ranges should be set * @param list the range of PEs */ - public void setPERangeList(int queue, PERangeList list) { + protected void setPERangeList(int queue, PERangeList list) { ranges_.put(queue, list); // testNumPEs(); } - private void testNumPEs() { + // FOR DEBUGGING PURPOSES ONLY + protected void testNumPEs() { try { if(getNumPE() > resource_.getNumPE()) throw new Exception("Entry contains more PEs than the maximum allowed"); @@ -834,22 +891,21 @@ System.exit(1); } } - /** * Returns the time associated with this entry * @return the time associated */ - public double getTime() { + protected double getTime() { return time_; } /** * Gets the number of PEs associated with this entry * @param queue the queue whose number of PEs be obtained - * @return the number of PEs + * @return the number of PEs available for the queue */ - public int getNumPE(int queue) { + protected int getNumPE(int queue) { PERangeList ranges = getPERanges(queue); if(ranges == null) return 0; @@ -857,38 +913,43 @@ return ranges.getNumPE(); } - public int getNumPE() { + /** + * Gets the number of PEs associated with this entry + * @return the number of PEs + */ + protected int getNumPE() { int numPE = 0; for(PERangeList list : ranges_.values()) { numPE += list.getNumPE(); } return numPE; } - - public void transferPEs(int recQueueId, PERangeList list) { - + + /** + * Transfers PEs from partitions to one selected partition + * @param recQueueId the partition receiving the ranges + * @param list the list of ranges + */ + protected void transferPEs(int recQueueId, PERangeList list) { for(Integer queueId : ranges_.keySet()) { -// if(queueId != recQueueId) { - PERangeList uptList = PERangeList.difference(ranges_.get(queueId), list); - if(uptList == null) - uptList = new PERangeList(); - ranges_.put(queueId, uptList); -// } + PERangeList uptList = PERangeList.difference(ranges_.get(queueId), list); + if(uptList == null) + uptList = new PERangeList(); + ranges_.put(queueId, uptList); } PERangeList queueList = ranges_.get(recQueueId); queueList.addAll(list.clone()); queueList.mergePERanges(); ranges_.put(recQueueId, queueList); - -// testNumPEs(); +// testNumPEs(); // for debugging purposes } /** * Sets the time associated with this event * @param time the time to be set */ - public void setTime(double time) { + protected void setTime(double time) { time_ = time; } @@ -896,7 +957,7 @@ * Increases the number of Gridlets that rely on this entry to mark * their expected completion time or their anchor point */ - public void increaseGridlet() { + protected void increaseGridlet() { numGridlets_++; } @@ -904,7 +965,7 @@ * Decreases the number of Gridlets that rely on this entry to mark * their expected completion time or their anchor point */ - public void decreaseGridlet() { + protected void decreaseGridlet() { numGridlets_--; } @@ -913,7 +974,7 @@ * their expected completion time or their anchor point * @return the number of Gridlets that use this entry */ - public int getNumGridlets() { + protected int getNumGridlets() { return numGridlets_; } @@ -923,7 +984,7 @@ * @param time the time for the cloned entry * @return the cloned entry */ - public ProfileEntry clone(double time) { + protected ProfileEntry clone(double time) { ProfileEntry clone = new ProfileEntry(time); for(Integer queueId : ranges_.keySet()) { PERangeList clonedRanges = ranges_.get(queueId).clone(); @@ -953,59 +1014,60 @@ /** * This class represents the profile containing the ranges of PEs * available at given simulation times + * * @author Marcos Dias de Assuncao * @since GridSim Turbo Alpha 0.1 */ - private class Profile extends ArrayList<ProfileEntry> { + private class MultiPartitionProfile extends ArrayList<ProfileEntry> { private static final long serialVersionUID = -1853610061073508770L; // The queues used by this scheduler - HashMap<Integer, EasyBackFillingQueue> queues_; + HashMap<Integer, QueuePartition> queues_; /** * Creates a new @link{AvailabilityProfile} object. */ - public Profile() { + protected MultiPartitionProfile() { super(); - queues_ = new HashMap<Integer, EasyBackFillingQueue>(); + queues_ = new HashMap<Integer, QueuePartition>(); } - public void addQueue(EasyBackFillingQueue queue) { - queues_.put(queue.queueId_, queue); + /** + * Returns the number of PEs assigned to the partitions + * @return the number of PEs assigned to the partitions + */ + protected int getNumberOfAssignedPEs() { + int numPEs = 0; + for(QueuePartition queue : queues_.values()) { + numPEs += queue.initialNumPEs_; + } + return numPEs; } - public int getNumberOfQueues() { - return queues_.size(); - } - - - public EasyBackFillingQueue getQueue(int queueId) { + /** + * Gets a partition with the given ID + * @param queueId the id of the partition + * @return the partition with the given ID + */ + protected QueuePartition getQueue(int queueId) { return queues_.get(queueId); } - public int getCorrespondingQueue(SSGridlet sgl) { - for(EasyBackFillingQueue queue : queues_.values()) { + /** + * Gets the able to handle the given gridlet + * @param sgl the gridlet for which a partition is to be found + * @return the partition ID + */ + protected int getCorrespondingQueue(SSGridlet sgl) { + for(QueuePartition queue : queues_.values()) { if(queue.predicate_.match(sgl)) - return queue.queueId_; + return queue.partitionId_; } return UNKNOWN; } /** - * Returns a clone of this object.<br> - * <b>NOTE:</b> this method does not clone the entries - * @return the cloned object - */ - public Profile clone() { - Profile clone = new Profile(); - for(ProfileEntry entry : this){ - clone.add(entry); - } - return clone; - } - - /** * Returns the entry whose time is closest to the <tt>time</tt> given but * smaller, or whose time is equals to <tt>time</tt> * @param time the time to be used to search for the entry @@ -1032,8 +1094,10 @@ * entries whose date is smaller or equals to refTime will * be removed. * @param refTime the reference time to be used for entry removal. + * @return the last entry removed or <tt>null</tt> if no + * entry has been removed */ - public ProfileEntry removePastEntries(double refTime) { + protected ProfileEntry removePastEntries(double refTime) { // Update the availability profile ProfileEntry lastRemoved = null; Iterator<ProfileEntry> iterProfile = super.iterator(); @@ -1051,23 +1115,27 @@ return lastRemoved; } + /** + * Updates the idle PEs at the queues based on a given profile entry + * @param status the profile entry to bed used + */ protected void setCurrentStatus(ProfileEntry status) { - for(EasyBackFillingQueue queue : queues_.values()) { - queue.idlePERanges_ = status.getPERanges(queue.queueId_).clone(); + for(QueuePartition queue : queues_.values()) { + queue.idlePERanges_ = status.getPERanges(queue.partitionId_).clone(); } } /** - * Selects a list of PE ranges able to provide enough - * PEs to handle a Gridlet. + * Checks what are the PEs available for the specified queue during + * the given time duration. * @param duration the duration of the Gridlet - * @return the list of ranges of PEs that can be used by the gridlet. - * Note that this method may return more PEs than the gridlet requires. + * @return the list of ranges of PEs that can be used + * during the given period. */ - private PERangeList getImmediateAvailability(int queueId, double duration) { + protected PERangeList getImmediateAvailability(int queueId, double duration) { double startTime = GridSim.clock(); // start time is now - EasyBackFillingQueue queue = queues_.get(queueId); + QueuePartition queue = queues_.get(queueId); // the gridlet's expected finish time double finishTime = startTime + duration; @@ -1076,8 +1144,8 @@ PERangeList intersectList = queue.idlePERanges_.clone(); // scan the availability profile until the expected termination - // of the Gridlet to check whether enough PEs will be available - // for the Gridlet. Stop the search if not enough PEs are available + // of the Gridlet to check what PEs will be available. Stops the + // search if no PEs are found at a particular time for(ProfileEntry entry : this) { double entryTime = entry.getTime(); if(entryTime < startTime) { @@ -1092,27 +1160,31 @@ if(entryTime < finishTime) { PERangeList listEntry = entry.getPERanges(queueId); intersectList = PERangeList.intersection(intersectList, listEntry); - if(intersectList == null) + if(intersectList == null || intersectList.getNumPE() == 0) break; } } } - // return null if the number of PEs available over the required - // time interval is smaller than what the Gridlet/Reservation requires + // To avoid returning null if(intersectList == null) { - return new PERangeList(); + intersectList = new PERangeList(); } // the PEs that can be used by the gridlet return intersectList; } - + /** + * Creates an entry to be used as anchor when the profile is empty. + * The entry is based on the currently idle PEs at the partitions + * @param time the time for the entry + * @return the entry created. + */ private ProfileEntry createHeadEntry(double time) { ProfileEntry entry = new ProfileEntry(time); - for(EasyBackFillingQueue queue : queues_.values()) { - entry.setPERangeList(queue.queueId_, queue.idlePERanges_.clone()); + for(QueuePartition queue : queues_.values()) { + entry.setPERangeList(queue.partitionId_, queue.idlePERanges_.clone()); } return entry; } @@ -1120,14 +1192,15 @@ /** * Allocates a list of PE ranges to a gridlet or and updates the * availability profile accordingly + * @param queueId the partition from which PEs have been selected * @param finishTime the finish time of the Gridlet * @param selected the list of PE ranges selected */ - public void allocateImmediateRanges(int queueId, double finishTime, + protected void allocateImmediateRanges(int queueId, double finishTime, PERangeList selected) { double startTime = GridSim.clock(); // start time is now - EasyBackFillingQueue queue = queues_.get(queueId); + QueuePartition queue = queues_.get(queueId); // check whether a new tail is needed to mark the end of the request ProfileEntry tailEntry = getPrecedingEntry(finishTime); @@ -1154,53 +1227,37 @@ continue; } else { - PERangeList difference = PERangeList.difference(entry.getPERanges(queueId), selected); + PERangeList difference = + PERangeList.difference(entry.getPERanges(queueId), selected); difference = difference == null ? new PERangeList() : difference; entry.setPERangeList(queueId, difference); } } - PERangeList difference = PERangeList.difference(queue.idlePERanges_, selected); + PERangeList difference = PERangeList.difference(queue.idlePERanges_, selected); + // avoid idle PEs from being null difference = difference == null ? new PERangeList() : difference; - queue.idlePERanges_ = difference; + queue.idlePERanges_ = difference; } - /* + /** * Gets the idle PEs in all queues */ - private PERangeList getOverallIdlePEs() { + protected PERangeList getOverallIdlePEs() { PERangeList idlePEs = new PERangeList(); - for(EasyBackFillingQueue queue: queues_.values()) { + for(QueuePartition queue: queues_.values()) { if(queue.idlePERanges_.getNumPE() > 0) idlePEs.addAll(queue.idlePERanges_.clone()); } return idlePEs; } - private ProfileEntry getIdlePEsPerQueue() { - ProfileEntry entry = new ProfileEntry(GridSim.clock()); - for(EasyBackFillingQueue queue: queues_.values()) { - entry.setPERangeList(queue.queueId_, queue.idlePERanges_.clone()); - } - return entry; - } - - private int getNumFreePEs() { - int freePE = 0; - for(EasyBackFillingQueue queue: queues_.values()) { - freePE += queue.idlePERanges_.getNumPE(); - } - return freePE; - } - /** - * Selects a list of PE ranges able to provide enough - * PEs to handle a Gridlet. + * Checks what PE ranges are available during the given interval. * @param duration the duration of the Gridlet - * @return the list of ranges of PEs that can be used by the gridlet. - * Note that this method may return more PEs than the gridlet requires. + * @return the list of ranges of PEs available */ - private PERangeList getImmediateAvailability(double duration) { + protected PERangeList getImmediateAvailability(double duration) { double startTime = GridSim.clock(); // start time is now @@ -1211,8 +1268,8 @@ PERangeList intersectList = getOverallIdlePEs(); // scan the availability profile until the expected termination - // of the Gridlet to check whether enough PEs will be available - // for the Gridlet. Stop the search if not enough PEs are available + // of the Gridlet to check what PEs will be available until the + // finishTime. Stops the search if it finds null resources for(ProfileEntry entry : this) { double entryTime = entry.getTime(); if(entryTime < startTime) { @@ -1227,24 +1284,33 @@ if(entryTime < finishTime) { PERangeList listEntry = entry.getPERanges(); intersectList = PERangeList.intersection(intersectList, listEntry); - if(intersectList == null) + if(intersectList == null || intersectList.getNumPE() == 0) break; } } } - // return null if the number of PEs available over the required - // time interval is smaller than what the Gridlet/Reservation requires + // to avoid returning null if(intersectList == null) { - return new PERangeList(); + intersectList = new PERangeList(); } // the PEs that can be used by the gridlet return intersectList; } - /* - * + /** + * Checks when anough PEs ranges will be available at a given queue to + * handle a given gridlet + * @param queueId the selected queue + * @param reqPE the number of PEs required + * @param duration the duration of the gridlet + * @return an array where: + * array[0] = index of entry used as anchor + * array[1] = index of entry closest to the completion + * array[2] = the list of PEs available at that time + * or <tt>null</tt> if not enough pes will be available at the queue at + * any time */ protected Object[] checkPERangesAvailability(int queueId, int reqPE, double duration) { @@ -1341,8 +1407,15 @@ return result; } - /* - * + /** + * Checks when anough PEs ranges will be available at all queues to + * handle a given gridlet + * @param reqPE the number of PEs required + * @param duration the duration of the gridlet + * @return an array where: + * array[0] = index of entry used as anchor + * array[1] = index of entry closest to the completion + * array[2] = the list of PEs available at that time */ protected Object[] checkPERangesAvailability(int reqPE, double duration) { @@ -1438,9 +1511,17 @@ return result; } - - - private void allocatePERanges(int queueId, + /** + * Allocate processing elements to a gridlet + * @param queueId the id of the gridlet's selected partition + * @param anchorIndex the index of the entry used as anchor + * @param tailIndex the index of the last entry close to the gridlet's + * finish time + * @param selected the selected ranges of PEs + * @param startTime the gridlet's start time + * @param finishTime the gridlet's finish time + */ + protected void allocatePERanges(int queueId, int anchorIndex, int tailIndex, PERangeList selected, double startTime, double finishTime) { @@ -1489,10 +1570,18 @@ } } - private Object[] checkPERangesAvailability(int queueId, + /** + * Checks what ranges of PEs will be available for a gridlet in its + * partition a given time over a period of time + * @param queueId the selected partition id + * @param startTime the start time of the gridlet + * @param duration the duration of the gridlet + * @return the ranges of PEs available + */ + protected Object[] checkPERangesAvailability(int queueId, double startTime, double duration) { - EasyBackFillingQueue queue = queues_.get(queueId); + QueuePartition queue = queues_.get(queueId); // the anchor index, the entry in the profile where // the gridlet will be placed OR the closest entry to the @@ -1555,8 +1644,6 @@ } if(intersectList == null || intersectList.getNumPE() == 0) { - // there are not enough PEs available to serve the - // advance reservation request, then returns null return null; } } @@ -1572,25 +1659,31 @@ return result; } + /** + * Transfers ranges of PEs from other partitons to a selected partition + * @param recQueueId the partition that will receive the PEs + * @param list the list of ranges of PEs to transfer + * @param startTime the start time of the transfer + * @param finishTime the finish time of the transfer + */ protected void transferPEs(int recQueueId, PERangeList list, double startTime, double finishTime) { - + + // if start time is equals to current time, then we have + // to transfer ranges across the idle pes as well if(startTime <= GridSim.clock()) { - for(EasyBackFillingQueue queue : queues_.values()) { -// if(queue.queueId_ != recQueueId) { - queue.idlePERanges_ = PERangeList.difference(queue.idlePERanges_, list); - if(queue.idlePERanges_ == null) - queue.idlePERanges_ = new PERangeList(); -// } + for(QueuePartition queue : queues_.values()) { + queue.idlePERanges_ = PERangeList.difference(queue.idlePERanges_, list); + if(queue.idlePERanges_ == null) + queue.idlePERanges_ = new PERangeList(); } - EasyBackFillingQueue queue = queues_.get(recQueueId); -// queue.idlePERanges_ = PERangeList.difference(queue.idlePERanges_, list); -// queue.idlePERanges_ = queue.idlePERanges_ == null ? new PERangeList() : queue.idlePERanges_; + QueuePartition queue = queues_.get(recQueueId); queue.idlePERanges_.addAll(list.clone()); queue.idlePERanges_.mergePERanges(); } + // transfer the ranges for(int i=0; i<super.size(); i++) { ProfileEntry nextEntry = super.get(i); if(nextEntry.getTime() < startTime) @@ -1603,11 +1696,6 @@ } } } - - protected void releaseRanges(int queueId, PERangeList ranges) { - EasyBackFillingQueue queue = queues_.get(queueId); - queue.idlePERanges_.addAll(ranges.clone()); - } /** * Creates an string representation of the profile Copied: branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartitionPredicate.java (from rev 102, branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePredicate.java) =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartitionPredicate.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartitionPredicate.java 2008-02-15 04:13:00 UTC (rev 103) @@ -0,0 +1,29 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + */ + +package gridsim.turbo; + +/** + * This interface is used to filter what gridlets should be put in a given + * partition by policies that use multiple partitions or queues. See for + * example {@link MultipleEasyBackfillingQueues}. + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + */ + +public interface QueuePartitionPredicate { + + /** + * Checks whether a given gridlet meets the criteria of the partition. + * @param gridlet the gridlet to be considered for scheduling. + * @return <tt>true</tt> if the gridlet can be included in this + * partition; <tt>false</tt> otherwise. + */ + boolean match(SSGridlet gridlet); + +} Deleted: branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePredicate.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePredicate.java 2008-02-14 12:00:22 UTC (rev 102) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePredicate.java 2008-02-15 04:13:00 UTC (rev 103) @@ -1,28 +0,0 @@ -/* - * Title: GridSim Toolkit - * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation - * of Parallel and Distributed Systems such as Clusters and Grids - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html - */ - -package gridsim.turbo; - -/** - * This interface is used to filter what gridlets should be put in a given - * scheduling queue by the {@link MultipleEasyBackfillingQueues}. - * - * @author Marcos Dias de Assuncao - * @since GridSim Turbo Alpha 0.1 - */ - -public interface QueuePredicate { - - /** - * Checks whether a given gridlet meet the criteria of the scheduling queue. - * @param gridlet the gridlet to be considered for scheduling. - * @return <tt>true</tt> whether the gridlet can be included in this - * queue, or <tt>false</tt> otherwise. - */ - boolean match(SSGridlet gridlet); - -} Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2008-02-14 12:00:22 UTC (rev 102) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2008-02-15 04:13:00 UTC (rev 103) @@ -9,6 +9,7 @@ import java.text.DecimalFormat; +import gridsim.GridResource; import gridsim.GridSim; import gridsim.Gridlet; import gridsim.gui.GridSimVisualizer; @@ -49,7 +50,14 @@ private int numPE_; // A list of ranges of PEs used by this Gridlet - private PERangeList peRangeList_ = null; + private PERangeList peRangeList_ = null; + + // the partiton or queue in the resource to which this + // gridlet was scheduled + private int partition_; + + // the priority of this gridlet assigned by the scheduler + private int priority_; // NOTE: Below attributes are related to AR stuff private final int NOT_FOUND = -1; @@ -287,6 +295,50 @@ } /** + * Gets the id of the partition or queue to which this + * gridlet was scheduled + * @return the partition id or <tt>-1</tt> if not found + */ + public int getPartitionID() { + return partition_; + } + + /** + * Sets the id of the partition or queue to which this + * gridlet was scheduled + * @param partition the partition id + * @return <tt>true</tt> if set correctly or <tt>false</tt> otherwise. + */ + public boolean setPartitionID(int partition) { + if(partition < 0) + return false; + + partition_ = partition; + return true; + } + + /** + * Gets the priority of this gridlet assigned by the scheduler + * @return the priority or <tt>-1</tt> if not found + */ + public int getPriority() { + return priority_; + } + + /** + * Sets the priority of this gridlet assigned by the scheduler + * @param priority the priority + * @return <tt>true</tt> if set correctly or <tt>false</tt> otherwise. + */ + public boolean setPriority(int priority) { + if(priority < 0) + return false; + + priority_ = priority; + return true; + } + + /** * Gets the remaining gridlet length * @return gridlet length * @pre $none @@ -476,6 +528,8 @@ this.startTime_ = NOT_FOUND; this.totalCompletionTime_ = 0.0; this.startExecTime_ = 0.0; + this.partition_ = NOT_FOUND; + this.priority_ = NOT_FOUND; // In case a Gridlet has been executed partially by some other grid // ... [truncated message content] |
From: <mar...@us...> - 2008-03-18 00:40:33
|
Revision: 161 http://gridsim.svn.sourceforge.net/gridsim/?rev=161&view=rev Author: marcos_dias Date: 2008-03-17 17:40:38 -0700 (Mon, 17 Mar 2008) Log Message: ----------- This update contains: + An additional item in the Options menu at the ResourceWindow that allows the user to visualise to which partition the jobs belong + A bug fix in the advance reservation features of the multiple partition policies. There were overlaps of advance reservations and normal jobs when using advance reservations. The transfer of PEs to the queue to which the advance reservation belongs, was not being done correctly. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java 2008-03-18 00:40:38 UTC (rev 161) @@ -96,10 +96,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java 2008-03-18 00:40:38 UTC (rev 161) @@ -96,10 +96,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-03-18 00:40:38 UTC (rev 161) @@ -85,10 +85,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java 2008-03-18 00:40:38 UTC (rev 161) @@ -43,12 +43,17 @@ private Composite transparentComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f); - private final Color[] colorQueued = createPalette(153, 153, 255, 40, 6); - private final Color[] colorDone = createPalette(204, 204, 204, 30, 6); - private final Color[] colorInExec = createPalette(255, 255, 102, 25, 6); - private final Color[] colorARNonCommitted = createPalette(153, 255, 153, 51, 6); - private final Color[] colorARCommitted = createPalette(153, 255, 255, 51, 6); - private final Color[] colorARInProgress = createPalette(255, 102, 102, 25, 6); + private final int colorPerPalette = 6; + private final Color[] colorQueued = createPalette(153, 153, 255, 40, colorPerPalette); + private final Color[] colorDone = createPalette(204, 204, 204, 30, colorPerPalette); + private final Color[] colorInExec = createPalette(255, 255, 102, 25, colorPerPalette); + private final Color[] colorARNonCommitted = createPalette(153, 255, 153, 51, colorPerPalette); + private final Color[] colorARCommitted = createPalette(153, 255, 255, 51, colorPerPalette); + private final Color[] colorARInProgress = createPalette(255, 102, 102, 25, colorPerPalette); + private final Color[] colorQueues = + new Color[]{Color.WHITE, Color.RED, Color.GREEN, Color.CYAN, + Color.DARK_GRAY, Color.MAGENTA, Color.ORANGE, Color.PINK, + Color.YELLOW, Color.BLUE}; private static GUISettings settingsInstance_ = null; @@ -63,7 +68,7 @@ return settingsInstance_; } - + /** * Gets the time span for the GUI components * @return the time span for the GUI components @@ -238,6 +243,13 @@ return colors; } + /** + * Return the colours to be used for the partitions + * @return the colors for the partitions + */ + public Color[] getQueueColors() { + return this.colorQueues; + } /** * Returns an array of colours Modified: branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-03-18 00:40:38 UTC (rev 161) @@ -110,6 +110,7 @@ private boolean drawID_ = true; private boolean autoScroll_ = true; private boolean animate_ = true; + private boolean showPartition_ = false; private JButton btSetSdWindowSize_; private JTextField fdSdWindowSize_; @@ -142,6 +143,7 @@ private Color[] colorsARNonCommitted; private Color[] colorsARCommitted; private Color[] colorsARInProgress; + private Color[] colorQueues; private static final int WINDOW_WIDTH = 900; private static final int WINDOW_HEIGHT = 350; @@ -185,6 +187,7 @@ colorsARNonCommitted = settings_.getARNonCommittedColors(); colorsARCommitted = settings_.getARCommittedColors(); colorsARInProgress = settings_.getARInProgressColors(); + colorQueues = settings_.getQueueColors(); } // -------------------------- PUBLIC METHODS ----------------------- @@ -476,6 +479,25 @@ menuCommand.add(mnAnimation); + JMenu mnPartition = new JMenu("Partitions"); + JCheckBoxMenuItem miPartition = new JCheckBoxMenuItem("Show Partition Informations"); + miPartition.setSelected(false); + mnPartition.add(miPartition); + + miPartition.addItemListener(new ItemListener(){ + public void itemStateChanged(ItemEvent e){ + if (e.getStateChange() == ItemEvent.DESELECTED){ + showPartition_ = false; + } + else if (e.getStateChange() == ItemEvent.SELECTED){ + showPartition_ = true; + } + updateResourceWindow(); + } + }); + + menuCommand.add(mnPartition); + menuBar.add(menuCommand); setJMenuBar(menuBar); } @@ -698,10 +720,13 @@ continue; int itemId = item.getID(); - if (item.getPERangeList() != null){ + if (item.getPERangeList() != null) { // the color of the font for normal gridlets is black fontColor = Color.BLACK; - if(!item.isAdvanceReservation()) { + if(showPartition_) { + boxColor = colorQueues[item.getPartitionID() % colorQueues.length]; + } + else if(!item.isAdvanceReservation()) { // Gridlet is in execution if(item.getStatus() == Gridlet.INEXEC){ boxColor = colorsInExec[(itemId % colorsInExec.length)]; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-03-18 00:40:38 UTC (rev 161) @@ -302,6 +302,9 @@ int duration = reservation.getDurationTime(); int reqPE = reservation.getNumPE(); + if(startTime == 0) + startTime = currentTime; + // creates a Server Side Reservation (i.e. SSReservation) SSReservation sRes = new SSReservation(reservation); sRes.setPartitionID(profile_.getCorrespondingPartitionID(sRes)); @@ -335,8 +338,8 @@ boolean success = true; - // if start time is 0, then it is an immediate reservation - if(startTime == 0 || startTime == currentTime) { + // if start time = current time, then it is an immediate reservation + if(startTime == currentTime) { success = handleImmediateReservation(sRes); expTime = sRes.getActualFinishTime(); } @@ -1088,19 +1091,31 @@ tailIndex, selected, startTime, res.getActualFinishTime()); } else { + + // number of additional PEs required + int addRequired = reqPE - ranges.getNumPE(); - // check when enough PEs to handle the gridlet will be available + // check when enough PEs to handle the gridlet will be available // considering all the partitions Object[] availObj = profile_.checkPERangesAvailability(startTime, duration); + // removes PEs already obtained from selected partition PERangeList addRanges = availObj == null ? - new PERangeList() : (PERangeList)availObj[2]; + new PERangeList() : + PERangeList.difference((PERangeList)availObj[2], ranges); - if(addRanges.getNumPE() < reqPE) - return false; + if(addRanges == null || addRanges.getNumPE() < addRequired) + return false; - addRanges = super.selectPERangeList(reqPE - ranges.getNumPE(), addRanges); + // selects and transfers PEs to the queue o which the AR belongs + addRanges = super.selectPERangeList(addRequired, addRanges); + profile_.transferPEs(queueId, addRanges, + startTime, startTime + duration); + + // now get the availability of the queue again + availObj = profile_.checkPERangesAvailability(queueId, + startTime, duration); // the anchor index, the entry in the profile where // the gridlet will be placed @@ -1109,16 +1124,11 @@ // corresponding to the gridlet's finish time will be placed int tailIndex = (Integer)availObj[1]; - // borrows the ranges from the queues and adds it into the - // specified queue - profile_.transferPEs(queueId, addRanges, startTime, - startTime + duration); - // finally allocate the ranges to the gridlet - ranges.addAll(addRanges); + ranges = super.selectPERangeList(reqPE, (PERangeList)availObj[2]); profile_.allocatePERanges(queueId, anchorIndex, tailIndex, - ranges, startTime, startTime + duration); + ranges, startTime, startTime + duration); res.setPERangeList(ranges); } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-03-18 00:40:38 UTC (rev 161) @@ -306,6 +306,9 @@ int duration = reservation.getDurationTime(); int reqPE = reservation.getNumPE(); + if(startTime == 0) + startTime = currentTime; + // creates a Server Side Reservation (i.e. SSReservation) SSReservation sRes = new SSReservation(reservation); sRes.setPartitionID(profile_.getCorrespondingPartitionID(sRes)); @@ -337,10 +340,10 @@ return; } - boolean success = true; + boolean success = false; - // if start time is 0, then it is an immediate reservation - if(startTime == 0 || startTime == currentTime) { + // if start time = current time, then it is an immediate reservation + if(startTime == currentTime) { success = handleImmediateReservation(sRes); expTime = sRes.getActualFinishTime(); } @@ -917,7 +920,8 @@ //-------------- USED FOR DEBUGGING PURPOSES ONLY ----------------- // If a gridlet has been cancelled, then inform the listeners - GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_CANCELLED, true, removedRes); + GridSim.notifyListeners(this.get_id(), + AllocationAction.ITEM_CANCELLED, true, removedRes); //----------------------------------------------------------------- @@ -930,7 +934,8 @@ // If a gridlet has started execution or one has finished, // then inform the listeners - GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + GridSim.notifyListeners(this.get_id(), + AllocationAction.SCHEDULE_CHANGED, true); //----------------------------------------------------------------- } @@ -1093,37 +1098,44 @@ tailIndex, selected, startTime, res.getActualFinishTime()); } else { - - // check when enough PEs to handle the gridlet will be available + + // number of additional PEs required + int addRequired = reqPE - ranges.getNumPE(); + + // check when enough PEs to handle the gridlet will be available // considering all the partitions Object[] availObj = profile_.checkPERangesAvailability(startTime, duration); - + + // removes PEs already obtained from selected partition PERangeList addRanges = availObj == null ? - new PERangeList() : (PERangeList)availObj[2]; + new PERangeList() : + PERangeList.difference((PERangeList)availObj[2], ranges); - if(addRanges.getNumPE() < reqPE) + if(addRanges == null || addRanges.getNumPE() < addRequired) return false; - - addRanges = super.selectPERangeList(reqPE - ranges.getNumPE(), addRanges); + // selects and transfers PEs to the queue o which the AR belongs + addRanges = super.selectPERangeList(addRequired, addRanges); + profile_.transferPEs(queueId, addRanges, + startTime, startTime + duration); + + // now get the availability of the queue again + availObj = profile_.checkPERangesAvailability(queueId, + startTime, duration); + // the anchor index, the entry in the profile where // the gridlet will be placed int anchorIndex = (Integer)availObj[0]; // insert index represents the position after which the entry // corresponding to the gridlet's finish time will be placed int tailIndex = (Integer)availObj[1]; - - // borrows the ranges from the queues and adds it into the - // specified queue - profile_.transferPEs(queueId, addRanges, startTime, - startTime + duration); - + // finally allocate the ranges to the gridlet - ranges.addAll(addRanges); + ranges = super.selectPERangeList(reqPE, (PERangeList)availObj[2]); profile_.allocatePERanges(queueId, anchorIndex, tailIndex, - ranges, startTime, startTime + duration); + ranges, startTime, startTime + duration); res.setPERangeList(ranges); } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-18 00:40:38 UTC (rev 161) @@ -1322,10 +1322,6 @@ tailIndex++; } - if(addEntryAfterTail) { - availProfile_.add(tailIndex, newEntryAfterTail); - } - if (anchorIndex > -1) { AvailabilityProfileEntry anchorEntry = availProfile_.get(anchorIndex); @@ -1356,6 +1352,10 @@ availProfile_.add(anchorIndex, newEntryAfterAnchor); tailIndex++; } + + if(addEntryAfterTail) { + availProfile_.add(tailIndex, newEntryAfterTail); + } // Update entries of the profile if(tailIndex > -1) { Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java 2008-03-18 00:40:38 UTC (rev 161) @@ -411,6 +411,39 @@ // --------------------- PROTECTED METHODS ----------------------- + /** + * This method is called to update the schedule. It removes completed + * gridlets and return them to the users and verifies whether there are + * gridlets in the waiting list that should start execution. It also + * removes old entries from the availability profile. + */ + protected void updateSchedule() { + + double currentTime = GridSim.clock(); + + // then finishes the Gridlets whose start time is smaller + // or equals to the current simulation time + int itemsFinished = finishRunningGridlets(currentTime); + + // remove past entries from the availability profile + MPProfileEntry currentStatus = profile_.removePastEntries(currentTime); + if(currentStatus != null) { + profile_.setCurrentStatus(currentStatus); + resource_.resetFreePERanges(currentStatus.getPERanges()); + } + + // Start the execution of Gridlets that are queued and whose + // potential start execution time is smaller than current time + int itemsStarted = startQueuedGridlets(currentTime); + + //---------------- USED FOR DEBUGGING PURPOSES ONLY -------------------- + + // If a gridlet has started execution or one has finished, + // then inform the listeners + if(itemsStarted > 0 || itemsFinished > 0){ + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + } + } /** * This method finalises the gridlets in execution whose time Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-03-18 00:40:38 UTC (rev 161) @@ -93,7 +93,7 @@ // indicates whether the borrowing of resources by the // partitions is allowed or not - private boolean allowBorrowing_; + protected boolean allowBorrowing_; // the number of partitions or queues in this scheduler protected int numPartitions_; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-03-14 06:26:19 UTC (rev 160) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-03-18 00:40:38 UTC (rev 161) @@ -214,7 +214,7 @@ if (tailEntry == null) { MPProfileEntry newTail = createHeadEntry(finishTime); - super.add(super.indexOf(tailEntry) + 1, newTail); + super.add(0, newTail); } else if(tailEntry.getTime() < finishTime) { MPProfileEntry newTail = tailEntry.clone(finishTime); @@ -520,11 +520,11 @@ } /** - * Allocate processing elements to a gridlet + * Allocate processing elements to a gridlet/reservation * @param queueId the id of the gridlet's selected partition * @param anchorIndex the index of the entry used as anchor - * @param tailIndex the index of the last entry close to the gridlet's - * finish time + * @param tailIndex the index of the last entry close to the + * gridlet's finish time * @param selected the selected ranges of PEs * @param startTime the gridlet's start time * @param finishTime the gridlet's finish time @@ -573,10 +573,6 @@ tailIndex++; } - if(addEntryAfterTail) { - super.add(tailIndex, newEntryAfterTail); - } - if (anchorIndex > -1) { MPProfileEntry anchorEntry = super.get(anchorIndex); @@ -605,6 +601,10 @@ super.add(anchorIndex, newEntryAfterAnchor); tailIndex++; } + + if(addEntryAfterTail) { + super.add(tailIndex, newEntryAfterTail); + } // Update entries of the profile if(tailIndex > -1) { @@ -865,6 +865,23 @@ public void transferPEs(int recQueueId, PERangeList list, double startTime, double finishTime) { +// // creates a new entry to be used as the tail for the +// // time slot transfered to another queue. This is required to +// // mark the finish time of a slot given to an advance reservation +// MPProfileEntry tailEntry = getPrecedingEntry(finishTime); +// if(tailEntry != null && tailEntry.getTime() < finishTime) { +// int newTailIndex = super.indexOf(tailEntry) + 1; +// MPProfileEntry newTailEntry = tailEntry.clone(finishTime); +// super.add(newTailIndex, newTailEntry); +// } +// else if (tailEntry != null && tailEntry.getTime() == finishTime) { +// tailEntry.increaseGridlet(); +// } +// else if (tailEntry == null) { +// MPProfileEntry newTailEntry = createHeadEntry(finishTime); +// super.add(0, newTailEntry); +// } + // if start time is equals to current time, then we have // to transfer ranges across the idle pes as well if(startTime <= GridSim.clock()) { @@ -877,15 +894,32 @@ queue.getIdlePERanges().addAll(list.clone()); queue.getIdlePERanges().mergePERanges(); } + else { + // creates a new entry to be used as anchor for the + // time slot transfered to another queue. This is required to + // mark the start time of a slot given to an advance reservation + MPProfileEntry anchorEntry = getPrecedingEntry(startTime); + + if (anchorEntry == null) { + MPProfileEntry newAnchorEntry = createHeadEntry(startTime); + super.add(0, newAnchorEntry); + } + else if(anchorEntry.getTime() < startTime) { + MPProfileEntry newAnchorEntry = anchorEntry.clone(startTime); + super.add(super.indexOf(anchorEntry) + 1, newAnchorEntry); + } + } // transfer the ranges for(int i=0; i<super.size(); i++) { MPProfileEntry nextEntry = super.get(i); - if(nextEntry.getTime() < startTime) + if(nextEntry.getTime() < startTime) { continue; - if(nextEntry.getTime() >= finishTime) + } + if(nextEntry.getTime() >= finishTime) { // if(nextEntry.getTime() > finishTime) break; + } else { nextEntry.transferPEs(recQueueId, list); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-04-09 01:48:20
|
Revision: 168 http://gridsim.svn.sourceforge.net/gridsim/?rev=168&view=rev Author: marcos_dias Date: 2008-04-08 18:48:26 -0700 (Tue, 08 Apr 2008) Log Message: ----------- This update includes the implementation of gridlet cancellation in the multiple partition easy backfilling resource allocation policy. Modified Paths: -------------- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java Added Paths: ----------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueuesCancellation.java Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueuesCancellation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueuesCancellation.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueuesCancellation.java 2008-04-09 01:48:26 UTC (rev 168) @@ -0,0 +1,215 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource using an aggressive + * backfilling policy without advance reservation features but with multiple + * partitions. The jobs are read from a trace file. Additionally, this example + * cancels some gridlets submitted. This example has been implemented in order + * to test the job cancellation features. To test this example, you can use + * one of the traces included in the workloads directory. + */ + +package examples.workload.parallel; + +import examples.QueuePredicateExample; +import examples.WorkloadWithCancellation; +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.turbo.EBMultiplePartitions; +import gridsim.turbo.TResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + +/** + * Test Driver class for this example + */ +public class TurboExampleEBMultiQueuesCancellation +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + String fileName = args[0]; + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + WorkloadWithCancellation workload = + new WorkloadWithCancellation("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode + GridSim.startGridSimulation(true); + + // Start the simulation in normal mode +// GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // this resource will use an aggressive backfilling policy with + // multiple partitions and without advance reservation features + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.EB_MULTI_PARTITIONS, + time_zone, cost); + + EBMultiplePartitions policy = null; + try { + policy = new EBMultiplePartitions(name, "Policy", 3); + } catch (Exception e1) { + e1.printStackTrace(); + } + + // creates three partitions, one for short jobs, one for medium length jobs + // and another for long jobs + QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); + QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); + QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + + // divide the resources equally amongst the partitions + policy.createPartition(0, resConfig.getNumPE() / 3, express); + policy.createPartition(1, resConfig.getNumPE() / 3, medium); + policy.createPartition(2, resConfig.getNumPE() / 3, large); + + // By default, the partitions will borrow PEs from one another + // when they require and the lending partitions are not using the PEs. + // You can change this behaviour by removing the comment from the line below +// policy.setAllowBorrowing(false); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + GridResource gridRes = null; + + ResourceCalendar resCalendar = new ResourceCalendar(time_zone, + peakLoad, offPeakLoad, holidayLoad, weekends, + holidays, seed); + + try { + gridRes = new GridResource(name, baud_rate, resConfig, + resCalendar, policy); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-04-07 23:06:47 UTC (rev 167) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java 2008-04-09 01:48:26 UTC (rev 168) @@ -444,17 +444,125 @@ return -1; } - /** - * Cancels a Gridlet running or in the waiting queue.<br> - * <b>NOTE: Not implemented YET.</b> + /** + * Cancels a Gridlet running or in the waiting queue. + * This method will search the running and waiting queues. + * The User ID is important as many users might have the same + * Gridlet ID in the lists. If a Gridlet is cancelled and the gridlet was + * either running or was a pivot, then the availability profile is updated. + * After that, the backfilling algorithm is called to check which + * gridlets can be started or scheduled. + * <b>NOTE:</b> + * <ul> + * <li> Before cancelling a Gridlet, this method updates when + * the expected completion time of the Gridlet is. If the + * completion time is smaller than the current time, then + * the Gridlet is considered to be <tt>finished</tt>. + * Therefore the Gridlet cannot be cancelled. + * + * <li> Once a Gridlet has been cancelled, it cannot be resumed + * to execute again since this method will pass the Gridlet + * back to sender, i.e. the <tt>userId</tt>. + * + * <li> If a Gridlet cannot be found in either execution and + * waiting lists, then a <tt>null</tt> Gridlet will be send back + * to sender, i.e. the <tt>userId</tt>. + * </ul> * @param gridletId a Gridlet ID * @param userId the user or owner's ID of this Gridlet * @pre gridletId > 0 * @pre userId > 0 */ public void gridletCancel(int gridletId, int userId) { - System.out.println(super.get_name() + - ".gridletCancel(): not supported at the moment."); + double currentTime = GridSim.clock(); + + // stores the gridlet if found + SSGridlet sgl = null; + boolean found = false; + boolean updateProfile = false; + + // Look for the Gridlet in the running queue + sgl = findSSGridlet(runningGridlets_, gridletId, userId); + if (sgl != null) { + found = true; + + // if the Gridlet's finish time is smaller than the current + // time or the status is FINISHED, it means that the Gridlet + // has finished, but has not been removed from the running + // queue yet. It will probably be done shortly, + // so just send a null to the user. + if(sgl.getStatus() == Gridlet.SUCCESS || + sgl.getActualFinishTime() <= currentTime){ + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, + null, gridletId, userId); + return; // return as it is impossible to cancel the Gridlet + } + else{ + // remove from the queue before compressing the schedule + runningGridlets_.remove(sgl); + updateProfile = true; + } + } + + if(!found) { + // Look for the gridlet in the waiting queue + sgl = findSSGridlet(queuedGridlets_, gridletId, userId); + if (sgl != null) { + found = true; + + // Get the Gridlet from the waiting queue and + // remove from the queue before compressing the schedule + queuedGridlets_.remove(sgl); + + // if start time has been set, then it means that gridlet is + // a pivot. So, we need to set the pivot of the corresponding + // queue partition to null + if(sgl.getStartTime() > 0) { + EasyBackFillingPartition pt = getPartition(sgl.getPartitionID()); + pt.pivot_ = null; + updateProfile = true; + } + } + } + + // If the Gridlet could not be found in neither queue, then send a null + // Gridlet to the user and return because there is no need to + // compress the schedule + if(!found) { + System.out.println(super.get_name() + ".gridletCancel():" + + " Cannot find Gridlet #" + gridletId + " for User #" + userId); + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, + null, gridletId, userId); + return; + } + + // check whether the Gridlet is running + sgl.setStatus(Gridlet.CANCELED); + + //----------------- USED FOR DEBUGGING PURPOSES ONLY ------------------- + + // If a gridlet has been cancelled, then inform the listeners + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_CANCELLED, true, sgl); + + //---------------------------------------------------------------------- + + // remove/update entries of the gridlet in the profile + if(updateProfile) { + removeGridlet(sgl); + backfillGridlets(currentTime); + + //------------------- USED FOR DEBUGGING PURPOSES ONLY ----------------- + + // Inform the listeners about the new schedule + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + + //---------------------------------------------------------------------- + } + + // sends the Gridlet back to user + sgl.finalizeGridlet(); + super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, + sgl.getGridlet(), gridletId, userId); } /** @@ -906,6 +1014,20 @@ return gridletStarted; } + // ------------------------- PRIVATE METHODS ---------------------------- + + /** + * This method removes/updates all the entries of a gridlet from the profile. + * @param gridlet the Gridlet to be removed + */ + private void removeGridlet(SSGridlet gridlet) { + if(!gridlet.hasReserved()) { + + // removes the gridlet from the profile + profile_.updateEntriesAtProfile(gridlet); + } + } + /* * This method obtains the queue from the profile and does a casting */ Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-04-07 23:06:47 UTC (rev 167) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java 2008-04-09 01:48:26 UTC (rev 168) @@ -949,14 +949,14 @@ transferPEs(partitionId, allocatedRanges, startTime, finishTime); MPProfileEntry entry = getPrecedingEntry(startTime); - if(entry.getTime() == startTime) { + if(entry != null && entry.getTime() == startTime) { entry.decreaseGridlet(); if(entry.getNumGridlets() == 0) super.remove(entry); } entry = getPrecedingEntry(finishTime); - if(entry.getTime() == startTime) { + if(entry != null && entry.getTime() == finishTime) { entry.decreaseGridlet(); if(entry.getNumGridlets() == 0) super.remove(entry); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-04-16 10:39:21
|
Revision: 170 http://gridsim.svn.sourceforge.net/gridsim/?rev=170&view=rev Author: marcos_dias Date: 2008-04-16 03:39:27 -0700 (Wed, 16 Apr 2008) Log Message: ----------- + Option to get free time slots from AvailabilityInfo object. + Changes in the java doc comments. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java branches/gridsim4.0-branch3/source/gridsim/Gridlet.java branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/util/Workload.java Modified: branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java 2008-04-16 10:39:27 UTC (rev 170) @@ -8,6 +8,7 @@ import eduni.simjava.Sim_event; import eduni.simjava.Sim_system; +import gridsim.GridSim; import gridsim.GridSimTags; import gridsim.Gridlet; import gridsim.IO_data; @@ -230,16 +231,10 @@ // create the gridlet int len = runTime * rating_; // calculate a job length for each PE - Gridlet gl = new Gridlet(id, len, size_, size_); + Gridlet gl = new Gridlet(id, len, size_, size_, GridSim.isTraceEnabled()); gl.setUserID( super.get_id() ); // set the owner ID gl.setNumPE(numProc); // set the requested num of proc - // printing to inform user - if (gridletID_ == 1 || gridletID_ % INTERVAL == 0) { - System.out.println(super.get_name() + ": Submitting Gridlets to " + - resName_ + " ..."); - } - // check the submit time if (submitTime < 0) { submitTime = 0; Modified: branches/gridsim4.0-branch3/source/gridsim/Gridlet.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/Gridlet.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/Gridlet.java 2008-04-16 10:39:27 UTC (rev 170) @@ -1199,7 +1199,7 @@ // Creates the history or transactions of this Gridlet newline_ = System.getProperty("line.separator"); num_ = new DecimalFormat("#0.00#"); // with 3 decimal spaces - history_ = new StringBuffer(1000); + history_ = new StringBuffer(500); history_.append("Time below denotes the simulation time."); history_.append( System.getProperty("line.separator") ); history_.append("Time (sec) Description Gridlet #"+gridletID_); Modified: branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java 2008-04-16 10:39:27 UTC (rev 170) @@ -215,8 +215,9 @@ // Creates a thread that will be responsible for starting the simulation // I don't want to block the buttons during the whole simulation because // they will be required for other things - simThread_ = new Thread(){ - public void run(){ + simThread_ = new Thread() { + public void run() { + this.setName("Simulation"); // here in fact, start the simulation GridSim.startGridSimulation(); } Modified: branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java 2008-04-16 10:39:27 UTC (rev 170) @@ -153,7 +153,7 @@ /** * Returns the font to be used in the graphs - * @return + * @return the font to be used in the graphs */ public Font getGraphFont() { return graphFont; @@ -186,6 +186,62 @@ } /** + * Return the colours to be used for the partitions + * @return the colors for the partitions + */ + public Color[] getQueueColors() { + return this.colorQueues; + } + + /** + * Returns an array of colours + * @return an array of colours + */ + public Color[] getJobQueuedColors() { + return this.colorQueued; + } + + /** + * Returns an array of colours + * @return an array of colours + */ + public Color[] getJobDoneColors() { + return this.colorDone; + } + + /** + * Returns an array of colours + * @return an array of colours + */ + public Color[] getJobInExecColors() { + return this.colorInExec; + } + + /** + * Returns an array of colours + * @return an array of colours + */ + public Color[] getARNonCommittedColors() { + return this.colorARNonCommitted; + } + + /** + * Returns an array of colours + * @return an array of colours + */ + public Color[] getARCommittedColors() { + return this.colorARCommitted; + } + + /** + * Returns an array of colours + * @return an array of colours + */ + public Color[] getARInProgressColors() { + return this.colorARInProgress; + } + + /** * Creates a colour palette * @return the colour palette */ @@ -242,60 +298,4 @@ return colors; } - - /** - * Return the colours to be used for the partitions - * @return the colors for the partitions - */ - public Color[] getQueueColors() { - return this.colorQueues; - } - - /** - * Returns an array of colours - * @return an array of colours - */ - public Color[] getJobQueuedColors() { - return this.colorQueued; - } - - /** - * Returns an array of colours - * @return an array of colours - */ - public Color[] getJobDoneColors() { - return this.colorDone; - } - - /** - * Returns an array of colours - * @return an array of colours - */ - public Color[] getJobInExecColors() { - return this.colorInExec; - } - - /** - * Returns an array of colours - * @return an array of colours - */ - public Color[] getARNonCommittedColors() { - return this.colorARNonCommitted; - } - - /** - * Returns an array of colours - * @return an array of colours - */ - public Color[] getARCommittedColors() { - return this.colorARCommitted; - } - - /** - * Returns an array of colours - * @return an array of colours - */ - public Color[] getARInProgressColors() { - return this.colorARInProgress; - } } Modified: branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-04-16 10:39:27 UTC (rev 170) @@ -691,7 +691,7 @@ x = SHIFT_X - 5; y = heightGph + SHIFT_Y - 10; g2D.rotate(-1.571, x, y); - g2D.drawString("Processing Elements", x, y); + g2D.drawString(" Processing Elements: " + numPE_, x, y); g2D.rotate(1.571, x, y); g2D.setColor(ctLineColor_); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2008-04-16 10:39:27 UTC (rev 170) @@ -383,7 +383,73 @@ return true; } + + /** + * Returns the scheduling options, or time slots contained in this + * availability information object within a specified period of time. <br> + * <b>NOTE:</b> The time slots returned by this method <b>OVERLAP</b> because + * they are not the scheduling options for jobs. + * @param startTime the start time of the period. + * @param finishTime the finish time of the period. + * @return a linked list with the time slots contained in this availability + * information object within a specified period of time. + */ + public LinkedList<TimeSlot> getSchedulingOptions(double startTime, double finishTime) { + LinkedList<TimeSlot> slots = new LinkedList<TimeSlot>(); + // start time cannot be smaller than the start time of the info obj + if(startTime < startTime_) + startTime = startTime_; + + // start time cannot be larger than the finish time of the info obj + if(startTime > finishTime_) { + return slots; + } + + AvailabilityInfoEntry entry = getPrecedingEntry(startTime); + AvailabilityInfoEntry nextEntry = null; + PERangeList slotRanges = null; + PERangeList intersect = null; + int size = super.size(); + + for(int i=super.indexOf(entry); i<size; i++) { + entry = super.get(i); + if(entry.getTime() >= finishTime) { + break; + } + else if (entry.getNumPE() == 0) { + continue; + } + + double slotStart = + entry.getTime() < startTime ? startTime : entry.getTime(); + slotRanges = entry.getAvailRanges(); + + for(int j=i; j<size; j++) { + nextEntry = super.get(j); + intersect = PERangeList.intersection(slotRanges, nextEntry.getAvailRanges()); + double endTime = entry.getTime(); + boolean different = !intersect.equals(slotRanges); + if(j < (size-1) && different) { + TimeSlot slot = new TimeSlot(slotStart, endTime, slotRanges); + slots.add(slot); + slotRanges = intersect; + } + else if (j == (size-1)) { + TimeSlot slot = new TimeSlot(slotStart, finishTime, slotRanges); + slots.add(slot); + continue; + } + + if(intersect == null && intersect.getNumPE() == 0) { + break; + } + } + } + + return slots; + } + /** * Returns the time slots contained in this availability information object * within a specified period of time. <br> Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java 2008-04-16 10:39:27 UTC (rev 170) @@ -104,26 +104,27 @@ } } - /** + /** * Creates an String representation of this list * @return the string representation */ public String toString() { - String result = "{"; - boolean first = true; - for(PERange range : this){ - if(!first){ - result += "," + range; - } - else{ - first = false; - result += range; - } + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("{"); + int index = -1; + int last = super.size() - 1; + String delim = ","; + + for(PERange range : this) { + index++; + stringBuilder.append(range); + delim = index < last ? delim : "}"; + stringBuilder.append(delim); } - result += "}"; - return result; + + return stringBuilder.toString(); } - + /** * Checks whether this list is equals to the list provided * @param list the list to compare this list against @@ -266,6 +267,10 @@ */ public static PERangeList selectPERangeList(int reqPE, PERangeList ranges){ PERangeList selected = new PERangeList(); + + if(ranges == null) + return null; + try{ ranges.sortRanges(); for(PERange range: ranges){ @@ -282,7 +287,8 @@ } } catch(Exception ex){ - ex.printStackTrace(); + System.out.println("PERangeList.selectPERangeList(): Exception: " + + ex.getMessage()); selected = null; } @@ -492,9 +498,11 @@ return false; } -// // FOR DEBUGGING PURPOSES ONLY... +//// // FOR DEBUGGING PURPOSES ONLY... // public static void main(String args[]){ // +// double start = System.currentTimeMillis(); +// // PERange ra = new PERange(0, 10); // PERange rb = new PERange(11, 20); // PERange rc = new PERange(21, 30); @@ -517,10 +525,13 @@ // // PERangeList list3 = new PERangeList(); // list3.add(new PERange(500, 2000)); -//// list3.add(new PERange(0, 499)); -//// list3.add(new PERange(1001, 1005)); +// list3.add(new PERange(0, 499)); +// list3.add(new PERange(1001, 1005)); // // PERangeList difference = symmetricDifference(list1, list3); // System.out.println("Symmetric difference between list " + list1 + " and " + list3 + " is " + difference); +// +// double finish = System.currentTimeMillis(); +// System.out.println("Time taken = " + (finish - start)); // } } \ No newline at end of file Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2008-04-16 10:39:27 UTC (rev 170) @@ -504,7 +504,7 @@ * Creates a String representation of this Gridlet * for debugging purposes */ - public String toString(){ + public String toString() { String result = "Gridlet {id=" + getID() + ", start time=" + startTime_ + ", expected finish time=" + expectedFinishTime_ + @@ -523,26 +523,23 @@ * @see GridSimVisualizer#TIME_UNIT_HOUR */ public String toString(int timeUnit){ - String timeDescr = getTimeDescr(timeUnit); - return "Gridlet ID: " + gridlet_.getGridletID() + "\n" + - "User ID: " + gridlet_.getUserID() + "\n" + - "Status: " + Gridlet.getStatusString(gridlet_.getGridletStatus()) + "\n" + - "Sub. Time: " + decFormater_.format(convertTime(getSubmissionTime(), timeUnit)) + - " " + timeDescr + "\n" + - "Start Time: " + decFormater_.format(convertTime(startTime_, timeUnit)) + - " " + timeDescr + "\n" + - "Exp. Finish Time: " + decFormater_.format(convertTime(expectedFinishTime_, timeUnit)) + - " " + timeDescr + "\n" + - "Finish Time: " + decFormater_.format(convertTime(actualFinishTime_, timeUnit)) + - " " + timeDescr + "\n" + - "Duration: " + decFormater_.format(convertTime(actualFinishTime_ - startTime_, timeUnit)) + - " " + timeDescr + "\n" + - "Length: " + decFormater_.format(gridlet_.getGridletLength()) + " MIs" + "\n" + - "Num. PEs: " + numPE_; + String timeDescr = " " + getTimeDescr(timeUnit); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("Gridlet ID: " + gridlet_.getGridletID()); + stringBuilder.append("\nUser ID: " + gridlet_.getUserID()); + stringBuilder.append("\nStatus: " + Gridlet.getStatusString(gridlet_.getGridletStatus())); + stringBuilder.append("\nSub. Time: " + formatTime(getSubmissionTime(), timeUnit) + timeDescr); + stringBuilder.append("\nStart Time: " + formatTime(startTime_, timeUnit) + timeDescr); + stringBuilder.append("\nExp. Finish Time: " + formatTime(expectedFinishTime_, timeUnit) + timeDescr); + stringBuilder.append("\nFinish Time: " + formatTime(actualFinishTime_, timeUnit) + timeDescr); + stringBuilder.append("\nDuration: " + formatTime(actualFinishTime_ - startTime_, timeUnit) + timeDescr); + stringBuilder.append("\nLength: " + gridlet_.getGridletLength() + " MIs"); + stringBuilder.append("\nNum. PEs: " + numPE_); + return stringBuilder.toString(); } // -------------------- PRIVATE METHODS --------------------- - + /** * Initialises all local attributes * @pre $none @@ -591,10 +588,11 @@ /** * Converts the time to the time unit in use * @param the time in seconds + * @param timeUnit the time unit id * @return the time in the unit in use */ - private double convertTime(double time, int timeUnit) { - return time / timeUnit; + private String formatTime(double time, int timeUnit) { + return decFormater_.format(time / timeUnit); } } // end class Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java 2008-04-16 10:39:27 UTC (rev 170) @@ -402,20 +402,17 @@ * @see GridSimVisualizer#TIME_UNIT_HOUR */ public String toString(int timeUnit) { - String unitDesc = getTimeDescr(timeUnit); - String result = "Reservation ID: " + reservation_.getID() + "\n" + - "User ID: " + getSenderID() + "\n" + - "Status: " + Reservation.getStatusString(reservation_.getStatus()) + "\n" + - "Sub. Time: " + decFormater_.format(convertTime(getSubmissionTime(), timeUnit)) + - " " + unitDesc + "\n" + - "Start Time: " + decFormater_.format(convertTime(reservation_.getStartTime(), timeUnit)) + - " " + unitDesc + "\n" + - "FinishTime: " + decFormater_.format(convertTime(getActualFinishTime(), timeUnit)) + - " " + unitDesc + "\n" + - "Duration: " + decFormater_.format(convertTime(reservation_.getDurationTime(), timeUnit)) + - " " + unitDesc + "\n" + - "Num. PEs: " + reservation_.getNumPE(); - return result; + String timeDescr = " " + getTimeDescr(timeUnit); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("Reservation ID: " + reservation_.getID()); + stringBuilder.append("\nUser ID: " + getSenderID()); + stringBuilder.append("\nStatus: " + Reservation.getStatusString(reservation_.getStatus())); + stringBuilder.append("\nSub. Time: " + formatTime(getSubmissionTime(), timeUnit) + timeDescr); + stringBuilder.append("\nStart Time: " + formatTime(reservation_.getStartTime(), timeUnit) + timeDescr); + stringBuilder.append("\nFinishTime: " + formatTime(getActualFinishTime(), timeUnit) + timeDescr); + stringBuilder.append("\nDuration: " + formatTime(reservation_.getDurationTime(), timeUnit) + timeDescr); + stringBuilder.append("\nNum. PEs: " + reservation_.getNumPE()); + return stringBuilder.toString(); } /** @@ -448,10 +445,11 @@ /** * Converts the time to the time unit in use * @param the time in seconds + * @param timeUnit the time unit id * @return the time in the unit in use */ - private static double convertTime(double time, int timeUnit) { - return time / timeUnit; + private String formatTime(double time, int timeUnit) { + return decFormater_.format(time / timeUnit); } /** Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java 2008-04-16 10:39:27 UTC (rev 170) @@ -150,7 +150,8 @@ } } catch(Exception ex){ - System.out.println(super.get_name() + ".selectPERangeList(): Exception: " + ex.getMessage()); + System.out.println(super.get_name() + + ".selectPERangeList(): Exception: " + ex.getMessage()); } return selected; } Modified: branches/gridsim4.0-branch3/source/gridsim/util/Workload.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/util/Workload.java 2008-04-11 00:58:22 UTC (rev 169) +++ branches/gridsim4.0-branch3/source/gridsim/util/Workload.java 2008-04-16 10:39:27 UTC (rev 170) @@ -90,7 +90,6 @@ private int MAX_FIELD; // max number of field in the trace file private String COMMENT; // a string that denotes the start of a comment private final int IRRELEVANT = -1; // irrelevant number - protected final int INTERVAL = 10; // number of intervals private String[] fieldArray_; // a temp array storing all the fields /** @@ -503,7 +502,9 @@ } boolean success = false; - + System.out.println(super.get_name() + ": Submitting Gridlets to " + + resName_ + " ..."); + // read the gz file if (fileName_.endsWith(".gz") == true) { success = readGZIPFile(fileName_); @@ -516,6 +517,9 @@ else { success = readFile(fileName_); } + + // help the garbage collector + fieldArray_ = null; // if all the gridlets have been submitted if (success == true) { @@ -741,13 +745,6 @@ gl.setUserID( super.get_id() ); // set the owner ID gl.setNumPE(numProc); // set the requested num of proc - // printing to inform user - if (gridletID_ == 1 || gridletID_ % INTERVAL == 0) - { - System.out.println(super.get_name() + ": Submitting Gridlets to " + - resName_ + " ..."); - } - // check the submit time if (submitTime < 0) { submitTime = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-11-05 01:07:01
|
Revision: 77 http://gridsim.svn.sourceforge.net/gridsim/?rev=77&view=rev Author: marcos_dias Date: 2007-11-04 17:07:03 -0800 (Sun, 04 Nov 2007) Log Message: ----------- This update contains some small bug fixes and changes in names of some classes. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java Added Paths: ----------- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java Removed Paths: ------------- branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java Modified: branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2007-11-05 01:07:03 UTC (rev 77) @@ -13,7 +13,7 @@ import gridsim.GridletList; import gridsim.turbo.Reservation; import gridsim.turbo.ReservationRequester; -import gridsim.turbo.TimeSlotList; +import gridsim.turbo.AvailabilityInfo; import java.util.ArrayList; import java.util.Calendar; @@ -180,7 +180,7 @@ resName = (String) resNameList.get(val); // queries the availability of the Grid resource - TimeSlotList availability = + AvailabilityInfo availability = super.queryFreeTime(GridSim.clock(), Integer.MAX_VALUE, resID); System.out.println("Availability information returned by the " + Modified: branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java 2007-11-05 01:07:03 UTC (rev 77) @@ -10,14 +10,10 @@ package gridsim; import java.util.Calendar; -import java.util.LinkedList; import eduni.simjava.Sim_entity; import eduni.simjava.Sim_event; import eduni.simjava.Sim_port; -import gridsim.gui.AllocationAction; -import gridsim.gui.DefaultGridSimVisualizer; -import gridsim.turbo.ScheduleItem; /** * AllocPolicy is an abstract class that handles the internal Modified: branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2007-11-05 01:07:03 UTC (rev 77) @@ -787,7 +787,7 @@ * @param item the item whose information has to be updated */ protected void updateItem(ScheduleItem item) { - int position = getPosition(item.getID(), item.getUserID(), + int position = getPosition(item.getID(), item.getSenderID(), item.isAdvanceReservation()); if(position < 0) { @@ -877,7 +877,7 @@ */ private String itemSummary(ScheduleItem item) { return (item.isAdvanceReservation() ? "Res. " : "Grl. ") + "ID: " + item.getID() + - ", User: " + item.getUserID(); + ", User: " + item.getSenderID(); } /** @@ -902,7 +902,7 @@ for (int i = 0; i < sizeVector; i++) { item = items_.get(i); if (item.getID() == itemId - && item.getUserID() == userId + && item.getSenderID() == userId && item.isAdvanceReservation() == ar) return i; } @@ -933,7 +933,7 @@ if(submittedTime == item.getSubmissionTime() && insertItem.getID() == item.getID() && insertItem.isAdvanceReservation() == item.isAdvanceReservation() - && insertItem.getUserID() == item.getUserID() ) { + && insertItem.getSenderID() == item.getSenderID() ) { return i; } } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java 2007-11-05 01:07:03 UTC (rev 77) @@ -32,7 +32,7 @@ // by informing the reservation requester when resource will be available to // fulfil the reservation. This attribute contains the list of PEs // available at a set of simulation times - private TimeSlotList resOptions_; + private AvailabilityInfo resOptions_; // the price associate with this message private double price_; @@ -383,7 +383,7 @@ * Gets the reservation options given by the Grid resource * @return the reservation options */ - public TimeSlotList getReservationOptions() { + public AvailabilityInfo getReservationOptions() { return resOptions_; } @@ -391,7 +391,7 @@ * Sets the reservation options given by the Grid resource * @param resOptions the reservation options object */ - public void setReservationOptions(TimeSlotList resOptions) { + public void setReservationOptions(AvailabilityInfo resOptions) { resOptions_ = resOptions; } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2007-11-05 01:07:03 UTC (rev 77) @@ -140,13 +140,13 @@ // internal event tags used by this gridlet // a tag to denote expiry time - private final int EXPIRY_TIME = 12; + private static final int EXPIRY_TIME = 12; // a tag to indicate that a reservation has to start - private final int START_RESERVATION = 13; + private static final int START_RESERVATION = 13; // a tag to indicate that a reservation has to finish - private final int FINISH_RESERVATION = 14; + private static final int FINISH_RESERVATION = 14; // a tag to indicate that a gridlet has finished private static final int GRIDLET_FINISHED = 10; @@ -630,7 +630,7 @@ * Handles a query free time request. * @param message the advance reservation message received. */ - public void handleQueryFreeTime(ARMessage message) { + public void handleQueryAvailability(ARMessage message) { // gets the reservation id of the message Reservation reservation = message.getReservation(); @@ -643,7 +643,7 @@ int duration = reservation.getDurationTime(); // gets the availability information from the availability profile - TimeSlotList availability = getAvailabilityInfo(startTime, duration); + AvailabilityInfo availability = getAvailabilityInfo(startTime, duration); // sets the options as the availability over the requested period response.setReservationOptions(availability); @@ -2298,9 +2298,9 @@ * entries that correspond to the availability profile between the times * specified by the requester. */ - private TimeSlotList getAvailabilityInfo(double startTime, int duration) { + private AvailabilityInfo getAvailabilityInfo(double startTime, int duration) { - TimeSlotList list = new TimeSlotList(); + AvailabilityInfo list = new AvailabilityInfo(); int anchorIndex = -1; // if the user specified the start time as 0, it means that the @@ -2319,7 +2319,7 @@ // a pointer to the anchor entry (described above) AvailabilityProfileEntry anchorEntry = null; int length = availProfile_.size(); - TimeSlotEntry firstEntry = null; + AvailabilityInfoEntry firstEntry = null; double entryTime; @@ -2340,15 +2340,17 @@ // before the first entry of the profile, so the intersection list // has to start with the ranges of PEs currently available if (anchorEntry == null) { + PERangeList peList = (resource_.getFreePERanges() == null) ? null : + resource_.getFreePERanges().clone(); firstEntry = - new TimeSlotEntry(startTime, resource_.getFreePERanges().clone()); + new AvailabilityInfoEntry(startTime, peList); } else { PERangeList newList = anchorEntry.getPERanges(); if(newList != null) { newList = newList.clone(); } - firstEntry = new TimeSlotEntry(startTime, newList); + firstEntry = new AvailabilityInfoEntry(startTime, newList); anchorIndex = availProfile_.indexOf(anchorEntry); } @@ -2369,14 +2371,15 @@ if(peList != null) { peList = peList.clone(); } - TimeSlotEntry tsEntry = - new TimeSlotEntry(nextEntry.getTime(), peList.clone()); + AvailabilityInfoEntry tsEntry = + new AvailabilityInfoEntry(nextEntry.getTime(), peList); list.add(tsEntry); } previousEntry = nextEntry; } } + list.sort(); // sort the list before send it back return list; } } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java 2007-11-05 01:07:03 UTC (rev 77) @@ -172,6 +172,8 @@ */ private void initARPolicy() throws Exception { try{ + arPolicy_ = (ARTPolicy)super.policy_; + if(arPolicy_ == null && policyType_ == TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED) { arPolicy_ = (ARParallelSpaceShared)policy_; @@ -263,7 +265,7 @@ break; case ARMessage.TYPE_AR_LIST_FREE_TIME: - arPolicy_.handleQueryFreeTime(message); + arPolicy_.handleQueryAvailability(message); break; } } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java 2007-11-05 01:07:03 UTC (rev 77) @@ -109,7 +109,7 @@ * @param message the advance reservation message received * @pre message != null */ - public abstract void handleQueryFreeTime(ARMessage message); + public abstract void handleQueryAvailability(ARMessage message); //-------------------- END OF ABSTRACT METHODS -------------------- Copied: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java (from rev 76, branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java) =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2007-11-05 01:07:03 UTC (rev 77) @@ -0,0 +1,312 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + */ + +package gridsim.turbo; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; + +/** + * The {@link AvailabilityInfo} class represents a list of entries + * that represent the availability of PES of a Grid resource over + * a period of time. This is used in return to a query availability + * in an advance reservation based allocation policy. + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see ARTPolicy + * @see PERange + * @see PERangeList + * @see ARParallelSpaceShared + * @see ARParallelSpaceShared#handleQueryAvailability(ARMessage) + */ + +public class AvailabilityInfo { + + private static final long serialVersionUID = -3951650752024908016L; + + private ArrayList<AvailabilityInfoEntry> list_; + private double startTime_; + private double finishTime_; + + private static final int UNKNOWN = -1; + + /** + * Default constructor. + */ + public AvailabilityInfo() { + list_ = new ArrayList<AvailabilityInfoEntry>(); + startTime_ = UNKNOWN; + finishTime_ = UNKNOWN; + } + + /** + * Returns the start time of this list. That is, + * the time of the first element of this list + * @return the start time + */ + public double getStartTime() { + return startTime_; + } + + /** + * Returns the end time of this list. + * @return the end time + */ + public double getEndTime() { + return finishTime_; + } + + /** + * Sets the start time of this list. + * @param startTime the start time + */ + public void setStartTime(double startTime) { + startTime_ = startTime; + } + + /** + * Sets the end time of this list. + * @param finishTime the end time + */ + public void setFinishTime(double finishTime) { + finishTime_ = finishTime; + } + + /** + * Adds the specified element to this list. + * @param entry the entry to be added to this list + * @return <tt>true + */ + public boolean add(AvailabilityInfoEntry entry) { + if(entry == null) { + return false; + } + else { + list_.add(entry); + } + return true; + } + + /** + * Sorts the entries of this availability info object. + */ + public void sort() { + Collections.sort(list_); + } + + /** + * Adds all of the elements in the specified Collection to this list, + * The behaviour of this operation is undefined if the specified + * Collection is modified while the operation is in progress. + * (This implies that the behaviour of this call is undefined if the + * specified Collection is this list, and this list is nonempty.) + * @param collection the collection to be included in this list + * @return <tt>true<tt> if the collection has been added successfully + * or <tt>false</tt> otherwise. + */ + public boolean addAll(Collection<? extends AvailabilityInfoEntry> collection) { + boolean result = true; + + // adds the collection to the list and sets the start + // and finish time again + if(collection != null && !collection.isEmpty()) { + list_.addAll(collection); + } + return result; + } + + /** + * Removes all elements from the list. + */ + public void clear() { + list_.clear(); + } + + /** + * Returns a shallow copy of this list. + * (The elements themselves are not copied.) + */ + public Object clone() { + return list_.clone(); + } + + /** + * Returns <tt>true</tt> if this list contains the specified element. + * @param entry the entry whose presence in this List is to be tested. + * @return <tt>true</tt> if the specified element is present; + * <tt>false</tt> otherwise. + */ + public boolean contains(Object entry) { + return list_.contains(entry); + } + + /** + * Returns the element at the specified position in this list. + * @param index the index of the element to return + * @return the element at the specified position in this list. + */ + public AvailabilityInfoEntry get(int index) { + return list_.get(index); + } + + /** + * Searches for the first occurence of the given argument, + * testing for equality using the equals method. + * @param entry the entry whose index is to be returned + * @return the index of the first occurrence of the argument + * in this list; returns <tt>-1</tt> if the object is not found. + */ + public int indexOf(Object entry) { + return list_.indexOf(entry); + } + + /** + * Tests if this list has no elements. + * @return <tt>true</tt> if the list has no elements. + */ + public boolean isEmpty() { + return list_.isEmpty(); + } + + /** + * Returns an iterator over the elements in this list in proper sequence. + * @return the iterator. + */ + public Iterator<AvailabilityInfoEntry> iterator() { + return list_.iterator(); + } + + /** + * Removes the element at a given index + * @param index the index of the element to be removed + * @return the removed element. + */ + public AvailabilityInfoEntry remove(int index) { + return list_.remove(index); + } + + /** + * Removes a given element from the list. + * @param entry the entry to be removed + * @return <tt>true</tt> if the collection contained the + * specified entry. + */ + public boolean remove(Object entry) { + return list_.remove(entry); + } + + /** + * Returns the size of this list. + * @return the size of this list + */ + public int size() { + return list_.size(); + } + + /** + * Scans the entries in a list and returns the first time frame over + * which a request with the characteristics provided can be scheduled + * @param duration the duration of the request + * @param reqPE the number of PEs required + * @return the start time or <tt>-1</tt> if not found + */ + public double getPotentialStartTime(int duration, int reqPE) { + + // the anchor index, the entry in the profile where + // the request would be placed OR the closest entry to the + // point where the anchor of the request would be placed + int anchorIndex = -1; + + // a pointer to the anchor entry (described above) + AvailabilityInfoEntry anchorEntry = null; + + // the list of selected ranges + PERangeList intersectList = null; + + double potStartTime = -1; // keep the potential start time of the request + double potFinishTime = -1; // store the gridlet's expected finish time + + intersectList = null; + int length = list_.size(); + + Iterator<AvailabilityInfoEntry> iterProfile = list_.iterator(); + while(iterProfile.hasNext()) { + + AvailabilityInfoEntry entry = iterProfile.next(); + anchorEntry = entry; + anchorIndex = list_.indexOf(anchorEntry); + + // sets the start time as the time of the entry + potStartTime = entry.getTime(); + // calculates when the finish time will be if + // the gridlet is put at this position + potFinishTime = potStartTime + duration; + + // scan the profile until an entry with enough PEs is found + if(entry.getNumPE() < reqPE) { + continue; + } + else { + // if an entry with enough PEs is found, then scan the list + // from that point onwards analysing the intersection of + // the ranges available in the entries until the + // request expected completion time + intersectList = entry.getAvailRanges().clone(); + + // Look for the intersection of available ranges from + // the anchor until the end of the profile or until + // the entries are further than the expected completion time + for(int i=anchorIndex+1; i<length; i++){ + AvailabilityInfoEntry nextEntry = list_.get(i); + if(nextEntry.getTime() > potFinishTime){ + break; + } + else{ + // if the finish time is equals to the entry time, so there + // is no need to check the intersection + if(nextEntry.getTime() < potFinishTime) { + intersectList = PERangeList.intersection(intersectList, + nextEntry.getAvailRanges()); + if(intersectList == null || intersectList.getNumPE() < reqPE) { + break; + } + } + } + } + // If a time slot with enough PEs has been found, then stop the search + if(intersectList != null && intersectList.getNumPE() >= reqPE) { + break; + } + } + } + + // if the potential finish time is larger than the end time of + // this list, then the request cannot be scheduled + if(potFinishTime > finishTime_) { + potStartTime = UNKNOWN; + } + + return potStartTime; + } + + /** + * Creates a string representation of the list + * @return a string representation + */ + public String toString() { + String result = "Availability={\n"; + for(AvailabilityInfoEntry entry : list_){ + result += entry + "\n"; + } + result += "}"; + return result; + } +} Copied: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java (from rev 76, branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java) =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java 2007-11-05 01:07:03 UTC (rev 77) @@ -0,0 +1,129 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + */ + +package gridsim.turbo; + +/** + * The {@link AvailabilityInfoEntry} class represents an entry in a list of + * time slots available, which can be allocated to a user. This is used + * in return to a query for free time slots in an advance reservation + * based allocation policy. + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see ARTPolicy + * @see PERange + * @see PERangeList + * @see AvailabilityInfo + * @see ARParallelSpaceShared + * @see ARParallelSpaceShared#handleQueryAvailability(ARMessage) + */ + +public class AvailabilityInfoEntry implements Comparable <AvailabilityInfoEntry> { + + private double time_; + private PERangeList availRanges_; + + /** + * Creates a new instance of {@link AvailabilityInfoEntry} + * @param time the time associated with this entry + */ + public AvailabilityInfoEntry(double time) { + time_ = time; + availRanges_ = null; + } + + /** + * Creates a new instance of {@link AvailabilityInfoEntry} + * @param time the time associated with this entry + * @param ranges the list of ranges of PEs available + */ + public AvailabilityInfoEntry(double time, PERangeList ranges) { + time_ = time; + availRanges_ = ranges; + } + + /** + * Gets the time associated with this entry + * @return the time associated with this entry + */ + public double getTime() { + return time_; + } + + /** + * Sets the time associated with this entry + * @param time the time associated with this entry + * @return <tt>true</tt> if the time has been set successfully or + * <tt>false</tt> otherwise. + */ + public boolean setTime(double time) { + if(time < 0) + return false; + + time_ = time; + return true; + } + + /** + * Returns the list of ranges available at this entry + * @return the list of ranges available + */ + public PERangeList getAvailRanges() { + return availRanges_; + } + + /** + * Sets the ranges of PEs available at this entry + * @param availRanges the list of ranges of PEs available + */ + public void setAvailRanges(PERangeList availRanges) { + availRanges_ = availRanges; + } + + /** + * Compares this object with the specified object for order. + * Returns a negative integer, zero, or a positive integer + * as this object is less than, equal to, or greater + * than the specified object. + * @param entry the entry to be compared. + * @return a negative integer, zero, or a positive integer as + * this entry is less than, equal to, or greater + * than the specified entry. + */ + public int compareTo(AvailabilityInfoEntry entry) { + int result = 0; + if(time_ < entry.time_) { + result = -1; + } + else if(time_ > entry.time_) { + result = 1; + } + return result; + } + + /** + * Gets the number of PEs associated with this entry + * @return the number of PEs + */ + public int getNumPE() { + if(availRanges_ == null) + return 0; + else + return availRanges_.getNumPE(); + } + + /** + * Creates a string representation of this entry + * @return a representation of this entry + */ + public String toString() { + return "{time="+ time_ + "; " + + ( (availRanges_!=null) ? availRanges_ : "{[]}") + "}"; + } +} Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java 2007-11-05 01:07:03 UTC (rev 77) @@ -314,7 +314,7 @@ * @pre startTime >= 0 * @pre finishTime > 0 */ - public TimeSlotList queryFreeTime(double startTime, + public AvailabilityInfo queryFreeTime(double startTime, int duration, int resID) { // check all the values first @@ -323,7 +323,7 @@ return null; } - TimeSlotList resOptions = null; + AvailabilityInfo resOptions = null; try { // create the reservation itself Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2007-11-05 01:07:03 UTC (rev 77) @@ -162,7 +162,7 @@ * @pre $none * @post $none */ - public int getUserID() { + public int getSenderID() { return gridlet_.getUserID(); } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java 2007-11-05 01:07:03 UTC (rev 77) @@ -235,7 +235,7 @@ * @pre $none * @post $none */ - public int getUserID() { + public int getSenderID() { if(reservation_==null) return UNKNOWN; @@ -342,7 +342,7 @@ public String toString(int timeUnit) { String unitDesc = getTimeDescr(timeUnit); String result = "Reservation ID: " + reservation_.getID() + "\n" + - "User ID: " + getUserID() + "\n" + + "User ID: " + getSenderID() + "\n" + "Status: " + Reservation.getStatusString(reservation_.getStatus()) + "\n" + "Sub. Time: " + decFormater_.format(convertTime(getSubmissionTime(), timeUnit)) + " " + unitDesc + "\n" + Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java 2007-11-05 01:07:03 UTC (rev 77) @@ -36,10 +36,10 @@ int getID(); /** - * Returns the id of the user that created this item + * Returns the id of the entity that created this item * @return the user id */ - int getUserID(); + int getSenderID(); /** * Returns the status of this item Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java 2007-11-05 01:07:03 UTC (rev 77) @@ -111,7 +111,7 @@ // Need to check against the userId as well since each user // might have same Gridlet id submitted to the same GridResource - if (rgl.getID()==gridletId && rgl.getUserID()==userId) { + if (rgl.getID()==gridletId && rgl.getSenderID()==userId) { return rgl; } } Deleted: branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotEntry.java 2007-11-05 01:07:03 UTC (rev 77) @@ -1,129 +0,0 @@ -/* - * Title: GridSim Toolkit - * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation - * of Parallel and Distributed Systems such as Clusters and Grids - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html - */ - -package gridsim.turbo; - -/** - * The {@link TimeSlotEntry} class represents an entry in a list of - * time slots available, which can be allocated to a user. This is used - * in return to a query for free time slots in an advance reservation - * based allocation policy. - * - * @author Marcos Dias de Assuncao - * @since GridSim Turbo Alpha 0.1 - * - * @see ARTPolicy - * @see PERange - * @see PERangeList - * @see TimeSlotList - * @see ARParallelSpaceShared - * @see ARParallelSpaceShared#handleQueryFreeTime(ARMessage) - */ - -public class TimeSlotEntry implements Comparable <TimeSlotEntry> { - - private double time_; - private PERangeList availRanges_; - - /** - * Creates a new instance of {@link TimeSlotEntry} - * @param time the time associated with this entry - */ - public TimeSlotEntry(double time) { - time_ = time; - availRanges_ = null; - } - - /** - * Creates a new instance of {@link TimeSlotEntry} - * @param time the time associated with this entry - * @param ranges the list of ranges of PEs available - */ - public TimeSlotEntry(double time, PERangeList ranges) { - time_ = time; - availRanges_ = ranges; - } - - /** - * Gets the time associated with this entry - * @return the time associated with this entry - */ - public double getTime() { - return time_; - } - - /** - * Sets the time associated with this entry - * @param time the time associated with this entry - * @return <tt>true</tt> if the time has been set successfully or - * <tt>false</tt> otherwise. - */ - public boolean setTime(double time) { - if(time < 0) - return false; - - time_ = time; - return true; - } - - /** - * Returns the list of ranges available at this entry - * @return the list of ranges available - */ - public PERangeList getAvailRanges() { - return availRanges_; - } - - /** - * Sets the ranges of PEs available at this entry - * @param availRanges the list of ranges of PEs available - */ - public void setAvailRanges(PERangeList availRanges) { - availRanges_ = availRanges; - } - - /** - * Compares this object with the specified object for order. - * Returns a negative integer, zero, or a positive integer - * as this object is less than, equal to, or greater - * than the specified object. - * @param entry the entry to be compared. - * @return a negative integer, zero, or a positive integer as - * this entry is less than, equal to, or greater - * than the specified entry. - */ - public int compareTo(TimeSlotEntry entry) { - int result = 0; - if(time_ < entry.time_) { - result = -1; - } - else if(time_ > entry.time_) { - result = 1; - } - return result; - } - - /** - * Gets the number of PEs associated with this entry - * @return the number of PEs - */ - public int getNumPE() { - if(availRanges_ == null) - return 0; - else - return availRanges_.getNumPE(); - } - - /** - * Creates a string representation of this entry - * @return a representation of this entry - */ - public String toString() { - return "{time="+ time_ + "; " - + ( (availRanges_!=null) ? availRanges_ : "{[]}") + "}"; - } -} Deleted: branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java 2007-10-31 03:45:23 UTC (rev 76) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/TimeSlotList.java 2007-11-05 01:07:03 UTC (rev 77) @@ -1,314 +0,0 @@ -/* - * Title: GridSim Toolkit - * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation - * of Parallel and Distributed Systems such as Clusters and Grids - * Licence: GPL - http://www.gnu.org/copyleft/gpl.html - */ - -package gridsim.turbo; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; - -/** - * The {@link TimeSlotList} class represents a list of time slots - * that are available and can be allocated to a user. This is used - * in return to a query for free time slots in an advance reservation - * based allocation policy. - * - * @author Marcos Dias de Assuncao - * @since GridSim Turbo Alpha 0.1 - * - * @see ARTPolicy - * @see PERange - * @see PERangeList - * @see ARParallelSpaceShared - * @see ARParallelSpaceShared#handleQueryFreeTime(ARMessage) - */ - -public class TimeSlotList { - - private static final long serialVersionUID = -3951650752024908016L; - - private ArrayList<TimeSlotEntry> list_; - private double startTime_; - private double finishTime_; - - private static final int UNKNOWN = -1; - - /** - * Default constructor. - */ - public TimeSlotList() { - list_ = new ArrayList<TimeSlotEntry>(); - startTime_ = UNKNOWN; - finishTime_ = UNKNOWN; - } - - /** - * Returns the start time of this list. That is, - * the time of the first element of this list - * @return the start time - */ - public double getStartTime() { - return startTime_; - } - - /** - * Returns the end time of this list. - * @return the end time - */ - public double getEndTime() { - return finishTime_; - } - - /** - * Sets the start time of this list. - * @param startTime the start time - */ - public void setStartTime(double startTime) { - startTime_ = startTime; - } - - /** - * Sets the end time of this list. - * @param finishTime the end time - */ - public void setFinishTime(double finishTime) { - finishTime_ = finishTime; - } - - /** - * Adds the specified element to this list. - * @param entry the entry to be added to this list - * @return <tt>true - */ - public boolean add(TimeSlotEntry entry) { - if(entry == null) { - return false; - } - else { - double entryTime = entry.getTime(); - int size = list_.size(); - int index = 0; - for (index=0; index<size; index++) { - if(list_.get(index).getTime() > entryTime) { - break; - } - } - list_.add(index, entry); - } - return true; - } - - /** - * Adds all of the elements in the specified Collection to this list, - * The behaviour of this operation is undefined if the specified - * Collection is modified while the operation is in progress. - * (This implies that the behaviour of this call is undefined if the - * specified Collection is this list, and this list is nonempty.) - * @param collection the collection to be included in this list - * @return <tt>true<tt> if the collection has been added successfully - * or <tt>false</tt> otherwise. - */ - public boolean addAll(Collection<? extends TimeSlotEntry> collection) { - boolean result = true; - - // adds the collection to the list and sets the start - // and finish time again - if(collection != null && !collection.isEmpty()) { - list_.addAll(collection); - Collections.sort(list_); - } - return result; - } - - /** - * Removes all elements from the list. - */ - public void clear() { - list_.clear(); - } - - /** - * Returns a shallow copy of this list. - * (The elements themselves are not copied.) - */ - public Object clone() { - return list_.clone(); - } - - /** - * Returns <tt>true</tt> if this list contains the specified element. - * @param entry the entry whose presence in this List is to be tested. - * @return <tt>true</tt> if the specified element is present; - * <tt>false</tt> otherwise. - */ - public boolean contains(Object entry) { - return list_.contains(entry); - } - - /** - * Returns the element at the specified position in this list. - * @param index the index of the element to return - * @return the element at the specified position in this list. - */ - public TimeSlotEntry get(int index) { - return list_.get(index); - } - - /** - * Searches for the first occurence of the given argument, - * testing for equality using the equals method. - * @param entry the entry whose index is to be returned - * @return the index of the first occurrence of the argument - * in this list; returns <tt>-1</tt> if the object is not found. - */ - public int indexOf(Object entry) { - return list_.indexOf(entry); - } - - /** - * Tests if this list has no elements. - * @return <tt>true</tt> if the list has no elements. - */ - public boolean isEmpty() { - return list_.isEmpty(); - } - - /** - * Returns an iterator over the elements in this list in proper sequence. - * @return the iterator. - */ - public Iterator<TimeSlotEntry> iterator() { - return list_.iterator(); - } - - /** - * Removes the element at a given index - * @param index the index of the element to be removed - * @return the removed element. - */ - public TimeSlotEntry remove(int index) { - return list_.remove(index); - } - - /** - * Removes a given element from the list. - * @param entry the entry to be removed - * @return <tt>true</tt> if the collection contained the - * specified entry. - */ - public boolean remove(Object entry) { - return list_.remove(entry); - } - - /** - * Returns the size of this list. - * @return the size of this list - */ - public int size() { - return list_.size(); - } - - /** - * Scans the entries in a list and returns the first time frame over - * which a request with the characteristics provided can be scheduled - * @param duration the duration of the request - * @param reqPE the number of PEs required - * @return the start time or <tt>-1</tt> if not found - */ - public double getPotentialStartTime(int duration, int reqPE) { - - // the anchor index, the entry in the profile where - // the request would be placed OR the closest entry to the - // point where the anchor of the request would be placed - int anchorIndex = -1; - - // a pointer to the anchor entry (described above) - TimeSlotEntry anchorEntry = null; - - // the list of selected ranges - PERangeList intersectList = null; - - double potStartTime = -1; // keep the potential start time of the request - double potFinishTime = -1; // store the gridlet's expected finish time - - intersectList = null; - int length = list_.size(); - - Iterator<TimeSlotEntry> iterProfile = list_.iterator(); - while(iterProfile.hasNext()) { - - TimeSlotEntry entry = iterProfile.next(); - anchorEntry = entry; - anchorIndex = list_.indexOf(anchorEntry); - - // sets the start time as the time of the entry - potStartTime = entry.getTime(); - // calculates when the finish time will be if - // the gridlet is put at this position - potFinishTime = potStartTime + duration; - - // scan the profile until an entry with enough PEs is found - if(entry.getNumPE() < reqPE) { - continue; - } - else { - // if an entry with enough PEs is found, then scan the list - // from that point onwards analysing the intersection of - // the ranges available in the entries until the - // request expected completion time - intersectList = entry.getAvailRanges().clone(); - - // Look for the intersection of available ranges from - // the anchor until the end of the profile or until - // the entries are further than the expected completion time - for(int i=anchorIndex+1; i<length; i++){ - TimeSlotEntry nextEntry = list_.get(i); - if(nextEntry.getTime() > potFinishTime){ - break; - } - else{ - // if the finish time is equals to the entry time, so there - // is no need to check the intersection - if(nextEntry.getTime() < potFinishTime) { - intersectList = PERangeList.intersection(intersectList, - nextEntry.getAvailRanges()); - if(intersectList == null || intersectList.getNumPE() < reqPE) { - break; - } - } - } - } - // If a time slot with enough PEs has been found, then stop the search - if(intersectList != null && intersectList.getNumPE() >= reqPE) { - break; - } - } - } - - // if the potential finish time is larger than the end time of - // this list, then the request cannot be scheduled - if(potFinishTime > finishTime_) { - potStartTime = UNKNOWN; - } - - return potStartTime; - } - - /** - * Creates a string representation of the list - * @return a string representation - */ - public String toString() { - String result = "Availability={\n"; - for(TimeSlotEntry entry : list_){ - result += entry + "\n"; - } - result += "}"; - return result; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2007-11-29 01:04:00
|
Revision: 81 http://gridsim.svn.sourceforge.net/gridsim/?rev=81&view=rev Author: marcos_dias Date: 2007-11-28 17:04:02 -0800 (Wed, 28 Nov 2007) Log Message: ----------- Problem with subversion. Deleting the files to update them later. Removed Paths: ------------- branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java branches/gridsim4.0-branch3/source/eduni/simjava/Evqueue.java branches/gridsim4.0-branch3/source/eduni/simjava/Semaphore.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_any_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_event.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_exception.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_from_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_none_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_not_from_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_not_type_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_outfile.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_output.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_port.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_predicate.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_system.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_type_p.java branches/gridsim4.0-branch3/source/gridsim/ARGridResource.java branches/gridsim4.0-branch3/source/gridsim/ARObject.java branches/gridsim4.0-branch3/source/gridsim/ARPolicy.java branches/gridsim4.0-branch3/source/gridsim/ARSimpleSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/Accumulator.java branches/gridsim4.0-branch3/source/gridsim/AdvanceReservation.java branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/GridInformationService.java branches/gridsim4.0-branch3/source/gridsim/GridResource.java branches/gridsim4.0-branch3/source/gridsim/GridSim.java branches/gridsim4.0-branch3/source/gridsim/GridSimCore.java branches/gridsim4.0-branch3/source/gridsim/GridSimRandom.java branches/gridsim4.0-branch3/source/gridsim/GridSimShutdown.java branches/gridsim4.0-branch3/source/gridsim/GridSimStandardPE.java branches/gridsim4.0-branch3/source/gridsim/GridSimTags.java branches/gridsim4.0-branch3/source/gridsim/GridStatistics.java branches/gridsim4.0-branch3/source/gridsim/GridUser.java branches/gridsim4.0-branch3/source/gridsim/Gridlet.java branches/gridsim4.0-branch3/source/gridsim/GridletList.java branches/gridsim4.0-branch3/source/gridsim/IO_data.java branches/gridsim4.0-branch3/source/gridsim/Machine.java branches/gridsim4.0-branch3/source/gridsim/MachineList.java branches/gridsim4.0-branch3/source/gridsim/ParameterException.java branches/gridsim4.0-branch3/source/gridsim/ResGridlet.java branches/gridsim4.0-branch3/source/gridsim/ResGridletList.java branches/gridsim4.0-branch3/source/gridsim/ResourceCalendar.java branches/gridsim4.0-branch3/source/gridsim/ResourceCharacteristics.java branches/gridsim4.0-branch3/source/gridsim/ResourceUserList.java branches/gridsim4.0-branch3/source/gridsim/Sim_from_port.java branches/gridsim4.0-branch3/source/gridsim/SpaceShared.java branches/gridsim4.0-branch3/source/gridsim/Stat.java branches/gridsim4.0-branch3/source/gridsim/TimeShared.java branches/gridsim4.0-branch3/source/gridsim/gui/AllocationAction.java branches/gridsim4.0-branch3/source/gridsim/gui/AllocationListener.java branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java branches/gridsim4.0-branch3/source/gridsim/gui/GridSimVisualizer.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/FilterARMessage.java branches/gridsim4.0-branch3/source/gridsim/turbo/OrderGridletByStartTime.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java branches/gridsim4.0-branch3/source/gridsim/turbo/ParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java Deleted: branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java 2007-11-14 11:23:50 UTC (rev 80) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java 2007-11-29 01:04:02 UTC (rev 81) @@ -1,250 +0,0 @@ -/* 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 - */ - -package examples; - -import eduni.simjava.Sim_event; -import eduni.simjava.Sim_system; -import gridsim.GridSimTags; -import gridsim.Gridlet; -import gridsim.IO_data; -import gridsim.ParameterException; -import gridsim.net.Link; -import gridsim.util.Workload; - -import java.util.ArrayList; - -/** - * This class is an extended version of {@link Workload}. This class - * cancels some gridlets submitted. - * - * @author Marcos Dias de Assuncao - * @since GridSim Turbo Alpha 0.1 - * - * @see Workload - */ -public class WorkloadWithCancellation extends Workload { - private final int NUM_GRIDLETS_BETWEEN_CANCELLATIONS = 50; - // value of 1, means that the cancellation will be sent - // at the gridlet's submission time + (gridlet duration * 1) - private final double TIME_CANCELLATION = 0.5; - - /** - * Create a new {@link WorkloadWithCancellation} object <b>without</b> using - * the network extension. This means this entity directly sends Gridlets - * to a resource destination without going through a wired network. <br> - * <tt>NOTE:</tt> - * You can not use this constructor in an experiment that uses a wired - * network topology. - * - * @param name this entity name - * @param fileName the workload trace filename in one of the following - * format: <i>ASCII text, zip, gz.</i> - * @param resourceName the resource name - * @param rating the resource's PE rating - * @throws Exception This happens when creating this entity before - * initialising GridSim package or this entity name is - * <tt>null</tt> or empty - * @throws ParameterException This happens for the following conditions: - * <ul> - * <li>the entity name is null or empty - * <li>the workload trace file name is null or empty - * <li>the resource entity name is null or empty - * <li>the resource PE rating <= 0 - * </ul> - * @pre name != null - * @pre fileName != null - * @pre resourceName != null - * @pre rating > 0 - * @post $none - */ - public WorkloadWithCancellation(String name, String fileName, String resourceName, - int rating) throws ParameterException, Exception { - - super(name, fileName, resourceName, rating); - } - - /** - * Create a new {@link WorkloadWithCancellation} object <b>with</b> the network extension. - * This means this entity directly sends Gridlets to a destination resource - * through a link. The link is automatically created by this constructor. - * - * @param name this entity name - * @param baudRate baud rate of this link (bits/s) - * @param propDelay Propagation delay of the Link in milliseconds - * @param MTU Maximum Transmission Unit of the Link in bytes. - * Packets which are larger than the MTU should be split - * up into MTU size units. - * For example, a 1024 byte packet trying to cross a 576 - * byte MTU link should get split into 2 packets of 576 - * bytes and 448 bytes. - * @param fileName the workload trace filename in one of the following - * format: <i>ASCII text, zip, gz.</i> - * @param resourceName the resource name - * @param rating the resource's PE rating - * @throws Exception This happens when creating this entity before - * initialising GridSim package or this entity name is - * <tt>null</tt> or empty - * @throws ParameterException This happens for the following conditions: - * <ul> - * <li>the entity name is null or empty - * <li> baudRate <= 0 - * <li> propDelay <= 0 - * <li> MTU <= 0 - * <li>the workload trace file name is null or empty - * <li>the resource entity name is null or empty - * <li>the resource PE rating <= 0 - * </ul> - * @pre name != null - * @pre baudRate > 0 - * @pre propDelay > 0 - * @pre MTU > 0 - * @pre fileName != null - * @pre resourceName != null - * @pre rating > 0 - * @post $none - */ - public WorkloadWithCancellation(String name, double baudRate, double propDelay, int MTU, - String fileName, String resourceName, int rating) - throws ParameterException, Exception { - - super( name, baudRate, propDelay, MTU, fileName, resourceName, rating ); - } - - /** - * Create a new Workload object <b>with</b> the network extension. - * This means this entity directly sends Gridlets to a destination resource - * through a link. The link is automatically created by this constructor. - * - * @param name this entity name - * @param link the link that will be used to connect this Workload - * to another entity or a Router. - * @param fileName the workload trace filename in one of the following - * format: <i>ASCII text, zip, gz.</i> - * @param resourceName the resource name - * @param rating the resource's PE rating - * @throws Exception This happens when creating this entity before - * initialising GridSim package or this entity name is - * <tt>null</tt> or empty - * @throws ParameterException This happens for the following conditions: - * <ul> - * <li>the entity name is null or empty - * <li>the link is empty - * <li>the workload trace file name is null or empty - * <li>the resource entity name is null or empty - * <li>the resource PE rating <= 0 - * </ul> - * @pre name != null - * @pre link != null - * @pre fileName != null - * @pre resourceName != null - * @pre rating > 0 - * @post $none - */ - public WorkloadWithCancellation(String name, Link link, String fileName, - String resourceName, int rating) - throws ParameterException, Exception { - - super(name, link, fileName, resourceName, rating); - } - - //////////////////////// PRIVATE METHODS /////////////////////// - - /** - * Collects Gridlets sent and stores them into a list. - * @pre $none - * @post $none - */ - protected void collectGridlet() { - System.out.println(super.get_name() + ": Collecting Gridlets ..."); - list_ = new ArrayList(gridletID_ + 1); - - Object data = null; - Gridlet gl = null; - - int counter = 1; // starts at 1, since gridletID_ starts at 1 too - Sim_event ev = new Sim_event(); - while ( Sim_system.running() ) { - - super.sim_get_next(ev); // get the next available event - data = ev.get_data(); // get the event's data - - // handle ping request - if (ev.get_tag() == GridSimTags.INFOPKT_SUBMIT) { - processPingRequest(ev); - continue; - } - - // get the Gridlet data - if (data != null && data instanceof Gridlet) { - gl = (Gridlet) data; - -// if(gl.getGridletStatus() == Gridlet.FAILED) -// System.out.println("Gridlet failed"); -// -// if(gl.getGridletStatus() == Gridlet.CANCELED) -// System.out.println("Gridlet cancelled"); - - list_.add(gl); - counter++; - } - - // if all the Gridlets have been collected - if (counter == gridletID_) { - break; - } - } - } - - /** - * Creates a Gridlet with the given information, then submit it to a - * resource - * @param id a Gridlet ID - * @param submitTime Gridlet's submit time - * @param runTime Gridlet's run time - * @param numProc number of processors - * @pre id >= 0 - * @pre submitTime >= 0 - * @pre runTime >= 0 - * @pre numProc > 0 - * @post $none - */ - protected void submitGridlet(int id, long submitTime, int runTime, int numProc) { - - // create the gridlet - int len = runTime * rating_; // calculate a job length for each PE - Gridlet gl = new Gridlet(id, len, size_, size_); - gl.setUserID( super.get_id() ); // set the owner ID - gl.setNumPE(numProc); // set the requested num of proc - - // printing to inform user - if (gridletID_ == 1 || gridletID_ % INTERVAL == 0) { - System.out.println(super.get_name() + ": Submitting Gridlets to " + - resName_ + " ..."); - } - - // check the submit time - if (submitTime < 0) { - submitTime = 0; - } - - gridletID_++; // increment the counter - - // submit a gridlet to resource - super.send(super.output, submitTime, GridSimTags.GRIDLET_SUBMIT, - new IO_data(gl, gl.getGridletFileSize(), resID_) ); - - // check whether a cancellation has to be scheduled or not - int result = gridletID_ % NUM_GRIDLETS_BETWEEN_CANCELLATIONS; - if(result == 0) { - super.send(super.output, (submitTime + (TIME_CANCELLATION * runTime)), GridSimTags.GRIDLET_CANCEL, - new IO_data(gl, 0, resID_) ); - gridletID_++; - } - } - -} // end class - Deleted: branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java 2007-11-14 11:23:50 UTC (rev 80) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java 2007-11-29 01:04:02 UTC (rev 81) @@ -1,1077 +0,0 @@ -/* - * 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 - * - */ - -package examples; - -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Enumeration; -import java.util.Random; -import java.util.zip.GZIPInputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import eduni.simjava.Sim_event; -import eduni.simjava.Sim_system; - -import gridsim.GridSim; -import gridsim.GridSimTags; -import gridsim.Gridlet; -import gridsim.IO_data; -import gridsim.ParameterException; -import gridsim.net.InfoPacket; -import gridsim.net.Link; -import gridsim.net.SimpleLink; -import gridsim.turbo.Reservation; -import gridsim.turbo.ReservationRequester; - -/** - * The main purpose of this class is to create a realistic simulation - * environment where your jobs or Gridlets are competing with others. - * In other words, the grid resource might not be available at certain times. - * In addition, the arrival time of jobs are also captured in the trace file. - * <p> - * This workload class has been modified to simulate advance reservations. - * Some parameters where included to indicate the frequency in which - * advance reservations are made. Additionally, it is possible to specify how - * long in advance the advance reservations are made. - * <p> - * This class is responsible for reading resource traces from a file and - * sends Gridlets to only <tt>one</tt> destinated resource. <br> - * <b>NOTE:</b> - * <ul> - * <li> This class can only take <tt>one</tt> trace file of the following - * format: <i>ASCII text, zip, gz.</i> - * <li> This class can be classified as <b>one grid user entity</b>. - * Hence, you need to incorporate this entity into <tt>numUser</tt> - * during {@link gridsim.GridSim#init(int, Calendar, boolean)} - * <li> If you need to use multiple trace files to submit Gridlets to - * same or different resources, then you need to create multiple - * instances of this class <tt>each with a unique entity name</tt>. - * <li> If size of the trace file is huge or contains lots of traces - * please increase the JVM heap size accordingly by using - * <tt>java -Xmx</tt> option when running the simulation. - * <li> If you are running an experiment using the network extension, - * i.e. the gridsim.net package, then you need to use - * {@link #Workload(String, double, double, int, String, String, int)} - * instead. - * <li> The default job file size for sending to and receiving from - * a resource is {@link gridsim.net.Link#DEFAULT_MTU}. - * However, you can specify - * the file size by using {@link #setGridletFileSize(int)}. - * <li> A job run time is only for 1 PE <tt>not</tt> the total number of - * allocated PEs. - * Therefore, a Gridlet length is also calculated for 1 PE.<br> - * For example, job #1 in the trace has a run time of 100 seconds - * for 2 processors. This means each processor runs - * job #1 for 100 seconds, if the processors have the same - * specification. - * </ul> - * <p> - * By default, this class follows the standard workload format as specified - * in <a href="http://www.cs.huji.ac.il/labs/parallel/workload/"> - * http://www.cs.huji.ac.il/labs/parallel/workload/</a> <br> - * However, you can use other format by calling the below methods before - * running the simulation: - * <ul> - * <li> {@link #setComment(String)} - * <li> {@link #setField(int, int, int, int, int)} - * </ul> - * - * @see gridsim.GridSim#init(int, Calendar, boolean) - * @author Marcos Dias de Assuncao (the most of the code came - * from {@link Workload} class) - * @since GridSim Turbo Alpha 0.1 - * @invariant $none - */ - -public class WorkloadWithReservation extends ReservationRequester { - - protected String fileName_; // file name - protected String resName_; // resource name - protected int resID_; // resource ID - protected int rating_; // a PE rating - protected int gridletID_; // gridletID - protected int size_; // job size for sending it through a network - protected ArrayList list_; // a list for getting all the Gridlets - - // constant - private int JOB_NUM; // job number - private int SUBMIT_TIME; // submit time of a Gridlet - private int RUN_TIME; // running time of a Gridlet - private int NUM_PROC; // number of processors needed for a Gridlet - private int REQ_NUM_PROC; // required number of processors - private int REQ_RUN_TIME; // required running time - private int MAX_FIELD; // max number of field in the trace file - private String COMMENT; // a string that denotes the start of a comment - private final int IRRELEVANT = -1; // irrelevant number - protected final int INTERVAL = 10; // number of intervals - private String[] fieldArray_; // a temp array storing all the fields - - // ADVANCE RESERVATION PROPERTIES - private double reservProbability_; - private double timeInAdvance_; - private Random numGen_; - private long seed_ = 11L*13*17*19*23+1; - - // TAGS FOR INTERNAL EVENTS - private final int GRIDLET_SUBMIT = 10; - private final int RESERVE_RESOURCES = 11; - - /** - * Create a new Workload object <b>without</b> using the network extension. - * This means this entity directly sends Gridlets to a destination resource - * without going through a wired network. <br> - * <tt>NOTE:</tt> - * You can not use this constructor in an experiment that uses a wired - * network topology. - * - * @param name this entity name - * @param fileName the workload trace filename in one of the following - * format: <i>ASCII text, zip, gz.</i> - * @param resourceName the resource name - * @param rating the resource's PE rating - * @throws Exception This happens when creating this entity before - * initialising GridSim package or this entity name is - * <tt>null</tt> or empty - * @throws ParameterException This happens for the following conditions: - * <ul> - * <li>the entity name is null or empty - * <li>the workload trace file name is null or empty - * <li>the resource entity name is null or empty - * <li>the resource PE rating <= 0 - * </ul> - * @pre name != null - * @pre fileName != null - * @pre resourceName != null - * @pre rating > 0 - * @post $none - */ - public WorkloadWithReservation(String name, String fileName, String resourceName, - int rating) throws ParameterException, Exception { - super(name, GridSimTags.DEFAULT_BAUD_RATE); - - // check the input parameters first - String msg = name + "(): Error - "; - if (fileName == null || fileName.length() == 0) { - throw new ParameterException(msg + "invalid trace file name."); - } - else if (resourceName == null || resourceName.length() == 0) { - throw new ParameterException(msg + "invalid resource name."); - } - else if (rating <= 0) { - throw new ParameterException(msg+"resource PE rating must be > 0."); - } - - System.out.println(name + ": Creating a workload object ..."); - init(fileName, resourceName, rating); - } - - /** - * Create a new Workload object <b>with</b> the network extension. - * This means this entity directly sends Gridlets to a destination resource - * through a link. The link is automatically created by this constructor. - * - * @param name this entity name - * @param baudRate baud rate of this link (bits/s) - * @param propDelay Propagation delay of the Link in milliseconds - * @param MTU Maximum Transmission Unit of the Link in bytes. - * Packets which are larger than the MTU should be split - * up into MTU size units. - * For example, a 1024 byte packet trying to cross a 576 - * byte MTU link should get split into 2 packets of 576 - * bytes and 448 bytes. - * @param fileName the workload trace filename in one of the following - * format: <i>ASCII text, zip, gz.</i> - * @param resourceName the resource name - * @param rating the resource's PE rating - * @throws Exception This happens when creating this entity before - * initialising GridSim package or this entity name is - * <tt>null</tt> or empty - * @throws ParameterException This happens for the following conditions: - * <ul> - * <li>the entity name is null or empty - * <li> baudRate <= 0 - * <li> propDelay <= 0 - * <li> MTU <= 0 - * <li>the workload trace file name is null or empty - * <li>the resource entity name is null or empty - * <li>the resource PE rating <= 0 - * </ul> - * @pre name != null - * @pre baudRate > 0 - * @pre propDelay > 0 - * @pre MTU > 0 - * @pre fileName != null - * @pre resourceName != null - * @pre rating > 0 - * @post $none - */ - public WorkloadWithReservation(String name, double baudRate, double propDelay, int MTU, - String fileName, String resourceName, int rating) - throws ParameterException, Exception { - super( name, new SimpleLink(name+"_link", baudRate, propDelay, MTU) ); - - // check the input parameters first - String msg = name + "(): Error - "; - if (fileName == null || fileName.length() == 0) { - throw new ParameterException(msg + "invalid trace file name."); - } - else if (resourceName == null || resourceName.length() == 0) { - throw new ParameterException(msg + "invalid resource name."); - } - else if (rating <= 0) { - throw new ParameterException(msg+"resource PE rating must be > 0."); - } - - System.out.println(name + ": Creating a workload object ..."); - init(fileName, resourceName, rating); - } - - /** - * Create a new Workload object <b>with</b> the network extension. - * This means this entity directly sends Gridlets to a destination resource - * through a link. The link is automatically created by this constructor. - * - * @param name this entity name - * @param link the link that will be used to connect this Workload - * to another entity or a Router. - * @param fileName the workload trace filename in one of the following - * format: <i>ASCII text, zip, gz.</i> - * @param resourceName the resource name - * @param rating the resource's PE rating - * @throws Exception This happens when creating this entity before - * initialising GridSim package or this entity name is - * <tt>null</tt> or empty - * @throws ParameterException This happens for the following conditions: - * <ul> - * <li>the entity name is null or empty - * <li>the link is empty - * <li>the workload trace file name is null or empty - * <li>the resource entity name is null or empty - * <li>the resource PE rating <= 0 - * </ul> - * @pre name != null - * @pre link != null - * @pre fileName != null - * @pre resourceName != null - * @pre rating > 0 - * @post $none - */ - public WorkloadWithReservation(String name, Link link, String fileName, - String resourceName, int rating) - throws ParameterException, Exception { - super(name, link); - - // check the input parameters first - String msg = name + "(): Error - "; - if (fileName == null || fileName.length() == 0) { - throw new ParameterException(msg + "invalid trace file name."); - } - else if (resourceName == null || resourceName.length() == 0) { - throw new ParameterException(msg + "invalid resource name."); - } - else if (rating <= 0) { - throw new ParameterException(msg+"resource PE rating must be > 0."); - } - - System.out.println(name + ": Creating a workload object ..."); - init(fileName, resourceName, rating); - } - - /** - * Gets the probability of a job in the workload - * be an advance reservation - * @return the reservation probability - */ - public double getReservationProbability() { - return reservProbability_; - } - - /** - * Sets the probability of a job in the workload - * be an advance reservation - * @param probability the reservation probability - */ - public void setReservationProbability(double probability) { - reservProbability_ = probability; - } - - /** - * Gets how long in advance an advance reservation has to - * be made. The time in advance is how long in advance to - * the submission time included in the log the reservation - * has to be made - * @return the time in advance - */ - public double getARTimeInAdvance() { - return timeInAdvance_; - } - - /** - * Sets how long in advance an advance reservation has to - * be made. The time in advance is how long in advance to - * the submission time included in the log the reservation - * has to be made - * @param time the time in advance - */ - public void setARTimeInAdvance(double time) { - timeInAdvance_ = time; - } - - /** - * Initialises all the attributes - * @param fileName trace file name - * @param resourceName resource entity name - * @param rating resource PE rating - * @pre $none - * @post $none - */ - private void init(String fileName, String resourceName, int rating) - { - fileName_ = fileName; - resName_ = resourceName; - resID_ = GridSim.getEntityId(resName_); - rating_ = rating; - gridletID_ = 1; // starts at 1 to make it the same as in a trace file - list_ = null; - size_ = Link.DEFAULT_MTU; - - timeInAdvance_ = 60 * 60; // one hour - reservProbability_ = 0D; - numGen_ = new Random(seed_); - - // if using Standard Workload Format -- don't forget to substract by 1 - // since an array starts at 0, but the field in a trace starts at 1 - JOB_NUM = 1 - 1; - SUBMIT_TIME = 2 - 1; - RUN_TIME = 4 - 1; - NUM_PROC = 5 - 1; - REQ_NUM_PROC = 8 - 1; - REQ_RUN_TIME = 9 - 1; - - COMMENT = ";"; // semicolon means the start of a comment - MAX_FIELD = 18; // standard workload format has 18 fields - fieldArray_ = null; - } - - /** - * Sets a Gridlet file size (in byte) for sending to/from a resource. - * @param size a Gridlet file size (in byte) - * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise - * @pre size > 0 - * @post $none - */ - public boolean setGridletFileSize(int size) { - if (size < 0) { - return false; - } - - size_ = size; - return true; - } - - /** - * Identifies the start of a comment line. Hence, a line that starts - * with a given comment will be ignored. - * @param comment a character that denotes the start of a comment, - * e.g. ";" or "#" - * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise - * @pre comment != null - * @post $none - */ - public boolean setComment(String comment) - { - boolean success = false; - if (comment != null && comment.length() > 0) - { - COMMENT = comment; - success = true; - } - return success; - } - - /** - * Tells this class what to look in the trace file. - * This method should be called before the start of the simulation. - * <p> - * By default, this class follows the standard workload format as specified - * in <a href="http://www.cs.huji.ac.il/labs/parallel/workload/"> - * http://www.cs.huji.ac.il/labs/parallel/workload/</a> <br> - * However, you can use other format by calling this method. - * <p> - * The parameters must be a positive integer number starting from 1. - * A special case is where <tt>jobNum == -1</tt>, meaning the job or - * gridlet ID starts at 1. - * - * @param maxField max. number of field/column in one row - * @param jobNum field/column number for locating the job ID - * @param submitTime field/column number for locating the job submit time - * @param runTime field/column number for locating the job run time - * @param numProc field/column number for locating the number of PEs - * required to run a job - * @return <tt>true</tt> if successful, <tt>false</tt> otherwise - * @pre maxField > 0 - * @pre submitTime > 0 - * @pre runTime > 0 - * @pre numProc > 0 - * @post $none - */ - public boolean setField(int maxField, int jobNum, int submitTime, - int runTime, int numProc) - { - // need to substract by 1 since array starts at 0. Need to convert, - // position in a field into the index of the array - if (jobNum > 0) { - JOB_NUM = jobNum - 1; - } - else if (jobNum == 0) - { - System.out.println(super.get_name() + - ".setField(): Invalid job number field."); - return false; - } - else { - JOB_NUM = -1; - } - - // get the max. number of field - if (maxField > 0) { - MAX_FIELD = maxField; - } - else - { - System.out.println(super.get_name() + - ".setField(): Invalid max. number of field."); - return false; - } - - // get the submit time field - if (submitTime > 0) { - SUBMIT_TIME = submitTime - 1; - } - else - { - System.out.println(super.get_name() + - ".setField(): Invalid submit time field."); - return false; - } - - // get the run time field - if (runTime > 0) { - REQ_RUN_TIME = runTime - 1; - } - else - { - System.out.println(super.get_name() + - ".setField(): Invalid run time field."); - return false; - } - - // get the number of processors field - if (numProc > 0) { - REQ_NUM_PROC = numProc - 1; - } - else - { - System.out.println(super.get_name() + - ".setField(): Invalid number of processors field."); - return false; - } - - return true; - } - - /** - * Gets a list of completed Gridlets - * @return a list of Gridlets - * @pre $none - * @post $none - */ - public ArrayList getGridletList() { - return list_; - } - - /** - * Prints the Gridlet objects - * @param history <tt>true</tt> means printing each Gridlet's history, - * <tt>false</tt> otherwise - * @pre $none - * @post $none - */ - public void printGridletList(boolean history) - { - String name = super.get_name(); - int size = list_.size(); - Gridlet gridlet; - - String indent = " "; - System.out.println(); - System.out.println("========== OUTPUT for " + name + " =========="); - System.out.println("Gridlet_ID" + indent + "STATUS" + indent + - "Resource_ID" + indent + "Cost"); - - int i = 0; - for (i = 0; i < size; i++) - { - gridlet = (Gridlet) list_.get(i); - System.out.print(indent + gridlet.getGridletID() + indent - + indent); - - // get the status of a Gridlet - System.out.print( gridlet.getGridletStatusString() ); - System.out.println( indent + indent + gridlet.getResourceID() + - indent + indent + gridlet.getProcessingCost() ); - } - - System.out.println(); - if (history == true) - { - // a loop to print each Gridlet's history - System.out.println(); - 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("========================================="); - System.out.println(); - } - } - } - - /** - * Reads from a given file when the simulation starts running. - * Then submits Gridlets to a resource and collects them before exiting. - * To collect the completed Gridlets, use {@link #getGridletList()} - * @pre $none - * @post $none - */ - public void body() { - System.out.println(); - System.out.println(super.get_name() + ".body() :%%%% Start ..."); - - // create a temp array - fieldArray_ = new String[MAX_FIELD]; - - // get the resource id - if (resID_ < 0) - { - System.out.println(super.get_name() + - ".body(): Error - invalid resource name: " + resName_); - return; - } - - boolean success = false; - - // read the gz file - if (fileName_.endsWith(".gz") == true) { - success = readGZIPFile(fileName_); - } - // read the zip file - else if (fileName_.endsWith(".zip") == true) { - success = readZipFile(fileName_); - } - // read from uncompressed file as well - else { - success = readFile(fileName_); - } - - // if all the gridlets have been submitted - if (!success ) { - System.out.println(super.get_name() + - ".body(): Error - unable to parse from a file."); - return; - } - - System.out.println(super.get_name() + ": Collecting Gridlets ..."); - list_ = new ArrayList(gridletID_ + 1); - - Object data = null; - Gridlet gl = null; - - int counter = 1; // starts at 1, since gridletID_ starts at 1 too - Sim_event ev = new Sim_event(); - Object[] reservObj = null; - - while ( Sim_system.running() - && counter < gridletID_ ) { - - super.sim_get_next(ev); // get the next available event - data = ev.get_data(); // get the event's data - - // handle ping request - if (ev.get_tag() == GridSimTags.INFOPKT_SUBMIT) { - processPingRequest(ev); - continue; - } - else if (ev.get_tag() == RESERVE_RESOURCES) { - - reservObj = (Object[])ev.get_data(); - - double startTime = (Double)reservObj[0]; - int duration = (Integer)reservObj[1]; - Gridlet resGl = (Gridlet)reservObj[2]; - - // creates a new reservation - Reservation reservation = null; - reservation = super.createReservation(startTime, duration, resGl.getNumPE(), resID_); - - success = true; - if(reservation == null) { - success = false; - } - - // commit the reservation - if(success) { - // for a reservation with an even number, commits straightaway - // without sending any Gridlets yet - success = super.commitReservation(reservation.getID()); - - // submit the gridlet if success - if(success) { - - // sets the reservation id of this gridlet - resGl.setReservationID(reservation.getID()); - - // submit the gridlet to the resource - super.send(super.output, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, - new IO_data(resGl, resGl.getGridletFileSize(), resID_) ); - } - // if the reservation fails, then sets the status of the - // gridlet to failed and adds the gridlet to the list - else { - try { - resGl.setGridletStatus(Gridlet.FAILED); - } - catch(Exception ex) { - - } - list_.add(resGl); - } - } - counter++; - } - - // get the Gridlet data - else if (data != null && data instanceof Gridlet) { - gl = (Gridlet) data; - list_.add(gl); - counter++; - } - - // if all the Gridlets have been collected - if (counter == gridletID_) { - break; - } - } - - // shut down all the entities, including GridStatistics entity since - // we used it to record certain events. - shutdownGridStatisticsEntity(); - shutdownUserEntity(); - terminateIOEntities(); - - System.out.println(super.get_name() + ".body() : %%%% Exit ..."); - } - - //////////////////////// PROTECTED METHODS /////////////////////// - - /** - * Processes a ping request. - * @param ev a Sim_event object - * @pre ev != null - * @post $none - */ - protected void processPingRequest(Sim_event ev) - { - InfoPacket pkt = (InfoPacket) ev.get_data(); - pkt.setTag(GridSimTags.INFOPKT_RETURN); - pkt.setDestID( pkt.getSrcID() ); - - // sends back to the sender - super.send(super.output, GridSimTags.SCHEDULE_NOW, - GridSimTags.INFOPKT_RETURN, - new IO_data(pkt, pkt.getSize(), pkt.getSrcID()) ); - } - - //////////////////////// PRIVATE METHODS /////////////////////// - - /** - * Breaks a line of string into many fields. - * @param line a line of string - * @param lineNum a line number - * @pre line != null - * @pre lineNum > 0 - * @post $none - */ - private void parseValue(String line, int lineNum) - { - // skip a comment line - if (line.startsWith(COMMENT) == true) { - return; - } - - String[] sp = line.split("\\s+"); // split the fields based on a space - int i; // a counter - int len = 0; // length of a string - int index = 0; // the index of an array - - // check for each field in the array - for (i = 0; i < sp.length; i++) - { - len = sp[i].length(); // get the length of a string - - // if it is empty then ignore - if (len == 0) { - continue; - } - // if not, then put into the array - else - { - fieldArray_[index] = sp[i]; - index++; - } - } - - if (index == MAX_FIELD) { - extractField(fieldArray_, lineNum); - } - } - - /** - * Extracts relevant information from a given array - * @param array an array of String - * @param line a line number - * @pre array != null - * @pre line > 0 - */ - private void extractField(String[] array, int line) - { - try - { - Integer obj = null; - - // get the job number - int id = 0; - if (JOB_NUM == IRRELEVANT) { - id = gridletID_; - } - else - { - obj = new Integer( array[JOB_NUM].trim() ); - id = obj.intValue(); - } - - // get the submit time - Long l = new Long( array[SUBMIT_TIME].trim() ); - long submitTime = l.intValue(); - - // get the run time - obj = new Integer( array[REQ_RUN_TIME].trim() ); - int runTime = obj.intValue(); - - // if the required run time field is ignored, then use - // the actual run time - if (runTime == IRRELEVANT) - { - obj = new Integer( array[RUN_TIME].trim() ); - runTime = obj.intValue(); - } - - // according to the SWF manual, runtime of 0 is possible due - // to rounding down. E.g. runtime is 0.4 seconds -> runtime = 0 - if (runTime == 0) { - runTime = 1; // change to 1 second - } - - // get the number of allocated processors - obj = new Integer( array[REQ_NUM_PROC].trim() ); - int numProc = obj.intValue(); - - // if the required num of allocated processors field is ignored - // or zero, then use the actual field - if (numProc == IRRELEVANT || numProc == 0) - { - obj = new Integer( array[NUM_PROC].trim() ); - numProc = obj.intValue(); - } - - // finally, check if the num of PEs required is valid or not - if (numProc <= 0) - { - System.out.println(super.get_name() + ": Warning - job #" - + id + " at line " + line + " requires " + numProc - + " CPU. Change to 1 CPU."); - numProc = 1; - } - - // creates a submission/reservation event - submitGridlet(id, submitTime, runTime, numProc); - } - catch (Exception e) - { - System.out.println(super.get_name() + - ": Exception in reading file at line #" + line); - e.printStackTrace(); - } - } - - /** - * Creates a Gridlet with the given information, then submit it to a - * resource - * @param id a Gridlet ID - * @param submitTime Gridlet's submit time - * @param runTime Gridlet's run time - * @param numProc number of processors - * @pre id >= 0 - * @pre submitTime >= 0 - * @pre runTime >= 0 - * @pre numProc > 0 - * @post $none - */ - protected void submitGridlet(int id, long submitTime, int runTime, int numProc) { - // create the gridlet - int len = runTime * rating_; // calculate a job length for each PE - Gridlet gridlet = new Gridlet(id, len, size_, size_); - gridlet.setUserID( super.get_id() ); // set the owner ID - gridlet.setNumPE(numProc); // set the requested num of proc - - // check the probability of creating an advance reservation - double probAR = Math.abs(numGen_.nextDouble()); - - // check the submit time - if (submitTime < 0) { - submitTime = 0; - } - - if(probAR <= reservProbability_) { - - // calculate how long in advance the reservation is made - double timeInAdvance = timeInAdvance_ * numGen_.nextDouble(); - - // convert to seconds - double timeToReserve = submitTime - timeInAdvance; - - // if the time the reservation would be done has already - // past, then consider now as the submission time - if(timeToReserve <= 0.0D) { - timeToReserve = GridSimTags.SCHEDULE_NOW; - } - - //TODO To check the duration of the advance reservation later - Object[] reservObj = new Object[3]; - reservObj[0] = new Double(submitTime); // start time of the reservation - reservObj[1] = (int) runTime + 1; // the advance reservation duration - reservObj[2] = gridlet; // the gridlet to be submitted - - // submit an internal event to create a reservation for this gridlet - super.send(super.get_id(), timeToReserve, RESERVE_RESOURCES, reservObj); - } - else { - // printing to inform user - if (gridletID_ == 1 || gridletID_ % INTERVAL == 0) { - System.out.println(super.get_name() + ": Submitting Gridlets to " + - resName_ + " ..."); - } - - // submit a gridlet to resource - super.send(super.output, submitTime, GridSimTags.GRIDLET_SUBMIT, - new IO_data(gridlet, gridlet.getGridletFileSize(), resID_) ); - } - - gridletID_++; // increment the counter - } - - /** - * Reads a text file one line at the time - * @param fileName a file name - * @return <tt>true</tt> if reading a file is successful, <tt>false</tt> - * otherwise. - * @pre fileName != null - * @post $none - */ - private boolean readFile(String fileName) - { - boolean success = false; - BufferedReader reader = null; - try - { - FileInputStream file = new FileInputStream(fileName); - InputStreamReader input = new InputStreamReader(file); - reader = new BufferedReader(input); - - // read one line at the time - int line = 1; - while ( reader.ready() ) - { - parseValue(reader.readLine(), line); - line++; - } - - reader.close(); // close the file - success = true; - } - catch (FileNotFoundException f) - { - System.out.println(super.get_name() + - ": Error - the file was not found: " + f.getMessage()); - } - catch (IOException e) - { - System.out.println(super.get_name() + - ": Error - an IOException occurred: " + e.getMessage()); - } - finally - { - if (reader != null) - { - try { - reader.close(); // close the file - } - catch (IOException e) - { - System.out.println(super.get_name() + - ": Error - an IOException occurred: " + e.getMessage()); - } - } - } - - return success; - } - - /** - * Reads a gzip file one line at the time - * @param fileName a gzip file name - * @return <tt>true</tt> if reading a file is successful, <tt>false</tt> - * otherwise. - * @pre fileName != null - * @post $none - */ - private boolean readGZIPFile(String fileName) - { - boolean success = false; - BufferedReader reader = null; - try - { - FileInputStream file = new FileInputStream(fileName); - GZIPInputStream gz = new GZIPInputStream(file); - InputStreamReader input = new InputStreamReader(gz); - reader = new BufferedReader(input); - - // read one line at the time - int line = 1; - while ( reader.ready() ) - { - parseValue(reader.readLine(), line); - line++; - } - - reader.close(); // close the file - success = true; - } - catch (FileNotFoundException f) - { - System.out.println(super.get_name() + - ": Error - the file was not found: " + f.getMessage()); - } - catch (IOException e) - { - System.out.println(super.get_name() + - ": Error - an IOException occurred: " + e.getMessage()); - } - finally - { - if (reader != null) - { - try { - reader.close(); // close the file - } - catch (IOException e) - { - System.out.println(super.get_name() + - ": Error - an IOException occurred: " + e.getMessage()); - } - } - } - - return success; - } - - /** - * Reads a Zip file. Iterating through each entry and reading it one line - * at the time. - * @param fileName a zip file name - * @return <tt>true</tt> if reading a file is successful, <tt>false</tt> - * otherwise. - * @pre fileName != null - * @post $none - */ - private boolean readZipFile(String fileName) - { - boolean success = false; - ZipFile zipFile = null; - try - { - InputStreamReader input = null; - BufferedReader reader = null; - - // ZipFile offers an Enumeration of all the files in the Zip file - zipFile = new ZipFile(fileName); - for (Enumeration e = zipFile.entries(); e.hasMoreElements();) - { - success = false; // reset the value again - ZipEntry zipEntry = (ZipEntry) e.nextElement(); - - input = new InputStreamReader(zipFile.getInputStream(zipEntry)); - reader = new BufferedReader(input); - - // read one line at the time - int line = 1; - while ( reader.ready() ) - { - parseValue(reader.readLine(), line); - line++; - } - - reader.close(); // close the file - success = true; - } - } - catch (IOException e) - { - System.out.println(super.get_name() + - ": Error - an IOException occurred: " + e.getMessage()); - } - finally - { - if (zipFile != null) - { - try { - zipFile.close(); // close the file - } - catch (IOException e) - { - System.out.println(super.get_name() + - ": Error - an IOException occurred: " + e.getMessage()); - } - } - } - - return success; - } -} Deleted: branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2007-11-14 11:23:50 UTC (rev 80) +++ branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2007-11-29 01:04:02 UTC (rev 81) @@ -1,288 +0,0 @@ -/* - * Author Marcos Dias de Assuncao - * Date: September 2007 - * Description: A simple program to demonstrate of how to use basic - * advanced reservation functionalities, such as create, commit - * and status. - */ - -package examples.ar; - -import gridsim.GridSim; -import gridsim.Gridlet; -import gridsim.GridletList; -import gridsim.turbo.Reservation; -import gridsim.turbo.ReservationRequester; -import gridsim.turbo.AvailabilityInfo; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.LinkedList; -import java.util.Random; - -/** - * A user entity that reserves a resource in advance. - * In this example, only explore some functionalities, such as: - * - requests a new advanced reservation - * - requests a new immediate reservation. Immediate reservation means use - * current time as the starting time - * - commits an accepted reservation - * - checks the status of a reservation - */ -public class ARTest extends ReservationRequester { - private GridletList list_; // a list containing new Gridlets - private GridletList receiveList_; // a list containing completed Gridlets - private int failReservation_; // number of reservations failed - - // time constant values - private final int SEC = 1; // 1 second - private final int MIN = 60 * SEC; // 1 min in seconds - private final int HOUR = 60 * MIN; // 1 hour in minutes - private final int DAY = 24 * HOUR; // 1 day in hours - - - /** - * Creates a new grid user entity - * @param name the Entity name of this object - * @param baud_rate the communication speed - * @param totalJob number of Gridlets to be created - * @throws Exception This happens when creating this entity before - * initializing GridSim package or the entity name is - * <tt>null</tt> or empty - * @see gridsim.GridSim#init(int, Calendar, boolean) - */ - public ARTest(String name, double baud_rate, int totalJob) throws Exception { - super(name, baud_rate); - this.receiveList_ = new GridletList(); - this.failReservation_ = 0; - - // create Gridlets - list_ = createGridlet( totalJob, super.get_id() ); - - System.out.println("Creating a grid user entity with name = " + - name + ", and id = " + super.get_id()); - System.out.println(name + ": Creating " + totalJob + " Gridlets."); - } - - /** - * The core method that handles communications among GridSim entities. - */ - public void body() { - LinkedList resList; - - // waiting to get list of resources. Since GridSim package uses - // multi-threaded environment, your request might arrive earlier - // before one or more grid resource entities manage to register - // themselves to GridInformationService (GIS) entity. - // Therefore, it's better to wait in the first place - while (true) { - // need to pause for a while to wait GridResources finish - // registering to GIS - super.gridSimHold(2*SEC); // wait for 2 seconds - - resList = getGridResourceList(); - if (resList.size() > 0) { - break; - } - else { - System.out.println(super.get_name() + - ": Waiting to get list of resources ..."); - } - } - - // list of resource IDs that can support Advanced Reservation (AR) - ArrayList resARList = new ArrayList(); - - // list of resource names that can support AR - ArrayList resNameList = new ArrayList(); - - int totalPE = 0; - int i = 0; - Integer intObj = null; // resource ID - String name; // resource name - - // a loop that gets a list of resources that can support AR - for (i = 0; i < resList.size(... [truncated message content] |
From: <mar...@us...> - 2007-12-16 23:08:29
|
Revision: 82 http://gridsim.svn.sourceforge.net/gridsim/?rev=82&view=rev Author: marcos_dias Date: 2007-12-16 15:08:32 -0800 (Sun, 16 Dec 2007) Log Message: ----------- This update contains an additional resource allocation policy that supports parallel jobs with aggressive (EASY) backfilling. Due to the inclusion of this policy, a few other classes have been updated as well. Added Paths: ----------- branches/gridsim4.0-branch3/build.xml branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java branches/gridsim4.0-branch3/source/eduni/simjava/Evqueue.java branches/gridsim4.0-branch3/source/eduni/simjava/Semaphore.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_any_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_entity.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_event.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_exception.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_from_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_none_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_not_from_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_not_type_p.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_outfile.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_output.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_port.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_predicate.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_system.java branches/gridsim4.0-branch3/source/eduni/simjava/Sim_type_p.java branches/gridsim4.0-branch3/source/gridsim/ARGridResource.java branches/gridsim4.0-branch3/source/gridsim/ARObject.java branches/gridsim4.0-branch3/source/gridsim/ARPolicy.java branches/gridsim4.0-branch3/source/gridsim/ARSimpleSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/Accumulator.java branches/gridsim4.0-branch3/source/gridsim/AdvanceReservation.java branches/gridsim4.0-branch3/source/gridsim/AllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/GridInformationService.java branches/gridsim4.0-branch3/source/gridsim/GridResource.java branches/gridsim4.0-branch3/source/gridsim/GridSim.java branches/gridsim4.0-branch3/source/gridsim/GridSimCore.java branches/gridsim4.0-branch3/source/gridsim/GridSimRandom.java branches/gridsim4.0-branch3/source/gridsim/GridSimShutdown.java branches/gridsim4.0-branch3/source/gridsim/GridSimStandardPE.java branches/gridsim4.0-branch3/source/gridsim/GridSimTags.java branches/gridsim4.0-branch3/source/gridsim/GridStatistics.java branches/gridsim4.0-branch3/source/gridsim/GridUser.java branches/gridsim4.0-branch3/source/gridsim/Gridlet.java branches/gridsim4.0-branch3/source/gridsim/GridletList.java branches/gridsim4.0-branch3/source/gridsim/IO_data.java branches/gridsim4.0-branch3/source/gridsim/Machine.java branches/gridsim4.0-branch3/source/gridsim/MachineList.java branches/gridsim4.0-branch3/source/gridsim/ParameterException.java branches/gridsim4.0-branch3/source/gridsim/ResGridlet.java branches/gridsim4.0-branch3/source/gridsim/ResGridletList.java branches/gridsim4.0-branch3/source/gridsim/ResourceCalendar.java branches/gridsim4.0-branch3/source/gridsim/ResourceCharacteristics.java branches/gridsim4.0-branch3/source/gridsim/ResourceUserList.java branches/gridsim4.0-branch3/source/gridsim/Sim_from_port.java branches/gridsim4.0-branch3/source/gridsim/SpaceShared.java branches/gridsim4.0-branch3/source/gridsim/Stat.java branches/gridsim4.0-branch3/source/gridsim/TimeShared.java branches/gridsim4.0-branch3/source/gridsim/gui/AllocationAction.java branches/gridsim4.0-branch3/source/gridsim/gui/AllocationListener.java branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java branches/gridsim4.0-branch3/source/gridsim/gui/GUISettings.java branches/gridsim4.0-branch3/source/gridsim/gui/GridSimVisualizer.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARMessage.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfoEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfileEntry.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/FilterARMessage.java branches/gridsim4.0-branch3/source/gridsim/turbo/OrderGridletByStartTime.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERange.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java branches/gridsim4.0-branch3/source/gridsim/turbo/Reservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/ReservationRequester.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java branches/gridsim4.0-branch3/workloads/sdsc_blue_2000_01.txt branches/gridsim4.0-branch3/workloads/sdsc_blue_2000_02.txt branches/gridsim4.0-branch3/workloads/sdsc_blue_2000_03.txt Removed Paths: ------------- branches/gridsim4.0-branch3/workloads/sdsc_blue_2000.swf Added: branches/gridsim4.0-branch3/build.xml =================================================================== --- branches/gridsim4.0-branch3/build.xml (rev 0) +++ branches/gridsim4.0-branch3/build.xml 2007-12-16 23:08:32 UTC (rev 82) @@ -0,0 +1,63 @@ +<?xml version="1.0"?> + +<!-- September 2004 +Build file or Makefile for GridSim. +NOTE: Make sure you have installed 'ant' and put the location of it into + your path so you can access it anywhere. + 'ant' can be downloadable from http://ant.apache.org/ + +Usage: +* type 'ant' to compile all gridsim source files and put them into + classes/ directory +* type 'ant makejar' to compile the source files (if necessary) and to create + a jar file into jar/ directory + +NOTE: rule for javadoc is not included yet. Use javadoc.sh script instead under + Unix/Linux environment. + +Acknowledgement: Thank to Uros Cibej for providing this file and instruction on + how to use it. +--> + + +<project name="GridSim" basedir="." default="build"> + <description> + This is the build file for GridSim + </description> + + <!-- gridsim version id --> + <property name="version" value="turbo01"/> + + <!-- location to store Java classes --> + <property name="class.dir" location="./classes" /> + + <!-- location to store GridSim source files --> + <property name="src.dir" location="./source" /> + + <!-- location to store jar files --> + <property name="jar.dir" location="./jars" /> + + <!-- location to store Javadoc files --> + <property name="doc.dir" location="./doc" /> + + <target name="prepare"> + <mkdir dir="${class.dir}" /> + </target> + + <!-- rule to compile GridSim source files --> + <target name="build" depends="prepare"> + <javac srcdir="${src.dir}" destdir="${class.dir}" classpath="." /> + </target> + + <!-- rule for making a jar file. + NOTE: + * The new jar file is named as "gridsim_VERSION.jar". + --> + <target name="makejar" depends="build"> + <echo>Compiling a new jar file, named: "gridsim_${version}.jar".</echo> + <jar destfile="${jar.dir}/gridsim_${version}.jar" basedir="${class.dir}" /> + </target> + +</project> + + Added: branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java 2007-12-16 23:08:32 UTC (rev 82) @@ -0,0 +1,250 @@ +/* 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 + */ + +package examples; + +import eduni.simjava.Sim_event; +import eduni.simjava.Sim_system; +import gridsim.GridSimTags; +import gridsim.Gridlet; +import gridsim.IO_data; +import gridsim.ParameterException; +import gridsim.net.Link; +import gridsim.util.Workload; + +import java.util.ArrayList; + +/** + * This class is an extended version of {@link Workload}. This class + * cancels some gridlets submitted. + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see Workload + */ +public class WorkloadWithCancellation extends Workload { + private final int NUM_GRIDLETS_BETWEEN_CANCELLATIONS = 50; + // value of 1, means that the cancellation will be sent + // at the gridlet's submission time + (gridlet duration * 1) + private final double TIME_CANCELLATION = 0.5; + + /** + * Create a new {@link WorkloadWithCancellation} object <b>without</b> using + * the network extension. This means this entity directly sends Gridlets + * to a resource destination without going through a wired network. <br> + * <tt>NOTE:</tt> + * You can not use this constructor in an experiment that uses a wired + * network topology. + * + * @param name this entity name + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithCancellation(String name, String fileName, String resourceName, + int rating) throws ParameterException, Exception { + + super(name, fileName, resourceName, rating); + } + + /** + * Create a new {@link WorkloadWithCancellation} object <b>with</b> the network extension. + * This means this entity directly sends Gridlets to a destination resource + * through a link. The link is automatically created by this constructor. + * + * @param name this entity name + * @param baudRate baud rate of this link (bits/s) + * @param propDelay Propagation delay of the Link in milliseconds + * @param MTU Maximum Transmission Unit of the Link in bytes. + * Packets which are larger than the MTU should be split + * up into MTU size units. + * For example, a 1024 byte packet trying to cross a 576 + * byte MTU link should get split into 2 packets of 576 + * bytes and 448 bytes. + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li> baudRate <= 0 + * <li> propDelay <= 0 + * <li> MTU <= 0 + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre baudRate > 0 + * @pre propDelay > 0 + * @pre MTU > 0 + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithCancellation(String name, double baudRate, double propDelay, int MTU, + String fileName, String resourceName, int rating) + throws ParameterException, Exception { + + super( name, baudRate, propDelay, MTU, fileName, resourceName, rating ); + } + + /** + * Create a new Workload object <b>with</b> the network extension. + * This means this entity directly sends Gridlets to a destination resource + * through a link. The link is automatically created by this constructor. + * + * @param name this entity name + * @param link the link that will be used to connect this Workload + * to another entity or a Router. + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li>the link is empty + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre link != null + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithCancellation(String name, Link link, String fileName, + String resourceName, int rating) + throws ParameterException, Exception { + + super(name, link, fileName, resourceName, rating); + } + + //////////////////////// PRIVATE METHODS /////////////////////// + + /** + * Collects Gridlets sent and stores them into a list. + * @pre $none + * @post $none + */ + protected void collectGridlet() { + System.out.println(super.get_name() + ": Collecting Gridlets ..."); + list_ = new ArrayList(gridletID_ + 1); + + Object data = null; + Gridlet gl = null; + + int counter = 1; // starts at 1, since gridletID_ starts at 1 too + Sim_event ev = new Sim_event(); + while ( Sim_system.running() ) { + + super.sim_get_next(ev); // get the next available event + data = ev.get_data(); // get the event's data + + // handle ping request + if (ev.get_tag() == GridSimTags.INFOPKT_SUBMIT) { + processPingRequest(ev); + continue; + } + + // get the Gridlet data + if (data != null && data instanceof Gridlet) { + gl = (Gridlet) data; + +// if(gl.getGridletStatus() == Gridlet.FAILED) +// System.out.println("Gridlet failed"); +// +// if(gl.getGridletStatus() == Gridlet.CANCELED) +// System.out.println("Gridlet cancelled"); + + list_.add(gl); + counter++; + } + + // if all the Gridlets have been collected + if (counter == gridletID_) { + break; + } + } + } + + /** + * Creates a Gridlet with the given information, then submit it to a + * resource + * @param id a Gridlet ID + * @param submitTime Gridlet's submit time + * @param runTime Gridlet's run time + * @param numProc number of processors + * @pre id >= 0 + * @pre submitTime >= 0 + * @pre runTime >= 0 + * @pre numProc > 0 + * @post $none + */ + protected void submitGridlet(int id, long submitTime, int runTime, int numProc) { + + // create the gridlet + int len = runTime * rating_; // calculate a job length for each PE + Gridlet gl = new Gridlet(id, len, size_, size_); + gl.setUserID( super.get_id() ); // set the owner ID + gl.setNumPE(numProc); // set the requested num of proc + + // printing to inform user + if (gridletID_ == 1 || gridletID_ % INTERVAL == 0) { + System.out.println(super.get_name() + ": Submitting Gridlets to " + + resName_ + " ..."); + } + + // check the submit time + if (submitTime < 0) { + submitTime = 0; + } + + gridletID_++; // increment the counter + + // submit a gridlet to resource + super.send(super.output, submitTime, GridSimTags.GRIDLET_SUBMIT, + new IO_data(gl, gl.getGridletFileSize(), resID_) ); + + // check whether a cancellation has to be scheduled or not + int result = gridletID_ % NUM_GRIDLETS_BETWEEN_CANCELLATIONS; + if(result == 0) { + super.send(super.output, (submitTime + (TIME_CANCELLATION * runTime)), GridSimTags.GRIDLET_CANCEL, + new IO_data(gl, 0, resID_) ); + gridletID_++; + } + } + +} // end class + Added: branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java 2007-12-16 23:08:32 UTC (rev 82) @@ -0,0 +1,1077 @@ +/* + * 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 + * + */ + +package examples; + +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Enumeration; +import java.util.Random; +import java.util.zip.GZIPInputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import eduni.simjava.Sim_event; +import eduni.simjava.Sim_system; + +import gridsim.GridSim; +import gridsim.GridSimTags; +import gridsim.Gridlet; +import gridsim.IO_data; +import gridsim.ParameterException; +import gridsim.net.InfoPacket; +import gridsim.net.Link; +import gridsim.net.SimpleLink; +import gridsim.turbo.Reservation; +import gridsim.turbo.ReservationRequester; + +/** + * The main purpose of this class is to create a realistic simulation + * environment where your jobs or Gridlets are competing with others. + * In other words, the grid resource might not be available at certain times. + * In addition, the arrival time of jobs are also captured in the trace file. + * <p> + * This workload class has been modified to simulate advance reservations. + * Some parameters where included to indicate the frequency in which + * advance reservations are made. Additionally, it is possible to specify how + * long in advance the advance reservations are made. + * <p> + * This class is responsible for reading resource traces from a file and + * sends Gridlets to only <tt>one</tt> destinated resource. <br> + * <b>NOTE:</b> + * <ul> + * <li> This class can only take <tt>one</tt> trace file of the following + * format: <i>ASCII text, zip, gz.</i> + * <li> This class can be classified as <b>one grid user entity</b>. + * Hence, you need to incorporate this entity into <tt>numUser</tt> + * during {@link gridsim.GridSim#init(int, Calendar, boolean)} + * <li> If you need to use multiple trace files to submit Gridlets to + * same or different resources, then you need to create multiple + * instances of this class <tt>each with a unique entity name</tt>. + * <li> If size of the trace file is huge or contains lots of traces + * please increase the JVM heap size accordingly by using + * <tt>java -Xmx</tt> option when running the simulation. + * <li> If you are running an experiment using the network extension, + * i.e. the gridsim.net package, then you need to use + * {@link #Workload(String, double, double, int, String, String, int)} + * instead. + * <li> The default job file size for sending to and receiving from + * a resource is {@link gridsim.net.Link#DEFAULT_MTU}. + * However, you can specify + * the file size by using {@link #setGridletFileSize(int)}. + * <li> A job run time is only for 1 PE <tt>not</tt> the total number of + * allocated PEs. + * Therefore, a Gridlet length is also calculated for 1 PE.<br> + * For example, job #1 in the trace has a run time of 100 seconds + * for 2 processors. This means each processor runs + * job #1 for 100 seconds, if the processors have the same + * specification. + * </ul> + * <p> + * By default, this class follows the standard workload format as specified + * in <a href="http://www.cs.huji.ac.il/labs/parallel/workload/"> + * http://www.cs.huji.ac.il/labs/parallel/workload/</a> <br> + * However, you can use other format by calling the below methods before + * running the simulation: + * <ul> + * <li> {@link #setComment(String)} + * <li> {@link #setField(int, int, int, int, int)} + * </ul> + * + * @see gridsim.GridSim#init(int, Calendar, boolean) + * @author Marcos Dias de Assuncao (the most of the code came + * from {@link Workload} class) + * @since GridSim Turbo Alpha 0.1 + * @invariant $none + */ + +public class WorkloadWithReservation extends ReservationRequester { + + protected String fileName_; // file name + protected String resName_; // resource name + protected int resID_; // resource ID + protected int rating_; // a PE rating + protected int gridletID_; // gridletID + protected int size_; // job size for sending it through a network + protected ArrayList list_; // a list for getting all the Gridlets + + // constant + private int JOB_NUM; // job number + private int SUBMIT_TIME; // submit time of a Gridlet + private int RUN_TIME; // running time of a Gridlet + private int NUM_PROC; // number of processors needed for a Gridlet + private int REQ_NUM_PROC; // required number of processors + private int REQ_RUN_TIME; // required running time + private int MAX_FIELD; // max number of field in the trace file + private String COMMENT; // a string that denotes the start of a comment + private final int IRRELEVANT = -1; // irrelevant number + protected final int INTERVAL = 10; // number of intervals + private String[] fieldArray_; // a temp array storing all the fields + + // ADVANCE RESERVATION PROPERTIES + private double reservProbability_; + private double timeInAdvance_; + private Random numGen_; + private long seed_ = 11L*13*17*19*23+1; + + // TAGS FOR INTERNAL EVENTS + private final int GRIDLET_SUBMIT = 10; + private final int RESERVE_RESOURCES = 11; + + /** + * Create a new Workload object <b>without</b> using the network extension. + * This means this entity directly sends Gridlets to a destination resource + * without going through a wired network. <br> + * <tt>NOTE:</tt> + * You can not use this constructor in an experiment that uses a wired + * network topology. + * + * @param name this entity name + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithReservation(String name, String fileName, String resourceName, + int rating) throws ParameterException, Exception { + super(name, GridSimTags.DEFAULT_BAUD_RATE); + + // check the input parameters first + String msg = name + "(): Error - "; + if (fileName == null || fileName.length() == 0) { + throw new ParameterException(msg + "invalid trace file name."); + } + else if (resourceName == null || resourceName.length() == 0) { + throw new ParameterException(msg + "invalid resource name."); + } + else if (rating <= 0) { + throw new ParameterException(msg+"resource PE rating must be > 0."); + } + + System.out.println(name + ": Creating a workload object ..."); + init(fileName, resourceName, rating); + } + + /** + * Create a new Workload object <b>with</b> the network extension. + * This means this entity directly sends Gridlets to a destination resource + * through a link. The link is automatically created by this constructor. + * + * @param name this entity name + * @param baudRate baud rate of this link (bits/s) + * @param propDelay Propagation delay of the Link in milliseconds + * @param MTU Maximum Transmission Unit of the Link in bytes. + * Packets which are larger than the MTU should be split + * up into MTU size units. + * For example, a 1024 byte packet trying to cross a 576 + * byte MTU link should get split into 2 packets of 576 + * bytes and 448 bytes. + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li> baudRate <= 0 + * <li> propDelay <= 0 + * <li> MTU <= 0 + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre baudRate > 0 + * @pre propDelay > 0 + * @pre MTU > 0 + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithReservation(String name, double baudRate, double propDelay, int MTU, + String fileName, String resourceName, int rating) + throws ParameterException, Exception { + super( name, new SimpleLink(name+"_link", baudRate, propDelay, MTU) ); + + // check the input parameters first + String msg = name + "(): Error - "; + if (fileName == null || fileName.length() == 0) { + throw new ParameterException(msg + "invalid trace file name."); + } + else if (resourceName == null || resourceName.length() == 0) { + throw new ParameterException(msg + "invalid resource name."); + } + else if (rating <= 0) { + throw new ParameterException(msg+"resource PE rating must be > 0."); + } + + System.out.println(name + ": Creating a workload object ..."); + init(fileName, resourceName, rating); + } + + /** + * Create a new Workload object <b>with</b> the network extension. + * This means this entity directly sends Gridlets to a destination resource + * through a link. The link is automatically created by this constructor. + * + * @param name this entity name + * @param link the link that will be used to connect this Workload + * to another entity or a Router. + * @param fileName the workload trace filename in one of the following + * format: <i>ASCII text, zip, gz.</i> + * @param resourceName the resource name + * @param rating the resource's PE rating + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li>the link is empty + * <li>the workload trace file name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre link != null + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public WorkloadWithReservation(String name, Link link, String fileName, + String resourceName, int rating) + throws ParameterException, Exception { + super(name, link); + + // check the input parameters first + String msg = name + "(): Error - "; + if (fileName == null || fileName.length() == 0) { + throw new ParameterException(msg + "invalid trace file name."); + } + else if (resourceName == null || resourceName.length() == 0) { + throw new ParameterException(msg + "invalid resource name."); + } + else if (rating <= 0) { + throw new ParameterException(msg+"resource PE rating must be > 0."); + } + + System.out.println(name + ": Creating a workload object ..."); + init(fileName, resourceName, rating); + } + + /** + * Gets the probability of a job in the workload + * be an advance reservation + * @return the reservation probability + */ + public double getReservationProbability() { + return reservProbability_; + } + + /** + * Sets the probability of a job in the workload + * be an advance reservation + * @param probability the reservation probability + */ + public void setReservationProbability(double probability) { + reservProbability_ = probability; + } + + /** + * Gets how long in advance an advance reservation has to + * be made. The time in advance is how long in advance to + * the submission time included in the log the reservation + * has to be made + * @return the time in advance + */ + public double getARTimeInAdvance() { + return timeInAdvance_; + } + + /** + * Sets how long in advance an advance reservation has to + * be made. The time in advance is how long in advance to + * the submission time included in the log the reservation + * has to be made + * @param time the time in advance + */ + public void setARTimeInAdvance(double time) { + timeInAdvance_ = time; + } + + /** + * Initialises all the attributes + * @param fileName trace file name + * @param resourceName resource entity name + * @param rating resource PE rating + * @pre $none + * @post $none + */ + private void init(String fileName, String resourceName, int rating) + { + fileName_ = fileName; + resName_ = resourceName; + resID_ = GridSim.getEntityId(resName_); + rating_ = rating; + gridletID_ = 1; // starts at 1 to make it the same as in a trace file + list_ = null; + size_ = Link.DEFAULT_MTU; + + timeInAdvance_ = 60 * 60; // one hour + reservProbability_ = 0D; + numGen_ = new Random(seed_); + + // if using Standard Workload Format -- don't forget to substract by 1 + // since an array starts at 0, but the field in a trace starts at 1 + JOB_NUM = 1 - 1; + SUBMIT_TIME = 2 - 1; + RUN_TIME = 4 - 1; + NUM_PROC = 5 - 1; + REQ_NUM_PROC = 8 - 1; + REQ_RUN_TIME = 9 - 1; + + COMMENT = ";"; // semicolon means the start of a comment + MAX_FIELD = 18; // standard workload format has 18 fields + fieldArray_ = null; + } + + /** + * Sets a Gridlet file size (in byte) for sending to/from a resource. + * @param size a Gridlet file size (in byte) + * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise + * @pre size > 0 + * @post $none + */ + public boolean setGridletFileSize(int size) { + if (size < 0) { + return false; + } + + size_ = size; + return true; + } + + /** + * Identifies the start of a comment line. Hence, a line that starts + * with a given comment will be ignored. + * @param comment a character that denotes the start of a comment, + * e.g. ";" or "#" + * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise + * @pre comment != null + * @post $none + */ + public boolean setComment(String comment) + { + boolean success = false; + if (comment != null && comment.length() > 0) + { + COMMENT = comment; + success = true; + } + return success; + } + + /** + * Tells this class what to look in the trace file. + * This method should be called before the start of the simulation. + * <p> + * By default, this class follows the standard workload format as specified + * in <a href="http://www.cs.huji.ac.il/labs/parallel/workload/"> + * http://www.cs.huji.ac.il/labs/parallel/workload/</a> <br> + * However, you can use other format by calling this method. + * <p> + * The parameters must be a positive integer number starting from 1. + * A special case is where <tt>jobNum == -1</tt>, meaning the job or + * gridlet ID starts at 1. + * + * @param maxField max. number of field/column in one row + * @param jobNum field/column number for locating the job ID + * @param submitTime field/column number for locating the job submit time + * @param runTime field/column number for locating the job run time + * @param numProc field/column number for locating the number of PEs + * required to run a job + * @return <tt>true</tt> if successful, <tt>false</tt> otherwise + * @pre maxField > 0 + * @pre submitTime > 0 + * @pre runTime > 0 + * @pre numProc > 0 + * @post $none + */ + public boolean setField(int maxField, int jobNum, int submitTime, + int runTime, int numProc) + { + // need to substract by 1 since array starts at 0. Need to convert, + // position in a field into the index of the array + if (jobNum > 0) { + JOB_NUM = jobNum - 1; + } + else if (jobNum == 0) + { + System.out.println(super.get_name() + + ".setField(): Invalid job number field."); + return false; + } + else { + JOB_NUM = -1; + } + + // get the max. number of field + if (maxField > 0) { + MAX_FIELD = maxField; + } + else + { + System.out.println(super.get_name() + + ".setField(): Invalid max. number of field."); + return false; + } + + // get the submit time field + if (submitTime > 0) { + SUBMIT_TIME = submitTime - 1; + } + else + { + System.out.println(super.get_name() + + ".setField(): Invalid submit time field."); + return false; + } + + // get the run time field + if (runTime > 0) { + REQ_RUN_TIME = runTime - 1; + } + else + { + System.out.println(super.get_name() + + ".setField(): Invalid run time field."); + return false; + } + + // get the number of processors field + if (numProc > 0) { + REQ_NUM_PROC = numProc - 1; + } + else + { + System.out.println(super.get_name() + + ".setField(): Invalid number of processors field."); + return false; + } + + return true; + } + + /** + * Gets a list of completed Gridlets + * @return a list of Gridlets + * @pre $none + * @post $none + */ + public ArrayList getGridletList() { + return list_; + } + + /** + * Prints the Gridlet objects + * @param history <tt>true</tt> means printing each Gridlet's history, + * <tt>false</tt> otherwise + * @pre $none + * @post $none + */ + public void printGridletList(boolean history) + { + String name = super.get_name(); + int size = list_.size(); + Gridlet gridlet; + + String indent = " "; + System.out.println(); + System.out.println("========== OUTPUT for " + name + " =========="); + System.out.println("Gridlet_ID" + indent + "STATUS" + indent + + "Resource_ID" + indent + "Cost"); + + int i = 0; + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list_.get(i); + System.out.print(indent + gridlet.getGridletID() + indent + + indent); + + // get the status of a Gridlet + System.out.print( gridlet.getGridletStatusString() ); + System.out.println( indent + indent + gridlet.getResourceID() + + indent + indent + gridlet.getProcessingCost() ); + } + + System.out.println(); + if (history == true) + { + // a loop to print each Gridlet's history + System.out.println(); + 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("========================================="); + System.out.println(); + } + } + } + + /** + * Reads from a given file when the simulation starts running. + * Then submits Gridlets to a resource and collects them before exiting. + * To collect the completed Gridlets, use {@link #getGridletList()} + * @pre $none + * @post $none + */ + public void body() { + System.out.println(); + System.out.println(super.get_name() + ".body() :%%%% Start ..."); + + // create a temp array + fieldArray_ = new String[MAX_FIELD]; + + // get the resource id + if (resID_ < 0) + { + System.out.println(super.get_name() + + ".body(): Error - invalid resource name: " + resName_); + return; + } + + boolean success = false; + + // read the gz file + if (fileName_.endsWith(".gz") == true) { + success = readGZIPFile(fileName_); + } + // read the zip file + else if (fileName_.endsWith(".zip") == true) { + success = readZipFile(fileName_); + } + // read from uncompressed file as well + else { + success = readFile(fileName_); + } + + // if all the gridlets have been submitted + if (!success ) { + System.out.println(super.get_name() + + ".body(): Error - unable to parse from a file."); + return; + } + + System.out.println(super.get_name() + ": Collecting Gridlets ..."); + list_ = new ArrayList(gridletID_ + 1); + + Object data = null; + Gridlet gl = null; + + int counter = 1; // starts at 1, since gridletID_ starts at 1 too + Sim_event ev = new Sim_event(); + Object[] reservObj = null; + + while ( Sim_system.running() + && counter < gridletID_ ) { + + super.sim_get_next(ev); // get the next available event + data = ev.get_data(); // get the event's data + + // handle ping request + if (ev.get_tag() == GridSimTags.INFOPKT_SUBMIT) { + processPingRequest(ev); + continue; + } + else if (ev.get_tag() == RESERVE_RESOURCES) { + + reservObj = (Object[])ev.get_data(); + + double startTime = (Double)reservObj[0]; + int duration = (Integer)reservObj[1]; + Gridlet resGl = (Gridlet)reservObj[2]; + + // creates a new reservation + Reservation reservation = null; + reservation = super.createReservation(startTime, duration, resGl.getNumPE(), resID_); + + success = true; + if(reservation == null) { + success = false; + } + + // commit the reservation + if(success) { + // for a reservation with an even number, commits straightaway + // without sending any Gridlets yet + success = super.commitReservation(reservation.getID()); + + // submit the gridlet if success + if(success) { + + // sets the reservation id of this gridlet + resGl.setReservationID(reservation.getID()); + + // submit the gridlet to the resource + super.send(super.output, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, + new IO_data(resGl, resGl.getGridletFileSize(), resID_) ); + } + // if the reservation fails, then sets the status of the + // gridlet to failed and adds the gridlet to the list + else { + try { + resGl.setGridletStatus(Gridlet.FAILED); + } + catch(Exception ex) { + + } + list_.add(resGl); + } + } + counter++; + } + + // get the Gridlet data + else if (data != null && data instanceof Gridlet) { + gl = (Gridlet) data; + list_.add(gl); + counter++; + } + + // if all the Gridlets have been collected + if (counter == gridletID_) { + break; + } + } + + // shut down all the entities, including GridStatistics entity since + // we used it to record certain events. + shutdownGridStatisticsEntity(); + shutdownUserEntity(); + terminateIOEntities(); + + System.out.println(super.get_name() + ".body() : %%%% Exit ..."); + } + + //////////////////////// PROTECTED METHODS /////////////////////// + + /** + * Processes a ping request. + * @param ev a Sim_event object + * @pre ev != null + * @post $none + */ + protected void processPingRequest(Sim_event ev) + { + InfoPacket pkt = (InfoPacket) ev.get_data(); + pkt.setTag(GridSimTags.INFOPKT_RETURN); + pkt.setDestID( pkt.getSrcID() ); + + // sends back to the sender + super.send(super.output, GridSimTags.SCHEDULE_NOW, + GridSimTags.INFOPKT_RETURN, + new IO_data(pkt, pkt.getSize(), pkt.getSrcID()) ); + } + + //////////////////////// PRIVATE METHODS /////////////////////// + + /** + * Breaks a line of string into many fields. + * @param line a line of string + * @param lineNum a line number + * @pre line != null + * @pre lineNum > 0 + * @post $none + */ + private void parseValue(String line, int lineNum) + { + // skip a comment line + if (line.startsWith(COMMENT) == true) { + return; + } + + String[] sp = line.split("\\s+"); // split the fields based on a space + int i; // a counter + int len = 0; // length of a string + int index = 0; // the index of an array + + // check for each field in the array + for (i = 0; i < sp.length; i++) + { + len = sp[i].length(); // get the length of a string + + // if it is empty then ignore + if (len == 0) { + continue; + } + // if not, then put into the array + else + { + fieldArray_[index] = sp[i]; + index++; + } + } + + if (index == MAX_FIELD) { + extractField(fieldArray_, lineNum); + } + } + + /** + * Extracts relevant information from a given array + * @param array an array of String + * @param line a line number + * @pre array != null + * @pre line > 0 + */ + private void extractField(String[] array, int line) + { + try + { + Integer obj = null; + + // get the job number + int id = 0; + if (JOB_NUM == IRRELEVANT) { + id = gridletID_; + } + else + { + obj = new Integer( array[JOB_NUM].trim() ); + id = obj.intValue(); + } + + // get the submit time + Long l = new Long( array[SUBMIT_TIME].trim() ); + long submitTime = l.intValue(); + + // get the run time + obj = new Integer( array[REQ_RUN_TIME].trim() ); + int runTime = obj.intValue(); + + // if the required run time field is ignored, then use + // the actual run time + if (runTime == IRRELEVANT) + { + obj = new Integer( array[RUN_TIME].trim() ); + runTime = obj.intValue(); + } + + // according to the SWF manual, runtime of 0 is possible due + // to rounding down. E.g. runtime is 0.4 seconds -> runtime = 0 + if (runTime == 0) { + runTime = 1; // change to 1 second + } + + // get the number of allocated processors + obj = new Integer( array[REQ_NUM_PROC].trim() ); + int numProc = obj.intValue(); + + // if the required num of allocated processors field is ignored + // or zero, then use the actual field + if (numProc == IRRELEVANT || numProc == 0) + { + obj = new Integer( array[NUM_PROC].trim() ); + numProc = obj.intValue(); + } + + // finally, check if the num of PEs required is valid or not + if (numProc <= 0) + { + System.out.println(super.get_name() + ": Warning - job #" + + id + " at line " + line + " requires " + numProc + + " CPU. Change to 1 CPU."); + numProc = 1; + } + + // creates a submission/reservation event + submitGridlet(id, submitTime, runTime, numProc); + } + catch (Exception e) + { + System.out.println(super.get_name() + + ": Exception in reading file at line #" + line); + e.printStackTrace(); + } + } + + /** + * Creates a Gridlet with the given information, then submit it to a + * resource + * @param id a Gridlet ID + * @param submitTime Gridlet's submit time + * @param runTime Gridlet's run time + * @param numProc number of processors + * @pre id >= 0 + * @pre submitTime >= 0 + * @pre runTime >= 0 + * @pre numProc > 0 + * @post $none + */ + protected void submitGridlet(int id, long submitTime, int runTime, int numProc) { + // create the gridlet + int len = runTime * rating_; // calculate a job length for each PE + Gridlet gridlet = new Gridlet(id, len, size_, size_); + gridlet.setUserID( super.get_id() ); // set the owner ID + gridlet.setNumPE(numProc); // set the requested num of proc + + // check the probability of creating an advance reservation + double probAR = Math.abs(numGen_.nextDouble()); + + // check the submit time + if (submitTime < 0) { + submitTime = 0; + } + + if(probAR <= reservProbability_) { + + // calculate how long in advance the reservation is made + double timeInAdvance = timeInAdvance_ * numGen_.nextDouble(); + + // convert to seconds + double timeToReserve = submitTime - timeInAdvance; + + // if the time the reservation would be done has already + // past, then consider now as the submission time + if(timeToReserve <= 0.0D) { + timeToReserve = GridSimTags.SCHEDULE_NOW; + } + + //TODO To check the duration of the advance reservation later + Object[] reservObj = new Object[3]; + reservObj[0] = new Double(submitTime); // start time of the reservation + reservObj[1] = (int) runTime + 1; // the advance reservation duration + reservObj[2] = gridlet; // the gridlet to be submitted + + // submit an internal event to create a reservation for this gridlet + super.send(super.get_id(), timeToReserve, RESERVE_RESOURCES, reservObj); + } + else { + // printing to inform user + if (gridletID_ == 1 || gridletID_ % INTERVAL == 0) { + System.out.println(super.get_name() + ": Submitting Gridlets to " + + resName_ + " ..."); + } + + // submit a gridlet to resource + super.send(super.output, submitTime, GridSimTags.GRIDLET_SUBMIT, + new IO_data(gridlet, gridlet.getGridletFileSize(), resID_) ); + } + + gridletID_++; // increment the counter + } + + /** + * Reads a text file one line at the time + * @param fileName a file name + * @return <tt>true</tt> if reading a file is successful, <tt>false</tt> + * otherwise. + * @pre fileName != null + * @post $none + */ + private boolean readFile(String fileName) + { + boolean success = false; + BufferedReader reader = null; + try + { + FileInputStream file = new FileInputStream(fileName); + InputStreamReader input = new InputStreamReader(file); + reader = new BufferedReader(input); + + // read one line at the time + int line = 1; + while ( reader.ready() ) + { + parseValue(reader.readLine(), line); + line++; + } + + reader.close(); // close the file + success = true; + } + catch (FileNotFoundException f) + { + System.out.println(super.get_name() + + ": Error - the file was not found: " + f.getMessage()); + } + catch (IOException e) + { + System.out.println(super.get_name() + + ": Error - an IOException occurred: " + e.getMessage()); + } + finally + { + if (reader != null) + { + try { + reader.close(); // close the file + } + catch (IOException e) + { + System.out.println(super.get_name() + + ": Error - an IOException occurred: " + e.getMessage()); + } + } + } + + return success; + } + + /** + * Reads a gzip file one line at the time + * @param fileName a gzip file name + * @return <tt>true</tt> if reading a file is successful, <tt>false</tt> + * otherwise. + * @pre fileName != null + * @post $none + */ + private boolean readGZIPFile(String fileName) + { + boolean success = false; + BufferedReader reader = null; + try + { + FileInputStream file = new FileInputStream(fileName); + GZIPInputStream gz = new GZIPInputStream(file); + InputStreamReader input = new InputStreamReader(gz); + reader = new BufferedReader(input); + + // read one line at the time + int line = 1; + while ( reader.ready() ) + { + parseValue(reader.readLine(), line); + line++; + } + + reader.close(); // close the file + success = true; + } + catch (FileNotFoundException f) + { + System.out.println(super.get_name() + + ": Error - the file was not found: " + f.getMessage()); + } + catch (IOException e) + { + System.out.println(super.get_name() + + ": Error - an IOException occurred: " + e.getMessage()); + } + finally + { + if (reader != null) + { + try { + reader.close(); // close the file + } + catch (IOException e) + { + System.out.println(super.get_name() + + ": Error - an IOException occurred: " + e.getMessage()); + } + } + } + + return success; + } + + /** + * Reads a Zip file. Iterating through each entry and reading it one line + * at the time. + * @param fileName a zip file name + * @return <tt>true</tt> if reading a file is successful, <tt>false</tt> + * otherwise. + * @pre fileName != null + * @post $none + */ + private boolean readZipFile(String fileName) + { + boolean success = false; + ZipFile zipFile = null; + try + { + InputStreamReader input = null; + BufferedReader reader = null; + + // ZipFile offers an Enumeration of all the files in the Zip file + zipFile = new ZipFile(fileName); + for (Enumeration e = zipFile.entries(); e.hasMoreElements();) + { + success = false; // reset the value again + ZipEntry zipEntry = (ZipEntry) e.nextElement(); + + input = new InputStreamReader(zipFile.getInputStream(zipEntry)); + reader = new BufferedReader(input); + + // read one line at the time + int line = 1; + while ( reader.ready() ) + { + parseValue(reader.readLine(), line); + line++; + } + + reader.close(); // close the file + success = true; + } + } + catch (IOException e) + { + System.out.println(super.get_name() + + ": Error - an IOException occurred: " + e.getMessage()); + } + finally + { + if (zipFile != null) + { + try { + zipFile.close(); // close the file + } + catch (IOException e) + { + System.out.println(super.get_name() + + ": Error - an IOException occurred: " + e.getMessage()); + } + } + } + + return success; + } +} Added: branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2007-12-16 23:08:32 UTC (rev 82) @@ -0,0 +1,288 @@ +/* + * Author Marcos Dias de Assuncao + * Date: September 2007 + * Description: A simple program to demonstrate of how to use basic + * advanced reservation functionalities, such as create, commit + * and status. + */ + +package examples.ar; + +import gridsim.GridSim; +import gridsim.Gridlet; +import gridsim.GridletList; +import gridsim.turbo.Reservation; +import gridsim.turbo.ReservationRequester; +import gridsim.turbo.AvailabilityInfo; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + +/** + * A user entity that reserves a resource in advance. + * In this example, only explore some functionalities, such as: + * - requests a new advanced reservation + * - requests a new immediate reservation. Immediate reservation means use + * current time as the starting time + * - commits an accepted reservation + * - checks the status of a reservation + */ +public class A... [truncated message content] |
From: <mar...@us...> - 2008-02-04 04:32:39
|
Revision: 85 http://gridsim.svn.sourceforge.net/gridsim/?rev=85&view=rev Author: marcos_dias Date: 2008-02-03 20:32:43 -0800 (Sun, 03 Feb 2008) Log Message: ----------- This update includes a workload class that generates gridlets according to Lublin and Feitelson's workload model. The model is described in: Uri Lublin and Dror G. Feitelson, The Workload on Parallel Supercomputers: Modeling the Characteristics of Rigid Jobs. J. Parallel & Distributed Comput. 63(11), pp. 1105-1122, Nov 2003. This update also includes a short example on how to use the Lubin99Workload class. Added Paths: ----------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java 2008-02-04 04:32:43 UTC (rev 85) @@ -0,0 +1,182 @@ + +package examples.workload.parallel; + +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.turbo.Lublin99Workload; +import gridsim.turbo.TResourceCharacteristics; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + +/** + * Test Driver class for this example + */ +public class LublinWorkloadExample01 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + long seed = 1062348; + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + Lublin99Workload workload = + new Lublin99Workload("Load_1", resArray[resID], rating, false, seed); + + // uHi is going to contain log2 of the maximum number of PEs that a + // parallel job can require + double uHi = Math.log(totalPE * totalMachine) / Math.log(2d); + double uMed = uHi-2.5; + + workload.setParallelJobProbabilities(Lublin99Workload.BATCH, + Lublin99Workload.ULOW_BATCH, uMed, uHi, + Lublin99Workload.UPROB_BATCH); + + // sets the workload to create 1000 jobs + workload.setNumJobs(1000); + + ////////////////////////////////////////// + // Starts the simulation in debug mode +// GridSim.startGridSimulation(true); + + // Start the simulation in normal mode + GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.CB_PARALLEL_SPACE_SHARED, + time_zone, cost); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + GridResource gridRes = null; + try { + gridRes = new GridResource(name, baud_rate, seed, + resConfig, peakLoad, offPeakLoad, holidayLoad, weekends, + holidays); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + Added: branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java 2008-02-04 04:32:43 UTC (rev 85) @@ -0,0 +1,1422 @@ +/* + * 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 + * + */ + +package gridsim.turbo; + +import eduni.simjava.*; +import gridsim.*; +import gridsim.net.*; +import java.util.*; + +/** + * The main purpose of this class is to create a realistic simulation + * environment where your jobs or Gridlets are competing with others. + * In other words, the grid resource might not be available at certain times. + * In addition, the arrival time of jobs are also captured in the workload model. + * <p> + * This class is responsible for creating jobs according to the workload model + * generator presented by Lublin and Feitelson and send Gridlets to only + * <tt>one</tt> destinated resource. <br> + * <b>NOTE:</b> + * <ul> + * <li> This class can be classified as <b>one grid user entity</b>. + * Hence, you need to incorporate this entity into <tt>numUser</tt> + * during {@link gridsim.GridSim#init(int, Calendar, boolean)} + * <li> If you need to use multiple trace files to submit Gridlets to + * same or different resources, then you need to create multiple + * instances of this class <tt>each with a unique entity name</tt>. + * <li> If you are running an experiment using the network extension, + * i.e. the gridsim.net package, then you need to use + * {@link #Lublin99Workload(String, double, double, int, String, String, int)} + * instead. + * <li> The default job file size for sending to and receiving from + * a resource is {@link gridsim.net.Link#DEFAULT_MTU}. + * However, you can specify + * the file size by using {@link #setGridletFileSize(int)}. + * <li> A job run time is only for 1 PE <tt>not</tt> the total number of + * allocated PEs. + * Therefore, a Gridlet length is also calculated for 1 PE.<br> + * For example, job #1 in the trace has a run time of 100 seconds + * for 2 processors. This means each processor runs + * job #1 for 100 seconds, if the processors have the same + * specification. + * </ul> + * <p> + * For more information on the workload model, please read the following paper: <br> + * Uri Lublin and Dror G. Feitelson, The Workload on Parallel Supercomputers: + * Modeling the Characteristics of Rigid Jobs. J. Parallel & Distributed Comput. 63(11), + * pp. 1105-1122, Nov 2003. + * <br> + * + * @see gridsim.GridSim#init(int, Calendar, boolean) + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * @invariant $none + */ +public class Lublin99Workload extends GridSim { + + private String resName_; // resource name + private int resID_; // resource ID + private int rating_; // a PE rating + private int gridletID_; // gridletID + private int size_; // job size for sending it through a network + private ArrayList list_; // a list for getting all the Gridlets + private Random random_ = null; // the number generator to be used + + // Log PI for lgamma method + private static final double LOGPI = 1.14472988584940017414; + protected final int INTERVAL = 10; // number of intervals + + // ------------ CONSTANTS USED BY THE WORKLOAD MODEL -------------- + + // number of jobs generated by this entity + private static final int SIZE = 1000; + + // no more than two days =exp(12) for runtime + private static final int TOO_MUCH_TIME = 12; + + // no more than 5 days =exp(13) for arrivetime + private static final int TOO_MUCH_ARRIVE_TIME = 13; + + // number of buckets in one day -- 48 half hours + private static final int BUCKETS = 48; + + // we now define (calculate) how many seconds are in one hour,day,bucket + private static final int SECONDS_IN_HOUR = 3600; + private static final int SECONDS_IN_DAY = (24*SECONDS_IN_HOUR); + private static final int SECONDS_IN_BUCKET = (SECONDS_IN_DAY/BUCKETS); + private static final int HOURS_IN_DAY = 24; + + // The hours of the day are being moved cyclically. + // instead of [0,23] make the day [CYCLIC_DAY_START,(24+CYCLIC_DAY_START-1)] + private static final int CYCLIC_DAY_START = 11; + + // max iterations number for the iterative calculations + private static final int ITER_MAX = 1000; + + // small epsilon for the iterative algorithm's accuracy + private static final double EPS = 1E-10; + + /** Represents interactive jobs */ + public static final int INTERACTIVE = 0; + + /** Represents batch jobs */ + public static final int BATCH = 1; + + // ------------------- MODEL DEFAULT PARAMETERS ----------------------- + + /* The parameters for number of nodes: + * serial_prob is the proportion of the serial jobs + * pow2_prob is the proportion of the jobs with power 2 number of nodes + * ULow , UMed , UHi and Uprob are the parameters for the two-stage-uniform + * which is used to calculate the number of nodes for parallel jobs. + * ULow is the log2 of the minimal size of job in the system (you can add or + * subtract 0.2 to give less/more probability to the minimal size) . + * UHi is the log2 of the maximal size of a job in the system (system's size) + * UMed should be in [UHi-1.5 , UHi-3.5] + * Uprob should be in [0.7 - 0.95] + */ + public static final double SERIAL_PROB_BATCH = 0.2927; + public static final double POW2_PROB_BATCH = 0.6686; + public static final double ULOW_BATCH = 1.2f; // smallest parallel batch job has 2 nodes + public static final double UMED_BATCH = 5; + public static final double UHI_BATCH = 7; // biggest batch job has 128 nodes + public static final double UPROB_BATCH = 0.875; + + public static final double SERIAL_PROB_ACTIVE = 0.1541; + public static final double POW2_PROB_ACTIVE = 0.625; + public static final double ULOW_ACTIVE = 1; // smallest interactive parallel job has 2 nodes + public static final double UMED_ACTIVE = 3; + public static final double UHI_ACTIVE = 5.5f; // biggest interactive job has 45 nodes + public static final double UPROB_ACTIVE = 0.705; + + /* The parameters for the running time + * The running time is computed using hyper-gamma distribution. + * The parameters a1,b1,a2,b2 are the parameters of the two gamma distributions + * The p parameter of the hyper-gamma distribution is calculated as a straight + * (linear) line p = pa*nodes + pb. + * 'nodes' will be calculated in the program, here we defined the 'pa','pb' + * parameters. + */ + public static final double A1_BATCH = 6.57; + public static final double B1_BATCH = 0.823; + public static final double A2_BATCH = 639.1; + public static final double B2_BATCH = 0.0156; + public static final double PA_BATCH = -0.003; + public static final double PB_BATCH = 0.6986; + + public static final double A1_ACTIVE = 3.8351; + public static final double B1_ACTIVE = 0.6605; + public static final double A2_ACTIVE = 7.073; + public static final double B2_ACTIVE = 0.6856; + public static final double PA_ACTIVE = -0.0118; + public static final double PB_ACTIVE = 0.9156; + + + /* The parameters for the inter-arrival time + * The inter-arriving time is calculated using two gamma distributions. + * gamma(aarr,barr) represents the inter_arrival time for the rush hours. It is + * independent on the hour the job arrived at. + * The cdf of gamma(bnum,anum) represents the proportion of number of jobs which + * arrived at each time interval (bucket). + * The inter-arrival time is calculated using both gammas + * Since gamma(aarr,barr) represents the arrive-time at the rush time , we use + * a constant ,ARAR (Arrive-Rush-All-Ratio), to set the alpha parameter (the new + * aarr) so it will represent the arrive-time at all hours of the day. + */ + public static final double AARR_BATCH = 6.0415; + public static final double BARR_BATCH = 0.8531; + public static final double ANUM_BATCH = 6.1271; + public static final double BNUM_BATCH = 5.2740; + public static final double ARAR_BATCH = 1.0519; + + public static final double AARR_ACTIVE = 6.5510; + public static final double BARR_ACTIVE = 0.6621; + public static final double ANUM_ACTIVE = 8.9186; + public static final double BNUM_ACTIVE = 3.6680; + public static final double ARAR_ACTIVE = 0.9797; + + /* + * Here are the model's parameters for typeless data (no batch nor interactive) + * We use those parameters when INCLUDE_JOBS_TYPE is off (0) + */ + public static final double SERIAL_PROB = 0.244; + public static final double POW2_PROB = 0.576; + public static final double ULOW = 0.8f; // The smallest parallel job is 2 nodes + public static final double UMED = 4.5f; + public static final double UHI = 7f; // SYSTEM SIZE is 2^UHI == 128 + public static final double UPROB = 0.86; + + public static final double A1 = 4.2; + public static final double B1 = 0.94; + public static final double A2 = 312; + public static final double B2 = 0.03; + public static final double PA = -0.0054; + public static final double PB = 0.78; + + public static final double AARR = 10.2303; + public static final double BARR = 0.4871; + public static final double ANUM = 8.1737; + public static final double BNUM = 3.9631; + public static final double ARAR = 1.0225; + + // start the simulation at midnight (hour 0) + private static final int START = 0; + + // -------------- Variable dependent attributes -------------------- + + // The workload duration, that is, for how long the workload can + // go creating and submitting gridlets. numJobs keeps the number of + // jobs that this workload should generate. The workload will + // finish when it apporaches whichever of these values + private double workloadDuration_; + private int numJobs_; + + private double[] a1, b1, a2, b2, pa, pb; + private double[] aarr, barr, anum, bnum; + private double[] serialProb, pow2Prob, uLow, uMed, uHi, uProb; + + // the appropriate weight (points) for each + // time-interval used in the arrive function + double[][] weights = new double[2][BUCKETS]; + + /* useJobType us if we should differ between batch and interactive + * jobs or not. If the value is true, then we use both batch and interactive + * values for the parameters and the output sample includes both interactive + * and batch jobs. We choose the type of the job to be the type whose next + * job arrives to the system first (smaller next arrival time). + * If the value is false, then we use the "whole sample" parameters. The output + * sample includes jobs from the same type (arbitrarily we choose batch). + * We force the type to be interactive by setting the next arrival time of + * interactive jobs to be Long.MAX_VALUE -- always larger than the batchs's + * next arrival. */ + private boolean useJobType_ = true; + + /* current time interval (the bucket's number) */ + private int[] current_; + + /* the number of seconds from the beginning of the simulation*/ + private long[] timeFromBegin_; + + /** + * Create a new Workload object <b>without</b> using the network extension. + * This means this entity directly sends Gridlets to a destination resource + * without going through a wired network. <br> + * <tt>NOTE:</tt> + * You can not use this constructor in an experiment that uses a wired + * network topology. + * @param name this entity name + * @param resourceName the resource name + * @param rating the resource's PE rating + * @param useJobType useJobType us if we should differ between batch and interactive + * jobs or not. If the value is <tt>true</tt>, then we use both batch and interactive + * values for the parameters and the output sample includes both interactive + * and batch jobs. We choose the type of the job to be the type whose next + * job arrives to the system first (smaller next arrival time). + * If the value is <tt>false</tt>, then we use the "whole sample" parameters. The output + * sample includes jobs from the same type (arbitrarily we choose batch). + * We force the type to be interactive by setting the next arrival time of + * interactive jobs to be <tt>Long.MAX_VALUE</tt> -- always larger than the batchs's + * next arrival. + * @param seed seed used by the random number generator + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre fileName != nullb2 + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public Lublin99Workload(String name, String resourceName, + int rating, boolean useJobType, long seed) + throws ParameterException, Exception { + super(name, GridSimTags.DEFAULT_BAUD_RATE); + + // check the input parameters first + String msg = name + "(): Error - "; + if (resourceName == null || resourceName.length() == 0) { + throw new ParameterException(msg + "invalid resource name."); + } + else if (rating <= 0) { + throw new ParameterException(msg+"resource PE rating must be > 0."); + } + + System.out.println(name + ": Creating a workload object ..."); + init(resourceName, rating, useJobType, seed); + } + + /** + * Create a new Workload object <b>with</b> the network extension. + * This means this entity directly sends Gridlets to a destination resourceb2 + * through a link. The link is automatically created by this constructor. + * + * @param name this entity name + * @param baudRate baud rate of this link (bits/s) + * @param propDelay Propagation delay of the Link in milliseconds + * @param MTU Maximum Transmission Unit of the Link in bytes. + * Packets which are larger than the MTU should be split + * up into MTU size units. + * For example, a 1024 byte packet trying to cross a 576 + * byte MTU link should get split into 2 packets of 576 + * bytes and 448 bytes. + * @param resourceName the resource name + * @param rating the resource's PE rating + * @param useJobType useJobType us if we should differ between batch and interactive + * jobs or not. If the value is <tt>true</tt>, then we use both batch and interactive + * values for the parameters and the output sample includes both interactive + * and batch jobs. We choose the type of the job to be the type whose next + * job arrives to the system first (smaller next arrival time). + * If the value is <tt>false</tt>, then we use the "whole sample" parameters. The output + * sample includes jobs from the same type (arbitrarily we choose batch). + * We force the type to be interactive by setting the next arrival time of + * interactive jobs to be <tt>Long.MAX_VALUE</tt> -- always larger than the batchs's + * next arrival. + * @param seed seed used by the random number generator + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li> baudRate <= 0 + * <li> propDelay <= 0 + * <li> MTU <= 0 + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre baudRate > 0 + * @pre propDelay > 0 + * @pre MTU > 0 + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public Lublin99Workload(String name, double baudRate, double propDelay, int MTU, + String resourceName, int rating, boolean useJobType, long seed) + throws ParameterException, Exception { + super( name, new SimpleLink(name+"_link", baudRate, propDelay, MTU) ); + + // check the input parameters first + String msg = name + "(): Error - "; + if (resourceName == null || resourceName.length() == 0) { + throw new ParameterException(msg + "invalid resource name."); + } + else if (rating <= 0) { + throw new ParameterException(msg+"resource PE rating must be > 0."); + } + + System.out.println(name + ": Creating a workload object ..."); + init(resourceName, rating, useJobType, seed); + } + + /** + * Create a new Workload object <b>with</b> the network extension. + * This means this entity directly sends Gridlets to a destination resource + * through a link. The link is automatically created by this constructor. + * + * @param name this entity name + * @param link the link that will be used to connect this Workload + * to another entity or a Router. + * @param resourceName the resource name + * @param rating the resource's PE rating + * @param useJobType useJobType us if we should differ between batch and interactive + * jobs or not. If the value is <tt>true</tt>, then we use both batch and interactive + * values for the parameters and the output sample includes both interactive + * and batch jobs. We choose the type of the job to be the type whose next + * job arrives to the system first (smaller next arrival time). + * If the value is <tt>false</tt>, then we use the "whole sample" parameters. The output + * sample includes jobs from the same type (arbitrarily we choose batch). + * We force the type to be interactive by setting the next arrival time of + * interactive jobs to be <tt>Long.MAX_VALUE</tt> -- always larger than the batchs's + * next arrival. + * @param seed seed used by the random number generator + * @throws Exception This happens when creating this entity before + * initialising GridSim package or this entity name is + * <tt>null</tt> or empty + * @throws ParameterException This happens for the following conditions: + * <ul> + * <li>the entity name is null or empty + * <li>the link is empty + * <li>the resource entity name is null or empty + * <li>the resource PE rating <= 0 + * </ul> + * @pre name != null + * @pre link != null + * @pre fileName != null + * @pre resourceName != null + * @pre rating > 0 + * @post $none + */ + public Lublin99Workload(String name, Link link, + String resourceName, int rating, boolean useJobType, long seed) + throws ParameterException, Exception { + super(name, link); + + // check the input parameters first + String msg = name + "(): Error - "; + if (resourceName == null || resourceName.length() == 0) { + throw new ParameterException(msg + "invalid resource name."); + } + else if (rating <= 0) { + throw new ParameterException(msg+"resource PE rating must be > 0."); + } + + System.out.println(name + ": Creating a workload object ..."); + init(resourceName, rating, useJobType, seed); + } + + /** + * Initialises all the attributes + * @param fileName trace file name + * @param resourceName resource entity name + * @param rating resource PE rating + * @param useJobType <tt>true</tt> whether the workload should generate + * both interactive and batch jobs; <tt>false</tt> if the workload + * should generate only batch jobs. + * @pre $none + * @post $none + */ + private void init(String resourceName, int rating, + boolean useJobType, long seed) { + + useJobType_ = useJobType; + resName_ = resourceName; + resID_ = GridSim.getEntityId(resName_); + rating_ = rating; + gridletID_ = 1; // starts at 1 to make it the same as in a trace file + list_ = null; + size_ = Link.DEFAULT_MTU; + random_ = new Random(seed); + workloadDuration_ = Double.MAX_VALUE; + numJobs_ = 1000; + + a1 = new double[2]; b1 = new double[2]; + a2 = new double[2]; b2 = new double[2]; + pa = new double[2]; pb = new double[2]; + aarr = new double[2]; barr = new double[2]; + anum = new double[2]; bnum = new double[2]; + serialProb = new double[2]; pow2Prob = new double[2]; + uLow = new double[2]; uMed = new double[2]; + uHi = new double[2]; uProb = new double[2]; + current_ = new int[2]; + timeFromBegin_ = new long[2]; + + // separate batch from interactive + if (useJobType_) { + serialProb[BATCH] = SERIAL_PROB_BATCH; + pow2Prob[BATCH] = POW2_PROB_BATCH; + uLow[BATCH] = ULOW_BATCH; + uMed[BATCH] = UMED_BATCH; + uHi[BATCH] = UHI_BATCH; + uProb[BATCH] = UPROB_BATCH; + + serialProb[INTERACTIVE] = SERIAL_PROB_ACTIVE; + pow2Prob[INTERACTIVE] = POW2_PROB_ACTIVE; + uLow[INTERACTIVE] = ULOW_ACTIVE; + uMed[INTERACTIVE] = UMED_ACTIVE; + uHi[INTERACTIVE] = UHI_ACTIVE; + uProb[INTERACTIVE] = UPROB_ACTIVE; + + a1[BATCH] = A1_BATCH; b1[BATCH] = B1_BATCH; + a2[BATCH] = A2_BATCH; b2[BATCH] = B2_BATCH; + pa[BATCH] = PA_BATCH; pb[BATCH] = PB_BATCH; + + a1[INTERACTIVE] = A1_ACTIVE; b1[INTERACTIVE] = B1_ACTIVE; + a2[INTERACTIVE] = A2_ACTIVE; b2[INTERACTIVE] = B2_ACTIVE; + pa[INTERACTIVE] = PA_ACTIVE; pb[INTERACTIVE] = PB_ACTIVE; + + aarr[BATCH] = AARR_BATCH*ARAR_BATCH; barr[BATCH] = BARR_BATCH; + anum[BATCH] = ANUM_BATCH; bnum[BATCH] = BNUM_BATCH; + + aarr[INTERACTIVE] = AARR_ACTIVE*ARAR_ACTIVE; + barr[INTERACTIVE] = BARR_ACTIVE; + anum[INTERACTIVE] = ANUM_ACTIVE; + bnum[INTERACTIVE] = BNUM_ACTIVE; + } + else { + // whole sample -- make all batch jobs + serialProb[BATCH] = serialProb[INTERACTIVE] = SERIAL_PROB; + pow2Prob[BATCH] = pow2Prob[INTERACTIVE] = POW2_PROB; + uLow[BATCH] = uLow[INTERACTIVE] = ULOW ; + uMed[BATCH] = uMed[INTERACTIVE] = UMED ; + uHi[BATCH] = uHi[INTERACTIVE] = UHI ; + uProb[BATCH] = uProb[INTERACTIVE] = UPROB ; + + a1[BATCH] = a1[INTERACTIVE] = A1; + b1[BATCH] = b1[INTERACTIVE] = B1; + a2[BATCH] = a2[INTERACTIVE] = A2; + b2[BATCH] = b2[INTERACTIVE] = B2; + pa[BATCH] = pa[INTERACTIVE] = PA; + pb[BATCH] = pb[INTERACTIVE] = PB; + + aarr[BATCH] = aarr[INTERACTIVE] = AARR * ARAR; + barr[BATCH] = barr[INTERACTIVE] = BARR; + anum[BATCH] = anum[INTERACTIVE] = ANUM; + bnum[BATCH] = bnum[INTERACTIVE] = BNUM; + } + + if ( ! useJobType_ ) // make all jobs batch + timeFromBegin_[INTERACTIVE] = Long.MAX_VALUE; + } + + /** + * Sets the probability for serial jobs + * @param jobType the type of jobs + * @param prob the probability + * @return <tt>true</tt> if the probability has been set, or + * <tt>false</tt> otherwise. + * @see #INTERACTIVE + * @see #BATCH + */ + public boolean setSerialProbability(int jobType, double prob) { + if(jobType > BATCH || jobType < INTERACTIVE) + return false; + + if(useJobType_) + serialProb[jobType] = prob; + else + serialProb[INTERACTIVE] = serialProb[BATCH] = prob; + + return true; + } + + /** + * Sets the probability for power of two jobs + * @param jobType the type of jobs + * @param prob the probability + * @return <tt>true</tt> if the probability has been set, or + * <tt>false</tt> otherwise. + * @see #INTERACTIVE + * @see #BATCH + */ + public boolean setPower2Probability(int jobType, double prob) { + if(jobType > BATCH || jobType < INTERACTIVE) + return false; + + if(useJobType_) + pow2Prob[jobType] = prob; + else + pow2Prob[INTERACTIVE] = pow2Prob[BATCH] = prob; + + return true; + } + + /** + * Sets the parameters for the two-stage-uniform + * which is used to calculate the number of nodes for parallel jobs. + * @param jobType the type of jobs + * @param uLow is the log2 of the minimal size of job in the system (you can add or + * subtract 0.2 to give less/more probability to the minimal size). + * @param uMed should be in [uHi-1.5 , uHi-3.5] + * @param uHi is the log2 of the maximal size of a job in the system (system's size) + * @param uProb should be in [0.7 - 0.95] + * @return <tt>true</tt> if the probabilities have been set, or + * <tt>false</tt> otherwise.b2 + * @see #INTERACTIVE + * @see #BATCH + */ + public boolean setParallelJobProbabilities(int jobType, + double uLow, double uMed, double uHi, double uProb) { + if(jobType > BATCH || jobType < INTERACTIVE) + return false; + else if (uLow > uHi) + return false; + else if (uMed > uHi-1.5 || uMed < uHi-3.5) + return false; + else if(uProb < 0.7 || uProb > 0.95) + return false; + + if(useJobType_) { + this.uLow[jobType] = uLow; + this.uMed[jobType] = uMed; + this.uHi[jobType] = uHi; + this.uProb[jobType] = uProb; + } + else { + this.uLow[INTERACTIVE] = this.uLow[BATCH] = uLow; + this.uMed[INTERACTIVE] = this.uMed[BATCH] = uMed; + this.uHi[INTERACTIVE] = this.uHi[BATCH] = uHi; + this.uProb[INTERACTIVE] = this.uProb[BATCH] = uProb; + } + + return true; + } + + /** Sets the parameters for the running time + * The running time is computed using hyper-gamma distribution. + * The parameters a1,b1,a2,b2 are the parameters of the two gamma distributions + * The p parameter of the hyper-gamma distribution is calculated as a straight + * (linear) line p = pa*nodes + pb. * 'nodes' will be calculated + * in the program, here we defined the 'pa','pb' + * parameters. + * @param a1 hyper-gamma distribution parameter. + * @param a2 hyper-gamma distribution parameter. + * @param b1 hyper-gamma distribution parameter. + * @param b2 hyper-gamma distribution parameter. + * @param pa hyper-gamma distribution parameter. + * @param pb hyper-gamma distribution parameter. + * @return <tt>true</tt> if the parameters have been set, or + * <tt>false</tt> otherwise. + */ + public boolean setRunTimeParameters(int jobType, + double a1, double a2, double b1, double b2, + double pa, double pb) { + if(jobType > BATCH || jobType < INTERACTIVE) + return false; + + if(useJobType_) { + this.a1[jobType] = a1; this.b1[jobType] = b1; + this.a2[jobType] = a2; this.b2[jobType] = b2; + this.pa[jobType] = pa; this.pb[jobType] = pb; + } + else { + this.a1[INTERACTIVE] = this.a1[BATCH] = a1; + this.b1[INTERACTIVE] = this.a1[BATCH] = b1; + this.a2[INTERACTIVE] = this.a1[BATCH] = a2; + this.b2[INTERACTIVE] = this.a1[BATCH] = b2; + this.pa[INTERACTIVE] = this.a1[BATCH] = pa; + this.pb[INTERACTIVE] = this.a1[BATCH] = pb; + } + + return true; + } + + /** + * Sets the parameters for the inter-arrival time + * The inter-arriving time is calculated using two gamma distributions. + * gamma(aarr,barr) represents the inter_arrival time for the rush hours. It is + * independent on the hour the job arrived at. + * The cdf of gamma(bnum,anum) represents the proportion of number of jobs which + * arrived at each time interval (bucket). + * The inter-arrival time is calculated using both gammas + * Since gamma(aarr,barr) represents the arrive-time at the rush time , we use + * a constant ,ARAR (Arrive-Rush-All-Ratio), to set the alpha parameter (the new + * aarr) so it will represent the arrive-time at all hours of the day. + */ + public boolean setInterArrivalTimeParameters(int jobType, + double aarr, double barr, double anum, double bnum, double arar) { + if(jobType > BATCH || jobType < INTERACTIVE) + return false; + + if(useJobType_) { + this.aarr[jobType] = aarr * arar; + this.barr[jobType] = barr; + this.anum[jobType] = anum; + this.bnum[jobType] = bnum; + } + else { + this.aarr[INTERACTIVE] = this.aarr[BATCH] = aarr * arar; + this.barr[INTERACTIVE] = this.barr[BATCH] = barr; + this.anum[INTERACTIVE] = this.barr[BATCH] = anum; + this.bnum[INTERACTIVE] = this.barr[BATCH] = bnum; + } + + return true; + } + + /** + * Sets the maximum number of jobs to be generated by this workload model + * @param numJobs the number of jobs + * @returns <tt>true</tt> if the number of jobs has been set; + * <tt>false</tt> othwerwise. + */ + public boolean setNumJobs(int numJobs) { + if(numJobs < 1) + return false; + + numJobs_ = numJobs; + return true; + } + + /** + * Sets the maximum time duration of the workload. The workload will create + * jobs whose time of submission is less or equals to workloadDuration. + * The workload model will stop when it approaches workloadDuration. + * @param workloadDuration the maximum duration of the workload. + * @return <tt>true</tt> if the duration has been set; + * <tt>false</tt> othwerwise. + */ + public boolean setMaximumWorkloadDuration(double workloadDuration) { + if(workloadDuration <= 0) + return false; + + workloadDuration_ = workloadDuration; + return true; + } + + /** + * Sets a Gridlet file size (in byte) for sending to/from a resource. + * @param size a Gridlet file size (in byte) + * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise + * @pre size > 0 + * @post $none + */ + public boolean setGridletFileSize(int size) { + if (size < 0) { + return false; + } + + size_ = size; + return true; + } + + /** + * Gets a list of completed Gridlets + * @return a list of Gridlets + * @pre $none + * @post $none + */ + public ArrayList getGridletList() { + return list_; + } + + /** + * Prints the Gridlet objects + * @param history <tt>true</tt> means printing each Gridlet's history, + * <tt>false</tt> otherwise + * @pre $none + * @post $none + */ + public void printGridletList(boolean history) { + String name = super.get_name(); + int size = list_.size(); + Gridlet gridlet; + + String indent = " "; + System.out.println(); + System.out.println("========== OUTPUT for " + name + " =========="); + System.out.println("Gridlet_ID" + indent + "STATUS" + indent + + "Resource_ID" + indent + "Cost"); + + int i = 0; + for (i = 0; i < size; i++) + { + gridlet = (Gridlet) list_.get(i); + System.out.print(indent + gridlet.getGridletID() + indent + + indent); + + // get the status of a Gridlet + System.out.print( gridlet.getGridletStatusString() ); + System.out.println( indent + indent + gridlet.getResourceID() + + indent + indent + gridlet.getProcessingCost() ); + } + + System.out.println(); + if (history == true) + { + // a loop to print each Gridlet's history + System.out.println(); + 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("========================================="); + System.out.println(); + } + } + } + + /** + * Reads from a given file when the simulation starts running. + * Then submits Gridlets to a resource and collects them before exiting. + * To collect the completed Gridlets, use {@link #getGridletList()} + * @pre $none + * @post $none + */ + public void body() { + System.out.println(); + System.out.println(super.get_name() + ".body() :%%%% Start ..."); + + // get the resource id + if (resID_ < 0) + { + System.out.println(super.get_name() + + ".body(): Error - invalid resource name: " + resName_); + return; + } + + boolean success = createGridlets(); + + // if all the gridlets have been submitted + if (success == true) { + collectGridlet(); + } + else { + System.out.println(super.get_name() + + ".body(): Error - unable to parse from a file."); + } + + // shut down all the entities, including GridStatistics entity since + // we used it to record certain events. + shutdownGridStatisticsEntity(); + shutdownUserEntity(); + terminateIOEntities(); + + System.out.println(super.get_name() + ".body() : %%%% Exit ..."); + } + + //////////////////////// PROTECTED METHODS /////////////////////// + + /** + * Collects Gridlets sent and stores them into a list. + * @pre $none + * @post $none + */ + protected void collectGridlet() { + System.out.println(super.get_name() + ": Collecting Gridlets ..."); + list_ = new ArrayList(gridletID_ + 1); + + Object data = null; + Gridlet gl = null; + + int counter = 1; // starts at 1, since gridletID_ starts at 1 too + Sim_event ev = new Sim_event(); + while ( Sim_system.running() ) + { + super.sim_get_next(ev); // get the next available event + data = ev.get_data(); // get the event's data + + // handle ping request + if (ev.get_tag() == GridSimTags.INFOPKT_SUBMIT) + { + processPingRequest(ev); + continue; + } + + // get the Gridlet data + if (data != null && data instanceof Gridlet) { + gl = (Gridlet) data; + list_.add(gl); + counter++; + } + + // if all the Gridlets have been collected + if (counter == gridletID_) { + break; + } + } + } + + /** + * Processes a ping request. + * @param ev a Sim_event object + * @pre ev != null + * @post $none + */ + protected void processPingRequest(Sim_event ev) { + InfoPacket pkt = (InfoPacket) ev.get_data(); + pkt.setTag(GridSimTags.INFOPKT_RETURN); + pkt.setDestID( pkt.getSrcID() ); + + // sends back to the sender + super.send(super.output, GridSimTags.SCHEDULE_NOW, + GridSimTags.INFOPKT_RETURN, + new IO_data(pkt, pkt.getSize(), pkt.getSrcID()) ); + } + + //////////////////////// PRIVATE METHODS /////////////////////// + + /** + * Creates the gridlets according to the workload model and sends them + * to the grid resource entity. + * @return <tt>true</tt> if the gridlets were created successfully or + * <tt>false</tt> otherwise. + */ + private boolean createGridlets() { + + int type = INTERACTIVE; + int nodes; long arrTime; int runTime; + + arrivalInit(aarr, barr, anum, bnum, START, weights); + + for (int i=0; i<numJobs_; i++) { + long[] info = arrive(type, weights, aarr, barr); + type = (int)info[0]; + arrTime = (long)info[1]; + + if(arrTime > workloadDuration_) { + return true; + } + + nodes = calcNumberOfNodes(serialProb[type] , pow2Prob[type], + uLow[type], uMed[type], uHi[type], uProb[type]); + + runTime = (int)timeFromNodes(a1[type], b1[type], a2[type], b2[type], + pa[type], pb[type], nodes); + + submitGridlet(i+1, arrTime, runTime, nodes); + } + + return true; + } + + /*----------------------------------------------------------------------------*/ + /* CALC_NUMBER_OF_NODES (NUMBER OF NODES) */ + /* -------------------------------------------------------------------------- */ + /* + * we distinguish between serial jobs , power2 jobs and other. + * for serial job (with probability SerialProb) the number of nodes is 1 + * for all parallel jobs (both power2 and other jobs) we randomly choose a + * number (called 'par') from two-stage-uniform distribution. + * if the job is a power2 job then we make it an integer (par = round(par)), + * the number of nodes will be 2^par but since it must be an integer we return + * round(pow(2,par)). + * if we made par an integer then 2^par is ,obviously, a power of 2. + */ + private int calcNumberOfNodes(double serialProb, double pow2Prob, double uLow, + double uMed, double uHi, double uProb) { + double u,par; + + u = random_.nextDouble(); + if (u <= serialProb) // serial job + return 1; + par = twoStageUniform(uLow, uMed, uHi, uProb); + if (u <= (serialProb + pow2Prob)) // power of 2 nodes parallel job + par = (int)(par + 0.5); // par = round(par) + + return (int)(Math.pow(2, par) + 0.5); // return round(2^par) + } + + /*----------------------------------------------------------------------------*/ + /* TIMES_FROM_NODES (RUNTIME) */ + /* -------------------------------------------------------------------------- */ + /* + * time_from_nodes returns a value of a random number from hyper_gamma + * distribution. + * The a1,b1,a2,b2 are the parameters of both gammas. + * The 'p' parameter is calculated from the 'nodes' 'pa' and 'pb' arguments + * using the formula: p = pa * nodes + pb. + * we keep 'p' a probability by forcing its value to be in the interval [0,1]. + * if the value that was randomly chosen is too big (larger than + * TOO_MUCH_TIME) then we choose another random value. + */ + private long timeFromNodes(double alpha1, double beta1, + double alpha2, double beta2, + double pa, double pb, int nodes) { + double hg; + double p = pa*nodes + pb; + + if (p>1) + p=1; + else if (p<0) + p=0; + do { + hg = hyperGamma(alpha1 , beta1 , alpha2 , beta2 , p); + } while (hg > TOO_MUCH_TIME); + + return (long)Math.exp(hg); + } + + /* The arrive process. + * 'arrive' returns arrival time (from the beginning of the simulation) of + * the current job. + * The (gamma distribution) parameters 'aarr' and 'barr' represent the + * inter-arrival time at rush hours. + * The (gamma distribution) parameters 'anum' and 'bnum' represent the number + * of jobs arriving at different times of the day. Those parameters fit a day + * that contains the hours [CYCLIC_DAY_START..24+CYCLIC_DAY_START] and are + * cyclically moved back to 0..24 + * 'start' is the starting time (in hours 0-23) of the simulation. + * If the inter-arrival time randomly chosen is too big (larger than + * TOO_MUCH_ARRIVE_TIME) then another value is chosen. + * + * The algorithm (briefly): + * A. Preparations (calculated only once in 'arrive_init()': + * 1. foreach time interval (bucket) calculate its proportion of the number + * of arriving jobs (using 'anum' and 'bnum'). This value will be the + * bucket's points. + * 2. calculate the mean number of points in a bucket () + * 3. divide the points in each bucket by the points mean ("normalize" the + * points in all buckets) + * B. randomly choosing a new arrival time for a job: + * 1. get a random value from distribution gamma(aarr , barr). + * 2. calculate the points we have. + * 3. accumulate inter-arrival time by passing buckets (while paying them + * points for that) until we do not have enough points. + * 4. handle reminders - add the new reminder and subtract the old reminder. + * 5. update the time variables ('current' and 'time_from_begin') + */ + private void arrivalInit(double[] aarr, double[] barr, + double[] anum, double[] bnum, int start_hour, double weights[][]) { + + int idx, moveto = CYCLIC_DAY_START; + double[] mean = new double[] {0,0}; + + for(int i=0; i<weights.length; i++) + for(int j=0; j<weights[i].length; j++) + weights[i][j] = 0; + + current_[BATCH] = current_[INTERACTIVE] = start_hour * BUCKETS / HOURS_IN_DAY; + + /* + * for both batch and interactive calculate the propotion of each bucket , + * and their mean */ + for (int j=0 ; j<=1 ; j++) { + for (int i=moveto ; i<BUCKETS+moveto ; i++) { + idx = (i-1)%BUCKETS; /* i-1 since array indices are 0..47 and not 1..48 */ + weights[j][idx] = + gamcdf(i+0.5, anum[j], bnum[j]) - gamcdf(i-0.5, anum[j],bnum[j]); + mean[j] += weights[j][idx]; + } + mean[j] /= BUCKETS; + } + + /* normalize it so we associates between seconds and points correctly */ + for (int j=0 ; j<=1 ; j++) + for (int i=0 ; i<BUCKETS ; i++) + weights[j][i] /= mean[j]; + + calcNextArrival(BATCH ,weights,aarr,barr); + calcNextArrival(INTERACTIVE,weights,aarr,barr); + } + + /* + * 'calcNextArrival' calculates the next inter-arrival time according + * to the current time of the day. + * 'type' is the type of the next job -- interactive or batch + * alpha and barr are the parameters of the gamma distribution of the + * inter-arrival time. + * NOTE: this function changes the global variables concerning the arrival time. + */ + private void calcNextArrival(int type, double[][] weights, + double[] aarr, double[] barr) { + + double[] points = new double []{0,0}; + double[] reminder = new double[]{0,0}; + int bucket; + double gam, nextArrival, newReminder, moreTime; + + bucket = current_[type]; // the bucket of the current time + do { // randomly choose a (not too big) number from gamma distribution + gam = gamrnd(aarr[type],barr[type]); + } while (gam > TOO_MUCH_ARRIVE_TIME); + + points[type] += (Math.exp(gam) / SECONDS_IN_BUCKET); // number of points + nextArrival = 0; + while (points[type] > weights[type][bucket]) { // while have more points + points[type] -= weights[type][bucket]; // pay points to this bucket + bucket = (bucket+1) % 48; // ... and goto the next bucket + nextArrival += SECONDS_IN_BUCKET; // accumulate time in next_arrive + } + + newReminder = points[type]/weights[type][bucket]; + moreTime = SECONDS_IN_BUCKET * ( newReminder - reminder[type]); + nextArrival += moreTime; // add reminders + reminder[type] = newReminder; // save it for next call + + // update the attributes + timeFromBegin_[type] += nextArrival; + current_[type] = bucket; + } + + /*----------------------------------------------------------------------------*/ + /* ARRIVE (ARRIVAL TIME AND TYPE) */ + /*----------------------------------------------------------------------------*/ + /* + * return the time for next job to arrive the system. + * returns also the type of the next job , which is the type that its + * next arrive time (time_from_begin) is closer to the start (smaller). + * notice that since calc_next_arrive changes time_from_begin[] we must save + * the time_from_begin in 'res' so we would be able to return it. + */ + private long[] arrive(int type, double[][] weights, double[] aarr, double[] barr) { + long res; + + type = (timeFromBegin_[BATCH] < timeFromBegin_[INTERACTIVE]) ? BATCH : INTERACTIVE; + res = timeFromBegin_[type]; // save the job's arrival time + + // randomly choose the next job's (of the same type) arrival time + calcNextArrival(type, weights, aarr, barr); + return new long[] {type, res}; + } + + /** + * Creates a Gridlet with the given information, then submit it to a + * resource + * @param id a Gridlet ID + * @param submitTime Gridlet's submit time + * @param runTime Gridlet's run time + * @param numProc number of processors + * @pre id >= 0 + * @pre submitTime >= 0 + * @pre runTime >= 0 + * @pre numProc > 0 + * @post $none + */ + protected void submitGridlet(int id, long submitTime, int runTime, int numProc) + { + // create the gridlet + int len = runTime * rating_; // calculate a job length for each PE + Gridlet gl = new Gridlet(id, len, size_, size_, GridSim.isTraceEnabled()); + gl.setUserID( super.get_id() ); // set the owner ID + gl.setNumPE(numProc); // set the requested num of proc + + // printing to inform user + if (gridletID_ == 1 || gridletID_ % INTERVAL == 0) + { + System.out.println(super.get_name() + ": Submitting Gridlets to " + + resName_ + " ..."); + } + + // check the submit time + if (submitTime < 0) { + submitTime = 0; + } + + gridletID_++; // increment the counter + + // submit a gridlet to resource + super.send(super.output, submitTime, GridSimTags.GRIDLET_SUBMIT, + new IO_data(gl, gl.getGridletFileSize(), resID_) ); + } + + + // --- Methods required by the distributions used by the workload model --- + + /* + * hyper_gamma returns a value of a random variable of mixture of two + * gammas. its parameters are those of the two gammas: a1,b1,a2,b2 and the + * relation between the gammas (p = the probability of the first gamma). we + * first randomly decide which gamma will be active ((a1,b1) or (a2,b2)). + * then we randomly choose a number from the chosen gamma distribution. + */ + double hyperGamma(double a1, double b1, double a2, double b2, double p) { + double a, b, hg, u = random_.nextDouble(); + + if (u <= p) { /* gamma(a1,b1) */ + a = a1; + b = b1; + } else { /* gamma(a2,b2) */ + a = a2; + b = b2; + } + + /* generate a value of a random variable from distribution gamma(a,b) */ + hg = gamrnd(a, b); + return hg; + } + + /* + * gamrnd returns a value of a random variable of gamma(alpha,beta). + * gamma(alpha,beta) = gamma(int(alpha),beta) + + * gamma(alpha-int(alpha),beta). This function and the following 3 functions + * were written according to Jain Raj, 'THE ART OF COMPUTER SYSTEMS + * PERFORMANCE ANALYSIS Techniques for Experimental Design, Measurement, + * Simulation, and Modeling'. Jhon Wiley & Sons , Inc. 1991. Chapter 28 - + * RANDOM-VARIATE GENERATION (pages 484,485,490,491) + * can be improved by getting 'diff' and 'intalpha' as function's parameters + */ + + private double gamrnd(double alpha, double beta) { + double diff, gam = 0; + long intalpha = (long) alpha; + if (alpha >= 1) + gam += gamrndIntAlpha(intalpha, beta); + if ((diff = alpha - intalpha) > 0) + gam += gamrndAlphaSmaller1(diff, beta); + return gam; + } + + /* + * gamrnd_int_alpha returns a value of a random variable of gamma(n,beta) + * distribution where n is integer(unsigned long actually). gamma(n,beta) == + * beta*gamma(n,1) == beta* sum(1..n){gamma(1,1)} == beta* sum(1..n){exp(1)} == + * beta* sum(1..n){-ln(uniform(0,1))} + */ + private double gamrndIntAlpha(long n, double beta) { + double acc = 0; + for (int i = 0; i < n; i++) + acc += Math.log(random_.nextDouble()); /* sum the exponential + * random variables + */ + return (-acc * beta); + } + + /* + * gamrnd_alpha_smaller_1 returns a value of a random variable of + * gamma(alpha,beta) where alpha is smaller than 1. This is done using the + * Beta distribution. (alpha<1) ==> (1-alpha<1) ==> we can use + * beta_less_1(alpha,1-alpha) gamma(alpha,beta) = exponential(beta) * + * Beta(alpha,1-alpha) + */ + private double gamrndAlphaSmaller1(double alpha, double beta) { + double x = betarndLess1(alpha, 1 - alpha); /* beta random variable */ + double y = -Math.log(random_.nextDouble()); /* exponential random + * variable */ + return (beta * x * y); + } + + /* + * betarnd_less_1 returns a value of a random variable of beta(alpha,beta) + * distribution where both alpha and beta are smaller than 1 (and larger + * than 0) + */ + private double betarndLess1(double alpha, double beta) { + double x, y, u1, u2; + do { + u1 = random_.nextDouble(); + u2 = random_.nextDouble(); + x = Math.pow(u1, 1 / alpha); + y = Math.pow(u2, 1 / beta); + } while (x + y > 1); + return (x / (x + y)); + } + + /* + * Returns the cumulative distribution function of gamma(alpha, beta) + * distribution at the point 'x'; return -1 if an error (non-convergence) + * occurs. + * This function and the following two functions were written + * according to William H. Press , Brian P. Flannery , Saul A. Teukolsky and + * William T. Vetterling. NUMERICAL RECIPES IN PASCAL The Art of Scientific + * Computing. Cambridge University Press 1989 Chapter 6 - Special Functions + * (pages 180-183). + */ + private double gamcdf(double x, double alpha, double beta) { + x /= beta; + if (x < (alpha + 1)) { + return gser(x, alpha); + } + + /* x >= a+1 */ + r... [truncated message content] |
From: <mar...@us...> - 2008-02-05 00:28:26
|
Revision: 86 http://gridsim.svn.sourceforge.net/gridsim/?rev=86&view=rev Author: marcos_dias Date: 2008-02-04 16:28:29 -0800 (Mon, 04 Feb 2008) Log Message: ----------- Small changes in the Lublin99 workload model and the availability info send by resource providers. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java 2008-02-04 04:32:43 UTC (rev 85) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java 2008-02-05 00:28:29 UTC (rev 86) @@ -83,9 +83,9 @@ double uHi = Math.log(totalPE * totalMachine) / Math.log(2d); double uMed = uHi-2.5; - workload.setParallelJobProbabilities(Lublin99Workload.BATCH, - Lublin99Workload.ULOW_BATCH, uMed, uHi, - Lublin99Workload.UPROB_BATCH); + workload.setParallelJobProbabilities(Lublin99Workload.BATCH_JOBS, + workload.getParallelJobULow(Lublin99Workload.BATCH_JOBS), uMed, uHi, + workload.getParallelJobUProb(Lublin99Workload.BATCH_JOBS)); // sets the workload to create 1000 jobs workload.setNumJobs(1000); @@ -120,8 +120,7 @@ * @param totalPE total number of PEs for each Machine */ private static GridResource createGridResource(String name, int peRating, - int totalMachine, int totalPE) - { + int totalMachine, int totalPE) { ////////////////////////////////////////// // Here are the steps needed to create a Grid resource: Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-02-04 04:32:43 UTC (rev 85) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-02-05 00:28:29 UTC (rev 86) @@ -9,7 +9,6 @@ import eduni.simjava.Sim_event; import eduni.simjava.Sim_system; -import gridsim.GridResource; import gridsim.GridSim; import gridsim.GridSimTags; import gridsim.Gridlet; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2008-02-04 04:32:43 UTC (rev 85) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2008-02-05 00:28:29 UTC (rev 86) @@ -212,6 +212,28 @@ } /** + * Returns the entry whose time is closest to the <tt>time</tt> given but + * smaller, or whose time is equals to <tt>time</tt> + * @param time the time to be used to search for the entry + * @return the entry whose time is closest to the <tt>time</tt> given but + * smaller, or whose time is equals to <tt>time</tt> + */ + private AvailabilityInfoEntry getPrecedingEntry(double time) { + Iterator<AvailabilityInfoEntry> it = list_.iterator(); + AvailabilityInfoEntry preceding = null; + + while(it.hasNext()) { + AvailabilityInfoEntry entry = it.next(); + if(entry.getTime() > time) + break; + + preceding = entry; + } + + return preceding; + } + + /** * Scans the entries in a list and returns the first time frame over * which a request with the characteristics provided can be scheduled * @param duration the duration of the request @@ -219,7 +241,28 @@ * @return the start time or <tt>-1</tt> if not found */ public double getPotentialStartTime(int duration, int reqPE) { + return getPotentialStartTime(0, duration, reqPE); + } + + /** + * Scans the entries in the availability info object returns the start + * time of the first time frame over which a request with the characteristics + * provided can be scheduled. + * @param readyTime the method will consider potential start times + * further in time than the value given by <tt>readyTime</tt>. + * @param duration the duration of the request + * @param reqPE the number of PEs required + * @return the start time or <tt>-1</tt> if not found. + */ + public double getPotentialStartTime(double readyTime, + int duration, int reqPE) { + if(readyTime < startTime_) + readyTime = startTime_; + + if(readyTime > finishTime_) + return UNKNOWN; + // the anchor index, the entry in the profile where // the request would be placed OR the closest entry to the // point where the anchor of the request would be placed @@ -228,27 +271,28 @@ // a pointer to the anchor entry (described above) AvailabilityInfoEntry anchorEntry = null; - // the list of selected ranges - PERangeList intersectList = null; - double potStartTime = -1; // keep the potential start time of the request double potFinishTime = -1; // store the gridlet's expected finish time - - intersectList = null; int length = list_.size(); - - Iterator<AvailabilityInfoEntry> iterProfile = list_.iterator(); - while(iterProfile.hasNext()) { + + anchorEntry = getPrecedingEntry(readyTime); + int firstAnchorIndex = list_.indexOf(anchorEntry); + if(firstAnchorIndex == -1) + firstAnchorIndex = 0; + + for(int j=firstAnchorIndex; j<length; j++) { + AvailabilityInfoEntry entry = list_.get(j); + anchorIndex = list_.indexOf(entry); - AvailabilityInfoEntry entry = iterProfile.next(); - anchorEntry = entry; - anchorIndex = list_.indexOf(anchorEntry); - // sets the start time as the time of the entry - potStartTime = entry.getTime(); - // calculates when the finish time will be if + if(entry.getTime() < readyTime) + potStartTime = readyTime; + else + potStartTime = entry.getTime(); + + // calculates when the finish time will be if // the gridlet is put at this position - potFinishTime = potStartTime + duration; + potFinishTime = potStartTime + duration; // scan the profile until an entry with enough PEs is found if(entry.getNumPE() < reqPE) { @@ -259,7 +303,7 @@ // from that point onwards analysing the intersection of // the ranges available in the entries until the // request expected completion time - intersectList = entry.getAvailRanges().clone(); + PERangeList intersectList = entry.getAvailRanges().clone(); // Look for the intersection of available ranges from // the anchor until the end of the profile or until @@ -274,7 +318,8 @@ // is no need to check the intersection if(nextEntry.getTime() < potFinishTime) { intersectList = PERangeList.intersection(intersectList, - nextEntry.getAvailRanges()); + nextEntry.getAvailRanges()); + if(intersectList == null || intersectList.getNumPE() < reqPE) { break; } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java 2008-02-04 04:32:43 UTC (rev 85) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java 2008-02-05 00:28:29 UTC (rev 86) @@ -70,13 +70,11 @@ // Log PI for lgamma method private static final double LOGPI = 1.14472988584940017414; - protected final int INTERVAL = 10; // number of intervals + private final int INTERVAL = 10; // number of intervals + private static final int UNKNOWN = -1; // ------------ CONSTANTS USED BY THE WORKLOAD MODEL -------------- - // number of jobs generated by this entity - private static final int SIZE = 1000; - // no more than two days =exp(12) for runtime private static final int TOO_MUCH_TIME = 12; @@ -103,10 +101,10 @@ private static final double EPS = 1E-10; /** Represents interactive jobs */ - public static final int INTERACTIVE = 0; + public static final int INTERACTIVE_JOBS = 0; /** Represents batch jobs */ - public static final int BATCH = 1; + public static final int BATCH_JOBS = 1; // ------------------- MODEL DEFAULT PARAMETERS ----------------------- @@ -121,19 +119,19 @@ * UMed should be in [UHi-1.5 , UHi-3.5] * Uprob should be in [0.7 - 0.95] */ - public static final double SERIAL_PROB_BATCH = 0.2927; - public static final double POW2_PROB_BATCH = 0.6686; - public static final double ULOW_BATCH = 1.2f; // smallest parallel batch job has 2 nodes - public static final double UMED_BATCH = 5; - public static final double UHI_BATCH = 7; // biggest batch job has 128 nodes - public static final double UPROB_BATCH = 0.875; + private static final double SERIAL_PROB_BATCH = 0.2927; + private static final double POW2_PROB_BATCH = 0.6686; + private static final double ULOW_BATCH = 1.2f; // smallest parallel batch job has 2 nodes + private static final double UMED_BATCH = 5; + private static final double UHI_BATCH = 7; // biggest batch job has 128 nodes + private static final double UPROB_BATCH = 0.875; - public static final double SERIAL_PROB_ACTIVE = 0.1541; - public static final double POW2_PROB_ACTIVE = 0.625; - public static final double ULOW_ACTIVE = 1; // smallest interactive parallel job has 2 nodes - public static final double UMED_ACTIVE = 3; - public static final double UHI_ACTIVE = 5.5f; // biggest interactive job has 45 nodes - public static final double UPROB_ACTIVE = 0.705; + private static final double SERIAL_PROB_ACTIVE = 0.1541; + private static final double POW2_PROB_ACTIVE = 0.625; + private static final double ULOW_ACTIVE = 1; // smallest interactive parallel job has 2 nodes + private static final double UMED_ACTIVE = 3; + private static final double UHI_ACTIVE = 5.5f; // biggest interactive job has 45 nodes + private static final double UPROB_ACTIVE = 0.705; /* The parameters for the running time * The running time is computed using hyper-gamma distribution. @@ -143,19 +141,19 @@ * 'nodes' will be calculated in the program, here we defined the 'pa','pb' * parameters. */ - public static final double A1_BATCH = 6.57; - public static final double B1_BATCH = 0.823; - public static final double A2_BATCH = 639.1; - public static final double B2_BATCH = 0.0156; - public static final double PA_BATCH = -0.003; - public static final double PB_BATCH = 0.6986; + private static final double A1_BATCH = 6.57; + private static final double B1_BATCH = 0.823; + private static final double A2_BATCH = 639.1; + private static final double B2_BATCH = 0.0156; + private static final double PA_BATCH = -0.003; + private static final double PB_BATCH = 0.6986; - public static final double A1_ACTIVE = 3.8351; - public static final double B1_ACTIVE = 0.6605; - public static final double A2_ACTIVE = 7.073; - public static final double B2_ACTIVE = 0.6856; - public static final double PA_ACTIVE = -0.0118; - public static final double PB_ACTIVE = 0.9156; + private static final double A1_ACTIVE = 3.8351; + private static final double B1_ACTIVE = 0.6605; + private static final double A2_ACTIVE = 7.073; + private static final double B2_ACTIVE = 0.6856; + private static final double PA_ACTIVE = -0.0118; + private static final double PB_ACTIVE = 0.9156; /* The parameters for the inter-arrival time @@ -169,41 +167,41 @@ * a constant ,ARAR (Arrive-Rush-All-Ratio), to set the alpha parameter (the new * aarr) so it will represent the arrive-time at all hours of the day. */ - public static final double AARR_BATCH = 6.0415; - public static final double BARR_BATCH = 0.8531; - public static final double ANUM_BATCH = 6.1271; - public static final double BNUM_BATCH = 5.2740; - public static final double ARAR_BATCH = 1.0519; + private static final double AARR_BATCH = 6.0415; + private static final double BARR_BATCH = 0.8531; + private static final double ANUM_BATCH = 6.1271; + private static final double BNUM_BATCH = 5.2740; + private static final double ARAR_BATCH = 1.0519; - public static final double AARR_ACTIVE = 6.5510; - public static final double BARR_ACTIVE = 0.6621; - public static final double ANUM_ACTIVE = 8.9186; - public static final double BNUM_ACTIVE = 3.6680; - public static final double ARAR_ACTIVE = 0.9797; + private static final double AARR_ACTIVE = 6.5510; + private static final double BARR_ACTIVE = 0.6621; + private static final double ANUM_ACTIVE = 8.9186; + private static final double BNUM_ACTIVE = 3.6680; + private static final double ARAR_ACTIVE = 0.9797; /* * Here are the model's parameters for typeless data (no batch nor interactive) * We use those parameters when INCLUDE_JOBS_TYPE is off (0) */ - public static final double SERIAL_PROB = 0.244; - public static final double POW2_PROB = 0.576; - public static final double ULOW = 0.8f; // The smallest parallel job is 2 nodes - public static final double UMED = 4.5f; - public static final double UHI = 7f; // SYSTEM SIZE is 2^UHI == 128 - public static final double UPROB = 0.86; + private static final double SERIAL_PROB = 0.244; + private static final double POW2_PROB = 0.576; + private static final double ULOW = 0.8f; // The smallest parallel job is 2 nodes + private static final double UMED = 4.5f; + private static final double UHI = 7f; // SYSTEM SIZE is 2^UHI == 128 + private static final double UPROB = 0.86; - public static final double A1 = 4.2; - public static final double B1 = 0.94; - public static final double A2 = 312; - public static final double B2 = 0.03; - public static final double PA = -0.0054; - public static final double PB = 0.78; + private static final double A1 = 4.2; + private static final double B1 = 0.94; + private static final double A2 = 312; + private static final double B2 = 0.03; + private static final double PA = -0.0054; + private static final double PB = 0.78; - public static final double AARR = 10.2303; - public static final double BARR = 0.4871; - public static final double ANUM = 8.1737; - public static final double BNUM = 3.9631; - public static final double ARAR = 1.0225; + private static final double AARR = 10.2303; + private static final double BARR = 0.4871; + private static final double ANUM = 8.1737; + private static final double BNUM = 3.9631; + private static final double ARAR = 1.0225; // start the simulation at midnight (hour 0) private static final int START = 0; @@ -217,6 +215,9 @@ private double workloadDuration_; private int numJobs_; + // hour of the day when the simulation starts + private int start_; + private double[] a1, b1, a2, b2, pa, pb; private double[] aarr, barr, anum, bnum; private double[] serialProb, pow2Prob, uLow, uMed, uHi, uProb; @@ -443,6 +444,7 @@ random_ = new Random(seed); workloadDuration_ = Double.MAX_VALUE; numJobs_ = 1000; + start_ = START; a1 = new double[2]; b1 = new double[2]; a2 = new double[2]; b2 = new double[2]; @@ -457,60 +459,60 @@ // separate batch from interactive if (useJobType_) { - serialProb[BATCH] = SERIAL_PROB_BATCH; - pow2Prob[BATCH] = POW2_PROB_BATCH; - uLow[BATCH] = ULOW_BATCH; - uMed[BATCH] = UMED_BATCH; - uHi[BATCH] = UHI_BATCH; - uProb[BATCH] = UPROB_BATCH; + serialProb[BATCH_JOBS] = SERIAL_PROB_BATCH; + pow2Prob[BATCH_JOBS] = POW2_PROB_BATCH; + uLow[BATCH_JOBS] = ULOW_BATCH; + uMed[BATCH_JOBS] = UMED_BATCH; + uHi[BATCH_JOBS] = UHI_BATCH; + uProb[BATCH_JOBS] = UPROB_BATCH; - serialProb[INTERACTIVE] = SERIAL_PROB_ACTIVE; - pow2Prob[INTERACTIVE] = POW2_PROB_ACTIVE; - uLow[INTERACTIVE] = ULOW_ACTIVE; - uMed[INTERACTIVE] = UMED_ACTIVE; - uHi[INTERACTIVE] = UHI_ACTIVE; - uProb[INTERACTIVE] = UPROB_ACTIVE; + serialProb[INTERACTIVE_JOBS] = SERIAL_PROB_ACTIVE; + pow2Prob[INTERACTIVE_JOBS] = POW2_PROB_ACTIVE; + uLow[INTERACTIVE_JOBS] = ULOW_ACTIVE; + uMed[INTERACTIVE_JOBS] = UMED_ACTIVE; + uHi[INTERACTIVE_JOBS] = UHI_ACTIVE; + uProb[INTERACTIVE_JOBS] = UPROB_ACTIVE; - a1[BATCH] = A1_BATCH; b1[BATCH] = B1_BATCH; - a2[BATCH] = A2_BATCH; b2[BATCH] = B2_BATCH; - pa[BATCH] = PA_BATCH; pb[BATCH] = PB_BATCH; + a1[BATCH_JOBS] = A1_BATCH; b1[BATCH_JOBS] = B1_BATCH; + a2[BATCH_JOBS] = A2_BATCH; b2[BATCH_JOBS] = B2_BATCH; + pa[BATCH_JOBS] = PA_BATCH; pb[BATCH_JOBS] = PB_BATCH; - a1[INTERACTIVE] = A1_ACTIVE; b1[INTERACTIVE] = B1_ACTIVE; - a2[INTERACTIVE] = A2_ACTIVE; b2[INTERACTIVE] = B2_ACTIVE; - pa[INTERACTIVE] = PA_ACTIVE; pb[INTERACTIVE] = PB_ACTIVE; + a1[INTERACTIVE_JOBS] = A1_ACTIVE; b1[INTERACTIVE_JOBS] = B1_ACTIVE; + a2[INTERACTIVE_JOBS] = A2_ACTIVE; b2[INTERACTIVE_JOBS] = B2_ACTIVE; + pa[INTERACTIVE_JOBS] = PA_ACTIVE; pb[INTERACTIVE_JOBS] = PB_ACTIVE; - aarr[BATCH] = AARR_BATCH*ARAR_BATCH; barr[BATCH] = BARR_BATCH; - anum[BATCH] = ANUM_BATCH; bnum[BATCH] = BNUM_BATCH; + aarr[BATCH_JOBS] = AARR_BATCH*ARAR_BATCH; barr[BATCH_JOBS] = BARR_BATCH; + anum[BATCH_JOBS] = ANUM_BATCH; bnum[BATCH_JOBS] = BNUM_BATCH; - aarr[INTERACTIVE] = AARR_ACTIVE*ARAR_ACTIVE; - barr[INTERACTIVE] = BARR_ACTIVE; - anum[INTERACTIVE] = ANUM_ACTIVE; - bnum[INTERACTIVE] = BNUM_ACTIVE; + aarr[INTERACTIVE_JOBS] = AARR_ACTIVE*ARAR_ACTIVE; + barr[INTERACTIVE_JOBS] = BARR_ACTIVE; + anum[INTERACTIVE_JOBS] = ANUM_ACTIVE; + bnum[INTERACTIVE_JOBS] = BNUM_ACTIVE; } else { // whole sample -- make all batch jobs - serialProb[BATCH] = serialProb[INTERACTIVE] = SERIAL_PROB; - pow2Prob[BATCH] = pow2Prob[INTERACTIVE] = POW2_PROB; - uLow[BATCH] = uLow[INTERACTIVE] = ULOW ; - uMed[BATCH] = uMed[INTERACTIVE] = UMED ; - uHi[BATCH] = uHi[INTERACTIVE] = UHI ; - uProb[BATCH] = uProb[INTERACTIVE] = UPROB ; + serialProb[BATCH_JOBS] = serialProb[INTERACTIVE_JOBS] = SERIAL_PROB; + pow2Prob[BATCH_JOBS] = pow2Prob[INTERACTIVE_JOBS] = POW2_PROB; + uLow[BATCH_JOBS] = uLow[INTERACTIVE_JOBS] = ULOW ; + uMed[BATCH_JOBS] = uMed[INTERACTIVE_JOBS] = UMED ; + uHi[BATCH_JOBS] = uHi[INTERACTIVE_JOBS] = UHI ; + uProb[BATCH_JOBS] = uProb[INTERACTIVE_JOBS] = UPROB ; - a1[BATCH] = a1[INTERACTIVE] = A1; - b1[BATCH] = b1[INTERACTIVE] = B1; - a2[BATCH] = a2[INTERACTIVE] = A2; - b2[BATCH] = b2[INTERACTIVE] = B2; - pa[BATCH] = pa[INTERACTIVE] = PA; - pb[BATCH] = pb[INTERACTIVE] = PB; + a1[BATCH_JOBS] = a1[INTERACTIVE_JOBS] = A1; + b1[BATCH_JOBS] = b1[INTERACTIVE_JOBS] = B1; + a2[BATCH_JOBS] = a2[INTERACTIVE_JOBS] = A2; + b2[BATCH_JOBS] = b2[INTERACTIVE_JOBS] = B2; + pa[BATCH_JOBS] = pa[INTERACTIVE_JOBS] = PA; + pb[BATCH_JOBS] = pb[INTERACTIVE_JOBS] = PB; - aarr[BATCH] = aarr[INTERACTIVE] = AARR * ARAR; - barr[BATCH] = barr[INTERACTIVE] = BARR; - anum[BATCH] = anum[INTERACTIVE] = ANUM; - bnum[BATCH] = bnum[INTERACTIVE] = BNUM; + aarr[BATCH_JOBS] = aarr[INTERACTIVE_JOBS] = AARR * ARAR; + barr[BATCH_JOBS] = barr[INTERACTIVE_JOBS] = BARR; + anum[BATCH_JOBS] = anum[INTERACTIVE_JOBS] = ANUM; + bnum[BATCH_JOBS] = bnum[INTERACTIVE_JOBS] = BNUM; } if ( ! useJobType_ ) // make all jobs batch - timeFromBegin_[INTERACTIVE] = Long.MAX_VALUE; + timeFromBegin_[INTERACTIVE_JOBS] = Long.MAX_VALUE; } /** @@ -519,20 +521,34 @@ * @param prob the probability * @return <tt>true</tt> if the probability has been set, or * <tt>false</tt> otherwise. - * @see #INTERACTIVE - * @see #BATCH + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS */ public boolean setSerialProbability(int jobType, double prob) { - if(jobType > BATCH || jobType < INTERACTIVE) + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) return false; if(useJobType_) serialProb[jobType] = prob; else - serialProb[INTERACTIVE] = serialProb[BATCH] = prob; + serialProb[INTERACTIVE_JOBS] = serialProb[BATCH_JOBS] = prob; return true; } + + /** + * Gets the probability for serial jobs + * @param jobType the type of jobs + * @returns prob the probability; <tt>-1</tt> if an error occurs. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS + */ + public double getSerialProbability(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return UNKNOWN; + + return serialProb[jobType]; + } /** * Sets the probability for power of two jobs @@ -540,20 +556,34 @@ * @param prob the probability * @return <tt>true</tt> if the probability has been set, or * <tt>false</tt> otherwise. - * @see #INTERACTIVE - * @see #BATCH + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS */ public boolean setPower2Probability(int jobType, double prob) { - if(jobType > BATCH || jobType < INTERACTIVE) + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) return false; if(useJobType_) pow2Prob[jobType] = prob; else - pow2Prob[INTERACTIVE] = pow2Prob[BATCH] = prob; + pow2Prob[INTERACTIVE_JOBS] = pow2Prob[BATCH_JOBS] = prob; return true; } + + /** + * Gets the probability for power of two jobs + * @param jobType the type of jobs + * @returns prob the probability; <tt>-1</tt> if an error occurs. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS + */ + public double getPower2Probability(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return UNKNOWN; + + return pow2Prob[jobType]; + } /** * Sets the parameters for the two-stage-uniform @@ -565,13 +595,13 @@ * @param uHi is the log2 of the maximal size of a job in the system (system's size) * @param uProb should be in [0.7 - 0.95] * @return <tt>true</tt> if the probabilities have been set, or - * <tt>false</tt> otherwise.b2 - * @see #INTERACTIVE - * @see #BATCH + * <tt>false</tt> otherwise. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS */ public boolean setParallelJobProbabilities(int jobType, double uLow, double uMed, double uHi, double uProb) { - if(jobType > BATCH || jobType < INTERACTIVE) + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) return false; else if (uLow > uHi) return false; @@ -587,16 +617,74 @@ this.uProb[jobType] = uProb; } else { - this.uLow[INTERACTIVE] = this.uLow[BATCH] = uLow; - this.uMed[INTERACTIVE] = this.uMed[BATCH] = uMed; - this.uHi[INTERACTIVE] = this.uHi[BATCH] = uHi; - this.uProb[INTERACTIVE] = this.uProb[BATCH] = uProb; + this.uLow[INTERACTIVE_JOBS] = this.uLow[BATCH_JOBS] = uLow; + this.uMed[INTERACTIVE_JOBS] = this.uMed[BATCH_JOBS] = uMed; + this.uHi[INTERACTIVE_JOBS] = this.uHi[BATCH_JOBS] = uHi; + this.uProb[INTERACTIVE_JOBS] = this.uProb[BATCH_JOBS] = uProb; } return true; } - /** Sets the parameters for the running time + /** + * Gets the probability of the job being a parallel job + * @return the value of uProb; <tt>-1</tt> if an error occurs. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS + */ + public double getParallelJobUProb(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return UNKNOWN; + + return uProb[jobType]; + } + + /** + * Gets the log2 of the maximal size of a job in the system (system's size) + * @param jobType the type of jobs + * @return the value of uHi; <tt>-1</tt> if an error occurs. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS + */ + public double getParallelJobUHi(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return UNKNOWN; + + return uHi[jobType]; + } + + /** + * Gets the medium size of parallel jobs in the system. It is log2 of + * the size. + * @param jobType the type of jobs + * @return the value of uMed; <tt>-1</tt> if an error occurs. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS + */ + public double getParallelJobUMed(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return UNKNOWN; + + return uMed[jobType]; + } + + /** + * Gets the the log2 of the minimal size of job in the system (you can add or + * subtract 0.2 to give less/more probability to the minimal size). + * @param jobType the type of jobs + * @return the value of uLow; <tt>-1</tt> if an error occurs. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS + */ + public double getParallelJobULow(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return UNKNOWN; + + return uLow[jobType]; + } + + /** + * Sets the parameters for the running time * The running time is computed using hyper-gamma distribution. * The parameters a1,b1,a2,b2 are the parameters of the two gamma distributions * The p parameter of the hyper-gamma distribution is calculated as a straight @@ -615,7 +703,7 @@ public boolean setRunTimeParameters(int jobType, double a1, double a2, double b1, double b2, double pa, double pb) { - if(jobType > BATCH || jobType < INTERACTIVE) + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) return false; if(useJobType_) { @@ -624,17 +712,40 @@ this.pa[jobType] = pa; this.pb[jobType] = pb; } else { - this.a1[INTERACTIVE] = this.a1[BATCH] = a1; - this.b1[INTERACTIVE] = this.a1[BATCH] = b1; - this.a2[INTERACTIVE] = this.a1[BATCH] = a2; - this.b2[INTERACTIVE] = this.a1[BATCH] = b2; - this.pa[INTERACTIVE] = this.a1[BATCH] = pa; - this.pb[INTERACTIVE] = this.a1[BATCH] = pb; + this.a1[INTERACTIVE_JOBS] = this.a1[BATCH_JOBS] = a1; + this.b1[INTERACTIVE_JOBS] = this.a1[BATCH_JOBS] = b1; + this.a2[INTERACTIVE_JOBS] = this.a1[BATCH_JOBS] = a2; + this.b2[INTERACTIVE_JOBS] = this.a1[BATCH_JOBS] = b2; + this.pa[INTERACTIVE_JOBS] = this.a1[BATCH_JOBS] = pa; + this.pb[INTERACTIVE_JOBS] = this.a1[BATCH_JOBS] = pb; } return true; } + /** + * Gets the runtime parameters. That is, it returns the parameters + * used for the hyper-gamma distribution. For more detail on the + * parameters, please check the paper that describes the model. + * @param jobType the type of jobs + * @return an array where: <br> + * array[0] = a1 - hyper-gamma distribution parameter. <br> + * array[1] = a2 - hyper-gamma distribution parameter. <br> + * array[2] = b1 - hyper-gamma distribution parameter. <br> + * array[3] = b2 - hyper-gamma distribution parameter. <br> + * array[4] = pa - hyper-gamma distribution parameter. <br> + * array[5] = pb - hyper-gamma distribution parameter. <br> + * The method will return <tt>null</tt> if an error occurs. + */ + public double[] getRunTimeParameters(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return null; + + return new double[] { this.a1[jobType], this.a2[jobType], + this.b1[jobType], this.b2[jobType], + this.pa[jobType], this.pb[jobType]}; + } + /** * Sets the parameters for the inter-arrival time * The inter-arriving time is calculated using two gamma distributions. @@ -644,12 +755,12 @@ * arrived at each time interval (bucket). * The inter-arrival time is calculated using both gammas * Since gamma(aarr,barr) represents the arrive-time at the rush time , we use - * a constant ,ARAR (Arrive-Rush-All-Ratio), to set the alpha parameter (the new + * a constant, ARAR (Arrive-Rush-All-Ratio), to set the alpha parameter (the new * aarr) so it will represent the arrive-time at all hours of the day. */ public boolean setInterArrivalTimeParameters(int jobType, double aarr, double barr, double anum, double bnum, double arar) { - if(jobType > BATCH || jobType < INTERACTIVE) + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) return false; if(useJobType_) { @@ -659,16 +770,44 @@ this.bnum[jobType] = bnum; } else { - this.aarr[INTERACTIVE] = this.aarr[BATCH] = aarr * arar; - this.barr[INTERACTIVE] = this.barr[BATCH] = barr; - this.anum[INTERACTIVE] = this.barr[BATCH] = anum; - this.bnum[INTERACTIVE] = this.barr[BATCH] = bnum; + this.aarr[INTERACTIVE_JOBS] = this.aarr[BATCH_JOBS] = aarr * arar; + this.barr[INTERACTIVE_JOBS] = this.barr[BATCH_JOBS] = barr; + this.anum[INTERACTIVE_JOBS] = this.barr[BATCH_JOBS] = anum; + this.bnum[INTERACTIVE_JOBS] = this.barr[BATCH_JOBS] = bnum; } return true; } /** + * Returns the parameters for the inter-arrival time + * The inter-arriving time is calculated using two gamma distributions. + * gamma(aarr,barr) represents the inter_arrival time for the rush hours. It is + * independent on the hour the job arrived at. + * The cdf of gamma(bnum,anum) represents the proportion of number of jobs which + * arrived at each time interval (bucket). + * The inter-arrival time is calculated using both gammas + * Since gamma(aarr,barr) represents the arrive-time at the rush time , we use + * a constant, ARAR (Arrive-Rush-All-Ratio), to set the alpha parameter (the new + * aarr) so it will represent the arrive-time at all hours of the day. + * @param jobType the type of jobs + * @return an array where: <br> + * array[0] = aarr - gamma distribution parameter. <br> + * array[1] = barr - gamma distribution parameter. <br> + * array[2] = anum - gamma distribution parameter. <br> + * array[3] = bnum - gamma distribution parameter. <br> + * The method will return <tt>null</tt> if an error occurs. + */ + public double[] getInterArrivalTimeParameters(int jobType) { + + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return null; + + return new double[] { this.aarr[jobType], this.barr[jobType], + this.anum[jobType], this.bnum[jobType]}; + } + + /** * Sets the maximum number of jobs to be generated by this workload model * @param numJobs the number of jobs * @returns <tt>true</tt> if the number of jobs has been set; @@ -699,6 +838,27 @@ } /** + * Gets the hour of the day when the simulation should start + * @return the start hour (between 0 and 23) + */ + public int getStartHour() { + return start_; + } + + /** + * Sets the hour of the day when the simulation should start + * @param start the start hour to set (between 0 and 23) + * @return <tt>true</tt> if set; <tt>false</tt> otherwise. + */ + public boolean setStartHour(int start) { + if(start < 0 || start > 23) + return false; + + start_ = start; + return false; + } + + /** * Sets a Gridlet file size (in byte) for sending to/from a resource. * @param size a Gridlet file size (in byte) * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise @@ -883,13 +1043,13 @@ */ private boolean createGridlets() { - int type = INTERACTIVE; + int type = INTERACTIVE_JOBS; int nodes; long arrTime; int runTime; arrivalInit(aarr, barr, anum, bnum, START, weights); for (int i=0; i<numJobs_; i++) { - long[] info = arrive(type, weights, aarr, barr); + long[] info = getNextArrival(type, weights, aarr, barr); type = (int)info[0]; arrTime = (long)info[1]; @@ -909,9 +1069,6 @@ return true; } - /*----------------------------------------------------------------------------*/ - /* CALC_NUMBER_OF_NODES (NUMBER OF NODES) */ - /* -------------------------------------------------------------------------- */ /* * we distinguish between serial jobs , power2 jobs and other. * for serial job (with probability SerialProb) the number of nodes is 1 @@ -936,12 +1093,8 @@ return (int)(Math.pow(2, par) + 0.5); // return round(2^par) } - /*----------------------------------------------------------------------------*/ - /* TIMES_FROM_NODES (RUNTIME) */ - /* -------------------------------------------------------------------------- */ - /* - * time_from_nodes returns a value of a random number from hyper_gamma - * distribution. + /* + * timeFromNodes returns a value of a random number from hyperGamma distribution. * The a1,b1,a2,b2 are the parameters of both gammas. * The 'p' parameter is calculated from the 'nodes' 'pa' and 'pb' arguments * using the formula: p = pa * nodes + pb. @@ -966,9 +1119,9 @@ return (long)Math.exp(hg); } - /* The arrive process. - * 'arrive' returns arrival time (from the beginning of the simulation) of - * the current job. + /* Initialises the variables for the arrival process. + * 'getNextArrival' returns arrival time (from the beginning of + * the simulation) of the current job. * The (gamma distribution) parameters 'aarr' and 'barr' represent the * inter-arrival time at rush hours. * The (gamma distribution) parameters 'anum' and 'bnum' represent the number @@ -980,7 +1133,7 @@ * TOO_MUCH_ARRIVE_TIME) then another value is chosen. * * The algorithm (briefly): - * A. Preparations (calculated only once in 'arrive_init()': + * A. Preparations (calculated only once in 'arrivalInit()': * 1. foreach time interval (bucket) calculate its proportion of the number * of arriving jobs (using 'anum' and 'bnum'). This value will be the * bucket's points. @@ -988,12 +1141,12 @@ * 3. divide the points in each bucket by the points mean ("normalize" the * points in all buckets) * B. randomly choosing a new arrival time for a job: - * 1. get a random value from distribution gamma(aarr , barr). + * 1. get a random value from distribution gamma(aarr, barr). * 2. calculate the points we have. * 3. accumulate inter-arrival time by passing buckets (while paying them * points for that) until we do not have enough points. * 4. handle reminders - add the new reminder and subtract the old reminder. - * 5. update the time variables ('current' and 'time_from_begin') + * 5. update the time variables ('current_' and 'timeFromBegin_') */ private void arrivalInit(double[] aarr, double[] barr, double[] anum, double[] bnum, int start_hour, double weights[][]) { @@ -1005,7 +1158,7 @@ for(int j=0; j<weights[i].length; j++) weights[i][j] = 0; - current_[BATCH] = current_[INTERACTIVE] = start_hour * BUCKETS / HOURS_IN_DAY; + current_[BATCH_JOBS] = current_[INTERACTIVE_JOBS] = start_hour * BUCKETS / HOURS_IN_DAY; /* * for both batch and interactive calculate the propotion of each bucket , @@ -1025,12 +1178,12 @@ for (int i=0 ; i<BUCKETS ; i++) weights[j][i] /= mean[j]; - calcNextArrival(BATCH ,weights,aarr,barr); - calcNextArrival(INTERACTIVE,weights,aarr,barr); + calcNextArrival(BATCH_JOBS ,weights,aarr,barr); + calcNextArrival(INTERACTIVE_JOBS,weights,aarr,barr); } /* - * 'calcNextArrival' calculates the next inter-arrival time according + * calcNextArrival calculates the next inter-arrival time according * to the current time of the day. * 'type' is the type of the next job -- interactive or batch * alpha and barr are the parameters of the gamma distribution of the @@ -1068,20 +1221,22 @@ current_[type] = bucket; } - /*----------------------------------------------------------------------------*/ - /* ARRIVE (ARRIVAL TIME AND TYPE) */ - /*----------------------------------------------------------------------------*/ - /* - * return the time for next job to arrive the system. - * returns also the type of the next job , which is the type that its - * next arrive time (time_from_begin) is closer to the start (smaller). - * notice that since calc_next_arrive changes time_from_begin[] we must save - * the time_from_begin in 'res' so we would be able to return it. - */ - private long[] arrive(int type, double[][] weights, double[] aarr, double[] barr) { + /* + * Return the time for next job to arrive the system. + * returns also the type of the next job , which is the type that its + * next arrive time (time_from_begin) is closer to the start (smaller). + * notice that since calc_next_arrive changes time_from_begin[] we must save + * the time_from_begin in 'res' so we would be able to return it. + * @returns an array where array[0] = type of the job, array[1] = arrival time + */ + private long[] getNextArrival(int type, double[][] weights, + double[] aarr, double[] barr) { + long res; - type = (timeFromBegin_[BATCH] < timeFromBegin_[INTERACTIVE]) ? BATCH : INTERACTIVE; + type = (timeFromBegin_[BATCH_JOBS] < timeFromBegin_[INTERACTIVE_JOBS]) ? + BATCH_JOBS : INTERACTIVE_JOBS; + res = timeFromBegin_[type]; // save the job's arrival time // randomly choose the next job's (of the same type) arrival time @@ -1102,11 +1257,12 @@ * @pre numProc > 0 * @post $none */ - protected void submitGridlet(int id, long submitTime, int runTime, int numProc) - { + protected void submitGridlet(int id, long submitTime, + int runTime, int numProc) { // create the gridlet int len = runTime * rating_; // calculate a job length for each PE - Gridlet gl = new Gridlet(id, len, size_, size_, GridSim.isTraceEnabled()); + Gridlet gl = new Gridlet(id, len, size_, + size_, GridSim.isTraceEnabled()); gl.setUserID( super.get_id() ); // set the owner ID gl.setNumPE(numProc); // set the requested num of proc @@ -1131,26 +1287,29 @@ // --- Methods required by the distributions used by the workload model --- + // --- Most of these methods were ported from C to Java, but the logic --- + // --- remains the same as in Lublin's workload model in C --- /* - * hyper_gamma returns a value of a random variable of mixture of two + * hyperGamma returns a value of a random variable of mixture of two * gammas. its parameters are those of the two gammas: a1,b1,a2,b2 and the * relation between the gammas (p = the probability of the first gamma). we * first randomly decide which gamma will be active ((a1,b1) or (a2,b2)). * then we randomly choose a number from the chosen gamma distribution. */ - double hyperGamma(double a1, double b1, double a2, double b2, double p) { + private double hyperGamma(double a1, double b1, double a2, + double b2, double p) { double a, b, hg, u = random_.nextDouble(); - if (u <= p) { /* gamma(a1,b1) */ + if (u <= p) { // gamma(a1,b1) a = a1; b = b1; - } else { /* gamma(a2,b2) */ + } else { // gamma(a2,b2) a = a2; b = b2; } - /* generate a value of a random variable from distribution gamma(a,b) */ + // generates a value of a random variable from distribution gamma(a,b) hg = gamrnd(a, b); return hg; } @@ -1177,7 +1336,7 @@ } /* - * gamrnd_int_alpha returns a value of a random variable of gamma(n,beta) + * gamrndIntAlpha returns a value of a random variable of gamma(n,beta) * distribution where n is integer(unsigned long actually). gamma(n,beta) == * beta*gamma(n,1) == beta* sum(1..n){gamma(1,1)} == beta* sum(1..n){exp(1)} == * beta* sum(1..n){-ln(uniform(0,1))} @@ -1185,28 +1344,27 @@ private double gamrndIntAlpha(long n, double beta) { double acc = 0; for (int i = 0; i < n; i++) - acc += Math.log(random_.nextDouble()); /* sum the exponential - * random variables - */ + acc += Math.log(random_.nextDouble()); // sum the exponential + // random variables return (-acc * beta); } /* - * gamrnd_alpha_smaller_1 returns a value of a random variable of + * gamrndAlphaSmaller1 returns a value of a random variable of * gamma(alpha,beta) where alpha is smaller than 1. This is done using the * Beta distribution. (alpha<1) ==> (1-alpha<1) ==> we can use * beta_less_1(alpha,1-alpha) gamma(alpha,beta) = exponential(beta) * * Beta(alpha,1-alpha) */ private double gamrndAlphaSmaller1(double alpha, double beta) { - double x = betarndLess1(alpha, 1 - alpha); /* beta random variable */ - double y = -Math.log(random_.nextDouble()); /* exponential random - * variable */ + double x = betarndLess1(alpha, 1 - alpha); // beta random variable + double y = -Math.log(random_.nextDouble()); // exponential random + // variable return (beta * x * y); } /* - * betarnd_less_1 returns a value of a random variable of beta(alpha,beta) + * betarndLess1 returns a value of a random variable of beta(alpha,beta) * distribution where both alpha and beta are smaller than 1 (and larger * than 0) */ @@ -1237,13 +1395,14 @@ return gser(x, alpha); } - /* x >= a+1 */ + // x >= a+1 return 1 - gcf(x, alpha); } - /*----------------------------------------------------------------------------*/ - /* GSER */ - /*----------------------------------------------------------------------------*/ + + /* + * Gser + */ private double gser(double x, double a) { int i; double sum, monom, aa = a; @@ -1255,14 +1414,15 @@ monom *= (x / aa); sum += monom; if (monom < sum * EPS) - return (sum * Math.exp(-x + a * Math.log(x) - lgamma(a))); + return (sum * Math.exp(-x + a * Math.log(x) - logGamma(a))); } - return -1; /* error did not converged */ + return -1; // error, did not converged } - /*----------------------------------------------------------------------------*/ - /* GCF */ - /*----------------------------------------------------------------------------*/ + + /* + * Returns the GCF + */ private double gcf(double x, double a) { int i; double gold = 0, g, a0 = 1, a1 = x, b0 = 0, b1 = 1, fac = 1, anf, ana; @@ -1278,11 +1438,11 @@ fac = 1 / a1; g = b1 * fac; if (Math.abs((g - gold) / g) < EPS) - return (g * Math.exp(-x + a * Math.log(x) - lgamma(a))); + return (g * Math.exp(-x + a * Math.log(x) - logGamma(a))); gold = g; } } - return 2; /* gamcdf will return -1 */ + return 2; // gamcdf will return -1 } /* @@ -1296,15 +1456,15 @@ double hi, double prob) { double a, b, tsu, u = random_.nextDouble(); - if (u <= prob) { /* uniform(low , med) */ + if (u <= prob) { // uniform(low , med) a = low; b = med; - } else { /* uniform(med , hi) */ + } else { // uniform(med , hi) a = med; b = hi; } - /* generate a value of a random variable from distribution uniform(a,b) */ + // generate a value of a random variable from distribution uniform(a,b) tsu = (random_.nextDouble() * (b - a)) + a; return tsu; } @@ -1316,7 +1476,7 @@ * Direct inquiries to 30 Frost Street, Cambridge, MA 02140 */ - static private double lgamma(double x) + static private double logGamma(double x) throws ArithmeticException { double p, q, w, z; @@ -1344,7 +1504,7 @@ if (x < -34.0) { q = -x; - w = lgamma(q); + w = logGamma(q); p = Math.floor(q); if (p == q) throw new ArithmeticException("lgamma: Overflow"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-02-11 23:42:34
|
Revision: 99 http://gridsim.svn.sourceforge.net/gridsim/?rev=99&view=rev Author: marcos_dias Date: 2008-02-11 15:42:40 -0800 (Mon, 11 Feb 2008) Log Message: ----------- This update contains: + A simpler advance reservation policy. Now the advance reservation policy extends the normal conservative backfilling so the repeating methods were eliminated. The advance reservation policy has become smaller and simpler. + Small corrections in the comments and java documentation. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java 2008-02-11 06:09:53 UTC (rev 98) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java 2008-02-11 23:42:40 UTC (rev 99) @@ -89,10 +89,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-02-11 06:09:53 UTC (rev 98) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-02-11 23:42:40 UTC (rev 99) @@ -8,14 +8,14 @@ package gridsim.turbo; import eduni.simjava.Sim_event; -import eduni.simjava.Sim_system; import gridsim.GridSim; import gridsim.GridSimTags; import gridsim.Gridlet; +import gridsim.IO_data; import gridsim.gui.AllocationAction; import java.util.Calendar; -import java.util.Collections; +import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; @@ -39,43 +39,15 @@ * Systems, 12:(6), pp. 529-543, 2001. * </ul> * - * This policy maintains an availability profile. The availability - * profile contains information about the ranges of processing elements - * (PEs) available at future times. The size of the availability profile - * is proportional to the number of gridlets in the running and waiting - * queues. To illustrate how the availability profile works, imagine that - * the simulation has just started and the availability profile is empty. - * The grid resource has 500 PEs. Therefore, the range of PEs available - * is [0..499]. At simulation time 100, a gridlet (GA) arrives requiring - * 100 PEs. The Gridlet is expected to execute for 500 seconds. As the - * resource is not executing any gridlets, GA is accepted and given - * the range [0..99]. The ranges of current PEs available is updated - * to [100..499] and one entry is inserted at the profile to indicate - * that the range [0..499] will be available again at simulation time - * 600 seconds. Now suppose that a Gridlet (GB) arrives at simulation - * time 200 requiring 400 PEs and expected to run for 500 seconds. - * The policy checks the ranges currently available and find [100..499]. - * It then scans the availability profile and analyses all the entries whose - * time is smaller than the expected termination time of GB. The policy - * finds the intersections of PEs amongst the entries, process similar - * to finding intersections of sequences. While scanning the profile, - * the policy finds the entry at 600 seconds. The intersection of - * [100..499] and [0..499] is [100..499]. That means that there are - * enough resources to schedule GB and then GB starts the execution. - * The policy then updates the ranges of current PEs to []. - * After that, the policy updates the entry at 600 seconds to [0..99] - * and inserts an entry with time 700 seconds with the range [0..499]. - * Now consider that a third Gridlet (GC) arrives at simulation time 250 - * requiring 500 PEs and expected to run for 100 seconds. As the - * current ranges available is [], the policy scans the profile until - * it finds an entry with enough PEs available. In this case, the entry - * found is at 700 seconds. The policy would continue scanning the profile - * finding the intersection with other ranges if there were more. In this - * case, 700 seconds is the last entry in the profile. The Gridlet is - * then set to start execution at time 700 seconds. The policy then - * updates the entry at time 700 seconds to [] and creates an entry - * at 800 with [0..499]. GC is then put in the waiting queue. - * <p> + * This policy extends <tt>CBParallelSpaceShared</tt> so also maintains + * an availability profile. The main difference is that in many instances + * an advance reservation will require two entries in the availability profile, + * one to mark its start time and another to delimit its finish time. For more + * details on the availability profile see {@link CBParallelSpaceShared}. + * Another important difference is that when a Gridlet is cancelled, the + * advance reservations are not removed from the availability profile and + * therefore are not moved forwards in the queue. + * <br> * This scheduler supports parallel jobs and some AR functionalities, * such as: * <ul> @@ -84,18 +56,20 @@ * <li> commit a reservation * <li> process a reservation status query * <li> list free time over a certain period of time + * <li> provide availability information when an advance + * reservation is cancelled. * </ul> * <p> * <b>LIMITATIONS:</b><br> * <ul> * <li> The list of machines comprising this resource must * be homogeneous. - * <li> Local load is not considered. If you would like to - * simulate this, you have to model the local load as - * gridlets. It is more precise and faster. + * <li> Local load is not considered. If you would like to simulate this, + * you have to model the local load as gridlets. It is more precise + * and faster. To do so, please check {@link Lublin99Workload}. * <li> Gridlets cannot be paused nor migrated. This could be * easily done, but due to time constraints, I could not - * implement these. + * implement these features. * </ul> * * @author Marcos Dias de Assuncao @@ -109,54 +83,22 @@ * @see CBParallelSpaceShared */ -public class ARParallelSpaceShared extends ARTPolicy { +public class ARParallelSpaceShared extends + CBParallelSpaceShared implements ARTPolicy { - // Queue of waiting Gridlets - private LinkedList<SSGridlet> queuedGridlets_; - - // Queue of running Gridlets - private LinkedList<SSGridlet> runningGridlets_; - - // Comparator to order gridlets by start time - private OrderGridletByStartTime orderStartTime_; - // a new reservation table private LinkedHashMap<Integer, SSReservation> reservTable_; // a table that contains expired reservations private LinkedHashMap<Integer, SSReservation> expiryTable_; - // The rating of one PE - private int ratingPE_; - - // a list containing the availability of PEs - private AvailabilityProfile availProfile_; - - // the resource characteristics object to be used - private TResourceCharacteristics resource_; - // default booking/reservation commit period private int commitPeriod_; // internal event tags used by this gridlet // a tag to denote expiry time private final int EXPIRY_TIME = 12; - - // a tag to indicate that a reservation has to start - private final int START_RESERVATION = 13; - - // a tag to indicate that a reservation has to finish - private final int FINISH_RESERVATION = 14; - - // a tag to indicate that a gridlet has finished - private static final int GRIDLET_FINISHED = 10; - - // Some variables to prevent the policy from iterating - // the lists unnecessarily - // the last time when the schedule update was called - private double lastScheduleUpdate_; - // last time the expiration of reservations was checked private double lastCheckExpiryTime_; @@ -243,42 +185,10 @@ * Handles internal events that are received by this entity. */ public void body() { - - // get the resource characteristics object to be used - resource_ = getTResourceCharacteristics(); - - // Gets the information on number of PEs and rating - // of one PE assuming that the machines are homogeneous - ratingPE_ = resource_.getMIPSRatingOfOnePE(); - - // a loop that is looking for internal events only - // This loop does not stop when the policy receives an - // end of simulation event because it needs to handle - // all the internal events before it finishes its - // execution. This is important particularly for the - // graphical user interface to show the completion of - // advance reservations - Sim_event ev = new Sim_event(); - while ( Sim_system.running() ) { - super.sim_get_next(ev); - processEvent(ev); - } - - // CHECK for ANY INTERNAL EVENTS WAITING TO BE PROCESSED - while (super.sim_waiting() > 0) { - // wait for event and ignore since it is likely to be related to - // internal event scheduled to update Gridlets processing - super.sim_get_next(ev); - System.out.println(super.get_name() + - ".body(): ignore internal events"); - } - - queuedGridlets_.clear(); - runningGridlets_.clear(); - orderStartTime_ = null; + super.body(); reservTable_.clear(); - expiryTable_.clear(); - availProfile_.clear(); + expiryTable_.clear(); + lastCheckExpiryTime_ = 0.0D; } //---------------- RESERVATION RELATED PUBLIC METHODS --------------------- @@ -323,7 +233,7 @@ reservation.setStatus(Reservation.STATUS_FAILED); response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); - super.sendARMessage(response); + sendARMessage(response); return; } @@ -436,7 +346,8 @@ // committed and sends an internal event to start the reservation if(currentTime == startTime) { sRes.setStatus(Reservation.STATUS_COMMITTED); - super.sendInternalEvent(GridSimTags.SCHEDULE_NOW, START_RESERVATION); + super.sendInternalEvent(GridSimTags.SCHEDULE_NOW, + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); } else { sRes.setStatus(Reservation.STATUS_NOT_COMMITTED); @@ -447,7 +358,7 @@ // add the reservation into the reservation table and sends the // response message to the requester reservTable_.put(new Integer(sRes.getID()), sRes); - super.sendARMessage(response); + sendARMessage(response); // then send this into itself to check for expired reservations super.sendInternalEvent(expTime - currentTime, @@ -469,7 +380,7 @@ reservation.setStatus(Reservation.STATUS_FAILED); reservation.setReservationOptions(availability); response.setErrorCode(ARMessage.EC_OPERATION_FAILURE_BUT_OPTIONS); - super.sendARMessage(response); + sendARMessage(response); } } @@ -515,7 +426,7 @@ // an error message back to the requester if(!success) { response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); - super.sendARMessage(response); + sendARMessage(response); return; } @@ -550,7 +461,7 @@ //---------------------------------------------------------------------- // send the response message back to the requester - super.sendARMessage(response); + sendARMessage(response); } /** @@ -606,7 +517,7 @@ // sends the message back to the requester if(!success) { response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); - super.sendARMessage(response); + sendARMessage(response); return; } @@ -616,11 +527,11 @@ // then send this into itself to start the reservation super.sendInternalEvent(sRes.getStartTime() - currentTime, - START_RESERVATION); + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); } // sends the response message with no error - super.sendARMessage(response); + sendARMessage(response); //-------------- FOR DEBUGGING PURPOSES ONLY -------------- @@ -663,7 +574,7 @@ response.getReservation().setReservationOptions(availability); // Sends the response back to the user - super.sendARMessage(response); + sendARMessage(response); } /** @@ -690,7 +601,7 @@ // Just sends the message because the reply has a reference to // the reservation object, which contains the status of the reservation - super.sendARMessage(response); + sendARMessage(response); } //---------------- GRIDLET RELATED PUBLIC METHODS ------------------------ @@ -704,247 +615,42 @@ */ public void gridletSubmit(Gridlet gridlet, boolean ack) { if(!gridlet.hasReserved()) { - handleNonReservationGridlet(gridlet, ack); + super.gridletSubmit(gridlet, ack); } else { handleReservationGridlet(gridlet, ack); } } - /** - * Finds the status of a specified <tt>Gridlet</tt>. - * @param gridletId a Gridlet ID - * @param userId the user or owner's ID of this Gridlet - * @return the Gridlet status or <tt>-1</tt> if not found - * @see gridsim.Gridlet - * @pre gridletId > 0 - * @pre userId > 0 - * @post $none - */ - public int gridletStatus(int gridletId, int userId) { - SSGridlet sgl = null; - - // Look for the Gridlet in the running queue - sgl = findSSGridlet(runningGridlets_, gridletId, userId); - if (sgl != null) { - // Get the Gridlet from the execution list - return sgl.getStatus(); - } - - // Look for the gridlet in the waiting queue - sgl = findSSGridlet(queuedGridlets_, gridletId, userId); - if (sgl != null) { - // Get the Gridlet from the execution list - return sgl.getStatus(); - } - - // if not found in all lists then report the Gridlet has not found - return -1; - } - - /** - * Cancels a Gridlet running or in the waiting queue. - * This method will search the running and waiting queues. - * The User ID is important as many users might have the same - * Gridlet ID in the lists. If a Gridlet is cancelled, the - * availability profile is shifted forwards. This process ensures - * that the Gridlets will not have an expected completion time - * worse than the one initially stipulated for the Gridlet. - * This process if known as the compression of the schedule. - * For more details please look at the references provided - * at the initial part of this documentation.<br> - * <b>NOTE:</b> - * <ul> - * <li> Before cancelling a Gridlet, this method updates when - * the expected completion time of the Gridlet is. If the - * completion time is smaller than the current time, then - * the Gridlet is considered to be <tt>finished</tt>. - * Therefore the Gridlet cannot be cancelled. - * - * <li> Once a Gridlet has been cancelled, it cannot be resumed - * to execute again since this method will pass the Gridlet - * back to sender, i.e. the <tt>userId</tt>. - * - * <li> If a Gridlet cannot be found in either execution and - * paused list, then a <tt>null</tt> Gridlet will be send back - * to sender, i.e. the <tt>userId</tt>. - * - * <li> Once a Gridlet is cancelled, the availability profile - * is scanned and Gridlets are moved forwards. The entries - * in the profile incurred by each Gridlet are updated and - * the new anchor for the Gridlet is found again. This process - * is repeated for each Gridlet. This guarantees that Gridlets - * will not have a time completion worse than those initially - * provided. - * </ul> - * @param gridletId a Gridlet ID - * @param userId the user or owner's ID of this Gridlet - * @pre gridletId > 0 - * @pre userId > 0 - */ - public void gridletCancel(int gridletId, int userId) { - double currentTime = GridSim.clock(); - - // stores the gridlet if found - SSGridlet sgl = null; - boolean found = false; - - // The gridlets whose execution time is larger than - // this time onwards have to be shifted forwards - double referenceTime = currentTime; - - // Look for the Gridlet in the running queue - sgl = findSSGridlet(runningGridlets_, gridletId, userId); - if (sgl != null) { - found = true; - - // if the Gridlet's finish time is smaller than the current - // time or the status is FINISHED, it means that the Gridlet - // has finished, but has not been removed from the running - // queue yet. It will probably be done shortly, - // so just send a null to the user. - if(sgl.getStatus() == Gridlet.SUCCESS || - sgl.getFinishTime() <= currentTime){ - super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, - null, gridletId, userId); - return; // return as it is impossible to cancel the Gridlet - } - else{ - // remove from the queue before compressing the schedule - runningGridlets_.remove(sgl); - } - } - - if(!found) { - // Look for the gridlet in the waiting queue - sgl = findSSGridlet(queuedGridlets_, gridletId, userId); - if (sgl != null) { - found = true; - - // Get the Gridlet from the waiting queue and - // remove from the queue before compressing the schedule - queuedGridlets_.remove(sgl); - referenceTime = sgl.getStartTime(); - } - } - - // If the Gridlet could not be found in neither queue, then send a null - // Gridlet to the user and return because there is no need to - // compress the schedule - if(!found) { - System.out.println(super.get_name() + ".gridletCancel():" + - " Cannot find Gridlet #" + gridletId + " for User #" + userId); - super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, - null, gridletId, userId); - return; - } - - //----------------- USED FOR DEBUGGING PURPOSES ONLY ------------------- - - // If a gridlet has been cancelled, then inform the listeners - GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_CANCELLED, true, sgl); - - //---------------------------------------------------------------------- - - // remove/update entries of the gridlet in the profile - this.removeGridlet(sgl); - - // compress the schedule, that is, moves the gridlets forwards - compressSchedule(referenceTime, sgl.getStatus() == Gridlet.INEXEC); - - //------------------- USED FOR DEBUGGING PURPOSES ONLY ----------------- - - // Inform the listeners about the new schedule - GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); - - //---------------------------------------------------------------------- - - // sends the Gridlet back to user - sgl.setStatus(Gridlet.CANCELED); - sgl.finalizeGridlet(); - super.sendCancelGridlet(GridSimTags.GRIDLET_CANCEL, - sgl.getGridlet(), gridletId, userId); - } - - /** - * Moves a Gridlet from this GridResource entity to a different one. - * <b>NOTE: This operation is not supported. </b> - * @param gridletId a Gridlet ID - * @param userId the user or owner's ID of this Gridlet - * @param destId a new destination GridResource ID for this Gridlet - * @param ack an acknowledgement, i.e. <tt>true</tt> if wanted to know - * whether this operation is success or not, <tt>false</tt> - * otherwise - */ - public void gridletMove(int gridletId, int userId, - int destId, boolean ack) { - System.out.println(super.get_name() + - ".gridletMove(): not supported at the moment."); - } - - /** - * Pauses a Gridlet only if it is currently executing. - * <b>NOTE: This operation is not supported. </b> - * @param gridletId a Gridlet ID - * @param userId the user or owner's ID of this Gridlet - * @param ack an acknowledgement, i.e. <tt>true</tt> if wanted to know - * whether this operation is success or not, <tt>false</tt> - * otherwise. - */ - public void gridletPause(int gridletId, int userId, boolean ack) { - System.out.println(super.get_name() + - ".gridletPause(): not supported at the moment."); - } - - /** - * Resumes a Gridlet only in the paused list. - * <b>NOTE: This operation is not supported. </b> - * @param gridletId a Gridlet ID - * @param userId the user or owner's ID of this Gridlet - * @param ack an acknowledgement, i.e. <tt>true</tt> if wanted to know - * whether this operation is success or not, <tt>false</tt> - * otherwise - */ - public void gridletResume(int gridletId, int userId, boolean ack) { - System.out.println(super.get_name() + - ".gridletResume(): not supported at the moment."); - } - // -------------------- PRIVATE METHODS ---------------------------- /** * Process and event sent to this entity * @param ev the event to be handled */ - private void processEvent(Sim_event ev) { + public void processOtherEvent(Sim_event ev) { // handle an internal event double currentTime = GridSim.clock(); - switch(ev.get_tag()) { - // time to update the schedule, finish gridlets, - // finish reservations, start reservations and start gridlets - case GRIDLET_FINISHED: - case START_RESERVATION: - case FINISH_RESERVATION: - if(currentTime > lastScheduleUpdate_) { - updateSchedule(); - } - lastScheduleUpdate_ = currentTime; - break; + if(ev.get_src() == myId_) { + switch(ev.get_tag()) { - // checks the expiry time for a given gridlet - case EXPIRY_TIME: - if(currentTime > lastCheckExpiryTime_) { - checkExpiryTime(); - } - lastCheckExpiryTime_ = currentTime; - break; - - default: - processOtherEvent(ev); - break; - } + // checks the expiry time for a given gridlet + case EXPIRY_TIME: + if(currentTime > lastCheckExpiryTime_) { + checkExpiryTime(); + } + lastCheckExpiryTime_ = currentTime; + break; + + default: + super.processOtherEvent(ev); + break; + } + } + else + super.processOtherEvent(ev); } /** @@ -954,92 +660,13 @@ */ private void init() { // initialises local data structure - runningGridlets_ = new LinkedList<SSGridlet>(); - queuedGridlets_ = new LinkedList<SSGridlet>(); - availProfile_ = new AvailabilityProfile(); reservTable_ = new LinkedHashMap<Integer, SSReservation>(); expiryTable_ = new LinkedHashMap<Integer, SSReservation>(); - orderStartTime_ = new OrderGridletByStartTime(); - lastScheduleUpdate_ = -1; - lastCheckExpiryTime_ = -1; - ratingPE_ = 0; + lastCheckExpiryTime_ = 0.0D; } /** * Schedules a new Gridlet received by the <tt>ARTGridResource</tt> - * entity and for which no advance reservation has been made. - * @param gridlet a Gridlet object to be executed - * @param ack an acknowledgement, i.e. <tt>true</tt> if the - * user wants to know whether this operation is successful - * or not, <tt>false</tt> otherwise. - */ - private void handleNonReservationGridlet(Gridlet gridlet, boolean ack) { - int reqPE = gridlet.getNumPE(); - - try{ - // reject the Gridlet if it requires more PEs than the resource - // is able to provide - if(reqPE > super.totalPE_){ - String userName = GridSim.getEntityName( gridlet.getUserID() ); - System.out.println(super.get_name() + ".gridletSubmit(): " + - " Gridlet #" + gridlet.getGridletID() + " from " + - userName + " user requires " + gridlet.getNumPE() + " PEs."); - System.out.println("--> The resource has only " + - super.totalPE_ + " PEs."); - gridlet.setGridletStatus(Gridlet.FAILED); - super.sendFinishGridlet(gridlet); - return; - } - } - catch(Exception ex){ - System.out.println(super.get_name() + - ": Exception on submission of a Gridlet"); - } - - // Create a resource Gridlet - SSGridlet sgl = new SSGridlet(gridlet); - - //------------------ FOR DEBUGGING PURPOSES ONLY------------------------ - - GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_ARRIVED, true, sgl); - - //---------------------------------------------------------------------- - - // If there enough PEs available at the moment, then - // check if it is possible to start the gridlet immediately - boolean success = false; - int freePE = resource_.getNumFreePE(); - - if( reqPE <= freePE ){ - success = scheduleGridletImmediately(sgl); - } - - // if the job could not be scheduled immediately, then - // find the anchor point where the job can be put - if(!success){ - findAnchorPoint(sgl); - // add this Gridlet into waiting list - queuedGridlets_.add(sgl); - } - - //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- - - // Notifies the listeners that a Gridlet has been either scheduled - // to run immediately or put in the waiting queue - GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_SCHEDULED, true, sgl); - - //--------------------------------------------------------------- - - // sends back an ack if required - if (ack == true) { - super.sendAck(GridSimTags.GRIDLET_SUBMIT_ACK, true, - gridlet.getGridletID(), gridlet.getUserID() - ); - } - } - - /** - * Schedules a new Gridlet received by the <tt>ARTGridResource</tt> * entity and for which an advance reservation has been made. * @param gridlet a Gridlet object to be executed * @param ack an acknowledgement, i.e. <tt>true</tt> if the @@ -1130,13 +757,15 @@ // reservation if (sRes.getStatus() == Reservation.STATUS_NOT_COMMITTED) { sRes.setStatus(Reservation.STATUS_COMMITTED); - super.sendInternalEvent(resStartTime - currentTime, START_RESERVATION); + super.sendInternalEvent(resStartTime - currentTime, + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); } // if the reservation has already started, then update the // schedule, which will force the gridlets in the queue to // be started else if(sRes.getStatus() == Reservation.STATUS_IN_PROGRESS) { - startQueuedGridlets(); + super.sendInternalEvent(resStartTime - currentTime, + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); } } @@ -1156,113 +785,7 @@ } } - /** - * Allocates a Gridlet into free PEs, sets the Gridlet status to INEXEC, - * updates the availability profile and the ranges currently available - * @param sgl a SSGridlet object - * @return <tt>true</tt> if there is are free PE to process this Gridlet, - * <tt>false</tt> otherwise - * @pre sgl != null - * @post $none - */ - private boolean scheduleGridletImmediately(SSGridlet sgl) { - int reqPE = sgl.getNumPE(); - - // calculate the execution time of the Gridlet - double executionTime = - super.forecastExecutionTime(ratingPE_, sgl.getRemainingLength()); - - // calculates how much ahead to look into the availability profile - double currentTime = GridSim.clock() ; - // the Gridlet's expected finish time - double finishTime = currentTime + executionTime; - - // check whether there are PEs available over the time interval requested - Object[] availObj = - checkImmediatePERangesAvailability(reqPE, currentTime, executionTime); - - // if the above method returns null, it means that there are not enough - // PEs to serve the reservation or Gridlet - if(availObj == null || availObj.length < 2){ - return false; - } - - int tailIndex = ((Integer)availObj[0]).intValue(); - PERangeList selected = (PERangeList)availObj[1]; - allocateImmediatePERanges(tailIndex, selected, currentTime, finishTime); - - // add this Gridlet into execution list - runningGridlets_.add(sgl); - sgl.setStartTime(currentTime); - sgl.setFinishTime(finishTime); - - // change Gridlet status - sgl.setStatus(Gridlet.INEXEC); - - // Sets the list of ranges used by the gridlet - sgl.setPERangeList(selected); - - // then send this event to itself to update the queues after - // this gridlet's completion time - super.sendInternalEvent(executionTime, GRIDLET_FINISHED); - return true; - } - /** - * Update the information about the jobs scheduled - * @param sgl the resource gridlet - */ - private void findAnchorPoint(SSGridlet sgl){ - int reqPE = sgl.getNumPE(); - - // calculate the execution time of the Gridlet - double executionTime = - super.forecastExecutionTime(ratingPE_, sgl.getRemainingLength()); - - double startTime = -1; // keep the potential start time of the gridlet - double finishTime = -1; // store the gridlet's expected finish time - - // check whether there are PEs available over the time - // interval requested - Object[] availObj = checkPERangesAvailability(reqPE, executionTime); - - // the anchor index, the entry in the profile where the gridlet - // will be placed - int anchorIndex = (Integer)availObj[0]; - // insert index represents the position after which the entry - // corresponding to the gridlet's finish time will be placed - int tailIndex = (Integer)availObj[1]; - PERangeList selected = (PERangeList)availObj[2]; - - // a pointer to the anchor entry - AvailabilityProfileEntry anchorEntry = availProfile_.get(anchorIndex); - startTime = anchorEntry.getTime(); - finishTime = startTime + executionTime; - allocatePERanges(anchorIndex, tailIndex, selected, startTime, finishTime); - - // Set the list of ranges used by the gridlet - sgl.setPERangeList(selected); - - // change Gridlet status - sgl.setStatus(Gridlet.QUEUED); - sgl.setStartTime(startTime); - sgl.setFinishTime(finishTime); - } - - /** - * This method removes/updates all the entries of a gridlet from the profile - * and updates the ranges of current free PEs if the gridlet was in execution. - * @param gridlet the Gridlet to be removed - */ - private void removeGridlet(SSGridlet gridlet) { - // check whether the Gridlet is running - boolean isRunning = gridlet.getStatus() == Gridlet.INEXEC; - - // removes the gridlet from the profile - updateEntriesAtProfile(isRunning, gridlet); - } - - /** * This method removes/updates all the entries of a reservation from * the profile and updates the ranges of current free PEs if the * reservation was in execution. @@ -1313,161 +836,6 @@ } /** - * This method performs the compression of the schedule and - * availability profile. The method iterates the queued gridlets list. - * For each gridlet, it removes its entry from the profile and - * then tries to reinsert the gridlet in the profile. In the worst case, - * the Gridlet will be put back in the same place. This process - * compress the schedule by shifting the jobs forwards, guarantees the - * initial order of jobs given by the scheduler and makes sure that - * no job will have a worse estimate than the one initially given.<br> - * <b>NOTE:</b> - * <ul> - * <li> Optimisations can be made so it may not be required to - * scan the whole list of gridlets. However, this will be - * left for future work as this feature is not required - * for my work YET. - * <li> You are more than welcome to improve it if you want. - * However, do please let me know if come up with a better algorithm. - * <li> This algorithm can be used in case you implement - * gridlets that finish before the expected completion time. - * </ul> - * - * @param referenceTime all gridlets whose start time is larger than - * @param runImmediately <tt>true</tt> means that the gridlet cancelled - * was running, so this method will try to run the gridlets immediately. - * If not possible they are reinserted in the queue with the new start time. - * reference time have to be shifted forwards. - * @return <tt>true</tt> if the Gridlet has been removed and - * the profile has successfully been updated or <tt>false</tt> - * otherwise. - */ - private boolean compressSchedule(double referenceTime, - boolean runImmediately) { - - // iterates the waiting queue and for each gridlet, put the ranges - // used back in the profile. That is, updates the entries - Collections.sort(queuedGridlets_, orderStartTime_); - - Iterator<SSGridlet> iterQueue = queuedGridlets_.iterator(); - while(iterQueue.hasNext()) { - SSGridlet queuedSgl = iterQueue.next(); - - // if the start time of the gridlet is already smaller or equals - // to reference time, then continue. It cannot get better than this. - if(queuedSgl.getStartTime() <= referenceTime) { - continue; - } - - // if the gridlet has not reserved resources, then it can be moved - if(!queuedSgl.hasReserved()) { - - updateEntriesAtProfile(false, queuedSgl); - - // Now try to either schedule the gridlet immediately or - // find the new anchor point - boolean success = false; - if(runImmediately) { - success = scheduleGridletImmediately(queuedSgl); - } - - if(success) { - iterQueue.remove(); - } - else { - findAnchorPoint(queuedSgl); - } - } - } - return true; - } - - /** - * This method removes/updates the entries from the profile - * corresponding to a the given Gridlet or advance reservation. - * - * @param wasRunning indicates whether the gridlet or advance - * reservation was in progress. - * <tt>true</tt> indicates that it was in progress and - * <tt>false</tt> otherwise. - * @param removedItem the Gridlet or advance reservation whose entries - * have to be removed or updated - */ - private void updateEntriesAtProfile(boolean wasRunning, - ScheduleItem removedItem) { - // ranges of PEs used by the Gridlet - PERangeList allocatedRanges = removedItem.getPERangeList(); - - // the reference time used to update the entries in the profile - double startTime = removedItem.getStartTime(); - - // the entries between reference time and endTime must be updated - double endTime = removedItem.getFinishTime(); - - // if the Gridlet was running, then update the range of PEs currently - // available and set the reference time as current simulation time - if(wasRunning) { - // returns the ranges to the list of free ranges - resource_.setPEsAvailable(allocatedRanges); - } - - Iterator<AvailabilityProfileEntry> iterProfile = - availProfile_.iterator(); - - while(iterProfile.hasNext()) { - AvailabilityProfileEntry entry = iterProfile.next(); - - double entryTime = entry.getTime(); - if(entryTime < startTime) { - continue; - } - else if(entryTime > endTime) { - break; - } - else{ - if(entryTime == endTime) { - // if the entry is equals to the finish time of the - // gridlet, then it means that the gridlet uses this entry - // to mark its termination. Therefore, it decreases the - // number of gridlets that rely on this entry to mark - // the finish time. If the number of gridlets is 0, it - // means that the entry can be deleted because it is - // not needed anymore - entry.decreaseGridlet(); - if(entry.getNumGridlets() == 0){ - iterProfile.remove(); - } - continue; - } - // if the entry is the gridlet's anchor point, then - // decrease the number of gridlets that rely on this - // entry to either mark their start time or completion - // time. If the number of Gridlets is 0 then, the - // entry is removed from the profile - if(entryTime == startTime) { - entry.decreaseGridlet(); - if(entry.getNumGridlets() == 0){ - iterProfile.remove(); - continue; - } - } - // returns the ranges to the list of free ranges in - // the entry, and consolidates the ranges to avoid fragments - // As the list may be null, make sure that the list will not be - // null so the released ranges can be added back to it - PERangeList listEntry = entry.getPERanges(); - if(listEntry == null){ - listEntry = new PERangeList(); - } - - listEntry.addAll(allocatedRanges.clone()); - listEntry.mergePERanges(); - entry.setPERangeList(listEntry); - } - } - } - - /** * Checks for expiry time of a given reservations in the list. * @param reservation the reservation to be checked */ @@ -1520,11 +888,6 @@ // gridlets in the queue forwards) compressSchedule(referenceTime, false); - // tries to start the Gridlets. - // TODO: I am not sure whether this is in fact needed. - // TODO: To check this later -// startQueuedGridlets(); - //---------------- USED FOR DEBUGGING PURPOSES ONLY ---------------- // If a gridlet has started execution or one has finished, @@ -1534,65 +897,8 @@ //----------------------------------------------------------------- } } - + /** - * This method is called to update the schedule. It removes completed - * gridlets and return them to the users and verifies whether there are - * gridlets in the waiting list that should start execution. It also - * removes old entries from the availability profile. - */ - private void updateSchedule() { - - int itemsFinished = 0; - double currentTime = GridSim.clock(); - int itemsStarted = 0; - - // finishes the advance reservations first - itemsFinished = finishReservation(currentTime); - - boolean reserved; - // remove all Gridlets that have already completed from - // the queue of running Gridlets - PERangeList releasedRanges = new PERangeList(); - - // iterates the list to check what has finished - Iterator<SSGridlet> iter = runningGridlets_.iterator(); - while (iter.hasNext()) { - SSGridlet gridlet = iter.next(); - reserved = gridlet.hasReserved(); - // as gridlets are removed from running queue once they finish - // time is smaller than current time, then testing the time - // is enough. There's no need to check status - if(gridlet.getFinishTime() <= currentTime) { - // Update the list of ranges released - if(!reserved) { - releasedRanges.addAll(gridlet.getPERangeList().clone()); - } - gridletFinish(gridlet, Gridlet.SUCCESS); - iter.remove(); - itemsFinished++; - } - } - resource_.setPEsAvailable(releasedRanges); - itemsStarted = startReservation(currentTime); - - // remove past entries from the availability profile - cleanAvailabilityProfile(currentTime); - - // Start the execution of Gridlets that are queued and whose - // potential start execution time is smaller than current time - itemsStarted += startQueuedGridlets(); - - //---------------- USED FOR DEBUGGING PURPOSES ONLY -------------------- - - // If a gridlet has started execution or one has finished, - // then inform the listeners - if(itemsStarted > 0 || itemsFinished > 0){ - GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); - } - } - - /** * This method is called to start a reservation and consequently update * the availability profile. * @refTime the reservations whose start time is smaller @@ -1619,7 +925,7 @@ startedReservations.add(sRes); super.sendInternalEvent(sRes.getFinishTime()-refTime, - FINISH_RESERVATION); + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); numStartedRes++; } @@ -1694,81 +1000,6 @@ return reservationFinished; } - /** - * Removes all the past entries from the availability profile that are - * older than the reference time - * @param referenceTime the time to be used as reference when removing - * past entries. - */ - private void cleanAvailabilityProfile(double referenceTime) { - // Update the availability profile - Iterator<AvailabilityProfileEntry> iterProfile = availProfile_.iterator(); - while(iterProfile.hasNext()) { - AvailabilityProfileEntry entry = iterProfile.next(); - - if(entry.getTime() <= referenceTime){ - iterProfile.remove(); - } - else{ - return; - } - } - } - - /** - * This method starts gridlets that are in the queue and - * whose start time is smaller than the reference time and updates - * the availability profile and ranges of PEs currently available accordingly - * @return the number of gridlets started - */ - private int startQueuedGridlets() { - - int gridletStarted = 0; - boolean reserved; // to indicate whether the gridlet refers to a reserv. - double currentTime = GridSim.clock(); - - // Start the execution of Gridlets that are queued and whose - // potential start execution time is smaller than reference time - PERangeList allocatedRanges = new PERangeList(); - Iterator<SSGridlet> iter = queuedGridlets_.iterator(); - while (iter.hasNext()) { - SSGridlet gridlet = iter.next(); - // check whether there is a reservation for this gridlet - reserved = gridlet.hasReserved(); - if(gridlet.getStartTime() <= currentTime) { - // Update the list of ranges allocated - if(!reserved) - allocatedRanges.addAll(gridlet.getPERangeList()); - - runningGridlets_.add(gridlet); - iter.remove(); - gridletStarted++; - - // change Gridlet status - gridlet.setStatus(Gridlet.INEXEC); - super.sendInternalEvent(gridlet.getFinishTime()-currentTime, - GRIDLET_FINISHED); - } - } - - resource_.setPEsBusy(allocatedRanges); - return gridletStarted++; - } - - /** - * Updates the Gridlet's properties, such as status once a - * Gridlet is considered finished. - * @param sgl a SSGridlet object - * @param status the Gridlet status - */ - private void gridletFinish(SSGridlet sgl, int status) { - // the order is important! Set the status first then finalise - // due to timing issues in SSGridlet class - sgl.setStatus(status); - sgl.finalizeGridlet(); - super.sendFinishGridlet( sgl.getGridlet() ); - } - /** * Selects a list of PE ranges able to provide enough PEs to handle * a reservation or a Gridlet. @@ -1856,114 +1087,6 @@ /** * Selects a list of PE ranges able to provide enough PEs - * to handle a Gridlet. - * - * @param reqPE the number of PEs - * @param duration the duration in seconds to execute the Gridlet - * @return an array[2] of Objects as follows:<br> - * array[0] the index of the anchor point<br> - * array[1] the index of the last entry before or equals to the finish time - * of the Gridlet in the availability profile<br> - * array[2] the list of PE ranges<br> - */ - private Object[] checkPERangesAvailability(int reqPE, double duration) { - - // the anchor index, the entry in the profile where - // the gridlet will be placed OR the closest entry to the - // point where the anchor of the advance reservation will be placed - int anchorIndex = -1; - - // tail index represents the position which corresponds to the closest - // entry to the gridlet's finish time OR an existing entry whose - // time is equals to the gridlet's or advance reservation's finish time - int tailIndex = -1; - - // a pointer to the last entry analysed (described above) - AvailabilityProfileEntry tailEntry = null; - - // a pointer to the anchor entry (described above) - AvailabilityProfileEntry anchorEntry = null; - - // the list of selected ranges - PERangeList intersectList = null; - - double potStartTime = -1; // keep the potential start time of the gridlet - double potFinishTime = -1; // store the gridlet's expected finish time - - intersectList = null; - int length = availProfile_.size(); - - Iterator<AvailabilityProfileEntry> iterProfile = availProfile_.iterator(); - while(iterProfile.hasNext()) { - - AvailabilityProfileEntry entry = iterProfile.next(); - - // scan the profile until an entry with enough PEs is found - if(entry.getNumPE() < reqPE) { - continue; - } - else { - - anchorEntry = entry; - anchorIndex = availProfile_.indexOf(anchorEntry); - tailEntry = entry; - - // sets the start time as the time of the entry - potStartTime = entry.getTime(); - // calculates when the finish time will be if - // the gridlet is put at this position - potFinishTime = potStartTime + duration; - - // if an entry with enough PEs is found, then scan the profile - // from that point onwards analysing the intersection of - // the ranges available in the entries until the - // gridlet expected completion time - intersectList = entry.getPERanges().clone(); - - // Look for the intersection of available ranges from - // the anchor until the end of the profile or until - // the entries are further than the expected completion time - for(int i=anchorIndex+1; i<length; i++){ - AvailabilityProfileEntry nextEntry = availProfile_.get(i); - if(nextEntry.getTime() > potFinishTime){ - break; - } - else{ - // if the finish time is equals to the entry time, so there - // is no need to check the intersection - if(nextEntry.getTime() < potFinishTime) { - intersectList = PERangeList.intersection(intersectList, - nextEntry.getPERanges()); - if(intersectList == null || intersectList.getNumPE() < reqPE) { - break; - } - } - tailEntry = nextEntry; - } - } - // If a time slot with enough PEs has been found, then stop the search - if(intersectList != null && intersectList.getNumPE() >= reqPE) { - break; - } - } - } - - if(intersectList == null || intersectList.getNumPE() < reqPE) - return null; - - anchorIndex = availProfile_.indexOf(anchorEntry); - tailIndex = availProfile_.indexOf(tailEntry); - - // creates the array with the result - Object[] result = new Object[3]; - result[0] = new Integer(anchorIndex); - result[1] = new Integer(tailIndex); - result[2] = super.selectPERangeList(reqPE, intersectList); - return result; - } - - /** - * Selects a list of PE ranges able to provide enough PEs * to handle a reservation. * * @param reqPE the number of PEs @@ -2042,7 +1165,6 @@ break; } else { - // Sep. 29, 2007 - Changed by Marcos // if the finish time is equals to the entry time, so there // is no need to check the intersection if(nextEntry.getTime() < finishTime) { @@ -2247,6 +1369,46 @@ } } + // ---------------------- PROTECTED METHODS ------------------------ + + /** + * This method is called to update the schedule. It removes completed + * gridlets and return them to the users and verifies whether there are + * gridlets in the waiting list that should start execution. It also + * removes old entries from the availability profile. + */ + protected void updateSchedule() { + + double currentTime = GridSim.clock(); + int itemsFinished = 0; + int itemsStarted = 0; + + // finishes the advance reservations first + itemsFinished = finishReservation(currentTime); + + // then finishes the Gridlets whose start time is smaller + // or equals to the current simulation time + itemsFinished += super.finishRunningGridlets(currentTime); + + // remove past entries from the availability profile + availProfile_.removePastEntries(currentTime); + + // starts the advance reservations + itemsStarted = startReservation(currentTime); + + // Start the execution of Gridlets that are queued and whose + // potential start execution time is smaller than current time + itemsStarted += super.startQueuedGridlets(currentTime); + + //---------------- USED FOR DEBUGGING PURPOSES ONLY -------------------- + + // If a gridlet has started execution or one has finished, + // then inform the listeners + if(itemsStarted > 0 || itemsFinished > 0){ + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + } + } + /** * This method returns a list that corresponds to the free time slots * in the scheduling queue managed by this scheduler or @@ -2329,4 +1491,48 @@ return list; } + + /** + * Search for a particular reservation in a data structure + * @param obj a data structure + * @param reservID a reservation ID + * @return location in the data structure; <tt>-1</tt> if not found + */ + protected int searchReservation(Collection<Reservation> obj, int reservID) { + + Reservation arObj = null; + int found = -1; // means the reservation is not in the list + + try { + // Search through the list to find the given reservation + int i = 0; + Iterator<Reservation> iter = obj.iterator(); + while ( iter.hasNext() ) { + arObj = iter.next(); + + if (arObj.getID() == reservID) { + found = i; + break; + } + i++; + } + } + catch (Exception e) { + System.out.println("ARTPolicy.findReservation(): " + + "The following error occured:" + e.getMessage()); + } + + return found; + } + + /** + * Sends a reservation message. + * @param message the message to be sent + */ + protected void sendARMessage(ARMessage message) { + // send message to the destination + super.sim_schedule(super.outputPort_, GridSimTags.SCHEDULE_NOW, + message.getMessageType(), new IO_data(message, + message.getMessageSize(), message.getDestinationID())); + } } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java 2008-02-11 06:09:53 UTC (rev 98) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java 2008-02-11 23:42:40 UTC (rev 99) @@ -68,7 +68,7 @@ */ public ARTGridResource(String name, double baud_rate, TResourceCharacteristics resource, ResourceCalendar calendar, - ARTPolicy policy) throws Exception { + TAllocPolicy policy) throws Exception { super(name, baud_rate, resource, calendar, policy); if(resource.getResourceAllocationPolicy() != TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED) { @@ -110,7 +110,7 @@ */ public ARTGridResource(String name, Link link, TResourceCharacteristics resource, ResourceCalendar calendar, - ARTPolicy policy) throws Exception { + TAllocPolicy policy) throws Exception { super(name, link, resource, calendar, policy); if(resource.getResourceAllocationPolicy() != TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED) { Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java 2008-02-11 06:09:53 UTC (rev 98) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARTPolicy.java 2008-02-11 23:42:40 UTC (rev 99) @@ -8,19 +8,12 @@ package gridsim.turbo; -import gridsim.GridSimTags; -import gridsim.IO_data; - -import java.util.Calendar; -import java.util.Collection; -import java.util.Iterator; - /** - * <tt>ARTPolicy</tt> is an abstract class that handles the internal - * <tt>ARTGridResource</tt> allocation policy related to Advanced - * Reservation functionalities. New scheduling algorithms can be added - * into a <tt>ARTGridResource</tt> entity by extending this class - * and implement the required abstract methods. + * <tt>ARTPolicy</tt> is an interface that defines the methods that an + * <tt>ARTGridResource</tt>'s needs to implement in order to have + * Advanced Reservation functionalities. New scheduling algorithms can be added + * into a <tt>ARTGridResource</tt> entity by implementing this interface + * and extending <tt>TAllocPolicy</tt>. * @author Marcos Dias de Assuncao * @since GridSim Turbo Alpha 0.1 @@ -31,48 +24,15 @@ * @see TAllocPolicy * */ -public abstract class ARTPolicy extends TAllocPolicy { +public interface ARTPolicy { /** - * Allocates a new <tt>ARTPolicy</tt> object. A child class should call this method - * during its constructor. The name of this entity (or the child class that - * inherits this class) will be <tt>"resName_entityName"</tt>. - * - * @param resourceName the GridResource entity name that will contain - * this allocation policy - * @param entityName this object entity name - * @throws Exception This happens when one of the following scenarios occur: - * <ul> - * <li> creating this entity before initialising 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 GridResource must contain one or more Machines. - * A Machine must contain one or more PEs. - * </ul> - * - * @see gridsim.GridSim#init(int, Calendar, boolean) - * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[], - * String) - * @pre resourceName != null - * @pre entityName != null - * @post $none - */ - public ARTPolicy(String resourceName, String entityName) - throws Exception { - super(resourceName, entityName); - } - - ///////////////////// ABSTRACT METHODS //////////////////////////////// - - /** * An abstract method that handles a new advanced reservation request. * @param message the advance reservation message received requesting * the reservation * @pre message != null */ - public abstract void handleCreateReservation(ARMessage message); + void handleCreateReservation(ARMessage message); /** * An abstract method that handles a modify reservation request. @@ -80,7 +40,7 @@ * the change * @pre message != null */ - public abstract void handleModifyReservation(ARMessage message); + void handleModifyReservation(ARMessage message); /** * An abstract method that handles a cancel reservation request. @@ -88,78 +48,27 @@ * the cancellation * @pre message != null */ - public abstract void handleCancelReservation(ARMessage message); + void handleCancelReservation(ARMessage message); /** * An abstract method that handles a commit reservation request. * @param message the advance reservation message received * @pre message != null */ - public abstract void handleCommitReservation(ARMessage message); + void handleCommitReservation(ARMessage message); /** * An abstract method that handles a query reservation request. * @param message the advance reservation message received * @pre message != null */ - public abstract void handleQueryReservation(ARMessage message); + void handleQueryReservation(ARMessage message); /** * An abstract method that handles a query free time request. * @param message the advance reservation message received ... [truncated message content] |
From: <mar...@us...> - 2008-02-12 05:46:22
|
Revision: 101 http://gridsim.svn.sourceforge.net/gridsim/?rev=101&view=rev Author: marcos_dias Date: 2008-02-11 21:46:26 -0800 (Mon, 11 Feb 2008) Log Message: ----------- A scheduler with multiple queues and easy backfilling is under development. Added Paths: ----------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java 2008-02-12 05:46:26 UTC (rev 101) @@ -0,0 +1,176 @@ + +package examples.workload.parallel; + +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.turbo.TResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example + */ +public class TurboExampleMultiEBQueues01 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + String fileName = args[0]; + // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf + + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode + GridSim.startGridSimulation(true); + + // Start the simulation in normal mode +// GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // this resource will use an aggressive backfilling policy (EASY) + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.EB_PARALLEL_SPACE_SHARED, + time_zone, cost); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + GridResource gridRes = null; + try { + gridRes = new GridResource(name, baud_rate, seed, + resConfig, peakLoad, offPeakLoad, holidayLoad, weekends, + holidays); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + Added: branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java 2008-02-12 05:46:26 UTC (rev 101) @@ -0,0 +1,322 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + * + */ + +package gridsim.turbo; + +import eduni.simjava.Sim_event; +import eduni.simjava.Sim_system; +import gridsim.GridSim; +import gridsim.GridSimTags; +import gridsim.Gridlet; +import gridsim.gui.AllocationAction; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Iterator; +import java.util.LinkedList; + +/** + * Under development... + * + * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see gridsim.GridSim + * @see gridsim.ResourceCharacteristics + * @see gridsim.turbo.TAllocPolicy + * @see gridsim.turbo.CBParallelSpaceShared + * @see gridsim.turbo.PERange + * @see gridsim.turbo.PERangeList + */ + +public class MultipleEasyBackfillingQueues extends TAllocPolicy { + + // Queue of running Gridlets + protected LinkedList<SSGridlet> runningGridlets_; + + // The queues used by this scheduler + protected ArrayList<EasyBackfillingQueue> queues_; + + // The rating of one PE + protected int ratingPE_; + + // the resource characteristics object to be used + protected TResourceCharacteristics resource_; + + // the last time when the schedule updated was called + private double lastScheduleUpdate_; + + // a tag to indicate that a gridlet has finished + private static final int UPDATE_SCHEDULE_TAG = 10; + + // a constant that denotes an unknown value + private static final int UNKNOWN = -1; + + /** + * Allocates a new <tt>EBParallelSpaceShared</tt> object + * + * @param resourceName the <tt>GridResource</tt> entity name that will + * contain this allocation policy + * @param entityName this object entity name + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> Creating this entity before initialising GridSim package + * <li> The entity name is <tt>null</tt> or empty + * <li> The entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs, which means that the Gridlets cannot be processed. + * A GridResource 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) + */ + public MultipleEasyBackfillingQueues(String resourceName, + String entityName) throws Exception{ + super(resourceName, entityName); + + // initialises local data structure + runningGridlets_ = new LinkedList<SSGridlet>(); + lastScheduleUpdate_ = 0.0D; + ratingPE_ = 0; + } + + /** + * Handles internal events that come to this entity. + */ + public void body() { + + // get the resource characteristics object to be used + resource_ = getTResourceCharacteristics(); + + // Gets the information on number of PEs and rating + // of one PE assuming that the machines are homogeneous + ratingPE_ = resource_.getMIPSRatingOfOnePE(); + + // a loop that is looking for internal events only + 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 || + super.isEndSimulation() == true) { + break; + } + + processEvent(ev); + } + + // CHECK for ANY INTERNAL EVENTS WAITING TO BE PROCESSED + while (super.sim_waiting() > 0) { + // wait for event and ignore since it is likely to be related to + // internal event scheduled to update Gridlets processing + super.sim_get_next(ev); + System.out.println(super.get_name() + ".body(): ignore internal events"); + } + + // reset variables to default values + runningGridlets_.clear(); + lastScheduleUpdate_ = 0.0D; + ratingPE_ = 0; + resource_.resetFreePERanges(); + } + + /** + * Schedules/adds to the queue a new <tt>Gridlet</tt> received by the + * <tt>GridResource</tt> entity. + * @param gridlet a Gridlet object to be executed + * @param ack an acknowledgement, i.e. <tt>true</tt> if the + * user wants to know whether this operation is successful + * or not, <tt>false</tt> otherwise. + */ + public void gridletSubmit(Gridlet gridlet, boolean ack) { + int reqPE = gridlet.getNumPE(); + + try{ + // reject the Gridlet if it requires more PEs than the resource + // is able to provide + if(reqPE > super.totalPE_){ + String userName = GridSim.getEntityName( gridlet.getUserID() ); + System.out.println(super.get_name() + ".gridletSubmit(): " + + " Gridlet #" + gridlet.getGridletID() + " from " + + userName + " user requires " + gridlet.getNumPE() + " PEs."); + System.out.println("--> The resource has only " + + super.totalPE_ + " PEs."); + gridlet.setGridletStatus(Gridlet.FAILED); + super.sendFinishGridlet(gridlet); + return; + } + } + catch(Exception ex){ + System.out.println(super.get_name() + + ": Exception on submission of a Gridlet"); + } + + // Create a resource Gridlet + SSGridlet sgl = new SSGridlet(gridlet); + + //-------------- FOR DEBUGGING PURPOSES ONLY -------------- + + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_ARRIVED, true, sgl); + + } + + /** + * Finds the status of a specified <tt>Gridlet</tt>. + * @param gridletId a Gridlet ID + * @param userId the user or owner's ID of this Gridlet + * @return the Gridlet status or <tt>-1</tt> if not found + * @see gridsim.Gridlet + * @pre gridletId > 0 + * @pre userId > 0 + * @post $none + */ + public int gridletStatus(int gridletId,int userId){ + return UNKNOWN; + } + + /** + * Cancels a Gridlet running or in the waiting queue.<br> + * <b>NOTE: Not implemented YET.</b> + * @param gridletId a Gridlet ID + * @param userId the user or owner's ID of this Gridlet + * @pre gridletId > 0 + * @pre userId > 0 + */ + public void gridletCancel(int gridletId, int userId) { + System.out.println(super.get_name() + + ".gridletCancel(): not supported at the moment."); + } + + /** + * Pauses a <tt>Gridlet</tt> only if it is currently executing. + * <b>NOTE: This operation is not supported. </b> + * @param gridletId a Gridlet ID + * @param userId the user or owner's ID of this Gridlet + * @param ack an acknowledgement, i.e. <tt>true</tt> if wanted to know + * whether this operation is success or not, <tt>false</tt> + * otherwise. + */ + public void gridletPause(int gridletId, int userId, boolean ack){ + System.out.println(super.get_name() + + ".gridletMove(): not supported at the moment."); + } + + /** + * Moves a Gridlet from this GridResource entity to a different one. + * <b>NOTE: This operation is not supported. </b> + * @param gridletId a Gridlet ID + * @param userId the user or owner's ID of this Gridlet + * @param destId a new destination GridResource ID for this Gridlet + * @param ack an acknowledgement, i.e. <tt>true</tt> if wanted to know + * whether this operation is success or not, <tt>false</tt> + * otherwise + */ + public void gridletMove(int gridletId, int userId, int destId, boolean ack){ + System.out.println(super.get_name() + + ".gridletPause(): not supported at the moment."); + } + + /** + * Resumes a Gridlet only in the paused list. + * <b>NOTE: This operation is not supported. </b> + * @param gridletId a Gridlet ID + * @param userId the user or owner's ID of this Gridlet + * @param ack an acknowledgement, i.e. <tt>true</tt> if wanted to know + * whether this operation is success or not, <tt>false</tt> + * otherwise + */ + public void gridletResume(int gridletId, int userId, boolean ack){ + System.out.println(super.get_name() + + ".gridletResume(): not supported at the moment."); + } + + // -------------------- PRIVATE METHODS ---------------------------- + + /** + * Process and event sent to this entity + * @param ev the event to be handled + */ + private void processEvent(Sim_event ev) { + + // handle an internal event + double currentTime = GridSim.clock(); + + // Internal Event if the event source is this entity + if(ev.get_src() == myId_) { + // time to update the schedule, finish gridlets, + // finish reservations, start reservations and start gridlets + if (ev.get_tag() == UPDATE_SCHEDULE_TAG) { + if(currentTime > lastScheduleUpdate_) { + updateSchedule(); + } + lastScheduleUpdate_ = currentTime; + } + else + processOtherEvent(ev); + } + else + processOtherEvent(ev); + } + + /** + * This method is called to update the schedule. It removes completed + * gridlets and return them to the users and verifies whether the first gridlet + * in the waiting queue can be started. If it cannot be started, them + * tries to backfill with jobs waiting in the queue. The method also + * removes old entries from the availability profile. + */ + private void updateSchedule(){ + + + } + + static class EasyBackfillingQueue { + + int queueId_ = UNKNOWN; + + // initial number of PEs assigned to this queue + int initialNumPE_ = 0; + + // Queue of Gridlets waiting in this queue + LinkedList<SSGridlet> queuedGridlets_; + + // the time when the first job in the waiting queue can + // start its execution + double shadowTime_ = Double.MAX_VALUE; + + // the list of PEs left unused when the first job in the waiting + // queue is scheduled + PERangeList extraPEs_ = null; + + // a list containing the availability of PEs + AvailabilityProfile availProfile_; + + // The list of PEs available at the current simulation time + PERangeList freePERanges_ = null; + + + + } + + /** + * Updates the Gridlet's properties, such as status once a + * Gridlet is considered finished. + * @param sgl a SSGridlet object + * @param status the Gridlet status + */ + private void gridletFinish(SSGridlet sgl, int status) { + // the order is important! Set the status first then finalise + // due to timing issues in SSGridlet class + sgl.setStatus(status); + sgl.finalizeGridlet(); + super.sendFinishGridlet( sgl.getGridlet() ); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-02-14 12:00:17
|
Revision: 102 http://gridsim.svn.sourceforge.net/gridsim/?rev=102&view=rev Author: marcos_dias Date: 2008-02-14 04:00:22 -0800 (Thu, 14 Feb 2008) Log Message: ----------- This update includes a bug fix in the easy backfilling policy and a preliminary version of a multiple queue backfilling policy. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java branches/gridsim4.0-branch3/source/gridsim/GridResource.java branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java branches/gridsim4.0-branch3/source/gridsim/turbo/PERangeList.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/turbo/TAllocPolicy.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java Added Paths: ----------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePredicate.java Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java 2008-02-12 05:46:26 UTC (rev 101) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java 2008-02-14 12:00:22 UTC (rev 102) @@ -85,10 +85,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode - GridSim.startGridSimulation(true); +// GridSim.startGridSimulation(true); // Start the simulation in normal mode -// GridSim.startGridSimulation(); + GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java 2008-02-12 05:46:26 UTC (rev 101) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java 2008-02-14 12:00:22 UTC (rev 102) @@ -1,10 +1,14 @@ package examples.workload.parallel; +import gridsim.AllocPolicy; import gridsim.GridResource; import gridsim.GridSim; import gridsim.Machine; import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.ResourceCharacteristics; +import gridsim.turbo.MultipleEasyBackfillingQueues; import gridsim.turbo.TResourceCharacteristics; import gridsim.util.Workload; @@ -85,10 +89,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode - GridSim.startGridSimulation(true); +// GridSim.startGridSimulation(true); // Start the simulation in normal mode -// GridSim.startGridSimulation(); + GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over @@ -143,6 +147,13 @@ TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.EB_PARALLEL_SPACE_SHARED, time_zone, cost); + + MultipleEasyBackfillingQueues policy = null; + try { + policy = new MultipleEasyBackfillingQueues(name, "Policy", 1); + } catch (Exception e1) { + e1.printStackTrace(); + } ////////////////////////////////////////// // 6. Finally, we need to create a GridResource object. @@ -160,10 +171,14 @@ // incorporates holidays. However, no holidays are set in this example LinkedList holidays = new LinkedList(); GridResource gridRes = null; + + ResourceCalendar resCalendar = new ResourceCalendar(time_zone, + peakLoad, offPeakLoad, holidayLoad, weekends, + holidays, seed); + try { - gridRes = new GridResource(name, baud_rate, seed, - resConfig, peakLoad, offPeakLoad, holidayLoad, weekends, - holidays); + gridRes = new GridResource(name, baud_rate, resConfig, + resCalendar, policy); } catch (Exception e) { e.printStackTrace(); Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java 2008-02-14 12:00:22 UTC (rev 102) @@ -0,0 +1,247 @@ + +package examples.workload.parallel; + +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.turbo.MultipleEasyBackfillingQueues; +import gridsim.turbo.QueuePredicate; +import gridsim.turbo.SSGridlet; +import gridsim.turbo.TResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example + */ +public class TurboExampleMultiEBQueues02 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + String fileName = args[0]; + // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf + + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode + GridSim.startGridSimulation(true); + + // Start the simulation in normal mode +// GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // this resource will use an aggressive backfilling policy (EASY) + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.EB_PARALLEL_SPACE_SHARED, + time_zone, cost); + + MultipleEasyBackfillingQueues policy = null; + try { + policy = new MultipleEasyBackfillingQueues(name, "Policy", 2); + } catch (Exception e1) { + e1.printStackTrace(); + } + + // creates two partitions, one for small jobs and another for long jobs + // assign the same number of PEs to both + QueuePredicateExample pred1 = new QueuePredicateExample(0, 10000, peRating); + QueuePredicateExample pred2 = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + + policy.createQueue(0, resConfig.getNumPE() / 2, pred1); + policy.createQueue(1, resConfig.getNumPE() / 2, pred2); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + GridResource gridRes = null; + + ResourceCalendar resCalendar = new ResourceCalendar(time_zone, + peakLoad, offPeakLoad, holidayLoad, weekends, + holidays, seed); + + try { + gridRes = new GridResource(name, baud_rate, resConfig, + resCalendar, policy); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + +class QueuePredicateExample implements QueuePredicate { + int minRuntime_; + int maxRuntime_; + int resRating_; + + /* + * Default constructor + */ + public QueuePredicateExample(int minRuntime, + int maxRuntime, int rating) { + this.minRuntime_ = minRuntime; + this.maxRuntime_ = maxRuntime; + this.resRating_ = rating; + } + + /* + * (non-Javadoc) + * @see gridsim.turbo.QueuePredicate#match(gridsim.turbo.SSGridlet) + */ + public boolean match(SSGridlet gridlet) { + double runtime = forecastExecutionTime(gridlet); + if(runtime < minRuntime_ || runtime >= maxRuntime_) + return false; + + return true; + } + + /* + * Forecast execution time of a Gridlet. + * <tt>execution time = length / available rating</tt> + * @param gridlet the gridlet to be considered + * @return Gridlet's execution time. + */ + private double forecastExecutionTime(SSGridlet gridlet) { + double executionTime = (gridlet.getLength() / resRating_); + + // This is as a safeguard since the finish time can be extremely + // small close to 0.0, such as 4.5474735088646414E-14. Hence causing + // some Gridlets never to be finished and consequently hang the program + if (executionTime < 1.0) { + executionTime = 1.0; + } + return executionTime; + } +} + + + Modified: branches/gridsim4.0-branch3/source/gridsim/GridResource.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/GridResource.java 2008-02-12 05:46:26 UTC (rev 101) +++ branches/gridsim4.0-branch3/source/gridsim/GridResource.java 2008-02-14 12:00:22 UTC (rev 102) @@ -14,7 +14,6 @@ import gridsim.turbo.EBParallelSpaceShared; import gridsim.turbo.CBParallelSpaceShared; import gridsim.turbo.MultipleEasyBackfillingQueues; -import gridsim.turbo.TAllocPolicy; import gridsim.turbo.TResourceCharacteristics; import gridsim.index.*; @@ -646,10 +645,11 @@ case TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED: policy_ = new ARParallelSpaceShared(super.get_name(), "ARParallelSpaceShared"); break; - + + // creates the scheduler with only one queue case TResourceCharacteristics.MULTIPLE_EASY_BACKFILLING_QUEUES: policy_ = new MultipleEasyBackfillingQueues(super.get_name(), - "MultipleEasyBackfillingQueues"); + "MultipleEasyBackfillingQueues", 1); break; default: Modified: branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-02-12 05:46:26 UTC (rev 101) +++ branches/gridsim4.0-branch3/source/gridsim/gui/ResourceWindow.java 2008-02-14 12:00:22 UTC (rev 102) @@ -694,7 +694,7 @@ for(int i=0; i<size; i++) { ScheduleItem item = (ScheduleItem)scheduledItems_.get(i); - if(item == null) + if(item == null || item.getStartTime() < 0) continue; int itemId = item.getID(); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2008-02-12 05:46:26 UTC (rev 101) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2008-02-14 12:00:22 UTC (rev 102) @@ -70,19 +70,25 @@ * entries whose date is smaller or equals to refTime will * be removed. * @param refTime the reference time to be used for entry removal. + * @return the last entry removed or <tt>null</tt> if no entry + * has been removed. */ - public void removePastEntries(double refTime) { + public AvailabilityProfileEntry removePastEntries(double refTime) { + AvailabilityProfileEntry lastRemoved = null; // Update the availability profile Iterator<AvailabilityProfileEntry> iterProfile = super.iterator(); while(iterProfile.hasNext()) { AvailabilityProfileEntry entry = iterProfile.next(); if(entry.getTime() <= refTime){ + lastRemoved = entry; iterProfile.remove(); } else{ break; } } + + return lastRemoved; } /** Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-02-12 05:46:26 UTC (rev 101) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-02-14 12:00:22 UTC (rev 102) @@ -239,7 +239,7 @@ // If there are no jobs in the queue list, then check if // there are enough PEs to process the job immediately boolean success = false; - int freePE = super.resource_.getNumFreePE(); + int freePE = resource_.getNumFreePE(); if( reqPE <= freePE ){ success = startGridlet(sgl); @@ -908,7 +908,6 @@ break; } else { - // Sep. 29, 2007 - Changed by Marcos // if the finish time is equals to the entry time, so there // is no need to check the intersection if(entryTime < finishTime) { @@ -1116,7 +1115,7 @@ * start time or the place where the new anchor (if needed) will be placed * @param tailIndex the index of the entry closest to the finish time but * whose time is smaller or equals to the finish time - * @param selected the lsit of PE ranges selected + * @param selected the list of PE ranges selected * @param startTime the start time of the Gridlet * @param finishTime the finish time of the Gridlet */ Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java 2008-02-12 05:46:26 UTC (rev 101) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java 2008-02-14 12:00:22 UTC (rev 102) @@ -37,8 +37,7 @@ * with Backfilling. IEEE Transactions on Parallel and Distributed * Systems, 12:(6), pp. 529-543, 2001. * </ul> - * - * This policy maintains an availability profile. The availability + * <br> This policy maintains an availability profile. The availability * profile contains information about the ranges of processing elements * (PEs) that will be released when the running jobs complete. * In addition, the policy maintains the list of extra nodes, that is, the nodes @@ -54,9 +53,7 @@ * simulate this, you have to model the local load as gridlets. * It is more precise and faster. To do so, please check * {@link Lublin99Workload}. - * <li> Gridlets cannot be paused nor migrated. This could be - * easily done, but due to time constraints, I could not - * implement these features. + * <li> Gridlets cannot be paused nor migrated. * </ul> * * @author Marcos Dias de Assuncao @@ -71,10 +68,12 @@ */ public class EBParallelSpaceShared extends TAllocPolicy { - // Queue of waiting Gridlets protected LinkedList<SSGridlet> queuedGridlets_; + // Pivot job (i.e. the first job in the queue) + private SSGridlet pivot_; + // Queue of running Gridlets protected LinkedList<SSGridlet> runningGridlets_; @@ -97,9 +96,6 @@ // queue is scheduled private PERangeList extraPEs_; - // used only to set the extraPEs_ back to the default value - private PERangeList allPEs_; - // a tag to indicate that a gridlet has finished private static final int UPDATE_SCHEDULE_TAG = 10; @@ -133,7 +129,9 @@ availProfile_ = new AvailabilityProfile(); lastScheduleUpdate_ = 0.0D; shadowTime_ = Double.MAX_VALUE; + extraPEs_ = null; ratingPE_ = 0; + pivot_ = null; } /** @@ -148,10 +146,6 @@ // of one PE assuming that the machines are homogeneous ratingPE_ = resource_.getMIPSRatingOfOnePE(); - // the extra PEs to start are the same that are free - extraPEs_ = resource_.getFreePERanges().clone(); - allPEs_ = extraPEs_.clone(); - // a loop that is looking for internal events only Sim_event ev = new Sim_event(); while ( Sim_system.running() ) { @@ -180,10 +174,8 @@ availProfile_.clear(); lastScheduleUpdate_ = 0.0D; shadowTime_ = Double.MAX_VALUE; - ratingPE_ = 0; + extraPEs_ = null; resource_.resetFreePERanges(); - extraPEs_ = resource_.getFreePERanges().clone(); - allPEs_ = extraPEs_.clone(); } /** @@ -233,21 +225,13 @@ if( reqPE <= freePE ) { success = startGridlet(sgl); - - //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- - - // Notifies the listeners that a Gridlet has been either scheduled - // to run immediately or put in the waiting queue - GridSim.notifyListeners(this.get_id(), - AllocationAction.ITEM_SCHEDULED, true, sgl); - - //--------------------------------------------------------------- } // if the job could not be scheduled immediately, then // it has to be put in the waiting queue if(!success) { - enqueueGridlet(sgl); + scheduleGridlet(sgl); + queuedGridlets_.add(sgl); } // sends back an ack if required @@ -396,8 +380,7 @@ private boolean startGridlet(SSGridlet sgl) { int reqPE = sgl.getNumPE(); - if(resource_.getFreePERanges() == null || - resource_.getFreePERanges().getNumPE() < reqPE) { + if(resource_.getNumFreePE() < reqPE) { return false; } @@ -419,72 +402,23 @@ // time is equals to the gridlet's or advance reservation's finish time int tailIndex = -1; - // if there are no jobs in the queue or in execution - if(availProfile_.size() == 0 && shadowTime_ == Double.MAX_VALUE) { - selected = super.selectPERangeList(reqPE, resource_.getFreePERanges()); - } - else { - // a pointer to the last entry analysed - AvailabilityProfileEntry tailEntry = null; - - // the list of selected ranges - PERangeList intersectList = null; - - // For immediate gridlets the start point - // is the current list of PEs available - intersectList = resource_.getFreePERanges().clone(); - - // scan the availability profile until the expected termination - // of the Gridlet to check whether enough PEs will be available - // for the Gridlet. Stop the search if not enough PEs are available - for(AvailabilityProfileEntry entry : availProfile_) { - double entryTime = entry.getTime(); - if(entryTime < currentTime) { - continue; - } - else if(entryTime > finishTime) { - break; - } - else { - tailEntry = entry; - // if the finish time is equals to the entry time, so there - // is no need to check the intersection - if(entryTime < finishTime) { - PERangeList listEntry = entry.getPERanges(); - intersectList = PERangeList.intersection(listEntry, intersectList); - if(intersectList == null || intersectList.getNumPE() < reqPE) - break; - } - } - tailIndex = availProfile_.indexOf(tailEntry); - } + PERangeList intersect = resource_.getFreePERanges(); + + if(finishTime > shadowTime_) + intersect = PERangeList.intersection(intersect, extraPEs_); + + selected = super.selectPERangeList(reqPE, intersect); + if(selected == null || selected.getNumPE() < reqPE) + return false; - // return false if the number of PEs available over the required - // time interval is smaller than what the Gridlet requires - if(intersectList == null || intersectList.getNumPE() < reqPE) { - return false; - } - else { - // the job has to finish before the shadow time or has - // to use less PEs than the extra nodes - if(finishTime < shadowTime_) { - selected = super.selectPERangeList(reqPE, intersectList); - } - else { - intersectList = PERangeList.intersection(intersectList, extraPEs_); - if(intersectList == null || intersectList.getNumPE() < reqPE) { - return false; - } - else { - selected = super.selectPERangeList(reqPE, intersectList); - extraPEs_ = PERangeList.difference(extraPEs_, selected); - } - } - } - } + // a pointer to the last entry analysed + AvailabilityProfileEntry tailEntry = + availProfile_.getPrecedingEntry(finishTime); + + tailIndex = tailEntry == null ? -1 : availProfile_.indexOf(tailEntry); // allocate the ranges of PEs to the gridlet - allocatePERanges(tailIndex, selected, currentTime, finishTime); + allocatePERanges(tailIndex, selected, finishTime); // add this Gridlet into execution list runningGridlets_.add(sgl); @@ -500,29 +434,36 @@ // then send this event to itself to update the queues after // this gridlet's completion time super.sendInternalEvent(executionTime, UPDATE_SCHEDULE_TAG); + + //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- + + // Notifies the listeners that a Gridlet has been either scheduled + // to run immediately or put in the waiting queue + GridSim.notifyListeners(this.get_id(), + AllocationAction.ITEM_SCHEDULED, true, sgl); + + //--------------------------------------------------------------- + return true; } /** - * Enqueues a gridlet. That is, put the gridlet into the - * queue of waiting gridlets. If the gridlet is the first into the queue, - * then updates the extra nodes and the shadow time. The shadow time will + * Tries to schedule a gridlet. That is, make the gridlet the pivot, + * or the first gridlet in the queue. If that is not possible, then return + * false. If the gridlet is the first into the queue, then updates the + * pivot, extra nodes and the shadow time. The shadow time will * be the start time of the gridlet whereas the extra PEs will be the * PEs left unused when the gridlet starts execution. * @param sgl the resource gridlet + * @return <tt>true</tt> if scheduled; <tt>false</tt> otherwise. */ - private void enqueueGridlet(SSGridlet sgl) { + private boolean scheduleGridlet(SSGridlet sgl) { int reqPE = sgl.getNumPE(); // if there are gridlets waiting execution already, then simply // insert this gridlet into the queue and return - if(queuedGridlets_.size() > 0) { - queuedGridlets_.add(sgl); - return; - } - - // otherwise, just add the gridlet in the queue and continue - queuedGridlets_.add(sgl); + if(pivot_ != null) + return false; // calculate the execution time of the Gridlet double executionTime = @@ -553,6 +494,7 @@ sgl.setStatus(Gridlet.QUEUED); sgl.setStartTime(startTime); sgl.setFinishTime(finishTime); + pivot_ = sgl; //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- @@ -561,6 +503,8 @@ GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_SCHEDULED, true, sgl); //--------------------------------------------------------------- + + return true; } /** @@ -568,13 +512,13 @@ * availability profile accordingly * @param tailIndex the index of the entry closest to the finish time but * whose time is smaller or equals to the finish time - * @param selected the list of PE ranges selected - * @param startTime the start time of the Gridlet + * @param selected the list of PE ranges selected * @param finishTime the finish time of the Gridlet */ private void allocatePERanges(int tailIndex, - PERangeList selected, double startTime, double finishTime) { + PERangeList selected, double finishTime) { + double startTime = GridSim.clock(); AvailabilityProfileEntry newEntryAfterTail = null; // if the time of the entry at (tailIndex) is equals to @@ -616,7 +560,7 @@ // Update entries of the profile for(int index=0; index<=updTo; index++) { AvailabilityProfileEntry entry = availProfile_.get(index); - if(entry.getTime() < startTime){ + if(entry.getTime() < startTime) { continue; } PERangeList uptList = @@ -630,6 +574,10 @@ // subtract the selected ranges from the currently free ranges resource_.setPEsBusy(selected); + + if(finishTime > shadowTime_) + extraPEs_ = PERangeList.difference(extraPEs_, selected); + } /** @@ -642,102 +590,41 @@ * array[1] the list of PE ranges available at that time<br> */ private Object[] findStartTime(int reqPE, double duration) { - - // the anchor index, the entry in the profile where - // the gridlet will be placed OR the closest entry to the - // point where the anchor of the advance reservation will be placed - int anchorIndex = -1; - - // a pointer to the anchor entry (described above) - AvailabilityProfileEntry anchorEntry = null; - - // the list of selected ranges - PERangeList intersectList = null; - - double potStartTime = -1; // keep the potential start time of the gridlet - double potFinishTime = -1; // store the gridlet's expected finish time - - intersectList = null; - int length = availProfile_.size(); + PERangeList availRanges = null; // list of ranges available for the job + double startTime = -1; // the job's potential start time Iterator<AvailabilityProfileEntry> iterProfile = availProfile_.iterator(); while(iterProfile.hasNext()) { - - AvailabilityProfileEntry entry = iterProfile.next(); + AvailabilityProfileEntry entry = iterProfile.next(); // scan the profile until an entry with enough PEs is found if(entry.getNumPE() < reqPE) { continue; } else { - - anchorEntry = entry; - anchorIndex = availProfile_.indexOf(anchorEntry); - - // sets the start time as the time of the entry - potStartTime = entry.getTime(); - // calculates when the finish time will be if - // the gridlet is put at this position - potFinishTime = potStartTime + duration; - - // if an entry with enough PEs is found, then scan the profile - // from that point onwards analysing the intersection of - // the ranges available in the entries until the - // gridlet expected completion time - intersectList = entry.getPERanges().clone(); - - // Look for the intersection of available ranges from - // the anchor until the end of the profile or until - // the entries are further than the expected completion time - for(int i=anchorIndex+1; i<length; i++){ - AvailabilityProfileEntry nextEntry = availProfile_.get(i); - if(nextEntry.getTime() > potFinishTime){ - break; - } - else { - // if the finish time is equals to the entry time, so there - // is no need to check the intersection - if(nextEntry.getTime() < potFinishTime) { - intersectList = PERangeList.intersection(intersectList, - nextEntry.getPERanges()); - if(intersectList == null || intersectList.getNumPE() < reqPE) { - break; - } - } - } - } - // If a time slot with enough PEs has been found, then stop the search - if(intersectList != null && intersectList.getNumPE() >= reqPE) { - break; - } + // sets the start time as the time of the entry + startTime = entry.getTime(); + availRanges = entry.getPERanges().clone(); + break; } } // creates the array with the result Object[] result = new Object[3]; - result[0] = new Double(anchorEntry.getTime()); - result[1] = intersectList; + result[0] = new Double(startTime); + result[1] = availRanges; return result; } - /** - * This method is called to update the schedule. It removes completed - * gridlets and return them to the users and verifies whether the first gridlet - * in the waiting queue can be started. If it cannot be started, them - * tries to backfill with jobs waiting in the queue. The method also - * removes old entries from the availability profile. + /** + * This method finalises the gridlets in execution whose time + * is smaller or equals to the current simulation time. + * @param currentTime the current simulation time + * @return the number of gridlets completed */ - private void updateSchedule(){ + protected int finishRunningGridlets(double currentTime) { + int itemsFinished = 0; - double currentTime = GridSim.clock(); - int gridletFinished = 0; - int gridletStarted = 0; - - // removes all Gridlets that have already completed from - // the queue of running Gridlets - PERangeList releasedRanges = new PERangeList(); - LinkedList<SSGridlet> grlsCompleted = new LinkedList<SSGridlet>(); - // iterates the list to check what has finished Iterator<SSGridlet> iter = runningGridlets_.iterator(); while (iter.hasNext()) { @@ -747,92 +634,86 @@ // is enough. There's no need to check status if(gridlet.getFinishTime() <= currentTime) { // Update the list of ranges released - releasedRanges.addAll(gridlet.getPERangeList().clone()); - grlsCompleted.add(gridlet); gridletFinish(gridlet, Gridlet.SUCCESS); iter.remove(); - gridletFinished++; - } - } + itemsFinished++; + } + } + return itemsFinished; + } + + /** + * This method is called to update the schedule. It removes completed + * gridlets and return them to the users and verifies whether the first gridlet + * in the waiting queue can be started. If it cannot be started, them + * tries to backfill with jobs waiting in the queue. The method also + * removes old entries from the availability profile. + */ + private void updateSchedule() { + int itemsFinished = 0; + double currentTime = GridSim.clock(); + int itemsStarted = 0; - // returns ranges of PEs to the list of PEs available - resource_.setPEsAvailable(releasedRanges); + itemsFinished = finishRunningGridlets(currentTime); - // Updates the availability profile - Iterator<AvailabilityProfileEntry> iterProfile = availProfile_.iterator(); - while(iterProfile.hasNext()) { - AvailabilityProfileEntry entry = iterProfile.next(); - if(entry.getTime() <= currentTime){ - iterProfile.remove(); - } + // remove past entries from the availability profile + AvailabilityProfileEntry currentStatus = availProfile_.removePastEntries(currentTime); + if(currentStatus != null) { + resource_.resetFreePERanges(currentStatus.getPERanges()); } + + itemsStarted = startQueuedGridlets(currentTime); - // if at least a gridlet has finished, then we should iterate the - // waiting queue. We need to try to start the first gridlet in the queue. - // If it cannot be started, then we should backfill with the remaining - // gridlets in the queue. - if(gridletFinished > 0) { - if(queuedGridlets_.size() > 0) { - - // This is a tricky approach. We decided to clone the waiting - // queue, try to start the first job, and then enqueue all - // jobs again, including the first job if it cannot be started - LinkedList<SSGridlet> clonedQueue = - (LinkedList<SSGridlet>)queuedGridlets_.clone(); - queuedGridlets_.clear(); - - //TODO: To think a better way to do this. But the idea is to - // try to start first job, then enqueue all the other jobs again. - // If the first job cannot be started, then try to start the other - // jobs (ie. backfill) or enqueue them again - SSGridlet gridlet = clonedQueue.getFirst(); - clonedQueue.removeFirst(); - - if(gridlet.getStartTime() <= currentTime) { - // if the gridlet can be started, then the extra nodes - // and the shadow time will be set back to the default values - // and will be changed when the next gridlet in the waiting queue - // is scheduled. - extraPEs_ = allPEs_.clone(); - shadowTime_ = Double.MAX_VALUE; - if (!startGridlet(gridlet)) { - // NOTE that it should NOT happen, - // but if it does, enqueue the job - enqueueGridlet(gridlet); - } - } - else { - // if the first job cannot be started, then put it back into - // the queue and backfill with other jobs. That is, try to - // start the other jobs. - queuedGridlets_.add(gridlet); - iter = clonedQueue.iterator(); - while(iter.hasNext()) { - gridlet = iter.next(); - if(startGridlet(gridlet)) - iter.remove(); - } - } - - // Add the jobs still remaining back into the waiting queue - iter = clonedQueue.iterator(); - while(iter.hasNext()) { - gridlet = iter.next(); - enqueueGridlet(gridlet); - } - } - - //---------------- USED FOR DEBUGGING PURPOSES ONLY -------------------- + //---------------- USED FOR DEBUGGING PURPOSES ONLY -------------------- - // If a gridlet has started execution or one has finished, - // then inform the listeners - if(gridletStarted > 0 || gridletFinished > 0){ - GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_COMPLETED, - true, grlsCompleted); - } + // If a gridlet has started execution or one has finished, + // then inform the listeners + if(itemsStarted > 0 || itemsFinished > 0) { + GridSim.notifyListeners(this.get_id(), + AllocationAction.SCHEDULE_CHANGED, true); + } - //---------------------------------------------------------------------- + //---------------------------------------------------------------------- + } + + /** + * This method starts gridlets that are in the queue and + * whose start time is smaller than the reference time and updates + * the availability accordingly + * @param currentTime the current simulation time + * @return the number of gridlets started + */ + protected int startQueuedGridlets(double currentTime) { + int gridletStarted = 0; + + // first checks the pivot first + if(pivot_ != null) { + if(pivot_.getStartTime() <= currentTime) { + shadowTime_ = Double.MAX_VALUE; + startGridlet(pivot_); + gridletStarted++; + queuedGridlets_.remove(pivot_); + pivot_ = null; + } } + + // Start the execution of Gridlets that are queued + Iterator<SSGridlet> iter = queuedGridlets_.iterator(); + while (iter.hasNext()) { + SSGridlet gridlet = iter.next(); + boolean success = startGridlet(gridlet); + + // if the job could not be scheduled immediately, then enqueue it + if(success) { + iter.remove(); + gridletStarted++; + } + else if (pivot_ == null) { // if there is not a pivot already + scheduleGridlet(gridlet); + } + } + + return gridletStarted; } /** Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java 2008-02-12 05:46:26 UTC (rev 101) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java 2008-02-14 12:00:22 UTC (rev 102) @@ -13,10 +13,12 @@ import gridsim.GridSim; import gridsim.GridSimTags; import gridsim.Gridlet; +import gridsim.ParameterException; import gridsim.gui.AllocationAction; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; @@ -37,17 +39,23 @@ public class MultipleEasyBackfillingQueues extends TAllocPolicy { // Queue of running Gridlets - protected LinkedList<SSGridlet> runningGridlets_; + protected LinkedList<MQGridlet> runningGridlets_; + + // Queue of Gridlets waiting in this queue + protected LinkedList<MQGridlet> queuedGridlets_; - // The queues used by this scheduler - protected ArrayList<EasyBackfillingQueue> queues_; - // The rating of one PE protected int ratingPE_; // the resource characteristics object to be used - protected TResourceCharacteristics resource_; + protected TResourceCharacteristics resource_; + // The availability profile + protected Profile profile_; + + // the number of queues in this scheduler + private int numQueues_; + // the last time when the schedule updated was called private double lastScheduleUpdate_; @@ -56,13 +64,14 @@ // a constant that denotes an unknown value private static final int UNKNOWN = -1; - + /** * Allocates a new <tt>EBParallelSpaceShared</tt> object * * @param resourceName the <tt>GridResource</tt> entity name that will * contain this allocation policy * @param entityName this object entity name + * @param numQueues The number of queues in the scheduler * @throws Exception This happens when one of the following scenarios occur: * <ul> * <li> Creating this entity before initialising GridSim package @@ -78,14 +87,30 @@ * String[], String[], String) */ public MultipleEasyBackfillingQueues(String resourceName, - String entityName) throws Exception{ + String entityName, int numQueues) throws Exception { super(resourceName, entityName); + // makes sure that the scheduler has at least one queue + if(numQueues <= 0) { + throw new ParameterException("Number of queues" + + "should be larger than 1"); + } + // initialises local data structure - runningGridlets_ = new LinkedList<SSGridlet>(); + runningGridlets_ = new LinkedList<MQGridlet>(); + queuedGridlets_ = new LinkedList<MQGridlet>(); + numQueues_ = numQueues; + profile_ = new Profile(); lastScheduleUpdate_ = 0.0D; ratingPE_ = 0; } + + + public boolean createQueue(int queueId, int numPE, QueuePredicate predicate) { + EasyBackFillingQueue queue = new EasyBackFillingQueue(queueId, numPE, predicate); + profile_.addQueue(queue); + return true; + } /** * Handles internal events that come to this entity. @@ -99,6 +124,51 @@ // of one PE assuming that the machines are homogeneous ratingPE_ = resource_.getMIPSRatingOfOnePE(); + if(numQueues_ > 1 && profile_.getNumberOfQueues() != numQueues_) { + System.out.println(super.get_name() + ".body(): The scheduler" + + " is expected to have " + numQueues_ + " queues. However," + + " only " + profile_.getNumberOfQueues() + " have been defined"); + return; + } + + //TODO: To validate the processing elements assigned to the queues + + // if the user has not specified the queues and the scheduler is + // expected to have only one queue, then creates the queue and + // includes it in the list. + if(profile_.getNumberOfQueues() == 0 && numQueues_ == 1) { + // creates the accept all predicate + QueuePredicate predicate = new QueuePredicate() { + public boolean match(SSGridlet gridlet) { + return true; + } + }; + + EasyBackFillingQueue queue = + new EasyBackFillingQueue(0, resource_.getNumPE(), predicate); + queue.idlePERanges_ = resource_.getFreePERanges().clone(); + profile_.addQueue(queue); + } + // assigns the PEs to the queues + else { + int allocPE = 0; + PERangeList freeRanges = resource_.getFreePERanges().clone(); + for(EasyBackFillingQueue queue : profile_.queues_.values()) { + allocPE += queue.initialNumPEs_; + + if(allocPE > resource_.getNumPE()) { + System.out.println(super.get_name() + ".body(): The scheduler" + + " cannot allocate PEs to all queues because there are not" + + " anough PEs"); + return; + } + + PERangeList selected = super.selectPERangeList(queue.initialNumPEs_, freeRanges); + queue.idlePERanges_ = selected; + freeRanges = PERangeList.difference(freeRanges, selected); + } + } + // a loop that is looking for internal events only Sim_event ev = new Sim_event(); while ( Sim_system.running() ) { @@ -160,12 +230,63 @@ } // Create a resource Gridlet - SSGridlet sgl = new SSGridlet(gridlet); + MQGridlet sgl = new MQGridlet(gridlet); //-------------- FOR DEBUGGING PURPOSES ONLY -------------- - GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_ARRIVED, true, sgl); + GridSim.notifyListeners(this.get_id(), + AllocationAction.ITEM_ARRIVED, true, sgl); + + //---------------------------------------------------------- + + // the id of the queue where the job can be scheduled + int queueId = profile_.getCorrespondingQueue(sgl); + + // if no queue can handle the gridlet, then reject it + if(queueId == UNKNOWN) { + String userName = GridSim.getEntityName( gridlet.getUserID() ); + System.out.println(super.get_name() + ".gridletSubmit(): " + + " Gridlet #" + gridlet.getGridletID() + " from " + + userName + " cannot be handled by any queue in this resource."); + try { + gridlet.setGridletStatus(Gridlet.FAILED); + } catch (Exception ex) { + System.out.println(super.get_name() + + ": Exception on submission of a Gridlet"); + } + super.sendFinishGridlet(gridlet); + return; + } + + sgl.setQueueID(queueId); + + // If there are no jobs in the queue list, then check if + // there are enough PEs to process the job immediately + boolean success = startGridlet(sgl); + // if the job could not be scheduled immediately, then enqueue it + if(!success) { + scheduleGridlet(sgl); + queuedGridlets_.add(sgl); + } + +// System.out.println("\nFree Ranges=" + profile_.getIdlePEsPerQueue()); +// System.out.println(profile_); + + //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- + + // Notifies the listeners that a Gridlet has been either scheduled + // to run immediately or put in the waiting queue + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_SCHEDULED, true, sgl); + + //--------------------------------------------------------------- + + // sends back an ack if required + if (ack == true) { + super.sendAck(GridSimTags.GRIDLET_SUBMIT_ACK, true, + gridlet.getGridletID(), gridlet.getUserID() + ); + } } /** @@ -239,8 +360,222 @@ } // -------------------- PRIVATE METHODS ---------------------------- + + /** + * + */ + private boolean startGridlet(MQGridlet sgl) { + + int reqPE = sgl.getNumPE(); + if(reqPE > resource_.getNumFreePE()) + return false; + + boolean success = false; // to test various conditions + int queueId = sgl.getQueueID(); + + // calculate the execution time of the Gridlet + double executionTime = + super.forecastExecutionTime(ratingPE_, sgl.getRemainingLength()); + // calculates how much ahead to look into the availability profile + double currentTime = GridSim.clock() ; + + // the Gridlet's expected finish time if it starts now + double finishTime = currentTime + executionTime; + + PERangeList ranges = + profile_.getImmediateAvailability(queueId, executionTime); + + // if the above method returns null, it means that there are not enough + // PEs to serve the reservation or Gridlet + if(ranges.getNumPE() >= reqPE) { + ranges = super.selectPERangeList(reqPE, ranges); + profile_.allocateImmediateRanges(queueId, finishTime, ranges); + success = true; + } + + // If the queue to which the gridlet is assigned does not have the + // required PEs, then try to borrow the additional PEs from other queues. + if(!success) { + PERangeList overallAvailPEs = + profile_.getImmediateAvailability(executionTime); + + // additional PEs required + int addRequired = reqPE - ranges.getNumPE(); + + PERangeList addRanges = + PERangeList.difference(overallAvailPEs, ranges); + + if(addRanges != null && addRanges.getNumPE() >= addRequired) { + // subtracts the ranges already obtained from the gridlet's queue + +// System.out.println("\nRanges to Add to queue " + queueId +" = " + +// addRanges + "\noverall = " + overallAvailPEs + +// "\n overall num available = " + overallAvailPEs.getNumPE() + +// "\n free PEs = " + resource_.getNumFreePE() + +// "\n free PEs profile = " + profile_.getNumFreePEs() + +// "\n PEs from the queue = " + ranges.getNumPE() + +// "\n req PEs = " + reqPE); + + // borrows the ranges from the queues and adds it into the + // specified queue + addRanges = super.selectPERangeList(addRequired, addRanges); + profile_.transferPEs(queueId, addRanges, currentTime, finishTime); + + // allocate the ranges to the job + ranges.addAll(addRanges); + profile_.allocateImmediateRanges(queueId, finishTime, ranges); + success = true; + } + } + + if(!success) + return false; + + // sets the PEs to busy at resource class. This is just to provide + // information to other classes that may query it + resource_.setPEsBusy(ranges); + + // add this Gridlet into execution list + runningGridlets_.add(sgl); + sgl.setStartTime(currentTime); + sgl.setFinishTime(finishTime); + + // change Gridlet status + sgl.setStatus(Gridlet.INEXEC); + + // Sets the list of ranges used by the gridlet + sgl.setPERangeList(ranges); + + // then send this event to itself to update the queues after + // this gridlet's completion time + super.sendInternalEvent(executionTime, UPDATE_SCHEDULE_TAG); + + //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- + + // Notifies the listeners that a Gridlet has been either scheduled + // to run immediately or put in the waiting queue + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_SCHEDULED, true, sgl); + + //--------------------------------------------------------------- + return true; + } + /** + * @param sgl the resource gridlet + */ + private boolean scheduleGridlet(MQGridlet sgl) { + int reqPE = sgl.getNumPE(); + int queueId = sgl.getQueueID(); + + EasyBackFillingQueue queue = profile_.getQueue(queueId); + + // if queue has a pivot already, then just add + // the job to the waiting queue + if(queue.pivot_ != null) { + return false; + } + + PERangeList ranges = null; + + // calculate the execution time of the Gridlet + double executionTime = + super.forecastExecutionTime(ratingPE_, sgl.getRemainingLength()); + + double startTime = -1; // keep the potential start time of the gridlet + double finishTime = -1; // store the gridlet's expected finish time + + // check whether there are PEs available over the time interval requested + Object[] availObjQueue = + profile_.checkPERangesAvailability(queueId, reqPE, executionTime); + + Object[] availObj = + profile_.checkPERangesAvailability(reqPE, executionTime); + + int anchor; + double startTimeQueue; + if (availObjQueue == null) + startTimeQueue = Double.MAX_VALUE; + else { + anchor = (Integer)availObjQueue[0]; + startTimeQueue=profile_.get(anchor).getTime(); + } + +// System.out.println(profile_); + + anchor = (Integer)availObj[0]; + double startTimeAll = profile_.get(anchor).getTime(); + + if(startTimeQueue <= startTimeAll) { + ranges = (PERangeList)availObjQueue[2]; + ranges = super.selectPERangeList(reqPE, ranges); + + int anchorIndex = (Integer)availObjQueue[0]; + int tailIndex = (Integer)availObjQueue[1]; + + startTime = startTimeQueue; + finishTime = startTime + executionTime; + + profile_.allocatePERanges(queueId, anchorIndex, tailIndex, + ranges, startTime, finishTime); + } + // If the queue to which the gridlet is assigned does not have the + // required PEs, then try to borrow the additional PEs from other queues. + else { + PERangeList addRanges = (PERangeList)availObj[2]; + + // the anchor index, the entry in the profile where the gridlet will be placed + int anchorIndex = (Integer)availObj[0]; + // insert index represents the position after which the entry + // corresponding to the gridlet's finish time will be placed + int tailIndex = (Integer)availObj[1]; + + // a pointer to the anchor entry + startTime = startTimeAll; + finishTime = startTime + executionTime; + + availObjQueue = profile_.checkPERangesAvailability(queueId, + startTime, executionTime); + + ranges = availObjQueue == null ? new PERangeList() : (PERangeList)availObjQueue[2]; + addRanges = availObjQueue == null ? addRanges : PERangeList.difference(addRanges, ranges); + addRanges = super.selectPERangeList(reqPE - ranges.getNumPE(), addRanges); + +// System.out.println("\nRanges to transfer to queue " + queueId +" = " + +// addRanges + " from " + startTime + " to " + finishTime); + + // borrows the ranges from the queues and adds it into the + // specified queue + profile_.transferPEs(queueId, addRanges, startTime, finishTime); + + // finally allocate the ranges to the gridlet + ranges.addAll(addRanges); + profile_.allocatePERanges(queueId, anchorIndex, tailIndex, + ranges, startTime, finishTime); + } + + queue.pivot_ = sgl; + + // Set the list of ranges used by the gridlet + sgl.setPERangeList(ranges); + + // change Gridlet status + sgl.setStatus(Gridlet.QUEUED); + sgl.setStartTime(startTime); + sgl.setFinishTime(finishTime); + + //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- + + // Notifies the listeners that a Gridlet has been either scheduled + // to run immediately or put in the waiting queue + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_SCHEDULED, true, sgl); + + //--------------------------------------------------------------- + + return true; + } + + /** * Process and event sent to this entity * @param ev the event to be handled */ @@ -273,39 +608,109 @@ * tries to backfill with jobs waiting in the queue. The method also * removes old entries from the availability profile. */ - private void updateSchedule(){ - + private void updateSchedule() { - } + int itemsFinished = 0; + double currentTime = GridSim.clock(); + int itemsStarted = 0; - static class EasyBackfillingQueue { + itemsFinished = finishRunningGridlets(currentTime); - int queueId_ = UNKNOWN; + // remove past entries from the availability profile + ProfileEntry currentStatus = profile_.removePastEntries(currentTime); + if(currentStatus != null) { + profile_.setCurrentStatus(currentStatus); + resource_.resetFreePERanges(currentStatus.getPERanges()); + } - // initial number of PEs assigned to this queue - int initialNumPE_ = 0; - - // Queue of Gridlets waiting in this queue - LinkedList<SSGridlet> queuedGridlets_; - - // the time when the first job in the waiting queue can - // start its execution - double shadowTime_ = ... [truncated message content] |
From: <mar...@us...> - 2008-02-15 07:03:55
|
Revision: 104 http://gridsim.svn.sourceforge.net/gridsim/?rev=104&view=rev Author: marcos_dias Date: 2008-02-14 23:03:53 -0800 (Thu, 14 Feb 2008) Log Message: ----------- Implementation of priorities in the multiple queue policy. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java 2008-02-15 04:13:00 UTC (rev 103) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java 2008-02-15 07:03:53 UTC (rev 104) @@ -89,10 +89,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode - GridSim.startGridSimulation(true); +// GridSim.startGridSimulation(true); // Start the simulation in normal mode -// GridSim.startGridSimulation(); + GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over @@ -150,18 +150,20 @@ MultipleEasyBackfillingQueues policy = null; try { - policy = new MultipleEasyBackfillingQueues(name, "Policy", 2); + policy = new MultipleEasyBackfillingQueues(name, "Policy", 3); } catch (Exception e1) { e1.printStackTrace(); } - // creates two partitions, one for small jobs and another for long jobs - // assign the same number of PEs to both - QueuePredicateExample pred1 = new QueuePredicateExample(0, 10000, peRating); - QueuePredicateExample pred2 = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + // creates three partitions, one for small jobs, one for medium size jobs + // and another for long jobs + QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); + QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); + QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); - policy.createPartition(0, resConfig.getNumPE() / 2, pred1); - policy.createPartition(1, resConfig.getNumPE() / 2, pred2); + policy.createPartition(0, resConfig.getNumPE() / 3, express); + policy.createPartition(1, resConfig.getNumPE() / 3, medium); + policy.createPartition(2, resConfig.getNumPE() / 3, large); ////////////////////////////////////////// // 6. Finally, we need to create a GridResource object. @@ -197,6 +199,12 @@ } } // end class +/** + * Example of queue predicate. This predicate filters + * gridlets according to their runtime + * + * @author Marcos Dias de Assuncao + */ class QueuePredicateExample implements QueuePartitionPredicate { int minRuntime_; int maxRuntime_; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-02-15 04:13:00 UTC (rev 103) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-02-15 07:03:53 UTC (rev 104) @@ -783,7 +783,7 @@ // if the above method returns null, it means that there are not enough // PEs to serve the reservation or Gridlet - if(availObj == null){ + if(availObj == null) { return false; } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java 2008-02-15 04:13:00 UTC (rev 103) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java 2008-02-15 07:03:53 UTC (rev 104) @@ -18,6 +18,8 @@ import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; @@ -52,11 +54,8 @@ * <li> Local load is not considered. If you would like to simulate this, * you have to model the local load as gridlets. It is more precise * and faster. To do so, please check {@link Lublin99Workload}. - * <li> Gridlets cannot be paused nor migrated. This could be - * easily done, but due to time constraints, I could not - * implement these features. - * <li> This policy still neither supports priorities nor advance - * reservation. + * <li> Gridlets cannot be paused nor migrated. + * <li> This policy does not support advance reservations. * </ul> * * @author Marcos Dias de Assuncao @@ -94,13 +93,16 @@ // the last time when the schedule updated was called private double lastScheduleUpdate_; + // to order the gridlets according to their priorities and submission times + private OrderGridletsByPriority orderByPriority_; + // a tag to indicate that a gridlet has finished private static final int UPDATE_SCHEDULE_TAG = 10; // a constant that denotes an unknown value private static final int UNKNOWN = -1; - /** + /** * Allocates a new <tt>MultiEasyBackfillingQueues</tt> object. * If the policy is create with only one partition, it will then work as * a normal aggressive (EASY) backfilling scheduler. @@ -136,6 +138,7 @@ // initialises local data structure runningGridlets_ = new LinkedList<SSGridlet>(); queuedGridlets_ = new LinkedList<SSGridlet>(); + orderByPriority_ = new OrderGridletsByPriority(); numPartitions_ = numPartitions; profile_ = new MultiPartitionProfile(); lastScheduleUpdate_ = 0.0D; @@ -337,6 +340,9 @@ if(!success) { scheduleGridlet(sgl); queuedGridlets_.add(sgl); + + // order gridlets according to their priorities + Collections.sort(queuedGridlets_, orderByPriority_); } //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- @@ -365,7 +371,7 @@ * @pre userId > 0 * @post $none */ - public int gridletStatus(int gridletId,int userId){ + public int gridletStatus(int gridletId, int userId) { return UNKNOWN; } @@ -537,7 +543,18 @@ // if queue has a pivot already, then just add // the job to the waiting queue if(queue.pivot_ != null) { - return false; + // checks whether the priority of the pivot is lower than the + // job being considered for scheduling. + // If priority of pivot is higher or equals to sgl's, then do not + // make any change + if(queue.pivot_.getPriority() >= sgl.getPriority()) + return false; + else { + profile_.updateEntriesAtProfile(queue.pivot_); + queue.pivot_.setStartTime(-1); + queue.pivot_.setFinishTime(-1); + queue.pivot_ = null; + } } PERangeList ranges = null; @@ -1696,6 +1713,103 @@ } } } + + /** + * This method removes/updates the entries from the profile + * corresponding to a the given Gridlet or advance reservation. + * @param removedItem the Gridlet or advance reservation whose entries + * have to be removed or updated + */ + protected void updateEntriesAtProfile(ScheduleItem removedItem) { + + int partitionId = removedItem.getPartitionID(); + + // ranges of PEs used by the Gridlet + PERangeList allocatedRanges = removedItem.getPERangeList(); + + // the reference time used to update the entries in the profile + double startTime = removedItem.getStartTime(); + + // the entries between reference time and endTime must be updated + double finishTime = removedItem.getFinishTime(); + + // transfer the PEs back to the queue + transferPEs(partitionId, allocatedRanges, startTime, finishTime); + + ProfileEntry entry = getPrecedingEntry(startTime); + if(entry.getTime() == startTime) { + entry.decreaseGridlet(); + if(entry.getNumGridlets() == 0) + super.remove(entry); + } + + entry = getPrecedingEntry(finishTime); + if(entry.getTime() == startTime) { + entry.decreaseGridlet(); + if(entry.getNumGridlets() == 0) + super.remove(entry); + } + +// // if the Gridlet was running, then update the range of PEs currently +// // available and set the reference time as current simulation time +// if(wasRunning) { +// // returns the ranges to the list of free ranges +// resource_.setPEsAvailable(allocatedRanges); +// } +// +// Iterator<ProfileEntry> iterProfile = super.iterator(); +// while(iterProfile.hasNext()) { +// ProfileEntry entry = iterProfile.next(); +// +// double entryTime = entry.getTime(); +// if(entryTime < startTime) { +// continue; +// } +// else if(entryTime > finishTime) { +// break; +// } +// else{ +// if(entryTime == finishTime) { +// // if the entry is equals to the finish time of the +// // gridlet, then it means that the gridlet uses this entry +// // to mark its termination. Therefore, it decreases the +// // number of gridlets that rely on this entry to mark +// // the finish time. If the number of gridlets is 0, it +// // means that the entry can be deleted because it is +// // not needed anymore +// entry.decreaseGridlet(); +// if(entry.getNumGridlets() == 0) { +// iterProfile.remove(); +// } +// continue; +// } +// // if the entry is the gridlet's anchor point, then +// // decrease the number of gridlets that rely on this +// // entry to either mark their start time or completion +// // time. If the number of Gridlets is 0 then, the +// // entry is removed from the profile +// if(entryTime == startTime) { +// entry.decreaseGridlet(); +// if(entry.getNumGridlets() == 0) { +// iterProfile.remove(); +// continue; +// } +// } +// // returns the ranges to the list of free ranges in +// // the entry, and consolidates the ranges to avoid fragments +// // As the list may be null, make sure that the list will not be +// // null so the released ranges can be added back to it +// PERangeList listEntry = entry.getPERanges(partitionId); +// if(listEntry == null){ +// listEntry = new PERangeList(); +// } +// +// listEntry.addAll(allocatedRanges.clone()); +// listEntry.mergePERanges(); +// entry.setPERangeList(partitionId, listEntry); +// } +// } + } /** * Creates an string representation of the profile @@ -1710,4 +1824,26 @@ return result; } } + + /** + * Comparator to order jobs according to their priorities + * and start time + * @author Marcos Dias de Assuncao + */ + private class OrderGridletsByPriority implements Comparator<SSGridlet> { + + public int compare(SSGridlet gl0, SSGridlet gl1) { + int result; + Integer priority0 = gl0.getPriority(); + Integer priority1 = gl1.getPriority(); + result = priority0.compareTo(priority1); + + if(result == 0) { + Double submission0 = gl0.getSubmissionTime(); + Double submission1 = gl1.getSubmissionTime(); + result = submission0.compareTo(submission1); + } + return result; + } + } } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2008-02-15 04:13:00 UTC (rev 103) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/SSGridlet.java 2008-02-15 07:03:53 UTC (rev 104) @@ -52,7 +52,7 @@ // A list of ranges of PEs used by this Gridlet private PERangeList peRangeList_ = null; - // the partiton or queue in the resource to which this + // the partition or queue in the resource to which this // gridlet was scheduled private int partition_; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java 2008-02-15 04:13:00 UTC (rev 103) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/SSReservation.java 2008-02-15 07:03:53 UTC (rev 104) @@ -36,6 +36,13 @@ // expiry time once a reservation has been made private double expiryTime_; + // the partition or queue in the resource to which this + // reservation was scheduled + private int partition_; + + // the priority of this reservation assigned by the scheduler + private int priority_; + // used to format the values for display private static DecimalFormat decFormater_; @@ -157,6 +164,50 @@ } /** + * Gets the id of the partition or queue to which this + * reservation was scheduled + * @return the partition id or <tt>-1</tt> if not found + */ + public int getPartitionID() { + return partition_; + } + + /** + * Sets the id of the partition or queue to which this + * reservation was scheduled + * @param partition the partition id + * @return <tt>true</tt> if set correctly or <tt>false</tt> otherwise. + */ + public boolean setPartitionID(int partition) { + if(partition < 0) + return false; + + partition_ = partition; + return true; + } + + /** + * Gets the priority of this reservation assigned by the scheduler + * @return the priority or <tt>-1</tt> if not found + */ + public int getPriority() { + return priority_; + } + + /** + * Sets the priority of this reservation assigned by the scheduler + * @param priority the priority + * @return <tt>true</tt> if set correctly or <tt>false</tt> otherwise. + */ + public boolean setPriority(int priority) { + if(priority < 0) + return false; + + priority_ = priority; + return true; + } + + /** * Sets the time of submission of this reservation * @param time the submission time * @return <tt>true</tt> if the time has been set or Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java 2008-02-15 04:13:00 UTC (rev 103) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ScheduleItem.java 2008-02-15 07:03:53 UTC (rev 104) @@ -51,7 +51,7 @@ * @return the number of items */ int getNumPE(); - + /** * Returns the time of submission of this item * @return the submission time @@ -73,6 +73,19 @@ double getFinishTime(); /** + * Gets the priority of this item assigned by the scheduler + * @return the priority or <tt>-1</tt> if not found + */ + int getPriority(); + + /** + * Gets the id of the partition or queue to which this + * item was scheduled + * @return the partition id or <tt>-1</tt> if not found + */ + int getPartitionID(); + + /** * Gets the list of ranges of PEs used by this item * @return a list containing the ranges */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2008-02-17 05:40:27
|
Revision: 105 http://gridsim.svn.sourceforge.net/gridsim/?rev=105&view=rev Author: marcos_dias Date: 2008-02-16 21:40:32 -0800 (Sat, 16 Feb 2008) Log Message: ----------- This update contains: + Changes in the multiple queue easy backfilling policy to make it reusable when implementing other multiple queue policies. + A preliminary implementation of a multiple queue policy that uses conservative backfilling. + A preliminary implementation of a multiple queue policy that uses conservative backfilling and supports advance reservation. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java branches/gridsim4.0-branch3/source/gridsim/GridResource.java branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartitionPredicate.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java Added Paths: ----------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/QueuePredicateExample.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultipleQueues.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultipleQueues.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultipleQueues.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPProfileEntry.java Removed Paths: ------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java branches/gridsim4.0-branch3/source/gridsim/turbo/MultipleEasyBackfillingQueues.java Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/QueuePredicateExample.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/QueuePredicateExample.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/QueuePredicateExample.java 2008-02-17 05:40:32 UTC (rev 105) @@ -0,0 +1,63 @@ +package examples.workload.parallel; + +import gridsim.turbo.QueuePartitionPredicate; +import gridsim.turbo.SSGridlet; +import gridsim.turbo.SSReservation; +import gridsim.turbo.ScheduleItem; + +/** + * Example of queue predicate. This predicate filters + * gridlets according to their runtime + * + * @author Marcos Dias de Assuncao + */ +class QueuePredicateExample implements QueuePartitionPredicate { + int minRuntime_; + int maxRuntime_; + int resRating_; + + /* + * Default constructor + */ + public QueuePredicateExample(int minRuntime, + int maxRuntime, int rating) { + this.minRuntime_ = minRuntime; + this.maxRuntime_ = maxRuntime; + this.resRating_ = rating; + } + + /* + * (non-Javadoc) + * @see gridsim.turbo.QueuePredicate#match(gridsim.turbo.ScheduleItem) + */ + public boolean match(ScheduleItem item) { + double runtime = 0; + if(!item.isAdvanceReservation()) + runtime = forecastExecutionTime((SSGridlet)item); + else + runtime = ((SSReservation)item).getDurationTime(); + + if(runtime < minRuntime_ || runtime >= maxRuntime_) + return false; + + return true; + } + + /* + * Forecast execution time of a Gridlet. + * <tt>execution time = length / available rating</tt> + * @param gridlet the gridlet to be considered + * @return Gridlet's execution time. + */ + private double forecastExecutionTime(SSGridlet gridlet) { + double executionTime = (gridlet.getLength() / resRating_); + + // This is as a safeguard since the finish time can be extremely + // small close to 0.0, such as 4.5474735088646414E-14. Hence causing + // some Gridlets never to be finished and consequently hang the program + if (executionTime < 1.0) { + executionTime = 1.0; + } + return executionTime; + } +} \ No newline at end of file Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2008-02-17 05:40:32 UTC (rev 105) @@ -37,8 +37,6 @@ // ASCII text, gzip or zip. String fileName = args[0]; - // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf - ArrayList<GridResource> resources = new ArrayList<GridResource>(); ////////////////////////////////////////// Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java 2008-02-17 05:40:32 UTC (rev 105) @@ -0,0 +1,180 @@ + +package examples.workload.parallel; + +import gridsim.AllocPolicy; +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.ResourceCharacteristics; +import gridsim.turbo.EBMultipleQueues; +import gridsim.turbo.TResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example + */ +public class TurboExampleCBMultiQueues01 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + String fileName = args[0]; + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode + GridSim.startGridSimulation(true); + + // Start the simulation in normal mode +// GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // this resource will use an aggressive backfilling policy (EASY) + TResourceCharacteristics resConfig = + new TResourceCharacteristics(arch, os, mList, + TResourceCharacteristics.MULTI_CONSERVATIVE_BACKFILLING_QUEUES, + time_zone, cost); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + GridResource gridRes = null; + + try { + gridRes = new GridResource(name, baud_rate, seed, + resConfig, peakLoad, offPeakLoad, holidayLoad, weekends, + holidays); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + Added: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java 2008-02-17 05:40:32 UTC (rev 105) @@ -0,0 +1,202 @@ + +package examples.workload.parallel; + +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.turbo.CBMultipleQueues; +import gridsim.turbo.EBMultipleQueues; +import gridsim.turbo.TResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example + */ +public class TurboExampleCBMultiQueues02 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + String fileName = args[0]; + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode + GridSim.startGridSimulation(true); + + // Start the simulation in normal mode +// GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // this resource will use an aggressive backfilling policy (EASY) + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.MULTI_CONSERVATIVE_BACKFILLING_QUEUES, + time_zone, cost); + + CBMultipleQueues policy = null; + try { + policy = new CBMultipleQueues(name, "Policy", 3); + } catch (Exception e1) { + e1.printStackTrace(); + } + + // creates three partitions, one for small jobs, one for medium size jobs + // and another for long jobs + QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); + QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); + QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + + policy.createPartition(0, resConfig.getNumPE() / 3, express); + policy.createPartition(1, resConfig.getNumPE() / 3, medium); + policy.createPartition(2, resConfig.getNumPE() / 3, large); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + GridResource gridRes = null; + + ResourceCalendar resCalendar = new ResourceCalendar(time_zone, + peakLoad, offPeakLoad, holidayLoad, weekends, + holidays, seed); + + try { + gridRes = new GridResource(name, baud_rate, resConfig, + resCalendar, policy); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + + + + + Copied: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java (from rev 104, branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java) =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java 2008-02-17 05:40:32 UTC (rev 105) @@ -0,0 +1,179 @@ + +package examples.workload.parallel; + +import gridsim.AllocPolicy; +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.ResourceCharacteristics; +import gridsim.turbo.EBMultipleQueues; +import gridsim.turbo.TResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example + */ +public class TurboExampleEBMultiQueues01 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + String fileName = args[0]; + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode +// GridSim.startGridSimulation(true); + + // Start the simulation in normal mode + GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // this resource will use an aggressive backfilling policy (EASY) + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.MULTI_EASY_BACKFILLING_QUEUES, + time_zone, cost); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + GridResource gridRes = null; + + try { + gridRes = new GridResource(name, baud_rate, seed, + resConfig, peakLoad, offPeakLoad, holidayLoad, weekends, + holidays); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + Copied: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java (from rev 104, branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java) =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-02-17 05:40:32 UTC (rev 105) @@ -0,0 +1,195 @@ + +package examples.workload.parallel; + +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.turbo.EBMultipleQueues; +import gridsim.turbo.TResourceCharacteristics; +import gridsim.util.Workload; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example + */ +public class TurboExampleEBMultiQueues02 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + String fileName = args[0]; + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); + + ////////////////////////////////////////// + // Starts the simulation in debug mode + GridSim.startGridSimulation(true); + + // Start the simulation in normal mode +// GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + // this resource will use an aggressive backfilling policy (EASY) + TResourceCharacteristics resConfig = new TResourceCharacteristics( + arch, os, mList, TResourceCharacteristics.MULTI_EASY_BACKFILLING_QUEUES, + time_zone, cost); + + EBMultipleQueues policy = null; + try { + policy = new EBMultipleQueues(name, "Policy", 3); + } catch (Exception e1) { + e1.printStackTrace(); + } + + // creates three partitions, one for small jobs, one for medium size jobs + // and another for long jobs + QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); + QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); + QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + + policy.createPartition(0, resConfig.getNumPE() / 3, express); + policy.createPartition(1, resConfig.getNumPE() / 3, medium); + policy.createPartition(2, resConfig.getNumPE() / 3, large); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + GridResource gridRes = null; + + ResourceCalendar resCalendar = new ResourceCalendar(time_zone, + peakLoad, offPeakLoad, holidayLoad, weekends, + holidays, seed); + + try { + gridRes = new GridResource(name, baud_rate, resConfig, + resCalendar, policy); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java 2008-02-17 05:40:32 UTC (rev 105) @@ -37,8 +37,6 @@ // ASCII text, gzip or zip. String fileName = args[0]; - // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf - ArrayList<GridResource> resources = new ArrayList<GridResource>(); ////////////////////////////////////////// Deleted: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues01.java 2008-02-17 05:40:32 UTC (rev 105) @@ -1,181 +0,0 @@ - -package examples.workload.parallel; - -import gridsim.AllocPolicy; -import gridsim.GridResource; -import gridsim.GridSim; -import gridsim.Machine; -import gridsim.MachineList; -import gridsim.ResourceCalendar; -import gridsim.ResourceCharacteristics; -import gridsim.turbo.MultipleEasyBackfillingQueues; -import gridsim.turbo.TResourceCharacteristics; -import gridsim.util.Workload; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.LinkedList; -import java.util.Random; - - -/** - * Test Driver class for this example - */ -public class TurboExampleMultiEBQueues01 -{ - /** - * Creates main() to run this example - */ - public static void main(String[] args) - { - long startTime = System.currentTimeMillis(); - if(args.length == 0){ - System.out.println("Please provide the location of the workload file!"); - System.exit(1); - } - - try { - - ////////////////////////////////////////// - // Get the workload to be used The format should be: - // ASCII text, gzip or zip. - - String fileName = args[0]; - // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf - - ArrayList<GridResource> resources = new ArrayList<GridResource>(); - - ////////////////////////////////////////// - // Initialize the GridSim package. It should be called - // before creating any entities. We can't run this example without - // initializing GridSim first. We will get run-time exception - // error. - - // number of grid user entities + any Workload entities. - int num_user = 1; - Calendar calendar = Calendar.getInstance(); - boolean trace_flag = false; // mean trace GridSim events - - // Initialize the GridSim package without any statistical - // functionalities. Hence, no GridSim_stat.txt file is created. - System.out.println("Initializing GridSim package"); - GridSim.init(num_user, calendar, trace_flag); - - ////////////////////////////////////////// - // Creates one or more GridResource entities - int totalResource = 1; // total number of Grid resources - int rating = 377; // rating of each PE in MIPS - int totalPE = 9; // total number of PEs for each Machine - int totalMachine = 128; // total number of Machines - int i = 0; - - String[] resArray = new String[totalResource]; - for (i = 0; i < totalResource; i++) { - String resName = "Res_" + i; - GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); - resources.add(resource); - - // add a resource name into an array - resArray[i] = resName; - } - - ////////////////////////////////////////// - // Creates one Workload trace entity. - - int resID = 0; - Random r = new Random(); - resID = r.nextInt(totalResource); - Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); - - ////////////////////////////////////////// - // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); - - // Start the simulation in normal mode - GridSim.startGridSimulation(); - - ////////////////////////////////////////// - // Final step: Prints the Gridlets when simulation is over - long finishTime = System.currentTimeMillis(); - System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); - - // prints the Gridlets inside a Workload entity - // workload.printGridletList(trace_flag); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * Creates one Grid resource. A Grid resource contains one or more - * Machines. Similarly, a Machine contains one or more PEs (Processing - * Elements or CPUs). - * @param name a Grid Resource name - * @param peRating rating of each PE - * @param totalMachine total number of Machines - * @param totalPE total number of PEs for each Machine - */ - private static GridResource createGridResource(String name, int peRating, - int totalMachine, int totalPE) - { - - ////////////////////////////////////////// - // Here are the steps needed to create a Grid resource: - // 1. We need to create an object of MachineList to store one or more - // Machines - MachineList mList = new MachineList(); - - for (int i = 0; i < totalMachine; i++) - { - ////////////////////////////////////////// - // 4. Create one Machine with its id and list of PEs or CPUs - mList.add( new Machine(i, totalPE, peRating) ); - } - - ////////////////////////////////////////// - // 5. Create a ResourceCharacteristics object that stores the - // properties of a Grid resource: architecture, OS, list of - // Machines, allocation policy: time- or space-shared, time zone - // and its price (G$/PE time unit). - String arch = "Sun Ultra"; // system architecture - String os = "Solaris"; // operating system - double time_zone = 0.0; // time zone this resource located - double cost = 3.0; // the cost of using this resource - - // this resource will use an aggressive backfilling policy (EASY) - TResourceCharacteristics resConfig = new TResourceCharacteristics( - arch, os, mList, TResourceCharacteristics.MULTIPLE_EASY_BACKFILLING_QUEUES, - time_zone, cost); - - ////////////////////////////////////////// - // 6. Finally, we need to create a GridResource object. - double baud_rate = 10000.0; // communication speed - long seed = 11L*13*17*19*23+1; - double peakLoad = 0.0; // the resource load during peak hour - double offPeakLoad = 0.0; // the resource load during off-peak hr - double holidayLoad = 0.0; // the resource load during holiday - - // incorporates weekends so the grid resource is on 7 days a week - LinkedList weekends = new LinkedList(); - weekends.add(new Integer(Calendar.SATURDAY)); - weekends.add(new Integer(Calendar.SUNDAY)); - - // incorporates holidays. However, no holidays are set in this example - LinkedList holidays = new LinkedList(); - GridResource gridRes = null; - - try { - gridRes = new GridResource(name, baud_rate, seed, - resConfig, peakLoad, offPeakLoad, holidayLoad, weekends, - holidays); - } - catch (Exception e) { - e.printStackTrace(); - } - - System.out.println("Creates one Grid resource with name = " + name); - return gridRes; - } -} // end class - Deleted: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleMultiEBQueues02.java 2008-02-17 05:40:32 UTC (rev 105) @@ -1,255 +0,0 @@ - -package examples.workload.parallel; - -import gridsim.GridResource; -import gridsim.GridSim; -import gridsim.Machine; -import gridsim.MachineList; -import gridsim.ResourceCalendar; -import gridsim.turbo.MultipleEasyBackfillingQueues; -import gridsim.turbo.QueuePartitionPredicate; -import gridsim.turbo.SSGridlet; -import gridsim.turbo.TResourceCharacteristics; -import gridsim.util.Workload; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.LinkedList; -import java.util.Random; - - -/** - * Test Driver class for this example - */ -public class TurboExampleMultiEBQueues02 -{ - /** - * Creates main() to run this example - */ - public static void main(String[] args) - { - long startTime = System.currentTimeMillis(); - if(args.length == 0){ - System.out.println("Please provide the location of the workload file!"); - System.exit(1); - } - - try { - - ////////////////////////////////////////// - // Get the workload to be used The format should be: - // ASCII text, gzip or zip. - - String fileName = args[0]; - // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf - - ArrayList<GridResource> resources = new ArrayList<GridResource>(); - - ////////////////////////////////////////// - // Initialize the GridSim package. It should be called - // before creating any entities. We can't run this example without - // initializing GridSim first. We will get run-time exception - // error. - - // number of grid user entities + any Workload entities. - int num_user = 1; - Calendar calendar = Calendar.getInstance(); - boolean trace_flag = false; // mean trace GridSim events - - // Initialize the GridSim package without any statistical - // functionalities. Hence, no GridSim_stat.txt file is created. - System.out.println("Initializing GridSim package"); - GridSim.init(num_user, calendar, trace_flag); - - ////////////////////////////////////////// - // Creates one or more GridResource entities - int totalResource = 1; // total number of Grid resources - int rating = 377; // rating of each PE in MIPS - int totalPE = 9; // total number of PEs for each Machine - int totalMachine = 128; // total number of Machines - int i = 0; - - String[] resArray = new String[totalResource]; - for (i = 0; i < totalResource; i++) { - String resName = "Res_" + i; - GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); - resources.add(resource); - - // add a resource name into an array - resArray[i] = resName; - } - - ////////////////////////////////////////// - // Creates one Workload trace entity. - - int resID = 0; - Random r = new Random(); - resID = r.nextInt(totalResource); - Workload workload = new Workload("Load_1", fileName, resArray[resID], rating); - - ////////////////////////////////////////// - // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); - - // Start the simulation in normal mode - GridSim.startGridSimulation(); - - ////////////////////////////////////////// - // Final step: Prints the Gridlets when simulation is over - long finishTime = System.currentTimeMillis(); - System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); - - // prints the Gridlets inside a Workload entity - // workload.printGridletList(trace_flag); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * Creates one Grid resource. A Grid resource contains one or more - * Machines. Similarly, a Machine contains one or more PEs (Processing - * Elements or CPUs). - * @param name a Grid Resource name - * @param peRating rating of each PE - * @param totalMachine total number of Machines - * @param totalPE total number of PEs for each Machine - */ - private static GridResource createGridResource(String name, int peRating, - int totalMachine, int totalPE) - { - - ////////////////////////////////////////// - // Here are the steps needed to create a Grid resource: - // 1. We need to create an object of MachineList to store one or more - // Machines - MachineList mList = new MachineList(); - - for (int i = 0; i < totalMachine; i++) - { - ////////////////////////////////////////// - // 4. Create one Machine with its id and list of PEs or CPUs - mList.add( new Machine(i, totalPE, peRating) ); - } - - ////////////////////////////////////////// - // 5. Create a ResourceCharacteristics object that stores the - // properties of a Grid resource: architecture, OS, list of - // Machines, allocation policy: time- or space-shared, time zone - // and its price (G$/PE time unit). - String arch = "Sun Ultra"; // system architecture - String os = "Solaris"; // operating system - double time_zone = 0.0; // time zone this resource located - double cost = 3.0; // the cost of using this resource - - // this resource will use an aggressive backfilling policy (EASY) - TResourceCharacteristics resConfig = new TResourceCharacteristics( - arch, os, mList, TResourceCharacteristics.MULTIPLE_EASY_BACKFILLING_QUEUES, - time_zone, cost); - - MultipleEasyBackfillingQueues policy = null; - try { - policy = new MultipleEasyBackfillingQueues(name, "Policy", 3); - } catch (Exception e1) { - e1.printStackTrace(); - } - - // creates three partitions, one for small jobs, one for medium size jobs - // and another for long jobs - QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); - QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); - QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); - - policy.createPartition(0, resConfig.getNumPE() / 3, express); - policy.createPartition(1, resConfig.getNumPE() / 3, medium); - policy.createPartition(2, resConfig.getNumPE() / 3, large); - - ////////////////////////////////////////// - // 6. Finally, we need to create a GridResource object. - double baud_rate = 10000.0; // communication speed - long seed = 11L*13*17*19*23+1; - double peakLoad = 0.0; // the resource load during peak hour - double offPeakLoad = 0.0; // the resource load during off-peak hr - double holidayLoad = 0.0; // the resource load during holiday - - // incorporates weekends so the grid resource is on 7 days a week - LinkedList weekends = new LinkedList(); - weekends.add(new Integer(Calendar.SATURDAY)); - weekends.add(new Integer(Calendar.SUNDAY)); - - // incorporates holidays. However, no holidays are set in this example - LinkedList holidays = new LinkedList(); - GridResource gridRes = null; - - ResourceCalendar resCalendar = new ResourceCalendar(time_zone, - peakLoad, offPeakLoad, holidayLoad, weekends, - holidays, seed); - - try { - gridRes = new GridResource(name, baud_rate, resConfig, - resCalendar, policy); - } - catch (Exception e) { - e.printStackTrace(); - } - - System.out.println("Creates one Grid resource with name = " + name); - return gridRes; - } -} // end class - -/** - * Example of queue predicate. This predicate filters - * gridlets according to their runtime - * - * @author Marcos Dias de Assuncao - */ -class QueuePredicateExample implements QueuePartitionPredicate { - int minRuntime_; - int maxRuntime_; - int resRating_; - - /* - * Default constructor - */ - public QueuePredicateExample(int minRuntime, - int maxRuntime, int rating) { - this.minRuntime_ = minRuntime; - this.maxRuntime_ = maxRuntime; - this.resRating_ = rating; - } - - /* - * (non-Javadoc) - * @see gridsim.turbo.QueuePredicate#match(gridsim.turbo.SSGridlet) - */ - public boolean match(SSGridlet gridlet) { - double runtime = forecastExecutionTime(gridlet); - if(runtime < minRuntime_ || runtime >= maxRuntime_) - return false; - - return true; - } - - /* - * Forecast execution time of a Gridlet. - * <tt>execution time = length / available rating</tt> - * @param gridlet the gridlet to be considered - * @return Gridlet's execution time. - */ - private double forecastExecutionTime(SSGridlet gridlet) { - double executionTime = (gridlet.getLength() / resRating_); - - // This is as a safeguard since the finish time can be extremely - // small close to 0.0, such as 4.5474735088646414E-14. Hence causing - // some Gridlets never to be finished and consequently hang the program - if (executionTime < 1.0) { - executionTime = 1.0; - } - return executionTime; - } -} - - - Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2008-02-17 05:40:32 UTC (rev 105) @@ -37,8 +37,6 @@ // ASCII text, gzip or zip. String fileName = args[0]; - // /Users/marcosd/Documents/workspace/intergrid/workloads/sdsc_blue_2000_400.swf - ArrayList<GridResource> resources = new ArrayList<GridResource>(); ////////////////////////////////////////// Modified: branches/gridsim4.0-branch3/source/gridsim/GridResource.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/GridResource.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/source/gridsim/GridResource.java 2008-02-17 05:40:32 UTC (rev 105) @@ -11,9 +11,10 @@ import gridsim.net.*; import gridsim.turbo.ARParallelSpaceShared; +import gridsim.turbo.CBMultipleQueues; import gridsim.turbo.EBParallelSpaceShared; import gridsim.turbo.CBParallelSpaceShared; -import gridsim.turbo.MultipleEasyBackfillingQueues; +import gridsim.turbo.EBMultipleQueues; import gridsim.turbo.TResourceCharacteristics; import gridsim.index.*; @@ -647,10 +648,15 @@ break; // creates the scheduler with only one queue - case TResourceCharacteristics.MULTIPLE_EASY_BACKFILLING_QUEUES: - policy_ = new MultipleEasyBackfillingQueues(super.get_name(), - "MultipleEasyBackfillingQueues", 1); + case TResourceCharacteristics.MULTI_EASY_BACKFILLING_QUEUES: + policy_ = new EBMultipleQueues(super.get_name(), + "EBMultipleQueues", 1); break; + + case TResourceCharacteristics.MULTI_CONSERVATIVE_BACKFILLING_QUEUES: + policy_ = new CBMultipleQueues(super.get_name(), + "CBMultipleQueues", 1); + break; default: throw new Exception(super.get_name()+" : Error - supports"+ Modified: branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java 2008-02-15 07:03:53 UTC (rev 104) +++ branches/gridsim4.0-branch3/source/gridsim/gui/DefaultGridSimVisualizer.java 2008-02-17 05:40:32 UTC (rev 105) @@ -18,8 +18,6 @@ import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -206,27 +204,6 @@ status_ = new JLabel("Current simulation time is " + GridSim.clock() + " seconds."); statusPanel.add(status_); - /* to show simulation time when mouse cursor passing over buttons */ - ... [truncated message content] |
From: <mar...@us...> - 2008-02-18 04:25:19
|
Revision: 106 http://gridsim.svn.sourceforge.net/gridsim/?rev=106&view=rev Author: marcos_dias Date: 2008-02-17 20:25:19 -0800 (Sun, 17 Feb 2008) Log Message: ----------- This update includes the final version of the multiple partition conservative policies. One of the policies supports advance reservations. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java branches/gridsim4.0-branch3/source/gridsim/GridResource.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/QueuePartitionPredicate.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java Added Paths: ----------- branches/gridsim4.0-branch3/examples/examples/QueuePredicateExample.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java Removed Paths: ------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/QueuePredicateExample.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultipleQueues.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultipleQueues.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultipleQueues.java Copied: branches/gridsim4.0-branch3/examples/examples/QueuePredicateExample.java (from rev 105, branches/gridsim4.0-branch3/examples/examples/workload/parallel/QueuePredicateExample.java) =================================================================== --- branches/gridsim4.0-branch3/examples/examples/QueuePredicateExample.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/QueuePredicateExample.java 2008-02-18 04:25:19 UTC (rev 106) @@ -0,0 +1,63 @@ +package examples; + +import gridsim.turbo.QueuePartitionPredicate; +import gridsim.turbo.SSGridlet; +import gridsim.turbo.SSReservation; +import gridsim.turbo.ScheduleItem; + +/** + * Example of queue predicate. This predicate filters + * gridlets according to their runtime + * + * @author Marcos Dias de Assuncao + */ +public class QueuePredicateExample implements QueuePartitionPredicate { + int minRuntime_; + int maxRuntime_; + int resRating_; + + /* + * Default constructor + */ + public QueuePredicateExample(int minRuntime, + int maxRuntime, int rating) { + this.minRuntime_ = minRuntime; + this.maxRuntime_ = maxRuntime; + this.resRating_ = rating; + } + + /* + * (non-Javadoc) + * @see gridsim.turbo.QueuePredicate#match(gridsim.turbo.ScheduleItem) + */ + public boolean match(ScheduleItem item) { + double runtime = 0; + if(!item.isAdvanceReservation()) + runtime = forecastExecutionTime((SSGridlet)item); + else + runtime = ((SSReservation)item).getDurationTime(); + + if(runtime < minRuntime_ || runtime >= maxRuntime_) + return false; + + return true; + } + + /* + * Forecast execution time of a Gridlet. + * <tt>execution time = length / available rating</tt> + * @param gridlet the gridlet to be considered + * @return Gridlet's execution time. + */ + private double forecastExecutionTime(SSGridlet gridlet) { + double executionTime = (gridlet.getLength() / resRating_); + + // This is as a safeguard since the finish time can be extremely + // small close to 0.0, such as 4.5474735088646414E-14. Hence causing + // some Gridlets never to be finished and consequently hang the program + if (executionTime < 1.0) { + executionTime = 1.0; + } + return executionTime; + } +} \ No newline at end of file Modified: branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java 2008-02-17 05:40:32 UTC (rev 105) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java 2008-02-18 04:25:19 UTC (rev 106) @@ -608,8 +608,7 @@ Sim_event ev = new Sim_event(); Object[] reservObj = null; - while ( Sim_system.running() - && counter < gridletID_ ) { + while ( Sim_system.running() && counter < gridletID_ ) { super.sim_get_next(ev); // get the next available event data = ev.get_data(); // get the event's data @@ -629,10 +628,12 @@ // creates a new reservation Reservation reservation = null; - reservation = super.createReservation(startTime, duration, resGl.getNumPE(), resID_); + reservation = super.createReservation(startTime, duration, + resGl.getNumPE(), resID_); success = true; - if(reservation == null || reservation.getStatus() == Reservation.STATUS_FAILED) { + if(reservation == null || + reservation.getStatus() == Reservation.STATUS_FAILED) { success = false; } @@ -661,10 +662,13 @@ catch(Exception ex) { } - list_.add(resGl); } } - counter++; + + if(!success) { + list_.add(resGl); + counter++; + } } // get the Gridlet data @@ -673,11 +677,6 @@ list_.add(gl); counter++; } - - // if all the Gridlets have been collected - if (counter == gridletID_) { - break; - } } // shut down all the entities, including GridStatistics entity since Added: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java 2008-02-18 04:25:19 UTC (rev 106) @@ -0,0 +1,206 @@ + +package examples.workload.ar; + +import examples.QueuePredicateExample; +import examples.WorkloadWithReservation; +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.turbo.ARCBMultiplePartitions; +import gridsim.turbo.ARTGridResource; +import gridsim.turbo.TResourceCharacteristics; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example. This example just tests + * the same features provided by the ParallelSpaceShared policy + */ +public class TurboARCBMultipleQueuesExample01 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + String fileName = args[0]; + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) + { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + WorkloadWithReservation workload = + new WorkloadWithReservation("Load_1", fileName, resArray[resID], rating); + + // sets how long in advance the reservations are made (24 hours here) + workload.setARTimeInAdvance( 24 * 60 * 60 ); + + // sets the probability of a job read from the trace file being an advance reservation + workload.setReservationProbability(0.5); + + ////////////////////////////////////////// + // Starts the simulation in debug mode +// GridSim.startGridSimulation(true); + + // Start the simulation in normal mode + GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + TResourceCharacteristics resConfig = + new TResourceCharacteristics(arch, os, mList, + TResourceCharacteristics.ARCB_MULTI_PARTITIONS, + time_zone, cost); + + ARCBMultiplePartitions policy = null; + try { + policy = new ARCBMultiplePartitions(name, "Policy", 3); + } catch (Exception e1) { + e1.printStackTrace(); + } + + // creates three partitions, one for small jobs, one for medium size jobs + // and another for long jobs + QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); + QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); + QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + + policy.createPartition(0, resConfig.getNumPE() / 3, express); + policy.createPartition(1, resConfig.getNumPE() / 3, medium); + policy.createPartition(2, resConfig.getNumPE() / 3, large); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + ResourceCalendar resCalendar = new ResourceCalendar(time_zone, + peakLoad, offPeakLoad, holidayLoad, weekends, + holidays, seed); + + ARTGridResource gridRes = null; + try { + gridRes = new ARTGridResource(name, baud_rate, resConfig, resCalendar, policy); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + Deleted: branches/gridsim4.0-branch3/examples/examples/workload/parallel/QueuePredicateExample.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/QueuePredicateExample.java 2008-02-17 05:40:32 UTC (rev 105) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/QueuePredicateExample.java 2008-02-18 04:25:19 UTC (rev 106) @@ -1,63 +0,0 @@ -package examples.workload.parallel; - -import gridsim.turbo.QueuePartitionPredicate; -import gridsim.turbo.SSGridlet; -import gridsim.turbo.SSReservation; -import gridsim.turbo.ScheduleItem; - -/** - * Example of queue predicate. This predicate filters - * gridlets according to their runtime - * - * @author Marcos Dias de Assuncao - */ -class QueuePredicateExample implements QueuePartitionPredicate { - int minRuntime_; - int maxRuntime_; - int resRating_; - - /* - * Default constructor - */ - public QueuePredicateExample(int minRuntime, - int maxRuntime, int rating) { - this.minRuntime_ = minRuntime; - this.maxRuntime_ = maxRuntime; - this.resRating_ = rating; - } - - /* - * (non-Javadoc) - * @see gridsim.turbo.QueuePredicate#match(gridsim.turbo.ScheduleItem) - */ - public boolean match(ScheduleItem item) { - double runtime = 0; - if(!item.isAdvanceReservation()) - runtime = forecastExecutionTime((SSGridlet)item); - else - runtime = ((SSReservation)item).getDurationTime(); - - if(runtime < minRuntime_ || runtime >= maxRuntime_) - return false; - - return true; - } - - /* - * Forecast execution time of a Gridlet. - * <tt>execution time = length / available rating</tt> - * @param gridlet the gridlet to be considered - * @return Gridlet's execution time. - */ - private double forecastExecutionTime(SSGridlet gridlet) { - double executionTime = (gridlet.getLength() / resRating_); - - // This is as a safeguard since the finish time can be extremely - // small close to 0.0, such as 4.5474735088646414E-14. Hence causing - // some Gridlets never to be finished and consequently hang the program - if (executionTime < 1.0) { - executionTime = 1.0; - } - return executionTime; - } -} \ No newline at end of file Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java 2008-02-17 05:40:32 UTC (rev 105) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java 2008-02-18 04:25:19 UTC (rev 106) @@ -8,7 +8,7 @@ import gridsim.MachineList; import gridsim.ResourceCalendar; import gridsim.ResourceCharacteristics; -import gridsim.turbo.EBMultipleQueues; +import gridsim.turbo.EBMultiplePartitions; import gridsim.turbo.TResourceCharacteristics; import gridsim.util.Workload; @@ -144,7 +144,7 @@ // this resource will use an aggressive backfilling policy (EASY) TResourceCharacteristics resConfig = new TResourceCharacteristics(arch, os, mList, - TResourceCharacteristics.MULTI_CONSERVATIVE_BACKFILLING_QUEUES, + TResourceCharacteristics.CB_MULTI_PARTITIONS, time_zone, cost); ////////////////////////////////////////// Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java 2008-02-17 05:40:32 UTC (rev 105) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java 2008-02-18 04:25:19 UTC (rev 106) @@ -1,13 +1,14 @@ package examples.workload.parallel; +import examples.QueuePredicateExample; import gridsim.GridResource; import gridsim.GridSim; import gridsim.Machine; import gridsim.MachineList; import gridsim.ResourceCalendar; -import gridsim.turbo.CBMultipleQueues; -import gridsim.turbo.EBMultipleQueues; +import gridsim.turbo.CBMultiplePartitions; +import gridsim.turbo.EBMultiplePartitions; import gridsim.turbo.TResourceCharacteristics; import gridsim.util.Workload; @@ -142,12 +143,12 @@ // this resource will use an aggressive backfilling policy (EASY) TResourceCharacteristics resConfig = new TResourceCharacteristics( - arch, os, mList, TResourceCharacteristics.MULTI_CONSERVATIVE_BACKFILLING_QUEUES, + arch, os, mList, TResourceCharacteristics.CB_MULTI_PARTITIONS, time_zone, cost); - CBMultipleQueues policy = null; + CBMultiplePartitions policy = null; try { - policy = new CBMultipleQueues(name, "Policy", 3); + policy = new CBMultiplePartitions(name, "Policy", 3); } catch (Exception e1) { e1.printStackTrace(); } Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java 2008-02-17 05:40:32 UTC (rev 105) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java 2008-02-18 04:25:19 UTC (rev 106) @@ -8,7 +8,7 @@ import gridsim.MachineList; import gridsim.ResourceCalendar; import gridsim.ResourceCharacteristics; -import gridsim.turbo.EBMultipleQueues; +import gridsim.turbo.EBMultiplePartitions; import gridsim.turbo.TResourceCharacteristics; import gridsim.util.Workload; @@ -143,7 +143,7 @@ // this resource will use an aggressive backfilling policy (EASY) TResourceCharacteristics resConfig = new TResourceCharacteristics( - arch, os, mList, TResourceCharacteristics.MULTI_EASY_BACKFILLING_QUEUES, + arch, os, mList, TResourceCharacteristics.EB_MULTI_PARTITIONS, time_zone, cost); ////////////////////////////////////////// Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-02-17 05:40:32 UTC (rev 105) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-02-18 04:25:19 UTC (rev 106) @@ -1,12 +1,13 @@ package examples.workload.parallel; +import examples.QueuePredicateExample; import gridsim.GridResource; import gridsim.GridSim; import gridsim.Machine; import gridsim.MachineList; import gridsim.ResourceCalendar; -import gridsim.turbo.EBMultipleQueues; +import gridsim.turbo.EBMultiplePartitions; import gridsim.turbo.TResourceCharacteristics; import gridsim.util.Workload; @@ -140,12 +141,12 @@ // this resource will use an aggressive backfilling policy (EASY) TResourceCharacteristics resConfig = new TResourceCharacteristics( - arch, os, mList, TResourceCharacteristics.MULTI_EASY_BACKFILLING_QUEUES, + arch, os, mList, TResourceCharacteristics.EB_MULTI_PARTITIONS, time_zone, cost); - EBMultipleQueues policy = null; + EBMultiplePartitions policy = null; try { - policy = new EBMultipleQueues(name, "Policy", 3); + policy = new EBMultiplePartitions(name, "Policy", 3); } catch (Exception e1) { e1.printStackTrace(); } Modified: branches/gridsim4.0-branch3/source/gridsim/GridResource.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/GridResource.java 2008-02-17 05:40:32 UTC (rev 105) +++ branches/gridsim4.0-branch3/source/gridsim/GridResource.java 2008-02-18 04:25:19 UTC (rev 106) @@ -10,11 +10,12 @@ package gridsim; import gridsim.net.*; +import gridsim.turbo.ARCBMultiplePartitions; import gridsim.turbo.ARParallelSpaceShared; -import gridsim.turbo.CBMultipleQueues; +import gridsim.turbo.CBMultiplePartitions; import gridsim.turbo.EBParallelSpaceShared; import gridsim.turbo.CBParallelSpaceShared; -import gridsim.turbo.EBMultipleQueues; +import gridsim.turbo.EBMultiplePartitions; import gridsim.turbo.TResourceCharacteristics; import gridsim.index.*; @@ -535,12 +536,10 @@ super.sim_get_next(ev); // if the simulation finishes then exit the loop - if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) - { + if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) { policy_.setEndSimulation(); break; } - // process the received event processEvent(ev); } @@ -648,16 +647,21 @@ break; // creates the scheduler with only one queue - case TResourceCharacteristics.MULTI_EASY_BACKFILLING_QUEUES: - policy_ = new EBMultipleQueues(super.get_name(), + case TResourceCharacteristics.EB_MULTI_PARTITIONS: + policy_ = new EBMultiplePartitions(super.get_name(), "EBMultipleQueues", 1); break; - case TResourceCharacteristics.MULTI_CONSERVATIVE_BACKFILLING_QUEUES: - policy_ = new CBMultipleQueues(super.get_name(), + case TResourceCharacteristics.CB_MULTI_PARTITIONS: + policy_ = new CBMultiplePartitions(super.get_name(), "CBMultipleQueues", 1); break; + case TResourceCharacteristics.ARCB_MULTI_PARTITIONS: + policy_ = new ARCBMultiplePartitions(super.get_name(), + "ARCBMultipleQueues", 1); + break; + default: throw new Exception(super.get_name()+" : Error - supports"+ " only TimeShared or SpaceShared policy."); Copied: branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java (from rev 105, branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultipleQueues.java) =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-02-18 04:25:19 UTC (rev 106) @@ -0,0 +1,1144 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + */ + +package gridsim.turbo; + +import eduni.simjava.Sim_event; +import gridsim.GridSim; +import gridsim.GridSimTags; +import gridsim.Gridlet; +import gridsim.IO_data; +import gridsim.gui.AllocationAction; + +import java.util.Calendar; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; + +/** + * This class implements a non-FCFS policy to schedule parallel jobs. The + * policy is based on conservative backfilling and supports advance reservation. + * This policy can use multiple partitions or queues and the jobs can be + * directed to these partitions using a partition predicate + * ({@link QueuePartitionPredicate}. A partition can borrow resources from + * another when it requires and the resources are not being used by the + * other partition. + * + * We use an availability profile to store the availability of processing + * elements. In order to represent the pivots (i.e. the first jobs in the + * partitions), we schedule them creating the entries in the availability + * profile. This way, we do not need to store the pivots' start times + * (or shadow times) and extra nodes in different variables. It also makes + * the search for available resources for a new pivot easier. + * <p> + * <b>LIMITATIONS:</b><br> + * <ul> + * <li> The list of machines comprising this resource must be + * homogeneous. + * <li> Local load is not considered. If you would like to simulate this, + * you have to model the local load as gridlets. It is more precise + * and faster. To do so, please check {@link Lublin99Workload}. + * <li> Gridlets cannot be paused nor migrated. + * </ul> + * + * @see gridsim.GridSim + * @see gridsim.ResourceCharacteristics + * @see gridsim.turbo.TAllocPolicy + * @see gridsim.turbo.CBMultiplePartitions + * @see gridsim.turbo.QueuePartitionPredicate + * @see gridsim.turbo.PERange + * @see gridsim.turbo.PERangeList + */ + +public class ARCBMultiplePartitions extends + CBMultiplePartitions implements ARTPolicy { + + // a new reservation table + private LinkedHashMap<Integer, SSReservation> reservTable_; + + // a table that contains expired reservations + private LinkedHashMap<Integer, SSReservation> expiryTable_; + + // default booking/reservation commit period + private int commitPeriod_; + + // internal event tags used by this gridlet + // a tag to denote expiry time + private final int EXPIRY_TIME = 12; + + // last time the expiration of reservations was checked + private double lastCheckExpiryTime_; + + /** + * Allocates a new <tt>CBMultipleQueues</tt> object. + * If the policy is create with only one partition, it will then work as + * a normal aggressive (EASY) backfilling scheduler. + * + * @param resourceName the <tt>GridResource</tt> entity name that will + * contain this allocation policy + * @param entityName this object entity name + * @param numPartitions The number of partitions of the scheduling queue + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> Creating this entity before initialising GridSim package + * <li> The entity name is <tt>null</tt> or empty + * <li> The entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs, which means that the Gridlets cannot be processed. + * A GridResource 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) + */ + public ARCBMultiplePartitions(String resourceName, + String entityName, int numPartitions) throws Exception { + super(resourceName, entityName, numPartitions); + commitPeriod_ = 30*60; // set the expiration time into 30 mins + init(); + } + + /** + * Allocates a new <tt>CBMultipleQueues</tt> object. + * If the policy is create with only one partition, it will then work as + * a normal aggressive (EASY) backfilling scheduler. + * + * @param resourceName the <tt>GridResource</tt> entity name that will + * contain this allocation policy + * @param entityName this object entity name + * @param numPartitions The number of partitions of the scheduling queue + * @param commitPeriod a default commit period time for a user to commit + * a reservation (unit is in second). <b>NOTE:</b> once it is set, you cannot + * change the time again. + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> Creating this entity before initialising GridSim package + * <li> The entity name is <tt>null</tt> or empty + * <li> The entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs, which means that the Gridlets cannot be processed. + * A GridResource 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) + */ + public ARCBMultiplePartitions(String resourceName, + String entityName, int numPartitions, + int commitPeriod) throws Exception { + super(resourceName, entityName, numPartitions); + if (commitPeriod <= 0) { + throw new Exception(resourceName + "." + entityName + + ": Error - Invalid expiry time."); + } + commitPeriod_ = commitPeriod; + init(); + } + + /** + * Handles internal events that come to this entity. + */ + public void body() { + super.body(); + reservTable_.clear(); + expiryTable_.clear(); + lastCheckExpiryTime_ = 0.0D; + } + + // -------------------- GRIDLET RELATED METHODS --------------------- + + /** + * Schedules a new <tt>Gridlet</tt> received by the <tt>GridResource</tt> entity. + * @param gridlet a Gridlet object to be executed + * @param ack an acknowledgement, i.e. <tt>true</tt> if the + * user wants to know whether this operation is successful + * or not, <tt>false</tt> otherwise. + */ + public void gridletSubmit(Gridlet gridlet, boolean ack) { + if(!gridlet.hasReserved()) { + super.gridletSubmit(gridlet, ack); + } + else { + handleReservationGridlet(gridlet, ack); + } + } + + /** + * Schedules a new Gridlet received by the <tt>ARTGridResource</tt> + * entity and for which an advance reservation has been made. + * @param gridlet a Gridlet object to be executed + * @param ack an acknowledgement, i.e. <tt>true</tt> if the + * user wants to know whether this operation is successful + * or not, <tt>false</tt> otherwise. + */ + private void handleReservationGridlet(Gridlet gridlet, boolean ack) { + + double currentTime = GridSim.clock(); + + int freePE; + int reqPE = gridlet.getNumPE(); + // gets the advance reservation + SSReservation sRes = reservTable_.get(gridlet.getReservationID()); + + // create an SSGridlet + SSGridlet sgl = new SSGridlet(gridlet); + + // forecast the execution time of the gridlet + double executionTime = + super.forecastExecutionTime(ratingPE_, sgl.getLength()); + + /////////////// FOR DEBUGGING PURPOSES ONLY //////// + + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_ARRIVED, true, sgl); + + ///////////////////////////////////////////////////// + + boolean success = true; + if(sRes == null) { + String userName = GridSim.getEntityName( gridlet.getUserID() ); + System.out.println(super.get_name() + ".gridletSubmit(): " + + " Gridlet #" + gridlet.getGridletID() + " from " + + userName + " cannot be accepted because the reservation #" + + gridlet.getReservationID() + " has not been found."); + success = false; + } + // check if the gridlet is requiring more PEs than what + // the reservation currently has + else if( (freePE = sRes.getNumRemainingPE()) < reqPE ) { + String userName = GridSim.getEntityName( gridlet.getUserID() ); + System.out.println(super.get_name() + ".gridletSubmit(): " + + " Gridlet #" + gridlet.getGridletID() + " from " + + userName + " cannot be accepted because the reservation #" + + sRes.getID() + " has only " + freePE + " PEs."); + success = false; + } + // check whether the gridlet is expected to run for longer than + // the time previously reserved + else if (executionTime >= sRes.getDurationTime()) { + String userName = GridSim.getEntityName( gridlet.getUserID() ); + System.out.println(super.get_name() + ".gridletSubmit(): " + + " Gridlet #" + gridlet.getGridletID() + " from " + + userName + " cannot be accepted because the reservation #" + + sRes.getID() + " is for " + sRes.getDurationTime() + + " while the gridlet is expected to run for " + + executionTime + " seconds."); + success = false; + } + + if(!success) { + try { + gridlet.setGridletStatus(Gridlet.FAILED); + super.sendFinishGridlet(gridlet); + return; + } + catch(Exception ex){ + System.out.println(super.get_name() + + ": Exception on submission of a Gridlet. Message = " + + ex.getMessage()); + return; + } + } + else { + // selects a list of ranges for the gridlet from the PEs available + // for the reservation + PERangeList selected = null; + success = ( ( selected = sRes.selectPERangeList(reqPE) ) != null ); + + sgl.setPERangeList(selected); + double resStartTime = sRes.getStartTime(); + sgl.setStartTime(resStartTime); + sgl.setFinishTime(resStartTime + executionTime); + sgl.setStatus(Gridlet.QUEUED); + queuedGridlets_.add(sgl); + + // if the reservation has not been committed, then commit the + // reservation + if (sRes.getStatus() == Reservation.STATUS_NOT_COMMITTED) { + sRes.setStatus(Reservation.STATUS_COMMITTED); + super.sendInternalEvent(resStartTime - currentTime, + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + } + // if the reservation has already started, then update the + // schedule, which will force the gridlets in the queue to + // be started + else if(sRes.getStatus() == Reservation.STATUS_IN_PROGRESS) { + super.sendInternalEvent(resStartTime - currentTime, + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + } + } + + //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- + + // Notifies the listeners that a Gridlet has been either scheduled + // to run immediately or put in the waiting queue + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_SCHEDULED, true, sgl); + + //--------------------------------------------------------------- + + // sends back an ack if required + if (ack == true) { + super.sendAck(GridSimTags.GRIDLET_SUBMIT_ACK, true, + gridlet.getGridletID(), gridlet.getUserID() + ); + } + } + + //---------------- RESERVATION RELATED PUBLIC METHODS --------------------- + + /** + * Handles an advance reservation request.<br> + * @param message the advance reservation message received + * @pre message != null + */ + public void handleCreateReservation(ARMessage message) { + double currentTime = GridSim.clock(); + + // gets the reservation object and extract some + // information from it + Reservation reservation = message.getReservation(); + double startTime = reservation.getStartTime(); + int duration = reservation.getDurationTime(); + int reqPE = reservation.getNumPE(); + + // creates a Server Side Reservation (i.e. SSReservation) + SSReservation sRes = new SSReservation(reservation); + sRes.setPartitionID(profile_.getCorrespondingPartitionID(sRes)); + double expTime = Double.NaN; + + // creates a response message to be sent to the requester + ARMessage response = message.createResponse(); + + //-------------- FOR DEBUGGING PURPOSES ONLY -------------- + + // informs the listeners that a reservation request has arrived + GridSim.notifyListeners(this.get_id(), + AllocationAction.ITEM_ARRIVED, true, sRes); + + //---------------------------------------------------------- + + if (reqPE > super.totalPE_) { + String userName = GridSim.getEntityName( message.getSourceID() ); + System.out.println(super.get_name() + ".handleCreateReservation():" + + " Reservation #" + reservation.getID() + " from " + + userName + " user requires " + reservation.getNumPE() + + " PEs from " + startTime + " to " + (startTime + duration)); + System.out.println("--> The resource has only " + + super.totalPE_ + " PEs available."); + + reservation.setStatus(Reservation.STATUS_FAILED); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); + sendARMessage(response); + return; + } + + boolean success = true; + + // if start time is 0, then it is an immediate reservation + if(startTime == 0 || startTime == currentTime) { + success = handleImmediateReservation(sRes); + expTime = sRes.getFinishTime(); + } + else { + success = handleAdvanceReservation(sRes); + expTime = currentTime + commitPeriod_; + } + + if(!success) { + String userName = GridSim.getEntityName( message.getSourceID() ); + System.out.println(super.get_name() + ".handleCreateReservation():" + + " Reservation #" + reservation.getID() + " from " + + userName + " user requires " + reservation.getNumPE() + + " PEs from " + startTime + " to " + (startTime + duration)); + System.out.println("--> The resource could not handle the reservation."); + + reservation.setStatus(Reservation.STATUS_FAILED); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); + sendARMessage(response); + return; + } + + // if the expiration time is greater than the start time of the + // reservation, then set the expiration time as the start time + if(expTime > startTime) { + expTime = startTime; + } + + // if the start time of the reservation is equals to the current + // time, meaning that it is an immediate reservation, then start + // the reservation straight away. Therefore, sets the status to + // committed and sends an internal event to start the reservation + if(currentTime == startTime) { + sRes.setStatus(Reservation.STATUS_COMMITTED); + super.sendInternalEvent(GridSimTags.SCHEDULE_NOW, + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + } + else { + sRes.setStatus(Reservation.STATUS_NOT_COMMITTED); + } + + sRes.setExpiryTime(expTime); + + // add the reservation into the reservation table and sends the + // response message to the requester + reservTable_.put(new Integer(sRes.getID()), sRes); + sendARMessage(response); + + // then send this into itself to check for expired reservations + super.sendInternalEvent(expTime - currentTime, + EXPIRY_TIME); + + //-------------- FOR DEBUGGING PURPOSES ONLY -------------- + + // Informs the listeners about the reservation that has been created + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_SCHEDULED, + true, sRes); + } + + /** + * Handles a commit reservation request. + * @param message the advance reservation message received + */ + public void handleCommitReservation(ARMessage message) { + + // gets the reservation id of the message + int reservationId = message.getReservationID(); + SSReservation sRes = null; + + // creates a response message to be sent to the requester + ARMessage response = message.createResponse(); + boolean success = true; + + // Tries to find the reservation in the lists + if(reservTable_.containsKey(reservationId)) { + sRes = reservTable_.get(reservationId); + } + else if(expiryTable_.containsKey(reservationId)) { + sRes = expiryTable_.get(reservationId); + switch(sRes.getStatus()) { + case Reservation.STATUS_CANCELLED: + System.out.println(super.get_name() + ".handleCommitReservation()" + + " Reservation # " + reservationId + + " cannot be committed because it has" + + " previously been cancelled by the allocation policy."); + break; + case Reservation.STATUS_FINISHED: + System.out.println(super.get_name() + ".handleCommitReservation()" + + " Reservation # " + reservationId + + " cannot be committed because it has finished."); + break; + default: + System.out.println(super.get_name() + ".handleCommitReservation()" + + " Reservation # " + reservationId + + " cannot be committed because it is in the expiry list."); + break; + } + success = false; + } + else { + System.out.println(super.get_name() + ".handleCommitReservation() " + + "Reservation # " + reservationId + " cannot be committed "+ + "because the allocation policy could not find it."); + success = false; + } + + // if there was no success, then sets the error code to failure and + // sends the message back to the requester + if(!success) { + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); + sendARMessage(response); + return; + } + + // sets the reservation to committed if it has not been set before + if(sRes.getStatus() == Reservation.STATUS_NOT_COMMITTED) { + sRes.setStatus(Reservation.STATUS_COMMITTED); + + // then send this into itself to start the reservation + super.sendInternalEvent(sRes.getStartTime() - GridSim.clock(), + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + } + + // sends the response message with no error + sendARMessage(response); + + //-------------- FOR DEBUGGING PURPOSES ONLY -------------- + + GridSim.notifyListeners(this.get_id(), + AllocationAction.ITEM_STATUS_CHANGED, true, sRes); + + //---------------------------------------------------------- + } + + /** + * Handles a modify reservation request<br> + * (NOTE: <b>NOT SUPPORTED YET</b>). + * @param message the advance reservation message received. + */ + public void handleModifyReservation(ARMessage message) { + System.out.println(super.get_name() + + ".handleModifyReservation(): not supported at the moment."); + } + + /** + * Handles a cancel reservation request<br> + * (NOTE: <b>NOT SUPPORTED YET</b>). + * @param message the advance reservation message received. + */ + public void handleCancelReservation(ARMessage message) { + System.out.println(super.get_name() + + ".handleCancelReservation(): not supported at the moment."); + } + + /** + * Handles a query free time request. + * @param message the advance reservation message received. + */ + public void handleQueryAvailability(ARMessage message) { + // gets the reservation id of the message + Reservation reservation = message.getReservation(); + + // creates a response message to be sent to the requester + ARMessage response = message.createResponse(); + + // gets the start time and finish time the user is interested in + double startTime = reservation.getStartTime(); + int duration = reservation.getDurationTime(); + + // gets the availability information from the availability profile + AvailabilityInfo availability = getAvailabilityInfo(startTime, duration); + + // sets the options as the availability over the requested period + response.getReservation().setReservationOptions(availability); + + // Sends the response back to the user + sendARMessage(response); + } + + /** + * Handles a query reservation request. + * @param message the advance reservation message received. + */ + public void handleQueryReservation(ARMessage message) { + + // gets the reservation id of the message + int reservationId = message.getReservationID(); + + // creates a response message to be sent to the requester + ARMessage response = message.createResponse(); + + // Tries to find the reservation in the lists + if(!reservTable_.containsKey(reservationId) + && !expiryTable_.containsKey(reservationId) ) { + System.out.println(super.get_name() + ".handleQueryReservation()" + + " Error querying the status of reservation # " + reservationId + + " because Grid Resource #" + super.resId_ + + " could not find it."); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); + } + + // Just sends the message because the reply has a reference to + // the reservation object, which contains the status of the reservation + sendARMessage(response); + } + + /** + * Process and event sent to this entity + * @param ev the event to be handled + */ + public void processOtherEvent(Sim_event ev) { + + // handle an internal event + double currentTime = GridSim.clock(); + + if(ev.get_src() == myId_) { + switch(ev.get_tag()) { + + // checks the expiry time for a given gridlet + case EXPIRY_TIME: + if(currentTime > lastCheckExpiryTime_) { + checkExpiryTime(); + } + lastCheckExpiryTime_ = currentTime; + break; + + default: + super.processOtherEvent(ev); + break; + } + } + else + super.processOtherEvent(ev); + } + + // --------------------- PROTECTED METHODS ----------------------- + + /** + * This method is called to update the schedule. It removes completed + * gridlets and return them to the users and verifies whether there are + * gridlets in the waiting list that should start execution. It also + * removes old entries from the availability profile. + */ + protected void updateSchedule() { + + int itemsFinished = 0; + double currentTime = GridSim.clock(); + int itemsStarted = 0; + + // finishes the advance reservations first + itemsFinished = finishReservation(currentTime); + + // then finishes the Gridlets whose start time is smaller + // or equals to the current simulation time + itemsFinished += super.finishRunningGridlets(currentTime); + + // remove past entries from the availability profile + MPProfileEntry currentStatus = profile_.removePastEntries(currentTime); + if(currentStatus != null) { + profile_.setCurrentStatus(currentStatus); + resource_.resetFreePERanges(currentStatus.getPERanges()); + } + + // starts the advance reservations + itemsStarted = startReservation(currentTime); + + // Start the execution of Gridlets that are queued and whose + // potential start execution time is smaller than current time + itemsStarted += super.startQueuedGridlets(currentTime); + + //---------------- USED FOR DEBUGGING PURPOSES ONLY -------------------- + + // If a gridlet has started execution or one has finished, + // then inform the listeners + if(itemsStarted > 0 || itemsFinished > 0){ + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + } + } + + /** + * This method is called to finish a reservation and consequently update + * the availability profile. + * @param refTime the time reference to check what reservations should + * be finished. All reservations whose finish time is smaller or + * equals to refTime will be completed + * @return the number of reservations completed + */ + protected int finishReservation(double refTime) { + int reservationFinished = 0; + + Iterator<SSReservation> iterRes = reservTable_.values().iterator(); + while(iterRes.hasNext()) { + SSReservation sRes = iterRes.next(); + if(sRes.getFinishTime() <= refTime) { + // Finish the reservation and include ranges in the + // list of ranges to be released + sRes.setStatus(Reservation.STATUS_FINISHED); + reservationFinished++; + iterRes.remove(); + expiryTable_.put(sRes.getID(), sRes); + } + } + + if(reservationFinished > 0) { + + //------------- USED FOR DEBUGGING PURPOSES ONLY ------------------ + + // If a gridlet has started execution or one has finished, + // then inform the listeners + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + + //----------------------------------------------------------------- + } + + return reservationFinished; + } + + /** + * This method is called to start a reservation and consequently update + * the availability profile. + * @refTime the reservations whose start time is smaller + * or equals to refTime will be started + */ + protected int startReservation(double refTime) { + LinkedList<SSReservation> startedReservations = new LinkedList<SSReservation>(); + int numStartedRes = 0; + + Iterator<SSReservation> iterRes = reservTable_.values().iterator(); + while(iterRes.hasNext()) { + SSReservation sRes = iterRes.next(); + + if(sRes.getStartTime() <= refTime && + sRes.getStatus() == Reservation.STATUS_COMMITTED) { + + // Start the reservation and update the ranges of + // PEs currently available + sRes.setStatus(Reservation.STATUS_IN_PROGRESS); + + startedReservations.add(sRes); + + super.sendInternalEvent(sRes.getFinishTime()-refTime, + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + + numStartedRes++; + } + } + return numStartedRes; + } + + /** + * This method returns a list that corresponds to the free time slots + * in the scheduling queue managed by this scheduler or + * resource allocation policy. + * + * @param startTime the start time in which the requester is interested. + * @param duration the duration in which the requester is interested. + * @return the list of free time slots. The list is actually a list of + * entries that correspond to the availability profile between the times + * specified by the requester. + */ + protected AvailabilityInfo getAvailabilityInfo(double startTime, int duration) { + + AvailabilityInfo list = new AvailabilityInfo(); + int anchorIndex = -1; + double currentTime = GridSim.clock(); + + // if the user specified the start time as 0, it means that the + // user is interested to know the availability starting from the + // current time, or the time when the resource received this request + if(startTime == 0) { + startTime = currentTime; + } + + list.setStartTime(startTime); + + // calculate the reservation's finish time + double finishTime = startTime + duration; + list.setFinishTime(finishTime); + + // a pointer to the anchor entry (described above) + MPProfileEntry anchorEntry = null; + int length = profile_.size(); + AvailabilityInfoEntry firstEntry = null; + + anchorEntry = (startTime <= currentTime) ? null : + profile_.getPrecedingEntry(startTime); + + // if the entry is null, then it means that the reservation is + // before the first entry of the profile, so the intersection list + // has to start with the ranges of PEs currently available + if (anchorEntry == null) { + PERangeList peList = (resource_.getFreePERanges() == null) ? + new PERangeList() : resource_.getFreePERanges().clone(); + firstEntry = + new AvailabilityInfoEntry(startTime, peList); + } + else { + PERangeList newList = anchorEntry.getPERanges(); + newList = (newList != null) ? newList.clone() : new PERangeList(); + firstEntry = new AvailabilityInfoEntry(startTime, newList); + anchorIndex = profile_.indexOf(anchorEntry); + } + + list.add(firstEntry); + AvailabilityInfoEntry previousEntry = firstEntry; + + // Iterates the availability profile and adds all the entries + // whose times are between start and finish time in the list + // to be returned. It removes repeated entries. + for(int i=anchorIndex+1; i<length; i++) { + MPProfileEntry nextEntry = profile_.get(i); + if(nextEntry.getTime() <= startTime) + continue; + if(nextEntry.getTime() > finishTime){ + break; + } + else { + PERangeList peList = nextEntry.getPERanges(); + peList = (peList != null) ? peList.clone() : new PERangeList(); + + if( !previousEntry.getAvailRanges().equals(peList)) { + AvailabilityInfoEntry tsEntry = + new AvailabilityInfoEntry(nextEntry.getTime(), peList); + list.add(tsEntry); + previousEntry = tsEntry; + } + } + } + + return list; + } + + /** + * This method returns a list that corresponds to the free time slots + * in the scheduling queue managed by this scheduler or + * resource allocation policy. This returns the resources available + * for a given partition. + * @param queueId the id of the partition whose availability is to be queried. + * @param startTime the start time in which the requester is interested. + * @param duration the duration in which the requester is interested. + * @return the list of free time slots. The list is actually a list of + * entries that correspond to the availability profile between the times + * specified by the requester. + */ + protected AvailabilityInfo getAvailabilityInfo(int queueId, + double startTime, int duration) { + + AvailabilityInfo list = new AvailabilityInfo(); + int anchorIndex = -1; + double currentTime = GridSim.clock(); + QueuePartition partition = profile_.getPartition(queueId); + + // if the user specified the start time as 0, it means that the + // user is interested to know the availability starting from the + // current time, or the time when the resource received this request + if(startTime == 0) { + startTime = currentTime; + } + + list.setStartTime(startTime); + + // calculate the reservation's finish time + double finishTime = startTime + duration; + list.setFinishTime(finishTime); + + // a pointer to the anchor entry (described above) + MPProfileEntry anchorEntry = null; + int length = profile_.size(); + AvailabilityInfoEntry firstEntry = null; + + anchorEntry = (startTime <= currentTime) ? null : + profile_.getPrecedingEntry(startTime); + + // if the entry is null, then it means that the reservation is + // before the first entry of the profile, so the intersection list + // has to start with the ranges of PEs currently available + if (anchorEntry == null) { + PERangeList peList = (partition.getIdlePERanges() == null) ? + new PERangeList() : partition.getIdlePERanges().clone(); + firstEntry = + new AvailabilityInfoEntry(startTime, peList); + } + else { + PERangeList newList = anchorEntry.getPERanges(queueId); + newList = (newList != null) ? newList.clone() : new PERangeList(); + firstEntry = new AvailabilityInfoEntry(startTime, newList); + anchorIndex = profile_.indexOf(anchorEntry); + } + + list.add(firstEntry); + AvailabilityInfoEntry previousEntry = firstEntry; + + // Iterates the availability profile and adds all the entries + // whose times are between start and finish time in the list + // to be returned. It removes repeated entries. + for(int i=anchorIndex+1; i<length; i++) { + MPProfileEntry nextEntry = profile_.get(i); + if(nextEntry.getTime() <= startTime) + continue; + if(nextEntry.getTime() > finishTime){ + break; + } + else { + PERangeList peList = nextEntry.getPERanges(queueId); + peList = (peList != null) ? peList.clone() : new PERangeList(); + + if( !previousEntry.getAvailRanges().equals(peList)) { + AvailabilityInfoEntry tsEntry = + new AvailabilityInfoEntry(nextEntry.getTime(), peList); + list.add(tsEntry); + previousEntry = tsEntry; + } + } + } + + return list; + } + + /** + * Sends a reservation message. + * @param message the message to be sent + */ + protected void sendARMessage(ARMessage message) { + // send message to the destination + super.sim_schedule(super.outputPort_, GridSimTags.SCHEDULE_NOW, + message.getMessageTyp... [truncated message content] |
From: <mar...@us...> - 2008-02-28 04:11:40
|
Revision: 137 http://gridsim.svn.sourceforge.net/gridsim/?rev=137&view=rev Author: marcos_dias Date: 2008-02-27 20:11:36 -0800 (Wed, 27 Feb 2008) Log Message: ----------- Inclusion of a parallel space shared policy with queue partitions, easy backfilling, priorities and advance reservation. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java branches/gridsim4.0-branch3/source/gridsim/GridResource.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARTGridResource.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java Added Paths: ----------- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java Modified: branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java 2008-02-27 23:37:51 UTC (rev 136) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java 2008-02-28 04:11:36 UTC (rev 137) @@ -63,7 +63,7 @@ * <tt>java -Xmx</tt> option when running the simulation. * <li> If you are running an experiment using the network extension, * i.e. the gridsim.net package, then you need to use - * {@link #Workload(String, double, double, int, String, String, int)} + * {@link #WorkloadWithReservation(String, double, double, int, String, String, int)} * instead. * <li> The default job file size for sending to and receiving from * a resource is {@link gridsim.net.Link#DEFAULT_MTU}. @@ -605,10 +605,12 @@ Gridlet gl = null; int counter = 1; // starts at 1, since gridletID_ starts at 1 too + int fails = 0; + int returned = 0; Sim_event ev = new Sim_event(); Object[] reservObj = null; - while ( Sim_system.running() && counter < gridletID_ ) { + while ( Sim_system.running()) { super.sim_get_next(ev); // get the next available event data = ev.get_data(); // get the event's data @@ -668,6 +670,7 @@ if(!success) { list_.add(resGl); counter++; + fails++; } } @@ -676,9 +679,16 @@ gl = (Gridlet) data; list_.add(gl); counter++; + returned++; } + + if(counter == gridletID_) + break; } +// System.out.println("gridlet ID = " + gridletID_ +// + ", fails = " + fails + ", returned = " + returned + ", counter=" + counter); + // shut down all the entities, including GridStatistics entity since // we used it to record certain events. shutdownGridStatisticsEntity(); Added: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java (rev 0) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java 2008-02-28 04:11:36 UTC (rev 137) @@ -0,0 +1,206 @@ + +package examples.workload.ar; + +import examples.QueuePredicateExample; +import examples.WorkloadWithReservation; +import gridsim.GridResource; +import gridsim.GridSim; +import gridsim.Machine; +import gridsim.MachineList; +import gridsim.ResourceCalendar; +import gridsim.turbo.AREBMultiplePartitions; +import gridsim.turbo.ARTGridResource; +import gridsim.turbo.TResourceCharacteristics; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.Random; + + +/** + * Test Driver class for this example. This example just tests + * the same features provided by the ParallelSpaceShared policy + */ +public class TurboAREBMultipleQueuesExample01 +{ + /** + * Creates main() to run this example + */ + public static void main(String[] args) + { + long startTime = System.currentTimeMillis(); + if(args.length == 0){ + System.out.println("Please provide the location of the workload file!"); + System.exit(1); + } + + try { + + ////////////////////////////////////////// + // Get the workload to be used The format should be: + // ASCII text, gzip or zip. + + String fileName = args[0]; + ArrayList<GridResource> resources = new ArrayList<GridResource>(); + + ////////////////////////////////////////// + // Initialize the GridSim package. It should be called + // before creating any entities. We can't run this example without + // initializing GridSim first. We will get run-time exception + // error. + + // number of grid user entities + any Workload entities. + int num_user = 1; + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace GridSim events + + // Initialize the GridSim package without any statistical + // functionalities. Hence, no GridSim_stat.txt file is created. + System.out.println("Initializing GridSim package"); + GridSim.init(num_user, calendar, trace_flag); + + ////////////////////////////////////////// + // Creates one or more GridResource entities + int totalResource = 1; // total number of Grid resources + int rating = 377; // rating of each PE in MIPS + int totalPE = 9; // total number of PEs for each Machine + int totalMachine = 128; // total number of Machines + int i = 0; + + String[] resArray = new String[totalResource]; + for (i = 0; i < totalResource; i++) + { + String resName = "Res_" + i; + GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); + resources.add(resource); + + // add a resource name into an array + resArray[i] = resName; + } + + ////////////////////////////////////////// + // Creates one Workload trace entity. + + int resID = 0; + Random r = new Random(); + resID = r.nextInt(totalResource); + WorkloadWithReservation workload = + new WorkloadWithReservation("Load_1", fileName, resArray[resID], rating); + + // sets how long in advance the reservations are made (24 hours here) + workload.setARTimeInAdvance( 24 * 60 * 60 ); + + // sets the probability of a job read from the trace file being an advance reservation + workload.setReservationProbability(0.5); + + ////////////////////////////////////////// + // Starts the simulation in debug mode +// GridSim.startGridSimulation(true); + + // Start the simulation in normal mode + GridSim.startGridSimulation(); + + ////////////////////////////////////////// + // Final step: Prints the Gridlets when simulation is over + long finishTime = System.currentTimeMillis(); + System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); + + // prints the Gridlets inside a Workload entity + // workload.printGridletList(trace_flag); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates one Grid resource. A Grid resource contains one or more + * Machines. Similarly, a Machine contains one or more PEs (Processing + * Elements or CPUs). + * @param name a Grid Resource name + * @param peRating rating of each PE + * @param totalMachine total number of Machines + * @param totalPE total number of PEs for each Machine + */ + private static GridResource createGridResource(String name, int peRating, + int totalMachine, int totalPE) + { + + ////////////////////////////////////////// + // Here are the steps needed to create a Grid resource: + // 1. We need to create an object of MachineList to store one or more + // Machines + MachineList mList = new MachineList(); + + for (int i = 0; i < totalMachine; i++) + { + ////////////////////////////////////////// + // 4. Create one Machine with its id and list of PEs or CPUs + mList.add( new Machine(i, totalPE, peRating) ); + } + + ////////////////////////////////////////// + // 5. Create a ResourceCharacteristics object that stores the + // properties of a Grid resource: architecture, OS, list of + // Machines, allocation policy: time- or space-shared, time zone + // and its price (G$/PE time unit). + String arch = "Sun Ultra"; // system architecture + String os = "Solaris"; // operating system + double time_zone = 0.0; // time zone this resource located + double cost = 3.0; // the cost of using this resource + + TResourceCharacteristics resConfig = + new TResourceCharacteristics(arch, os, mList, + TResourceCharacteristics.AREB_MULTI_PARTITIONS, + time_zone, cost); + + AREBMultiplePartitions policy = null; + try { + policy = new AREBMultiplePartitions(name, "Policy", 3); + } catch (Exception e1) { + e1.printStackTrace(); + } + + // creates three partitions, one for small jobs, one for medium size jobs + // and another for long jobs + QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); + QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); + QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + + policy.createPartition(0, resConfig.getNumPE() / 3, express); + policy.createPartition(1, resConfig.getNumPE() / 3, medium); + policy.createPartition(2, resConfig.getNumPE() / 3, large); + + ////////////////////////////////////////// + // 6. Finally, we need to create a GridResource object. + double baud_rate = 10000.0; // communication speed + long seed = 11L*13*17*19*23+1; + double peakLoad = 0.0; // the resource load during peak hour + double offPeakLoad = 0.0; // the resource load during off-peak hr + double holidayLoad = 0.0; // the resource load during holiday + + // incorporates weekends so the grid resource is on 7 days a week + LinkedList weekends = new LinkedList(); + weekends.add(new Integer(Calendar.SATURDAY)); + weekends.add(new Integer(Calendar.SUNDAY)); + + // incorporates holidays. However, no holidays are set in this example + LinkedList holidays = new LinkedList(); + ResourceCalendar resCalendar = new ResourceCalendar(time_zone, + peakLoad, offPeakLoad, holidayLoad, weekends, + holidays, seed); + + ARTGridResource gridRes = null; + try { + gridRes = new ARTGridResource(name, baud_rate, resConfig, resCalendar, policy); + } + catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("Creates one Grid resource with name = " + name); + return gridRes; + } +} // end class + Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-02-27 23:37:51 UTC (rev 136) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-02-28 04:11:36 UTC (rev 137) @@ -85,10 +85,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode - GridSim.startGridSimulation(true); +// GridSim.startGridSimulation(true); // Start the simulation in normal mode -// GridSim.startGridSimulation(); + GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over Modified: branches/gridsim4.0-branch3/source/gridsim/GridResource.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/GridResource.java 2008-02-27 23:37:51 UTC (rev 136) +++ branches/gridsim4.0-branch3/source/gridsim/GridResource.java 2008-02-28 04:11:36 UTC (rev 137) @@ -11,6 +11,7 @@ import gridsim.net.*; import gridsim.turbo.ARCBMultiplePartitions; +import gridsim.turbo.AREBMultiplePartitions; import gridsim.turbo.ARParallelSpaceShared; import gridsim.turbo.CBMultiplePartitions; import gridsim.turbo.EBParallelSpaceShared; @@ -662,6 +663,11 @@ "ARCBMultipleQueues", 1); break; + case TResourceCharacteristics.AREB_MULTI_PARTITIONS: + policy_ = new AREBMultiplePartitions(super.get_name(), + "AREBMultipleQueues", 1); + break; + default: throw new Exception(super.get_name()+" : Error - supports"+ " only TimeShared or SpaceShared policy."); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-02-27 23:37:51 UTC (rev 136) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARCBMultiplePartitions.java 2008-02-28 04:11:36 UTC (rev 137) @@ -29,11 +29,7 @@ * other partition. * * We use an availability profile to store the availability of processing - * elements. In order to represent the pivots (i.e. the first jobs in the - * partitions), we schedule them creating the entries in the availability - * profile. This way, we do not need to store the pivots' start times - * (or shadow times) and extra nodes in different variables. It also makes - * the search for available resources for a new pivot easier. + * elements. * <p> * <b>LIMITATIONS:</b><br> * <ul> @@ -74,9 +70,9 @@ private double lastCheckExpiryTime_; /** - * Allocates a new <tt>CBMultipleQueues</tt> object. + * Allocates a new <tt>ARCBMultipleQueues</tt> object. * If the policy is create with only one partition, it will then work as - * a normal aggressive (EASY) backfilling scheduler. + * a conservative backfilling scheduler. * * @param resourceName the <tt>GridResource</tt> entity name that will * contain this allocation policy @@ -104,9 +100,9 @@ } /** - * Allocates a new <tt>CBMultipleQueues</tt> object. + * Allocates a new <tt>ARCBMultipleQueues</tt> object. * If the policy is create with only one partition, it will then work as - * a normal aggressive (EASY) backfilling scheduler. + * a conservative backfilling scheduler. * * @param resourceName the <tt>GridResource</tt> entity name that will * contain this allocation policy @@ -591,7 +587,7 @@ int itemsStarted = 0; // finishes the advance reservations first - itemsFinished = finishReservation(currentTime); + itemsFinished = finishReservations(currentTime); // then finishes the Gridlets whose start time is smaller // or equals to the current simulation time @@ -605,11 +601,11 @@ } // starts the advance reservations - itemsStarted = startReservation(currentTime); + itemsStarted = startReservations(currentTime); // Start the execution of Gridlets that are queued and whose // potential start execution time is smaller than current time - itemsStarted += super.backfillGridlets(currentTime); + itemsStarted += super.startQueuedGridlets(currentTime); //---------------- USED FOR DEBUGGING PURPOSES ONLY -------------------- @@ -628,7 +624,7 @@ * equals to refTime will be completed * @return the number of reservations completed */ - protected int finishReservation(double refTime) { + protected int finishReservations(double refTime) { int reservationFinished = 0; Iterator<SSReservation> iterRes = reservTable_.values().iterator(); @@ -664,7 +660,7 @@ * @refTime the reservations whose start time is smaller * or equals to refTime will be started */ - protected int startReservation(double refTime) { + protected int startReservations(double refTime) { LinkedList<SSReservation> startedReservations = new LinkedList<SSReservation>(); int numStartedRes = 0; Added: branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java (rev 0) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AREBMultiplePartitions.java 2008-02-28 04:11:36 UTC (rev 137) @@ -0,0 +1,1145 @@ +/* + * Title: GridSim Toolkit + * Description: GridSim (Grid Simulation) Toolkit for Modelling and Simulation + * of Parallel and Distributed Systems such as Clusters and Grids + * Licence: GPL - http://www.gnu.org/copyleft/gpl.html + */ + +package gridsim.turbo; + +import eduni.simjava.Sim_event; +import gridsim.GridSim; +import gridsim.GridSimTags; +import gridsim.Gridlet; +import gridsim.IO_data; +import gridsim.gui.AllocationAction; + +import java.util.Calendar; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; + +/** + * This class implements a non-FCFS policy to schedule parallel jobs. The + * policy is based on easy backfilling and supports advance reservation. + * This policy can use multiple partitions or queues and the jobs can be + * directed to these partitions using a partition predicate + * ({@link QueuePartitionPredicate}. A partition can borrow resources from + * another when it requires and the resources are not being used by the + * other partition. + * + * We use an availability profile to store the availability of processing + * elements. In order to represent the pivots (i.e. the first jobs in the + * partitions), we schedule them creating the entries in the availability + * profile. This way, we do not need to store the pivots' start times + * (or shadow times) and extra nodes in different variables. It also makes + * the search for available resources for a new pivot easier. + * <p> + * <b>LIMITATIONS:</b><br> + * <ul> + * <li> The list of machines comprising this resource must be + * homogeneous. + * <li> Local load is not considered. If you would like to simulate this, + * you have to model the local load as gridlets. It is more precise + * and faster. To do so, please check {@link Lublin99Workload}. + * <li> Gridlets cannot be paused nor migrated. + * </ul> + * + * @see gridsim.GridSim + * @see gridsim.ResourceCharacteristics + * @see gridsim.turbo.TAllocPolicy + * @see gridsim.turbo.EBMultiplePartitions + * @see gridsim.turbo.QueuePartitionPredicate + * @see gridsim.turbo.PERange + * @see gridsim.turbo.PERangeList + */ + +public class AREBMultiplePartitions extends + EBMultiplePartitions implements ARTPolicy { + + // a new reservation table + private LinkedHashMap<Integer, SSReservation> reservTable_; + + // a table that contains expired reservations + private LinkedHashMap<Integer, SSReservation> expiryTable_; + + // default booking/reservation commit period + private int commitPeriod_; + + // internal event tags used by this gridlet + // a tag to denote expiry time + private final int EXPIRY_TIME = 12; + + // last time the expiration of reservations was checked + private double lastCheckExpiryTime_; + + /** + * Allocates a new <tt>AREBMultiplePartitions</tt> object. + * If the policy is create with only one partition, it will then work as + * a normal aggressive (EASY) backfilling scheduler. + * + * @param resourceName the <tt>GridResource</tt> entity name that will + * contain this allocation policy + * @param entityName this object entity name + * @param numPartitions The number of partitions of the scheduling queue + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> Creating this entity before initialising GridSim package + * <li> The entity name is <tt>null</tt> or empty + * <li> The entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs, which means that the Gridlets cannot be processed. + * A GridResource 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) + */ + public AREBMultiplePartitions(String resourceName, + String entityName, int numPartitions) throws Exception { + super(resourceName, entityName, numPartitions); + commitPeriod_ = 30*60; // set the expiration time into 30 mins + init(); + } + + /** + * Allocates a new <tt>AREBMultiplePartitions</tt> object. + * If the policy is create with only one partition, it will then work as + * a normal aggressive (EASY) backfilling scheduler. + * + * @param resourceName the <tt>GridResource</tt> entity name that will + * contain this allocation policy + * @param entityName this object entity name + * @param numPartitions The number of partitions of the scheduling queue + * @param commitPeriod a default commit period time for a user to commit + * a reservation (unit is in second). <b>NOTE:</b> once it is set, you cannot + * change the time again. + * @throws Exception This happens when one of the following scenarios occur: + * <ul> + * <li> Creating this entity before initialising GridSim package + * <li> The entity name is <tt>null</tt> or empty + * <li> The entity has <tt>zero</tt> number of PEs (Processing + * Elements). <br> + * No PEs, which means that the Gridlets cannot be processed. + * A GridResource 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) + */ + public AREBMultiplePartitions(String resourceName, + String entityName, int numPartitions, + int commitPeriod) throws Exception { + super(resourceName, entityName, numPartitions); + if (commitPeriod <= 0) { + throw new Exception(resourceName + "." + entityName + + ": Error - Invalid expiry time."); + } + commitPeriod_ = commitPeriod; + init(); + } + + /** + * Handles internal events that come to this entity. + */ + public void body() { + super.body(); + reservTable_.clear(); + expiryTable_.clear(); + lastCheckExpiryTime_ = 0.0D; + } + + // -------------------- GRIDLET RELATED METHODS --------------------- + + /** + * Schedules a new <tt>Gridlet</tt> received by the <tt>GridResource</tt> entity. + * @param gridlet a Gridlet object to be executed + * @param ack an acknowledgement, i.e. <tt>true</tt> if the + * user wants to know whether this operation is successful + * or not, <tt>false</tt> otherwise. + */ + public void gridletSubmit(Gridlet gridlet, boolean ack) { + if(!gridlet.hasReserved()) { + super.gridletSubmit(gridlet, ack); + } + else { + handleReservationGridlet(gridlet, ack); + } + } + + /** + * Schedules a new Gridlet received by the <tt>ARTGridResource</tt> + * entity and for which an advance reservation has been made. + * @param gridlet a Gridlet object to be executed + * @param ack an acknowledgement, i.e. <tt>true</tt> if the + * user wants to know whether this operation is successful + * or not, <tt>false</tt> otherwise. + */ + private void handleReservationGridlet(Gridlet gridlet, boolean ack) { + + double currentTime = GridSim.clock(); + + int freePE; + int reqPE = gridlet.getNumPE(); + // gets the advance reservation + SSReservation sRes = reservTable_.get(gridlet.getReservationID()); + + // create an SSGridlet + SSGridlet sgl = new SSGridlet(gridlet); + + // forecast the execution time of the gridlet + double executionTime = + super.forecastExecutionTime(ratingPE_, sgl.getLength()); + + /////////////// FOR DEBUGGING PURPOSES ONLY //////// + + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_ARRIVED, true, sgl); + + ///////////////////////////////////////////////////// + + boolean success = true; + if(sRes == null) { + String userName = GridSim.getEntityName( gridlet.getUserID() ); + System.out.println(super.get_name() + ".gridletSubmit(): " + + " Gridlet #" + gridlet.getGridletID() + " from " + + userName + " cannot be accepted because the reservation #" + + gridlet.getReservationID() + " has not been found."); + success = false; + } + // check if the gridlet is requiring more PEs than what + // the reservation currently has + else if( (freePE = sRes.getNumRemainingPE()) < reqPE ) { + String userName = GridSim.getEntityName( gridlet.getUserID() ); + System.out.println(super.get_name() + ".gridletSubmit(): " + + " Gridlet #" + gridlet.getGridletID() + " from " + + userName + " cannot be accepted because the reservation #" + + sRes.getID() + " has only " + freePE + " PEs."); + success = false; + } + // check whether the gridlet is expected to run for longer than + // the time previously reserved + else if (executionTime >= sRes.getDurationTime()) { + String userName = GridSim.getEntityName( gridlet.getUserID() ); + System.out.println(super.get_name() + ".gridletSubmit(): " + + " Gridlet #" + gridlet.getGridletID() + " from " + + userName + " cannot be accepted because the reservation #" + + sRes.getID() + " is for " + sRes.getDurationTime() + + " while the gridlet is expected to run for " + + executionTime + " seconds."); + success = false; + } + + if(!success) { + try { + gridlet.setGridletStatus(Gridlet.FAILED); + super.sendFinishGridlet(gridlet); + return; + } + catch(Exception ex){ + System.out.println(super.get_name() + + ": Exception on submission of a Gridlet. Message = " + + ex.getMessage()); + return; + } + } + else { + // selects a list of ranges for the gridlet from the PEs available + // for the reservation + PERangeList selected = null; + success = ( ( selected = sRes.selectPERangeList(reqPE) ) != null ); + + sgl.setPERangeList(selected); + double resStartTime = sRes.getStartTime(); + sgl.setStartTime(resStartTime); + sgl.setActualFinishTime(resStartTime + executionTime); + sgl.setStatus(Gridlet.QUEUED); + queuedGridlets_.add(sgl); + + // if the reservation has not been committed, then commit the + // reservation + if (sRes.getStatus() == Reservation.STATUS_NOT_COMMITTED) { + sRes.setStatus(Reservation.STATUS_COMMITTED); + super.sendInternalEvent(resStartTime - currentTime, + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + } + // if the reservation has already started, then update the + // schedule, which will force the gridlets in the queue to + // be started + else if(sRes.getStatus() == Reservation.STATUS_IN_PROGRESS) { + super.sendInternalEvent(resStartTime - currentTime, + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + } + } + + //------------------ FOR DEBUGGING PURPOSES ONLY ---------------- + + // Notifies the listeners that a Gridlet has been either scheduled + // to run immediately or put in the waiting queue + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_SCHEDULED, true, sgl); + + //--------------------------------------------------------------- + + // sends back an ack if required + if (ack == true) { + super.sendAck(GridSimTags.GRIDLET_SUBMIT_ACK, true, + gridlet.getGridletID(), gridlet.getUserID() + ); + } + } + + //---------------- RESERVATION RELATED PUBLIC METHODS --------------------- + + /** + * Handles an advance reservation request.<br> + * @param message the advance reservation message received + * @pre message != null + */ + public void handleCreateReservation(ARMessage message) { + double currentTime = GridSim.clock(); + + // gets the reservation object and extract some + // information from it + Reservation reservation = message.getReservation(); + double startTime = reservation.getStartTime(); + int duration = reservation.getDurationTime(); + int reqPE = reservation.getNumPE(); + + // creates a Server Side Reservation (i.e. SSReservation) + SSReservation sRes = new SSReservation(reservation); + sRes.setPartitionID(profile_.getCorrespondingPartitionID(sRes)); + double expTime = Double.NaN; + + // creates a response message to be sent to the requester + ARMessage response = message.createResponse(); + + //-------------- FOR DEBUGGING PURPOSES ONLY -------------- + + // informs the listeners that a reservation request has arrived + GridSim.notifyListeners(this.get_id(), + AllocationAction.ITEM_ARRIVED, true, sRes); + + //---------------------------------------------------------- + + if (reqPE > super.totalPE_) { + String userName = GridSim.getEntityName( message.getSourceID() ); + System.out.println(super.get_name() + ".handleCreateReservation():" + + " Reservation #" + reservation.getID() + " from " + + userName + " user requires " + reservation.getNumPE() + + " PEs from " + startTime + " to " + (startTime + duration)); + System.out.println("--> The resource has only " + + super.totalPE_ + " PEs available."); + + reservation.setStatus(Reservation.STATUS_FAILED); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); + sendARMessage(response); + return; + } + + boolean success = true; + + // if start time is 0, then it is an immediate reservation + if(startTime == 0 || startTime == currentTime) { + success = handleImmediateReservation(sRes); + expTime = sRes.getActualFinishTime(); + } + else { + success = handleAdvanceReservation(sRes); + expTime = currentTime + commitPeriod_; + } + + if(!success) { + String userName = GridSim.getEntityName( message.getSourceID() ); + System.out.println(super.get_name() + ".handleCreateReservation():" + + " Reservation #" + reservation.getID() + " from " + + userName + " user requires " + reservation.getNumPE() + + " PEs from " + startTime + " to " + (startTime + duration)); + System.out.println("--> The resource could not handle the reservation."); + + reservation.setStatus(Reservation.STATUS_FAILED); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); + sendARMessage(response); + return; + } + + // if the expiration time is greater than the start time of the + // reservation, then set the expiration time as the start time + if(expTime > startTime) { + expTime = startTime; + } + + // if the start time of the reservation is equals to the current + // time, meaning that it is an immediate reservation, then start + // the reservation straight away. Therefore, sets the status to + // committed and sends an internal event to start the reservation + if(currentTime == startTime) { + sRes.setStatus(Reservation.STATUS_COMMITTED); + super.sendInternalEvent(GridSimTags.SCHEDULE_NOW, + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + } + else { + sRes.setStatus(Reservation.STATUS_NOT_COMMITTED); + } + + sRes.setExpiryTime(expTime); + + // add the reservation into the reservation table and sends the + // response message to the requester + reservTable_.put(new Integer(sRes.getID()), sRes); + sendARMessage(response); + + // then send this into itself to check for expired reservations + super.sendInternalEvent(expTime - currentTime, + EXPIRY_TIME); + + //-------------- FOR DEBUGGING PURPOSES ONLY -------------- + + // Informs the listeners about the reservation that has been created + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_SCHEDULED, + true, sRes); + } + + /** + * Handles a commit reservation request. + * @param message the advance reservation message received + */ + public void handleCommitReservation(ARMessage message) { + + // gets the reservation id of the message + int reservationId = message.getReservationID(); + SSReservation sRes = null; + + // creates a response message to be sent to the requester + ARMessage response = message.createResponse(); + boolean success = true; + + // Tries to find the reservation in the lists + if(reservTable_.containsKey(reservationId)) { + sRes = reservTable_.get(reservationId); + } + else if(expiryTable_.containsKey(reservationId)) { + sRes = expiryTable_.get(reservationId); + switch(sRes.getStatus()) { + case Reservation.STATUS_CANCELLED: + System.out.println(super.get_name() + ".handleCommitReservation()" + + " Reservation # " + reservationId + + " cannot be committed because it has" + + " previously been cancelled by the allocation policy."); + break; + case Reservation.STATUS_FINISHED: + System.out.println(super.get_name() + ".handleCommitReservation()" + + " Reservation # " + reservationId + + " cannot be committed because it has finished."); + break; + default: + System.out.println(super.get_name() + ".handleCommitReservation()" + + " Reservation # " + reservationId + + " cannot be committed because it is in the expiry list."); + break; + } + success = false; + } + else { + System.out.println(super.get_name() + ".handleCommitReservation() " + + "Reservation # " + reservationId + " cannot be committed "+ + "because the allocation policy could not find it."); + success = false; + } + + // if there was no success, then sets the error code to failure and + // sends the message back to the requester + if(!success) { + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); + sendARMessage(response); + return; + } + + // sets the reservation to committed if it has not been set before + if(sRes.getStatus() == Reservation.STATUS_NOT_COMMITTED) { + sRes.setStatus(Reservation.STATUS_COMMITTED); + + // then send this into itself to start the reservation + super.sendInternalEvent(sRes.getStartTime() - GridSim.clock(), + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + } + + // sends the response message with no error + sendARMessage(response); + + //-------------- FOR DEBUGGING PURPOSES ONLY -------------- + + GridSim.notifyListeners(this.get_id(), + AllocationAction.ITEM_STATUS_CHANGED, true, sRes); + + //---------------------------------------------------------- + } + + /** + * Handles a modify reservation request<br> + * (NOTE: <b>NOT SUPPORTED YET</b>). + * @param message the advance reservation message received. + */ + public void handleModifyReservation(ARMessage message) { + System.out.println(super.get_name() + + ".handleModifyReservation(): not supported at the moment."); + } + + /** + * Handles a cancel reservation request<br> + * (NOTE: <b>NOT SUPPORTED YET</b>). + * @param message the advance reservation message received. + */ + public void handleCancelReservation(ARMessage message) { + System.out.println(super.get_name() + + ".handleCancelReservation(): not supported at the moment."); + } + + /** + * Handles a query free time request. + * @param message the advance reservation message received. + */ + public void handleQueryAvailability(ARMessage message) { +// // gets the reservation id of the message +// Reservation reservation = message.getReservation(); +// +// // creates a response message to be sent to the requester +// ARMessage response = message.createResponse(); +// +// // gets the start time and finish time the user is interested in +// double startTime = reservation.getStartTime(); +// int duration = reservation.getDurationTime(); +// +// // gets the availability information from the availability profile +// AvailabilityInfo availability = getAvailabilityInfo(startTime, duration); +// +// // sets the options as the availability over the requested period +// response.getReservation().setReservationOptions(availability); +// +// // Sends the response back to the user +// sendARMessage(response); + } + + /** + * Handles a query reservation request. + * @param message the advance reservation message received. + */ + public void handleQueryReservation(ARMessage message) { + + // gets the reservation id of the message + int reservationId = message.getReservationID(); + + // creates a response message to be sent to the requester + ARMessage response = message.createResponse(); + + // Tries to find the reservation in the lists + if(!reservTable_.containsKey(reservationId) + && !expiryTable_.containsKey(reservationId) ) { + System.out.println(super.get_name() + ".handleQueryReservation()" + + " Error querying the status of reservation # " + reservationId + + " because Grid Resource #" + super.resId_ + + " could not find it."); + response.setErrorCode(ARMessage.EC_OPERATION_FAILURE); + } + + // Just sends the message because the reply has a reference to + // the reservation object, which contains the status of the reservation + sendARMessage(response); + } + + /** + * Process and event sent to this entity + * @param ev the event to be handled + */ + public void processOtherEvent(Sim_event ev) { + + // handle an internal event + double currentTime = GridSim.clock(); + + if(ev.get_src() == myId_) { + switch(ev.get_tag()) { + + // checks the expiry time for a given gridlet + case EXPIRY_TIME: + if(currentTime > lastCheckExpiryTime_) { + checkExpiryTime(); + } + lastCheckExpiryTime_ = currentTime; + break; + + default: + super.processOtherEvent(ev); + break; + } + } + else + super.processOtherEvent(ev); + } + + // --------------------- PROTECTED METHODS ----------------------- + + /** + * This method is called to update the schedule. It removes completed + * gridlets and return them to the users and verifies whether there are + * gridlets in the waiting list that should start execution. It also + * removes old entries from the availability profile. + */ + protected void updateSchedule() { + + int itemsFinished = 0; + double currentTime = GridSim.clock(); + int itemsStarted = 0; + + // finishes the advance reservations first + itemsFinished = finishReservations(currentTime); + + // then finishes the Gridlets whose start time is smaller + // or equals to the current simulation time + itemsFinished += super.finishRunningGridlets(currentTime); + + // remove past entries from the availability profile + MPProfileEntry currentStatus = profile_.removePastEntries(currentTime); + if(currentStatus != null) { + profile_.setCurrentStatus(currentStatus); + resource_.resetFreePERanges(currentStatus.getPERanges()); + } + + // starts the advance reservations + itemsStarted = startReservations(currentTime); + + // Start the execution of Gridlets that are queued and whose + // potential start execution time is smaller than current time + itemsStarted += backfillGridlets(currentTime); + + //---------------- USED FOR DEBUGGING PURPOSES ONLY -------------------- + + // If a gridlet has started execution or one has finished, + // then inform the listeners + if(itemsStarted > 0 || itemsFinished > 0){ + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + } + } + + /** + * This method is called to finish a reservation and consequently update + * the availability profile. + * @param refTime the time reference to check what reservations should + * be finished. All reservations whose finish time is smaller or + * equals to refTime will be completed + * @return the number of reservations completed + */ + protected int finishReservations(double refTime) { + int reservationFinished = 0; + + Iterator<SSReservation> iterRes = reservTable_.values().iterator(); + while(iterRes.hasNext()) { + SSReservation sRes = iterRes.next(); + if(sRes.getActualFinishTime() <= refTime) { + // Finish the reservation and include ranges in the + // list of ranges to be released + sRes.setStatus(Reservation.STATUS_FINISHED); + reservationFinished++; + iterRes.remove(); + expiryTable_.put(sRes.getID(), sRes); + } + } + + if(reservationFinished > 0) { + + //------------- USED FOR DEBUGGING PURPOSES ONLY ------------------ + + // If a gridlet has started execution or one has finished, + // then inform the listeners + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + + //----------------------------------------------------------------- + } + + return reservationFinished; + } + + /** + * This method is called to start a reservation and consequently update + * the availability profile. + * @refTime the reservations whose start time is smaller + * or equals to refTime will be started + */ + protected int startReservations(double refTime) { + LinkedList<SSReservation> startedReservations = new LinkedList<SSReservation>(); + int numStartedRes = 0; + + Iterator<SSReservation> iterRes = reservTable_.values().iterator(); + while(iterRes.hasNext()) { + SSReservation sRes = iterRes.next(); + + if(sRes.getStartTime() <= refTime && + sRes.getStatus() == Reservation.STATUS_COMMITTED) { + + // Start the reservation and update the ranges of + // PEs currently available + sRes.setStatus(Reservation.STATUS_IN_PROGRESS); + + startedReservations.add(sRes); + + super.sendInternalEvent(sRes.getActualFinishTime()-refTime, + CBParallelSpaceShared.UPDATE_SCHEDULE_TAG); + + numStartedRes++; + } + } + return numStartedRes; + } + + /** + * This method returns a list that corresponds to the free time slots + * in the scheduling queue managed by this scheduler or + * resource allocation policy. + * + * @param startTime the start time in which the requester is interested. + * @param duration the duration in which the requester is interested. + * @return the list of free time slots. The list is actually a list of + * entries that correspond to the availability profile between the times + * specified by the requester. + */ + protected AvailabilityInfo getAvailabilityInfo(double startTime, int duration) { + + AvailabilityInfo list = new AvailabilityInfo(); + int anchorIndex = -1; + double currentTime = GridSim.clock(); + + // if the user specified the start time as 0, it means that the + // user is interested to know the availability starting from the + // current time, or the time when the resource received this request + if(startTime == 0) { + startTime = currentTime; + } + + list.setStartTime(startTime); + + // calculate the reservation's finish time + double finishTime = startTime + duration; + list.setFinishTime(finishTime); + + // a pointer to the anchor entry (described above) + MPProfileEntry anchorEntry = null; + int length = profile_.size(); + AvailabilityInfoEntry firstEntry = null; + + anchorEntry = (startTime <= currentTime) ? null : + profile_.getPrecedingEntry(startTime); + + // if the entry is null, then it means that the reservation is + // before the first entry of the profile, so the intersection list + // has to start with the ranges of PEs currently available + if (anchorEntry == null) { + PERangeList peList = (resource_.getFreePERanges() == null) ? + new PERangeList() : resource_.getFreePERanges().clone(); + firstEntry = + new AvailabilityInfoEntry(startTime, peList); + } + else { + PERangeList newList = anchorEntry.getPERanges(); + newList = (newList != null) ? newList.clone() : new PERangeList(); + firstEntry = new AvailabilityInfoEntry(startTime, newList); + anchorIndex = profile_.indexOf(anchorEntry); + } + + list.add(firstEntry); + AvailabilityInfoEntry previousEntry = firstEntry; + + // Iterates the availability profile and adds all the entries + // whose times are between start and finish time in the list + // to be returned. It removes repeated entries. + for(int i=anchorIndex+1; i<length; i++) { + MPProfileEntry nextEntry = profile_.get(i); + if(nextEntry.getTime() <= startTime) + continue; + if(nextEntry.getTime() > finishTime){ + break; + } + else { + PERangeList peList = nextEntry.getPERanges(); + peList = (peList != null) ? peList.clone() : new PERangeList(); + + if( !previousEntry.getAvailRanges().equals(peList)) { + AvailabilityInfoEntry tsEntry = + new AvailabilityInfoEntry(nextEntry.getTime(), peList); + list.add(tsEntry); + previousEntry = tsEntry; + } + } + } + + return list; + } + + /** + * This method returns a list that corresponds to the free time slots + * in the scheduling queue managed by this scheduler or + * resource allocation policy. This returns the resources available + * for a given partition. + * @param queueId the id of the partition whose availability is to be queried. + * @param startTime the start time in which the requester is interested. + * @param duration the duration in which the requester is interested. + * @return the list of free time slots. The list is actually a list of + * entries that correspond to the availability profile between the times + * specified by the requester. + */ + protected AvailabilityInfo getAvailabilityInfo(int queueId, + double startTime, int duration) { + + AvailabilityInfo list = new AvailabilityInfo(); + int anchorIndex = -1; + double currentTime = GridSim.clock(); + QueuePartition partition = profile_.getPartition(queueId); + + // if the user specified the start time as 0, it means that the + // user is interested to know the availability starting from the + // current time, or the time when the resource received this request + if(startTime == 0) { + startTime = currentTime; + } + + list.setStartTime(startTime); + + // calculate the reservation's finish time + double finishTime = startTime + duration; + list.setFinishTime(finishTime); + + // a pointer to the anchor entry (described above) + MPProfileEntry anchorEntry = null; + int length = profile_.size(); + AvailabilityInfoEntry firstEntry = null; + + anchorEntry = (startTime <= currentTime) ? null : + profile_.getPrecedingEntry(startTime); + + // if the entry is null, then it means that the reservation is + // before the first entry of the profile, so the intersection list + // has to start with the ranges of PEs currently available + if (anchorEntry == null) { + PERangeList peList = (partition.getIdlePERanges() == null) ? + new PERangeList() : partition.getIdlePERanges().clone(); + firstEntry = + new AvailabilityInfoEntry(startTime, peList); + } + else { + PERangeList newList = anchorEntry.getPERanges(queueId); + newList = (newList != null) ? newList.clone() : new PERangeList(); + firstEntry = new AvailabilityInfoEntry(startTime, newList); + anchorIndex = profile_.indexOf(anchorEntry); + } + + list.add(firstEntry); + AvailabilityInfoEntry previousEntry = firstEntry; + + // Iterates the availability profile and adds all the entries + // whose times are between start and finish time in the list + // to be returned. It removes repeated entries. + for(int i=anchorIndex+1; i<length; i++) { + MPProfileEntry nextEntry = profile_.get(i); + if(nextEntry.getTime() <= startTime) + continue; + if(nextEntry.getTime() > finishTime){ + break; + } + else { + PERangeList peList = nextEntry.getPERanges(queueId); + peList = (peList != null) ? peList.clone() : new PERangeList(); + + if( !previousEntry.getAvailRanges().equals(peList)) { + AvailabilityInfoEntry tsEntry = + new AvailabilityInfoEntry(nextEntry.getTime(), peList); + list.add(tsEntry); + previousEntry = tsEntry; + } + } + } + + return list; + } + + /** + * Sends a reservation message. + * @param message the message to be sent + */ + protected void sendARMessage(ARMessage message) { + // send message to the destination + super.sim_schedule(super.outputPort_, GridSimTags.SCHEDULE_NOW, + message.getMessageType(), new IO_data(message, + message.getMessageSize(), message.getDestinationID())); + } + + // ------------------------- PRIVATE MTHODS ---------------------- + + /** + * Checks for expiry time of a given reservations in the list. + * @param reservation the reservation to be checked + */ + private void checkExpiryTime() { + + double currentTime = GridSim.clock(); // get current time + + // gridlets whose start time is larger than reference time + // will be shifted forwards when the compression of the + // schedule takes place + double referenceTime = Double.MAX_VALUE; + LinkedList<SSReservation> removedRes = new LinkedList<SSReservation>(); + + Iterator<SSReservation> iterRes = reservTable_.values().iterator(); + while(iterRes.hasNext()) { + SSReservation sRes = iterRes.next(); + int status = sRes.getStatus(); + + // check for expiry time + if (status == Reservation.STATUS_NOT_COMMITTED && + sRes.getExpiryTime() <= currentTime) { + System.out.println(super.get_name() + ".checkExpiryTime(): " + + "Reservation # " + sRes.getID() + " has not been " + + "committed and has hence been cancelled at time #" + currentTime); + + // update the profile (i.e. removes/updates entries at the profile) + removeReservation(sRes); + + sRes.setStatus(Reservation.STATUS_CANCELLED); + expiryTable_.put(sRes.getID(), sRes); + iterRes.remove(); + + if(sRes.getStartTime() < referenceTime) { + referenceTime = sRes.getStartTime(); + } + removedRes.add(sRes); + } + } + + if(removedRes.size() > 0) { + + //-------------- USED FOR DEBUGGING PURPOSES ONLY ----------------- + + // If a gridlet has been cancelled, then inform the listeners + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_CANCELLED, true, removedRes); + + //----------------------------------------------------------------- + + // backfills Gridlets to fill the fragment created by the + // cancellation of the advance reservation + super.backfillGridlets(currentTime); +// super.compressSchedule(referenceTime, false); + + //---------------- USED FOR DEBUGGING PURPOSES ONLY ---------------- + + // If a gridlet has started execution or one has finished, + // then inform the listeners + GridSim.notifyListeners(this.get_id(), AllocationAction.SCHEDULE_CHANGED, true); + + //----------------------------------------------------------------- + } + } + + /** + * This method removes/updates all the entries of a reservation from + * the profile and updates the ranges of current free PEs if the + * reservation was in execution. + * @param reservation the Reservation to be removed + */ + private void removeReservation(SSReservation reservation) { + // check whether the reservation is in progress + boolean inProgress = reservation.getStatus() == Reservation.STATUS_IN_PROGRESS; + + // removes the reservation from the profile + profile_.updateEntriesAtProfile(reservation); + + // removes from the queue all gridlets that are associated to the + // advance reservation. This iterates the lists and removes the + // gridlets that have this reservation has their reservation ID + int reservationId = reservation.getID(); + LinkedList<SSGridlet> removedGridlets = new LinkedList<SSGridlet>(); + + Iterator<SSGridlet> iterGrl = + inProgress ? runningGridlets_.iterator() : queuedGridlets_.iterator(); + + while(iterGrl.hasNext()) { + SSGridlet gridlet = iterGrl.next(); + if(gridlet.getReservationID() == reservationId + && gridlet.getStatus() != Gridlet.SUCCESS + && gridlet.getStatus() != Gridlet.FAILED) { + + gridlet.setStatus(Gridlet.CANCELED); + gridlet.finalizeGridlet(); + super.sendFinishGridlet(gridlet.getGridlet()); + + removedGridlets.add(gridlet); + iterGrl.remove(); + } + } + + // notifies the listener that the gridlets have been cancelled + if(removedGridlets.size() > 0) { + + //---------------- USED FOR DEBUGGING PURPOSES ONLY ---------------- + + // If a gridlet has been cancelled, then inform the listeners + GridSim.notifyListeners(this.get_id(), AllocationAction.ITEM_CANCELLED, + false, removedGridlets); + + //------------------------------------------------------------------ + } + } + + /* + * Handles an immediate reservation + * @return true if the reservation was successful + */ + private boolean handleImmediateReservation(SSReservation res) { + double startTime = GridSim.clock(); + res.setStartTime(startTime); + + int duration = res.getDurationTime(); + int reqPE = res.getNumPE(); + int queueId = res.getPartitionID(); + + // check the start time against the availability. That is, + // check if there are enough PEs currently free and + // whether they will be available until the termination + // of the advance reservation + PERangeList ranges = profile_.getImmediateAvailability(queueId, duration); + + // if there are resource available in the queue, then allocate it + if(ranges.getNumPE() >= reqPE) { + // gets the list of PEs selected for the reservation + PERangeList selected = super.selectPERangeList(reqPE, ranges); + + // allocates the list of PEs to the reservation + res.setPERangeList(selected); + + // updates the availability profile accordingly + profile_.allocateImmediateRanges(queueId, startTime + duration, selected); + } + // Tries all the queues + else { + + // gets all available PEs during given time interval + PERangeList overallAvailPEs = + profile_.getImmediateAvailability(duration); + + if(overallAvailPEs.getNumPE() < reqPE) + return false; + + // removes PEs already obtained from selected partition + PERangeList addRanges = + PERangeList.difference(overallAvailPEs, ranges); + + // additional PEs required + int addRequired = reqPE - ranges.getNumPE(); + + if(addRanges != null && addRanges.getNumPE() >= addRequired) { + // borrows the additional PEs required from the partitions + // and adds them into the specified queue + addRanges = super.selectPERangeList(addRequired, addRanges); + profile_.transferPEs(queueId, addRanges, startTime, startTime + duration); + + // allocates the ranges to the gridlet + ranges.addAll(addRanges); + profile_.allocateImmediateRanges(queueId, startTime + duration, ranges); + res.setPERangeList(ranges); + } + else { + return false; + } + } + return true; + } + + /* + * Handles an advance reservation + * @return true if the reservation was successful + */ + private boolean handleAdvanceReservation(SSReservation res) { + + double startTime = res.getStartTime(); + int duration = res.getDurationTime(); + int reqPE = res.getNumPE(); + int queueId = res.getPartitionID(); + + // check whether there are PEs available over the time + // frame requested + Object[] availObjQueue = + ... [truncated message content] |
From: <mar...@us...> - 2008-03-30 03:49:30
|
Revision: 165 http://gridsim.svn.sourceforge.net/gridsim/?rev=165&view=rev Author: marcos_dias Date: 2008-03-29 20:49:36 -0700 (Sat, 29 Mar 2008) Log Message: ----------- This update contains better descriptions of the examples, an improved version of the aggressive backfilling policy and changes in the visibility of some methods to improve the reuseability. The aggressive backfilling policy now looks similar to that implemented in the MAUI scheduler, where the system administrator can configure the number of jobs that cannot be delayed when the backfilling algorithm is invoked. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/QueuePredicateExample.java branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/EBMultiplePartitions.java branches/gridsim4.0-branch3/source/gridsim/turbo/MPAvailabilityProfile.java branches/gridsim4.0-branch3/source/gridsim/turbo/TResourceCharacteristics.java Added Paths: ----------- branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java Removed Paths: ------------- branches/gridsim4.0-branch3/source/gridsim/turbo/EBParallelSpaceShared.java Modified: branches/gridsim4.0-branch3/examples/examples/QueuePredicateExample.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/QueuePredicateExample.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/QueuePredicateExample.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,23 +1,33 @@ package examples; +import gridsim.turbo.CBMultiplePartitions; +import gridsim.turbo.EBMultiplePartitions; import gridsim.turbo.QueuePartitionPredicate; import gridsim.turbo.SSGridlet; import gridsim.turbo.SSReservation; import gridsim.turbo.ScheduleItem; /** - * Example of queue predicate. This predicate filters - * gridlets according to their runtime + * Example of queue predicate. This predicate filters gridlets and + * advance reservations according to their runtime or duration * * @author Marcos Dias de Assuncao + * @since GridSim Turbo Alpha 0.1 + * + * @see QueuePartitionPredicate + * @see EBMultiplePartitions + * @see CBMultiplePartitions */ public class QueuePredicateExample implements QueuePartitionPredicate { - int minRuntime_; - int maxRuntime_; - int resRating_; + int minRuntime_; // the minimum run time for the partition + int maxRuntime_; // the maximum run time for the partition + int resRating_; // the rating of the resource's PEs - /* + /** * Default constructor + * @param minRuntime the minimum run time for the partition + * @param maxRuntime the maximum run time for the partition + * @param rating the rating of the resource's PEs */ public QueuePredicateExample(int minRuntime, int maxRuntime, int rating) { @@ -26,9 +36,12 @@ this.resRating_ = rating; } - /* - * (non-Javadoc) - * @see gridsim.turbo.QueuePredicate#match(gridsim.turbo.ScheduleItem) + /** + * This method returns <tt>true</tt> if the item can be scheduled + * using the partition. + * @return <tt>true</tt> if the item can be scheduled + * using the partition; <tt>false</tt> otherwise. + * @see QueuePartitionPredicate#match(gridsim.turbo.ScheduleItem) */ public boolean match(ScheduleItem item) { double runtime = 0; Modified: branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithCancellation.java 2008-03-30 03:49:36 UTC (rev 165) @@ -19,7 +19,8 @@ /** * This class is an extended version of {@link Workload}. This class - * cancels some gridlets submitted. + * cancels some gridlets submitted. This class has been created only for + * example and debugging purposes. * * @author Marcos Dias de Assuncao * @since GridSim Turbo Alpha 0.1 @@ -27,10 +28,12 @@ * @see Workload */ public class WorkloadWithCancellation extends Workload { - private final int NUM_GRIDLETS_BETWEEN_CANCELLATIONS = 50; + + private int numGrlsBetweenCancellations_ = 50; + // value of 1, means that the cancellation will be sent // at the gridlet's submission time + (gridlet duration * 1) - private final double TIME_CANCELLATION = 0.5; + private double timeCancellation_ = 0.5; /** * Create a new {@link WorkloadWithCancellation} object <b>without</b> using @@ -154,6 +157,23 @@ //////////////////////// PRIVATE METHODS /////////////////////// /** + * Set the number of gridlets interval between cancelations. + * @param numGrlsBetweenCancellations the number of gridlets + */ + public void setNumGrlsBetweenCancellations(int numGrlsBetweenCancellations) { + numGrlsBetweenCancellations_ = numGrlsBetweenCancellations; + } + + /** + * Configures the cancellation time of the gridlets. The cancellation time + * of a gridlet will be submission time + (runtime * timeCancellation) + * @param timeCancellation the cancellation time + */ + public void setTimeCancellation(double timeCancellation) { + timeCancellation_ = timeCancellation; + } + + /** * Collects Gridlets sent and stores them into a list. * @pre $none * @post $none @@ -182,12 +202,6 @@ if (data != null && data instanceof Gridlet) { gl = (Gridlet) data; -// if(gl.getGridletStatus() == Gridlet.FAILED) -// System.out.println("Gridlet failed"); -// -// if(gl.getGridletStatus() == Gridlet.CANCELED) -// System.out.println("Gridlet cancelled"); - list_.add(gl); counter++; } @@ -238,10 +252,10 @@ new IO_data(gl, gl.getGridletFileSize(), resID_) ); // check whether a cancellation has to be scheduled or not - int result = gridletID_ % NUM_GRIDLETS_BETWEEN_CANCELLATIONS; + int result = gridletID_ % numGrlsBetweenCancellations_; if(result == 0) { - super.send(super.output, (submitTime + (TIME_CANCELLATION * runTime)), GridSimTags.GRIDLET_CANCEL, - new IO_data(gl, 0, resID_) ); + super.send(super.output, (submitTime + (timeCancellation_ * runTime)), + GridSimTags.GRIDLET_CANCEL, new IO_data(gl, 0, resID_) ); gridletID_++; } } Modified: branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/WorkloadWithReservation.java 2008-03-30 03:49:36 UTC (rev 165) @@ -14,7 +14,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.Calendar; import java.util.Enumeration; import java.util.Random; import java.util.zip.GZIPInputStream; @@ -34,65 +33,17 @@ import gridsim.net.SimpleLink; import gridsim.turbo.Reservation; import gridsim.turbo.ReservationRequester; +import gridsim.util.SimReport; +import gridsim.util.Workload; /** - * The main purpose of this class is to create a realistic simulation - * environment where your jobs or Gridlets are competing with others. - * In other words, the grid resource might not be available at certain times. - * In addition, the arrival time of jobs are also captured in the trace file. - * <p> - * This workload class has been modified to simulate advance reservations. - * Some parameters where included to indicate the frequency in which - * advance reservations are made. Additionally, it is possible to specify how - * long in advance the advance reservations are made. - * <p> - * This class is responsible for reading resource traces from a file and - * sends Gridlets to only <tt>one</tt> destinated resource. <br> - * <b>NOTE:</b> - * <ul> - * <li> This class can only take <tt>one</tt> trace file of the following - * format: <i>ASCII text, zip, gz.</i> - * <li> This class can be classified as <b>one grid user entity</b>. - * Hence, you need to incorporate this entity into <tt>numUser</tt> - * during {@link gridsim.GridSim#init(int, Calendar, boolean)} - * <li> If you need to use multiple trace files to submit Gridlets to - * same or different resources, then you need to create multiple - * instances of this class <tt>each with a unique entity name</tt>. - * <li> If size of the trace file is huge or contains lots of traces - * please increase the JVM heap size accordingly by using - * <tt>java -Xmx</tt> option when running the simulation. - * <li> If you are running an experiment using the network extension, - * i.e. the gridsim.net package, then you need to use - * {@link #WorkloadWithReservation(String, double, double, int, String, String, int)} - * instead. - * <li> The default job file size for sending to and receiving from - * a resource is {@link gridsim.net.Link#DEFAULT_MTU}. - * However, you can specify - * the file size by using {@link #setGridletFileSize(int)}. - * <li> A job run time is only for 1 PE <tt>not</tt> the total number of - * allocated PEs. - * Therefore, a Gridlet length is also calculated for 1 PE.<br> - * For example, job #1 in the trace has a run time of 100 seconds - * for 2 processors. This means each processor runs - * job #1 for 100 seconds, if the processors have the same - * specification. - * </ul> - * <p> - * By default, this class follows the standard workload format as specified - * in <a href="http://www.cs.huji.ac.il/labs/parallel/workload/"> - * http://www.cs.huji.ac.il/labs/parallel/workload/</a> <br> - * However, you can use other format by calling the below methods before - * running the simulation: - * <ul> - * <li> {@link #setComment(String)} - * <li> {@link #setField(int, int, int, int, int)} - * </ul> - * - * @see gridsim.GridSim#init(int, Calendar, boolean) - * @author Marcos Dias de Assuncao (the most of the code came - * from {@link Workload} class) + * This class was created to create jobs and advance reservations based on + * information read from a job trace. Most of the source code has been copied + * from {@link Workload} class. + * + * @see Workload + * @author Marcos Dias de Assuncao * @since GridSim Turbo Alpha 0.1 - * @invariant $none */ public class WorkloadWithReservation extends ReservationRequester { @@ -125,7 +76,6 @@ private long seed_ = 11L*13*17*19*23+1; // TAGS FOR INTERNAL EVENTS - private final int GRIDLET_SUBMIT = 10; private final int RESERVE_RESOURCES = 11; /** @@ -564,6 +514,13 @@ public void body() { System.out.println(); System.out.println(super.get_name() + ".body() :%%%% Start ..."); + + SimReport report = null; + try { + report = new SimReport("report"); + } catch (ParameterException e) { + e.printStackTrace(); + } // create a temp array fieldArray_ = new String[MAX_FIELD]; @@ -680,6 +637,16 @@ list_.add(gl); counter++; returned++; + + if(gl.getGridletStatus() == Gridlet.SUCCESS) { + double runTime = gl.getFinishTime() - gl.getExecStartTime(); + + if(runTime < 1) + runTime = 1; + + double slowdown = (gl.getWaitingTime() + runTime) / runTime; + report.write(gl.getGridletID() + ", " + slowdown); + } } if(counter == gridletID_) @@ -695,6 +662,8 @@ shutdownUserEntity(); terminateIOEntities(); + report.finalWrite(); + System.out.println(super.get_name() + ".body() : %%%% Exit ..."); } Modified: branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/ar/ARTest.java 2008-03-30 03:49:36 UTC (rev 165) @@ -28,6 +28,7 @@ * current time as the starting time * - commits an accepted reservation * - checks the status of a reservation + * - submits gridlets to the resource */ public class ARTest extends ReservationRequester { private GridletList list_; // a list containing new Gridlets @@ -39,7 +40,6 @@ private final int MIN = 60 * SEC; // 1 min in seconds private final int HOUR = 60 * MIN; // 1 hour in minutes private final int DAY = 24 * HOUR; // 1 day in hours - /** * Creates a new grid user entity Modified: branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/ar/SimpleARExample01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -85,6 +85,7 @@ // Fourth step: Starts the simulation // GridSim.startGridSimulation(); + // Start Gridsim in debug mode (i.e., it shows the visualiser) GridSim.startGridSimulation(true); //------------------------------------------------ Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARCBMultipleQueuesExample01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,12 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource with a conservative + * backfilling policy with advance reservation features and with multiple + * partitions. The jobs are read from a trace file. To test this example, + * you can use one of the traces included in the workloads directory. + */ package examples.workload.ar; @@ -150,6 +159,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource + // this resource will use a conservative backfilling policy with + // multiple partitions and advance reservation features TResourceCharacteristics resConfig = new TResourceCharacteristics(arch, os, mList, TResourceCharacteristics.ARCB_MULTI_PARTITIONS, @@ -162,15 +173,21 @@ e1.printStackTrace(); } - // creates three partitions, one for small jobs, one for medium size jobs + // creates three partitions, one for short jobs, one for medium length jobs // and another for long jobs QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + // divide the resources equally amongst the partitions policy.createPartition(0, resConfig.getNumPE() / 3, express); policy.createPartition(1, resConfig.getNumPE() / 3, medium); policy.createPartition(2, resConfig.getNumPE() / 3, large); + + // By default, the partitions will borrow PEs from one another + // when they require and the lending partitions are not using the PEs. + // You can change this behaviour by removing the comment from the line below +// policy.setAllowBorrowing(false); ////////////////////////////////////////// // 6. Finally, we need to create a GridResource object. Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboAREBMultipleQueuesExample01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -155,6 +155,8 @@ TResourceCharacteristics.AREB_MULTI_PARTITIONS, time_zone, cost); + // this resource will use a aggressive backfilling policy with + // multiple partitions and advance reservation features AREBMultiplePartitions policy = null; try { policy = new AREBMultiplePartitions(name, "Policy", 3); @@ -162,15 +164,21 @@ e1.printStackTrace(); } - // creates three partitions, one for small jobs, one for medium size jobs + // creates three partitions, one for short jobs, one for medium length jobs // and another for long jobs QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + // divide the resources equally amongst the partitions policy.createPartition(0, resConfig.getNumPE() / 3, express); policy.createPartition(1, resConfig.getNumPE() / 3, medium); policy.createPartition(2, resConfig.getNumPE() / 3, large); + + // By default, the partitions will borrow PEs from one another + // when they require and the lending partitions are not using the PEs. + // You can change this behaviour by removing the comment from the line below +// policy.setAllowBorrowing(false); ////////////////////////////////////////// // 6. Finally, we need to create a GridResource object. Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,14 @@ +/* + * Author Marcos Dias de Assuncao + * Date: September 2007 + * + * Description: This example shows how to create a resource with a + * conservative backfilling policy with advance reservation features. The jobs are + * read from a trace file. To test this example, you can use one of the traces + * included in the workloads directory. The jobs generated by this class are not + * advance reservations, however. This example has been created for debugging + * purposes. + */ package examples.workload.ar; @@ -143,6 +154,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource + // Creates the resource characteristics object and inform it that + // the policy to be used is TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED, time_zone, cost); Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample02.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,12 @@ +/* + * Author Marcos Dias de Assuncao + * Date: September 2007 + * + * Description: This example shows how to create a resource with a + * conservative backfilling policy with advance reservation features. The jobs are + * read from a trace file. To test this example, you can use one of the traces + * included in the workloads directory. + */ package examples.workload.ar; @@ -150,6 +159,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource + // Creates the resource characteristics object and inform it that + // the policy to be used is TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.AR_PARALLEL_SPACE_SHARED, time_zone, cost); Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExample03.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,13 @@ +/* + * Author Marcos Dias de Assuncao + * Date: September 2007 + * + * Description: This example creates three resources and three workload + * objects. The workloads make advance reservations and submit gridlets + * to the resources. The policy used by the resources is conservative + * backfilling with advance reservation. To test this example, you can use + * one of the traces included in the workloads directory. + */ package examples.workload.ar; @@ -13,9 +23,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.LinkedList; -import java.util.Random; - /** * Test Driver class for this example. This example just tests * the same features provided by the ParallelSpaceShared policy Modified: branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/ar/TurboARExampleWithCancellation01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,14 @@ +/* + * Author Marcos Dias de Assuncao + * Date: September 2007 + * + * Description: This example shows how to create a resource with a + * conservative backfilling policy with advance reservation features. The jobs are + * read from a trace file. The workload object cancels some of the gridlets + * submitted to the resource. This example has been implemented to test + * the cancellation features. To test this example, you can use one of the traces + * included in the workloads directory. + */ package examples.workload.ar; Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,15 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a workload that submits + * jobs to a grid resource based on the workload model described by Lublin and + * Feitelson in the following paper: + * + * Uri Lublin and Dror G. Feitelson, The Workload on Parallel Supercomputers: + * Modeling the Characteristics of Rigid Jobs. J. Parallel & Distributed + * Comput. 63(11), pp. 1105-1122, Nov 2003. + */ package examples.workload.parallel; Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExample01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,12 @@ +/* + * Author Marcos Dias de Assuncao + * Date: September 2007 + * + * Description: This example shows how to create a resource with a + * conservative backfilling policy without advance reservation features. The jobs are + * read from a trace file. To test this example, you can use one of the traces + * included in the workloads directory. + */ package examples.workload.parallel; @@ -15,7 +24,7 @@ /** - * Test Driver class for this example + * Test Driver class for this example. */ public class TurboExample01 { @@ -137,6 +146,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource + // Create the TResourceCharacteristics object and inform that the + // policy to be used is TResourceCharacteristics.CB_PARALLEL_SPACE_SHARED TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.CB_PARALLEL_SPACE_SHARED, time_zone, cost); Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,14 +1,22 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource with a conservative + * backfilling policy without advance reservation features but with multiple + * partitions. This example creates the policy with only one partition, however. + * This has been done for debugging purposes. The policy should behave like a + * normal conservative backfilling policy when only one partition is created. + * The jobs are read from a trace file. To test this example, you can use one + * of the traces included in the workloads directory. + */ package examples.workload.parallel; -import gridsim.AllocPolicy; import gridsim.GridResource; import gridsim.GridSim; import gridsim.Machine; import gridsim.MachineList; -import gridsim.ResourceCalendar; -import gridsim.ResourceCharacteristics; -import gridsim.turbo.EBMultiplePartitions; import gridsim.turbo.TResourceCharacteristics; import gridsim.util.Workload; @@ -17,7 +25,6 @@ import java.util.LinkedList; import java.util.Random; - /** * Test Driver class for this example */ @@ -132,7 +139,7 @@ } ////////////////////////////////////////// - // 5. Create a ResourceCharacteristics object that stores the + // 5. Create a TResourceCharacteristics 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). @@ -141,7 +148,9 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource - // this resource will use an aggressive backfilling policy (EASY) + // this resource will use a conservative backfilling policy but + // with only one partition. Note that we do not have to specify the + // number of partitions, so only one will be created TResourceCharacteristics resConfig = new TResourceCharacteristics(arch, os, mList, TResourceCharacteristics.CB_MULTI_PARTITIONS, Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleCBMultiQueues02.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,12 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource with a conservative + * backfilling policy without advance reservation features but with multiple + * partitions. The jobs are read from a trace file. To test this example, + * you can use one of the traces included in the workloads directory. + */ package examples.workload.parallel; @@ -8,7 +17,6 @@ import gridsim.MachineList; import gridsim.ResourceCalendar; import gridsim.turbo.CBMultiplePartitions; -import gridsim.turbo.EBMultiplePartitions; import gridsim.turbo.TResourceCharacteristics; import gridsim.util.Workload; @@ -141,7 +149,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource - // this resource will use an aggressive backfilling policy (EASY) + // this resource will use a conservative backfilling policy with + // multiple partitions and without advance reservation features TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.CB_MULTI_PARTITIONS, time_zone, cost); @@ -153,16 +162,22 @@ e1.printStackTrace(); } - // creates three partitions, one for small jobs, one for medium size jobs + // creates three partitions, one for short jobs, one for medium length jobs // and another for long jobs QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + // divide the resources equally amongst the partitions policy.createPartition(0, resConfig.getNumPE() / 3, express); policy.createPartition(1, resConfig.getNumPE() / 3, medium); policy.createPartition(2, resConfig.getNumPE() / 3, large); + // By default, the partitions will borrow PEs from one another + // when they require and the lending partitions are not using the PEs. + // You can change this behaviour by removing the comment from the line below +// policy.setAllowBorrowing(false); + ////////////////////////////////////////// // 6. Finally, we need to create a GridResource object. double baud_rate = 10000.0; // communication speed Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,14 +1,22 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource with an aggressive + * backfilling policy without advance reservation features but with multiple + * partitions. This example creates the policy with only one partition, however. + * This has been done for debugging purposes. The policy should behave like a + * normal aggressive backfilling policy when only one partition is created. + * The jobs are read from a trace file. To test this example, you can use one + * of the traces included in the workloads directory. + */ package examples.workload.parallel; -import gridsim.AllocPolicy; import gridsim.GridResource; import gridsim.GridSim; import gridsim.Machine; import gridsim.MachineList; -import gridsim.ResourceCalendar; -import gridsim.ResourceCharacteristics; -import gridsim.turbo.EBMultiplePartitions; import gridsim.turbo.TResourceCharacteristics; import gridsim.util.Workload; @@ -17,7 +25,6 @@ import java.util.LinkedList; import java.util.Random; - /** * Test Driver class for this example */ @@ -141,7 +148,9 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource - // this resource will use an aggressive backfilling policy (EASY) + // this resource will use an aggressive backfilling policy (EASY) but + // with only one partition. Note that we do not have to specify the + // number of partitions, so only one will be created TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.EB_MULTI_PARTITIONS, time_zone, cost); Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEBMultiQueues02.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,12 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource with an aggressive + * backfilling policy without advance reservation features but with multiple + * partitions. The jobs are read from a trace file. To test this example, + * you can use one of the traces included in the workloads directory. + */ package examples.workload.parallel; @@ -16,7 +25,6 @@ import java.util.LinkedList; import java.util.Random; - /** * Test Driver class for this example */ @@ -139,7 +147,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource - // this resource will use an aggressive backfilling policy (EASY) + // this resource will use an aggressive backfilling policy with + // multiple partitions and without advance reservation features TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.EB_MULTI_PARTITIONS, time_zone, cost); @@ -150,17 +159,23 @@ } catch (Exception e1) { e1.printStackTrace(); } - - // creates three partitions, one for small jobs, one for medium size jobs + + // creates three partitions, one for short jobs, one for medium length jobs // and another for long jobs QueuePredicateExample express = new QueuePredicateExample(0, 1000, peRating); QueuePredicateExample medium = new QueuePredicateExample(1000, 10000, peRating); QueuePredicateExample large = new QueuePredicateExample(10000, Integer.MAX_VALUE, peRating); + // divide the resources equally amongst the partitions policy.createPartition(0, resConfig.getNumPE() / 3, express); policy.createPartition(1, resConfig.getNumPE() / 3, medium); policy.createPartition(2, resConfig.getNumPE() / 3, large); + // By default, the partitions will borrow PEs from one another + // when they require and the lending partitions are not using the PEs. + // You can change this behaviour by removing the comment from the line below +// policy.setAllowBorrowing(false); + ////////////////////////////////////////// // 6. Finally, we need to create a GridResource object. double baud_rate = 10000.0; // communication speed Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleEasy01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,12 @@ +/* + * Author Marcos Dias de Assuncao + * Date: February 2008 + * + * Description: This example shows how to create a resource with an aggressive + * backfilling policy without advance reservation features. The jobs are + * read from a trace file. To test this example, you can use one of the traces + * included in the workloads directory. + */ package examples.workload.parallel; @@ -83,10 +92,10 @@ ////////////////////////////////////////// // Starts the simulation in debug mode -// GridSim.startGridSimulation(true); + GridSim.startGridSimulation(true); // Start the simulation in normal mode - GridSim.startGridSimulation(); +// GridSim.startGridSimulation(); ////////////////////////////////////////// // Final step: Prints the Gridlets when simulation is over @@ -137,7 +146,8 @@ double time_zone = 0.0; // time zone this resource located double cost = 3.0; // the cost of using this resource - // this resource will use an aggressive backfilling policy (EASY) + // this resource will use an aggressive backfilling policy (EASY) but + // without advance reservations TResourceCharacteristics resConfig = new TResourceCharacteristics( arch, os, mList, TResourceCharacteristics.EB_PARALLEL_SPACE_SHARED, time_zone, cost); Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/TurboExampleWithCancellation01.java 2008-03-30 03:49:36 UTC (rev 165) @@ -1,3 +1,14 @@ +/* + * Author Marcos Dias de Assuncao + * Date: September 2007 + * + * Description: This example shows how to create a resource with a + * conservative backfilling policy without advance reservation features. + * This example has beenn implemented to test the job cancellation. The workload + * object created in this example cancels some of the gridlets submitted. The + * jobs are read from a trace file. To test this example, you can use one + * of the traces included in the workloads directory. + */ package examples.workload.parallel; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-03-30 03:49:36 UTC (rev 165) @@ -906,7 +906,6 @@ private int startReservation(double refTime) { LinkedList<SSReservation> startedReservations = new LinkedList<SSReservation>(); - PERangeList allocatedRanges = new PERangeList(); int numStartedRes = 0; Iterator<SSReservation> iterRes = reservTable_.values().iterator(); @@ -919,8 +918,6 @@ // Start the reservation and update the ranges of // PEs currently available sRes.setStatus(Reservation.STATUS_IN_PROGRESS); - - allocatedRanges.addAll(sRes.getPERangeList().clone()); startedReservations.add(sRes); super.sendInternalEvent(sRes.getActualFinishTime()-refTime, @@ -935,9 +932,6 @@ // the gridlets in the queue that can be started if(numStartedRes > 0) { - // allocates the ranges to the advance reservations - resource_.setPEsBusy(allocatedRanges); - //------------- USED FOR DEBUGGING PURPOSES ONLY ------------------ // notify the listeners @@ -965,9 +959,6 @@ private int finishReservation(double refTime) { int reservationFinished = 0; - // remove all reservations that have already completed - PERangeList releasedRanges = new PERangeList(); - Iterator<SSReservation> iterRes = reservTable_.values().iterator(); while(iterRes.hasNext()) { SSReservation sRes = iterRes.next(); @@ -975,16 +966,12 @@ // Finish the reservation and include ranges in the // list of ranges to be released sRes.setStatus(Reservation.STATUS_FINISHED); - releasedRanges.addAll(sRes.getPERangeList().clone()); reservationFinished++; iterRes.remove(); expiryTable_.put(sRes.getID(), sRes); } } - // returns the ranges to the list of current available ranges - resource_.setPEsAvailable(releasedRanges); - if(reservationFinished > 0) { //------------- USED FOR DEBUGGING PURPOSES ONLY ------------------ @@ -1000,91 +987,6 @@ } /** - * Selects a list of PE ranges able to provide enough PEs to handle - * a reservation or a Gridlet. - * - * @param reqPE the number of PEs - * @param startTime the start time of the reservation / Gridlet<br> - * @param duration the duration of the reservation / Gridlet - * @return an array[2] of Objects as follows if there are enough PEs - * to serve the Gridlet or reservation:<br> - * array[0] the index of the last entry before the finish time - * of the reservation/Gridlet in the availability profile<br> - * array[1] the list of PE ranges<br> - * OR an <tt>null</tt> if a range with enough PEs is not found. - */ - private Object[] checkImmediatePERangesAvailability(int reqPE, - double startTime, double duration) { - - // tail index represents the position which corresponds to the closest - // entry to the gridlet's finish time OR an existing entry whose - // time is equals to the gridlet's or advance reservation's finish time - int tailIndex = -1; - - if(availProfile_.size() == 0) { - // creates the array with the result - Object[] result = new Object[2]; - result[0] = tailIndex; - result[1] = super.selectPERangeList(reqPE, resource_.getFreePERanges()); - return result; - } - - // a pointer to the last entry analysed (described above) - AvailabilityProfileEntry tailEntry = null; - - // NOTE: freePERanges_ does not need to be cloned here as the - // PERangeList.intersection() and selectPERangeList() methods will - // create a new list of ranges with the intersection anyway. - // For immediate gridlets or advance reservations, the start point - // is the current list of PEs available - PERangeList intersectList = resource_.getFreePERanges(); - - // if time is unknown, then make the current time the start time - if(startTime < 0) - startTime = GridSim.clock(); - - // the gridlet's expected finish time - double finishTime = startTime + duration; - - // scan the availability profile until the expected termination - // of the Gridlet to check whether enough PEs will be available - // for the Gridlet. Stop the search if not enough PEs are available - for(AvailabilityProfileEntry entry : availProfile_) { - double entryTime = entry.getTime(); - if(entryTime < startTime) { - continue; - } - else if(entryTime > finishTime) { - break; - } - else { - tailEntry = entry; - // if the finish time is equals to the entry time, so there - // is no need to check the intersection - if(entryTime < finishTime) { - PERangeList listEntry = entry.getPERanges(); - intersectList = PERangeList.intersection(listEntry, intersectList); - if(intersectList == null || intersectList.getNumPE() < reqPE) - break; - } - } - tailIndex = availProfile_.indexOf(tailEntry); - } - - // return null if the number of PEs available over the required - // time interval is smaller than what the Gridlet/Reservation requires - if(intersectList == null || intersectList.getNumPE() < reqPE) { - return null; - } - - // creates the array with the result - Object[] result = new Object[2]; - result[0] = tailIndex; - result[1] = super.selectPERangeList(reqPE, intersectList); - return result; - } - - /** * Selects a list of PE ranges able to provide enough PEs * to handle a reservation. * @@ -1096,7 +998,7 @@ * of the reservation in the availability profile<br> * array[2] the list of PE ranges<br> */ - private Object[] checkPERangesAvailability(int reqPE, + protected Object[] checkPERangesAvailability(int reqPE, double startTime, double duration) { // the anchor index, the entry in the profile where @@ -1191,183 +1093,6 @@ return result; } - /** - * Allocates a list of PE ranges to a gridlet or reservation - * and updates the availability profile accordingly. - * - * @param tailIndex the index of the entry closest to the - * finish time but whose time is smaller or equals to the finish time - * @param selected the lsit of PE ranges selected - * @param startTime the start time of the Gridlet / reservation - * @param finishTime the finish time of the Gridlet / reservation - */ - private void allocateImmediatePERanges(int tailIndex, - PERangeList selected, - double startTime, double finishTime) { - - AvailabilityProfileEntry newEntryAfterTail = null; - - // if the time of the entry at (tailIndex) is equals to - // the gridlet finish time, then a new entry in the profile - // is not needed. In this case, the entry at (tailIndex) - // is updated to show that one more gridlet relies on the entry - // to represent its completion time. This reduces the number of - // entries in the availability profile - boolean addEntryAfterTail = true; - - if(tailIndex == -1) { - // Creates a new entry to be added to the profile - newEntryAfterTail = new AvailabilityProfileEntry(finishTime); - newEntryAfterTail.setPERangeList(resource_.getFreePERanges().clone()); - tailIndex++; - } - else { - // get the tail entry (that is, the closest entry - // to the finish time - AvailabilityProfileEntry tailEntry = - availProfile_.get(tailIndex); - - if (tailEntry.getTime() == finishTime) { - addEntryAfterTail = false; - tailEntry.increaseGridlet(); - } - // If a new entry is required, then add it to the profile - else { - - // Gathers the information that must be added at the profile after - // the tail entry, if needed - PERangeList listTail = tailEntry.getPERanges().clone(); - - // Creates a new entry to be added to the profile - newEntryAfterTail = new AvailabilityProfileEntry(finishTime); - newEntryAfterTail.setPERangeList(listTail); - tailIndex++; - } - } - - if(addEntryAfterTail) { - availProfile_.add(tailIndex, newEntryAfterTail); - } - - // Update entries of the profile - for(int index=0; index<tailIndex; index++) { - AvailabilityProfileEntry entry = availProfile_.get(index); - - PERangeList uptList = - PERangeList.difference(entry.getPERanges(), selected); - entry.setPERangeList(uptList); - } - - // subtract the selected ranges from the currently free ranges - resource_.setPEsBusy(selected); - - } - - /** - * Allocates a list of PE ranges to a gridlet or reservation and updates the - * availability profile accordingly - * - * @param anchorIndex the index of the anchor that contains the - * Gridlet's start time - * or the place where the new anchor (if needed) will be placed - * @param tailIndex the index of the entry closest to the finish time but - * whose time is smaller or equals to the finish time - * @param selected the list of PE ranges selected - * @param startTime the start time of the Gridlet / reservation - * @param finishTime the finish time of the Gridlet / reservation - */ - private void allocatePERanges(int anchorIndex, int tailIndex, - PERangeList selected, double startTime, - double finishTime) { - - AvailabilityProfileEntry newEntryAfterTail = null; - AvailabilityProfileEntry newEntryAfterAnchor = null; - - // if the time of the entry at (tailIndex) is equals to - // the gridlet finish time, then a new entry in the profile - // is not needed. In this case, the entry at (tailIndex) - // is updated to show that one more gridlet relies on the entry - // to represent its completion time. This reduces the number of - // entries in the availability profile - boolean addEntryAfterTail = true; - - // if the time of the entry at (anchor) is equals to - // the gridlet finish time, then a new entry in the profile - // is not needed. In this case, the entry at (anchorIndex) - // is updated to show that one more gridlet relies on the entry - // to represent its completion time. This reduces the number of - // entries in the availability profile. - boolean addEntryAfterAnchor = false; - - if (tailIndex > -1) { - AvailabilityProfileEntry tailEntry = availProfile_.get(tailIndex); - - if (tailEntry.getTime() == finishTime) { - addEntryAfterTail = false; - tailEntry.increaseGridlet(); - } - // If a new entry is required, then created it to be added - // to the profile - else { - // Creates a new entry to be added to the profile - newEntryAfterTail = new AvailabilityProfileEntry(finishTime); - newEntryAfterTail.setPERangeList(tailEntry.getPERanges().clone()); - tailIndex++; - } - } - else { - // Creates a new entry to be added to the profile - newEntryAfterTail = new AvailabilityProfileEntry(finishTime); - newEntryAfterTail.setPERangeList(resource_.getFreePERanges().clone()); - tailIndex++; - } - - if (anchorIndex > -1) { - AvailabilityProfileEntry anchorEntry = availProfile_.get(anchorIndex); - - double anchorTime = anchorEntry.getTime(); - if ( anchorTime < startTime ) { - addEntryAfterAnchor = true; - // Creates a new entry to be added to the profile - newEntryAfterAnchor = new AvailabilityProfileEntry(startTime); - newEntryAfterAnchor.setPERangeList(anchorEntry.getPERanges().clone()); - // increment the position where the new anchor will be added - anchorIndex++; - } - else if (anchorTime == startTime) { - anchorEntry.increaseGridlet(); - } - } - else { - addEntryAfterAnchor = true; - - // Creates a new entry to be added to the profile - newEntryAfterAnchor = new AvailabilityProfileEntry(startTime); - newEntryAfterAnchor.setPERangeList(resource_.getFreePERanges().clone()); - // increment the position where the new anchor will be added - anchorIndex++; - } - - if(addEntryAfterAnchor) { - availProfile_.add(anchorIndex, newEntryAfterAnchor); - tailIndex++; - } - - if(addEntryAfterTail) { - availProfile_.add(tailIndex, newEntryAfterTail); - } - - // Update entries of the profile - if(tailIndex > -1) { - for(int index=anchorIndex; index<tailIndex; index++){ - AvailabilityProfileEntry entry = availProfile_.get(index); - PERangeList uptList = - PERangeList.difference(entry.getPERanges(), selected); - entry.setPERangeList(uptList); - } - } - } - // ---------------------- PROTECTED METHODS ------------------------ /** @@ -1390,7 +1115,11 @@ itemsFinished += super.finishRunningGridlets(currentTime); // remove past entries from the availability profile - availProfile_.removePastEntries(currentTime); + AvailabilityProfileEntry currentStatus = + availProfile_.removePastEntries(currentTime); + if(currentStatus != null) { + resource_.resetFreePERanges(currentStatus.getPERanges()); + } // starts the advance reservations itemsStarted = startReservation(currentTime); Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityProfile.java 2008-03-30 03:49:36 UTC (rev 165) @@ -51,7 +51,7 @@ * smaller, or whose time is equals to <tt>time</tt>; <tt>null</tt> if * not found. */ - protected AvailabilityProfileEntry getPrecedingEntry(double time) { + public AvailabilityProfileEntry getPrecedingEntry(double time) { Iterator<AvailabilityProfileEntry> it = super.iterator(); AvailabilityProfileEntry preceding = null; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-03-28 11:14:42 UTC (rev 164) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/CBParallelSpaceShared.java 2008-03-30 03:49:36 UTC (rev 165) @@ -639,31 +639,21 @@ */ protected int finishRunningGridlets(double currentTime) { int itemsFinished = 0; - boolean reserved; // to indicate whether the gridlet refers to a reserv. - // remove all Gridlets that have already completed from - // the queue of running Gridlets - PERangeList releasedRanges = new PERangeList(); - // iterates the list to check what has finished Iterator<SSGridlet> iter = runningGridlets_.iterator(); while (iter.hasNext()) { SSGridlet gridlet = iter.next(); - reserved = gridlet.hasReserved(); // as gridlets are removed from running queue once they finish // time is smaller than current time, then testing the time // is enough. There's no need to check status if(gridlet.getActualFinishTime() <= currentTime) { // Update the list of ranges released - if(!reserved) { - releasedRanges.addAll(gridlet.getPERangeList().clone()); - } gridletFinish(gridlet, Gridlet.SUCCESS); iter.remove(); itemsFinished++; } } - resource_.setPEsAvailable(releasedRanges); return itemsFinished; } @@ -676,20 +666,14 @@ */ protected int startQueuedGridlets(double currentTime) { int gridletStarted = 0; - boolean reserved; // to indicate whether the gridlet refers to a reserv. // Start the execution of Gridlets that are queued and whose // potential start execution time is smaller than reference time - PERangeList allocatedRanges = new PERangeList(); Iterator<SSGridlet> iter = queuedGridlets_.iterator(); while (iter.hasNext()) { SSGridlet gridlet = iter.next(); // check whether there is a reservation for this gridlet - reserved = gridlet.hasReserved(); if(gridlet.getStartTime() <= currentTime) { - // Update the list of ranges allocated - if(!reserved) - allocatedRanges.addAll(gridlet.getPERangeList()); runningGridlets_.add(gridlet); iter.remove(); @@ -702,7 +686,6 @@ } } - resource_.setPEsBusy(allocatedRanges); return gridletStarted; } @@ -720,7 +703,11 @@ itemsFinished = finishRunningGridlets(currentTime); // remove past entries from the availability profile - availProfile_.removePastEntries(currentTime); + AvailabilityProfileEntry currentStatus = + availProfile_.removePastEntries(currentTime); + if(currentStatus != null) { + resource_.resetFreePERanges(currentStatus.getPERanges()); + } // Start the execution of Gridlets that are queued and whose // potential start execution time is smaller than current time @@ -771,7 +758,7 @@ * @pre sgl != null * @post $none */ - private boolean startGridlet(SSGridlet sgl) { + protected boolean startGridlet(SSGridlet sgl) { int reqPE = sgl.getNumPE(); // calculate the execution time of the Gridlet @@ -821,7 +808,7 @@ * elements allocated. * @param sgl the resource gridlet */ - private void enqueueGridlet(SSGridlet sgl){ + protected void enqueueGridlet(SSGridlet sgl){ int reqPE = sgl.getNumPE(); // calculate the execution time of the Gridlet @@ -856,23 +843,24 @@ sgl.setActualFinishTime(finishTime); } - /** + /** * Selects a list of PE ranges able to provide enough PEs to handle - * a Gridlet. + * a reservation or a Gridlet. + * * @param reqPE the number of PEs - * @param startTime the start time of the Gridlet<br> - * @param duration the duration of the Gridlet + * @param startTime the start time of the reservation / Gridlet<br> + * @param duration the duration of the reservation / Gridlet * @return an array[2] of Objects as follows if there are enough PEs * to serve the Gridlet or reservation:<br> * array[0] the index of the last entry before the finish time - * of the Gridlet in the availability profile<br> + * of the reservation/Gridlet in the availability profile<br> * array[1] the li... [truncated message content] |