From: <sul...@us...> - 2008-09-29 10:27:52
|
Revision: 247 http://gridsim.svn.sourceforge.net/gridsim/?rev=247&view=rev Author: sulistio Date: 2008-09-29 10:27:42 +0000 (Mon, 29 Sep 2008) Log Message: ----------- deleted since it is redundant. Removed Paths: ------------- trunk/source/gridsim/net/fnb/FnbRouter.java Deleted: trunk/source/gridsim/net/fnb/FnbRouter.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbRouter.java 2008-09-23 11:11:48 UTC (rev 246) +++ trunk/source/gridsim/net/fnb/FnbRouter.java 2008-09-29 10:27:42 UTC (rev 247) @@ -1,365 +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 - * - * Author: Agustin Caminero - * Organization: Universidad de Castilla La Mancha (UCLM), Spain. - * Author: Gokul Poduval & Chen-Khong Tham - * Copyright (c) 2008, The University of Melbourne, Australia and - * Universidad de Castilla La Mancha (UCLM), Spain - */ - -package gridsim.net.fnb; - -import java.util.*; -import gridsim.*; -import gridsim.net.*; -import gridsim.util.SimReport; -import eduni.simjava.*; - -/** - * This class implements a Router which forwards data from one entity to - * another. - * <p> - * This abstract class only contains abstract methods to connect other - * routers and hosts. In addition, common functionalities are available - * in this class for its children classes to use. - * However, this class does not provide methods on how to setup forwarding - * tables, so the design of that is left to the user if he/she wants to - * create a Router with some specific routing algorithm. - * <p> - * Few important notes to consider when extending from this class: - * <ul> - * <li>do not override {@link #body()} method as - * it contains code/functionality to register this entity to - * {@link gridsim.GridInformationService} entity, and finalizing - * logging information before exiting the simulation. - * <li>must overridden {@link #advertiseHosts()} method. It is - * needed for advertising all hosts or - * entities connected to this entity to adjacent routers. - * <li>{@link #registerOtherEntity()} method : for registering other - * event type/tag to {@link gridsim.GridInformationService}. - * This is optional. - * <li>must overridden {@link #processEvent(Sim_event)} method. - * It is needed for processing incoming events. - * <li>do not forget to implement logging or recording functionalities - * for incoming and outgoing packets. <br> - * {@link gridsim.util.SimReport} object is created in this class, - * hence, you only need to use {@link #write(String)} method. - * </ul> - * - * @invariant $none - * @since GridSim Toolkit 4.2 - * @author Agustin Caminero, University of Castilla La Mancha, Spain. - * Based on class Router, by Gokul Poduval & Chen-Khong Tham, - * National University of Singapore. - * Functions added or modified: - * - get_my_id() - */ -public abstract class FnbRouter extends Sim_entity -{ - /** An attribute that logs incoming and outgoing packets into a file. - * Use {@link #write(String)} to log or record the information. - */ - protected SimReport reportWriter_; - - /** Denotes a time delay (in second) for sending events in the future. */ - protected static int DELAY = 2; // in seconds - - - /** - *Creates a new RIPRouter object. By default, <b>no recording or logging</b> - * is done for packets' activities. If you want to log operations of this - * entity, please use {@link #FnbRouter(String, boolean)}. - * - * @param name Name of this router - * @throws NullPointerException This happens when name is empty or null - * @see #FnbRouter(String, boolean) - * @pre name != null - * @post $none - */ - public FnbRouter(String name) throws NullPointerException - { - super(name); - reportWriter_ = null; - } - - /** - * Creates a new FnbRouter object with logging facility if it is turned on. - * <br> - * NOTE: If logging facility is turned on, there are some overheads - * in terms of performance and memory consumption. - * - * @param name Name of this router - * @param trace <tt>true</tt> if you want to record this router's - * activity, <tt>false</tt> otherwise - * @throws NullPointerException This happens when name is empty or null - * @pre name != null - * @post $none - */ - public FnbRouter(String name, boolean trace) throws NullPointerException - { - super(name); - try - { - if (trace == true) { - reportWriter_ = new SimReport(name + "_report"); - } - else { - reportWriter_ = null; - } - } - catch (Exception e) - { - System.out.println(name + "(): Exception error."); - System.out.println( e.getMessage() ); - reportWriter_ = null; - } - } - - /** - * Joins two routers with a Link. - * - * @param router The router on the other side to which this one will - * be attached. - * @param link This is the link that will be used to connect the two - * routers. - * @param thisSched The scheduling policy used on this routers egress port - * when sending data through it. - * @param otherSched The scheduling policy that will be used on the - * egress port of the router being connected to when - * sending data to this router. - * @pre router != null - * @pre link != null - * @pre thisSched != null - * @pre otherSched != null - * @post $none - */ - public abstract void attachRouter(FnbRouter router, Link link, - PacketScheduler thisSched, PacketScheduler otherSched); - - /** - * Joins two routers together. This is called by the routers themselves - * and should not be called by other entities. - * - * @param router The FnbRouter to which this router will be connected. - * @param link The Link that will be used to join these routers. - * @param sched The scheduling policy used on the egress port of the - * router when sending data through this route. - * @pre router != null - * @pre link != null - * @pre sched != null - * @post $none - */ - protected abstract void attachRouter(FnbRouter router, Link link, - PacketScheduler sched); - - /** - * Attaches an entity to this router. The link between the router and the - * entity being attached is taken from - * {@link gridsim.GridSimCore#getLink()}. - * - * @param entity The entity to be attached. - * @param sched The scheduling policy that will be used on the egress - * port when the router sends data to the entity being - * joined. - * @see gridsim.GridSimCore#getLink() - * @pre entity != null - * @pre sched != null - * @post $none - */ - public abstract void attachHost(GridSimCore entity, PacketScheduler sched); - - /** - * Returns the Scheduler associated with a packet. Each packet has a - * destination. The router returns the scheduler that it would use to - * scheduler this packet if it were traversing this router. Once a - * reference to the scheduler is obtained, different parameters - * (like priorities, weights etc.) could be modified. - * - * @param np NetPacket for which the associated scheduler is to be - * returned. This can be used to set weigths, priorities, etc. - * as the case may be on the Scheduler. - * @return the packet's scheduler - * @pre np != null - * @post $none - */ - public abstract PacketScheduler getScheduler(Packet np); - - /** - * Returns the Scheduler that the router would use to reach a particular - * destination. Once a reference to the scheduler is obtained, different - * parameters (like priorities, weights etc.) could be modified. - * - * @param dest id of the destination for which the Scheduler is required. - * @return the packet's scheduler - * @pre dest > 0 - * @post $none - */ - public abstract PacketScheduler getScheduler(int dest); - - /** - * Returns the Scheduler that the router would use to reach a particular - * destination. This can be used to set weigths, priorities etc. as the - * case may be on the Scheduler - * - * @param dest Name of the destination for which the Scheduler is required. - * @return the packet's scheduler - * @pre dest != null - * @post $none - */ - public abstract PacketScheduler getScheduler(String dest); - - /** - * This method prints out the forwarding table of the router in a human - * readable form. - * @pre $none - * @post $none - */ - public abstract void printRoutingTable(); - - - /** - * Returns an ArrayList containing this router's routing table in a nice-formatted layout, using RoutingPath class. - * @pre $none - * @post $none - */ - - // public abstract ArrayList getRoutingTable(); - - - /** - * Returns the my_id_ of this router - * @pre $none - * @post $none - * @return the my_id_ of he entity - */ - - public abstract int get_my_id(); - - /** - * Handles incoming requests. <b>DO NOT</b> overrides this method as - * it contains code/functionality to register this entity to - * {@link gridsim.GridInformationService} entity, and finalizing - * logging information before exiting the simulation. - * <p> - * This method also calls these methods in the following order: - * <ol> - * <li>must overridden {@link #advertiseHosts()} method. It is - * needed for advertising all hosts or - * entities connected to this entity to adjacent routers. - * <li> {@link #registerOtherEntity()} method : for registering other - * event type/tag to {@link gridsim.GridInformationService}. - * This is optional. - * <li>must overridden {@link #processEvent(Sim_event)} method. - * It is needed for processing incoming events. - * </ol> - * - * @pre $none - * @post $none - */ - public void body() - { - //register oneself - write("register this entity to GridInformationService entity."); - super.sim_schedule(GridSim.getGridInfoServiceEntityId(), - GridSimTags.SCHEDULE_NOW, GridSimTags.REGISTER_ROUTER, - new Integer(super.get_id()) ); - - // methods to be overriden by children classes - advertiseHosts(); - registerOtherEntity(); - - // This random is to avoid the initial stages of sims, where nothing happens - // (as users have not started to send gridlets). - Random random = new Random(5); - super.sim_schedule(super.get_id(), - GridSimTags.SCHEDULE_NOW + (200 * random.nextDouble()), - GridSimTags.FNB_UPDATE_ARED_PARAMETERS); - - // Process incoming events - Sim_event ev = new Sim_event(); - while ( Sim_system.running() ) - { - //Sim_event ev = new Sim_event(); - super.sim_get_next(ev); - - // if the simulation finishes then exit the loop - if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) - { - write("receives, END_OF_SIMULATION, signal, from, " + - GridSim.getEntityName(ev.get_src()) ); - break; - } - - // process the received event - processEvent(ev); - } - - // finalize logging before exiting - if (reportWriter_ != null) { - reportWriter_.finalWrite(); - } - } - - /** - * All hosts connected to this router are advertised to adjacent routers - * @pre $none - * @post $none - */ - protected abstract void advertiseHosts(); - - /** - * Overrides this method when creating a new type of router. - * This method is called by {@link #body()} for incoming unknown tags. - * <p> - * The services or tags available for this resource are: - * <ul> - * <li> {@link gridsim.GridSimTags#PKT_FORWARD} - * <li> {@link gridsim.GridSimTags#JUNK_PKT} - * <li> {@link gridsim.GridSimTags#ROUTER_AD} - * </ul> - * - * @param ev a Sim_event object - * @pre ev != null - * @post $none - */ - protected abstract void processEvent(Sim_event ev); - - /** - * Overrides this method when making a type of router. - * This method is called by {@link #body()} to register other type to - * {@link gridsim.GridInformationService} entity. In doing so, you - * need to create a new child class extending from - * {@link gridsim.GridInformationService}. - * <br> - * <b>NOTE:</b> You do not need to override {@link #body()} method, if - * you use this method. - * - * @pre $none - * @post $none - * @see gridsim.GridInformationService - */ - protected void registerOtherEntity() { - // ... empty - } - - /** - * Writes a debug information to a file. - * The format of information is left to the coder. - * - * @param str a string message - * @pre str != null - * @post $none - */ - protected void write(String str) - { - if (reportWriter_ != null) { - reportWriter_.write(str); - } - } - - -} // end class This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |