From: <aca...@us...> - 2008-05-29 16:42:44
|
Revision: 177 http://gridsim.svn.sourceforge.net/gridsim/?rev=177&view=rev Author: acaminero Date: 2008-05-29 09:42:45 -0700 (Thu, 29 May 2008) Log Message: ----------- incorporated FNB I/O ports Modified Paths: -------------- branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java Modified: branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java =================================================================== --- branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java 2008-05-29 16:40:25 UTC (rev 176) +++ branches/gridsim4.0-branch2/source/gridsim/GridSimCore.java 2008-05-29 16:42:45 UTC (rev 177) @@ -14,6 +14,7 @@ import gridsim.net.flow.*; import gridsim.util.*; import java.util.Collection; +import gridsim.net.fnb.*; /** @@ -166,7 +167,6 @@ * * @author Manzur Murshed and Rajkumar Buyya * @author Anthony Sulistio (re-written this class) - * @author James Broberg (added FlowInput and FlowOutput) * @since GridSim Toolkit 3.0 * @see eduni.simjava.Sim_entity * @see gridsim.net.Output @@ -177,7 +177,7 @@ */ public class GridSimCore extends Sim_entity { - private boolean networkedFlag_; // true, if networked entity, other false + private boolean networkedFlag_; // true, if networked entity, other false // false means NOT invoked private boolean terminateIOEntitiesFlag_ = false; @@ -191,11 +191,11 @@ /** Sending data via output port to external entities */ protected Sim_port output; - + // Output port but only for a network extension. private NetIO out_ = null; - // TODO: new addition + /** Specifies which type of network to be used */ protected static int NETWORK_TYPE = GridSimTags.NET_PACKET_LEVEL; @@ -313,27 +313,30 @@ // Packet Level networking has input & output if (GridSimCore.NETWORK_TYPE == GridSimTags.NET_PACKET_LEVEL) { - in = new Input("Input_" + name, baudRate); + in = new Input("Input_" + name, baudRate); out_ = new Output("Output_" + name, baudRate); } // Flow Level networking has flow input & output else if (GridSimCore.NETWORK_TYPE == GridSimTags.NET_FLOW_LEVEL) { - in = new FlowInput("Input_" + name, baudRate); - out_ = new FlowOutput("Output_" + name, baudRate); + in = new FlowInput("Input_" + name, baudRate); + out_ = new FlowOutput("Output_" + name, baudRate); } - else if (GridSimCore.NETWORK_TYPE == GridSimTags.NET_BUFFER_PACKET_LEVEL) + // Use Finite network buffer + else if (GridSimCore.NETWORK_TYPE == + GridSimTags.NET_BUFFER_PACKET_LEVEL) { - // TODO: + in = new FnbInput("Input_" + name, baudRate); + out_ = new FnbOutput("Output_" + name, baudRate); } - + System.out.println(super.get_name() + ".initNetwork()"); Sim_system.link_ports(name, "input", "Input_" + name, "input_buffer"); Sim_system.link_ports(name, "output", "Output_" + name, "output_buffer"); if (link != null) { - in.addLink(link); - out_.addLink(link); + in.addLink(link); + out_.addLink(link); } } @@ -347,7 +350,8 @@ * @pre $none * @post $none */ - public Link getLink() { + public Link getLink() + { return link_; } @@ -394,6 +398,7 @@ return out_.setBackgroundTraffic(gen, userName); } + /** * Pings to a particular entity ID with a given packet size. * <p> @@ -409,7 +414,8 @@ * @pre size >= 0 * @post $none */ - protected boolean ping(int entityID, int size) { + protected boolean ping(int entityID, int size) + { return ping(entityID, size, 0.0, 0); } @@ -428,7 +434,8 @@ * @pre size >= 0 * @post $none */ - protected boolean ping(String entityName, int size) { + protected boolean ping(String entityName, int size) + { return ping(entityName, size, 0.0, 0); } @@ -454,7 +461,7 @@ * @post $none */ protected boolean ping(String entityName, int size, double delay, - int netServiceLevel) + int netServiceLevel) { int id = GridSim.getEntityId(entityName); return ping(id, size, delay, netServiceLevel); @@ -487,24 +494,25 @@ if (entityID < 0) { System.out.println(super.get_name() + ".ping(): Error - " + - "invalid entity ID or name."); + "invalid entity ID or name."); return false; } if (size < 0) { System.out.println(super.get_name() + ".ping(): Error - " + - "invalid packet size."); + "invalid packet size."); return false; } - if (delay < 0) { + if (delay < 0) + { delay = 0.0; } // send this ping to the destination - send( this.output, delay, GridSimTags.INFOPKT_SUBMIT, - new IO_data(null, size, entityID, netServiceLevel) ); + send(this.output, delay, GridSimTags.INFOPKT_SUBMIT, + new IO_data(null, size, entityID, netServiceLevel)); return true; } @@ -533,7 +541,8 @@ int netServiceLevel) { boolean result = ping(entityID, size, delay, netServiceLevel); - if (result == false) { + if (result == false) + { return null; } @@ -624,21 +633,20 @@ super.sim_get_next(tag, ev); InfoPacket pkt = null; - try { + try + { pkt = (InfoPacket) ev.get_data(); - } - catch(Sim_exception sim) + } catch (Sim_exception sim) { System.out.print(super.get_name() + ".getPingResult(): Error - "); System.out.println("exception occurs. See the below message:"); - System.out.println( sim.getMessage() ); + System.out.println(sim.getMessage()); pkt = null; - } - catch(Exception e) + } catch (Exception e) { System.out.print(super.get_name() + ".getPingResult(): Error - "); System.out.println("exception occurs. See the below message:"); - System.out.println( e.getMessage() ); + System.out.println(e.getMessage()); pkt = null; } @@ -657,7 +665,8 @@ * @pre $none * @post $none */ - protected void TerminateInputOutputEntities() { + protected void TerminateInputOutputEntities() + { terminateIOEntities(); } @@ -675,7 +684,7 @@ protected void terminateIOEntities() { // If it is Networked entity and Not yet terminated, then terminate. - if ( isNetworked() && !terminateIOEntitiesFlag_ ) + if (isNetworked() && !terminateIOEntitiesFlag_) { // Send END_OF_SIMULATION to Input entity send(input, 0.0, GridSimTags.END_OF_SIMULATION); @@ -696,7 +705,8 @@ * @pre $none * @post $none */ - protected void finalize() { + protected void finalize() + { finalizeGridSimulation(); } @@ -707,7 +717,8 @@ * @pre $none * @post $none */ - protected void finalizeGridSimulation() { + protected void finalizeGridSimulation() + { terminateIOEntities(); } @@ -719,7 +730,8 @@ * @pre $none * @post $result == true || false */ - protected boolean IsNetworked() { + protected boolean IsNetworked() + { return isNetworked(); } @@ -730,7 +742,8 @@ * @pre $none * @post $result == true || false */ - protected boolean isNetworked() { + protected boolean isNetworked() + { return networkedFlag_; } @@ -777,7 +790,8 @@ * @pre delay >= 0.0 * @post $none */ - protected void Send(String entityName, double delay, int gridSimTag) { + protected void Send(String entityName, double delay, int gridSimTag) + { send(entityName, delay, gridSimTag); } @@ -823,12 +837,14 @@ */ protected void send(String entityName, double delay, int gridSimTag) { - if (entityName == null) { + if (entityName == null) + { return; } // if delay is -ve, then it doesn't make sense. So resets to 0.0 - if (delay < 0.0) { + if (delay < 0.0) + { delay = 0.0; } @@ -836,7 +852,7 @@ if (id < 0) { System.out.println(super.get_name() + ".send(): Error - " + - "invalid entity name \"" + entityName + "\"."); + "invalid entity name \"" + entityName + "\"."); return; } @@ -938,12 +954,14 @@ protected void send(String entityName, double delay, int gridSimTag, Object data) { - if (entityName == null) { + if (entityName == null) + { return; } // if delay is -ve, then it doesn't make sense. So resets to 0.0 - if (delay < 0.0) { + if (delay < 0.0) + { delay = 0.0; } @@ -951,7 +969,7 @@ if (id < 0) { System.out.println(super.get_name() + ".send(): Error - " + - "invalid entity name \"" + entityName + "\"."); + "invalid entity name \"" + entityName + "\"."); return; } @@ -1000,7 +1018,8 @@ * @pre delay >= 0.0 * @post $none */ - protected void Send(int entityID, double delay, int gridSimTag) { + protected void Send(int entityID, double delay, int gridSimTag) + { send(entityID, delay, gridSimTag); } @@ -1046,19 +1065,21 @@ */ protected void send(int entityID, double delay, int gridSimTag) { - if (entityID < 0) { + if (entityID < 0) + { return; } // if delay is -ve, then it doesn't make sense. So resets to 0.0 - if (delay < 0.0) { + if (delay < 0.0) + { delay = 0.0; } if (entityID < 0) { System.out.println(super.get_name() + ".send(): Error - " + - "invalid entity id " + entityID); + "invalid entity id " + entityID); return; } @@ -1158,19 +1179,21 @@ */ protected void send(int entityID, double delay, int gridSimTag, Object data) { - if (entityID < 0) { + if (entityID < 0) + { return; } // if delay is -ve, then it doesn't make sense. So resets to 0.0 - if (delay < 0.0) { + if (delay < 0.0) + { delay = 0.0; } if (entityID < 0) { System.out.println(super.get_name() + ".send(): Error - " + - "invalid entity id " + entityID); + "invalid entity id " + entityID); return; } @@ -1219,7 +1242,8 @@ * @pre delay >= 0.0 * @post $none */ - protected void Send(Sim_port destPort, double delay, int gridSimTag) { + protected void Send(Sim_port destPort, double delay, int gridSimTag) + { send(destPort, delay, gridSimTag); } @@ -1268,12 +1292,13 @@ if (destPort == null) { System.out.println(super.get_name() + ".send(): Error - " + - "destination port is null or empty."); + "destination port is null or empty."); return; } // if delay is -ve, then it doesn't make sense. So resets to 0.0 - if (delay < 0.0) { + if (delay < 0.0) + { delay = 0.0; } @@ -1326,7 +1351,7 @@ * @see gridsim.IO_data */ protected void Send(Sim_port destPort, double delay, int gridSimTag, - Object data) + Object data) { send(destPort, delay, gridSimTag, data); } @@ -1375,22 +1400,32 @@ * @see gridsim.IO_data */ protected void send(Sim_port destPort, double delay, int gridSimTag, - Object data) + Object data) { if (destPort == null) { System.out.println(super.get_name() + ".send(): Error - " + - "destination port is null or empty."); + "destination port is null or empty."); return; } // if delay is -ve, then it doesn't make sense. So resets to 0.0 - if (delay < 0.0) { + if (delay < 0.0) + { delay = 0.0; } super.sim_schedule(destPort, delay, gridSimTag, data); } + /**This function returns the NETWORK_TYPE parameter. + * @return NETWORK_TYPE + * */ + public static int getNetworkType() + { + return NETWORK_TYPE; + } + + } // end class This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |