|
From: <bro...@us...> - 2008-02-21 05:35:49
|
Revision: 118
http://gridsim.svn.sourceforge.net/gridsim/?rev=118&view=rev
Author: brobergj
Date: 2008-02-20 21:35:52 -0800 (Wed, 20 Feb 2008)
Log Message:
-----------
*Fixed deregisterFlow(), now notifies any affected active flows if bottleneck bandwidth increases
Modified Paths:
--------------
branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java
Modified: branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java
===================================================================
--- branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java 2008-02-21 05:33:52 UTC (rev 117)
+++ branches/gridsim4.0-branch2/source/gridsim/net/flow/FlowLink.java 2008-02-21 05:35:52 UTC (rev 118)
@@ -253,6 +253,7 @@
{
case GridSimTags.PKT_FORWARD: // for normal packets
case GridSimTags.JUNK_PKT: // for background traffic
+ case GridSimTags.FLOW_UPDATE:
System.out.println(super.get_name() + ".processEvent(): enque() + at time = " + GridSim.clock());
enque(ev);
break;
@@ -420,25 +421,33 @@
* @post $none
*/
private synchronized void registerFlow(Packet np) {
+
+ FlowPacket tempFlow;
+
+ // Add flow to link
+ flows_.put(np.getID(), np );
+
System.out.println(super.get_name() + ".registerFlow(): registering flow #" + np.getID()
+ " total of " + flows_.size() + " flows");
-
- // Add flow to link
- flows_.put(np.getID(), np );
-
+
// Register link to flow
((FlowPacket)np).addLink(this);
// Check if this affects any existing flows
Iterator<Integer> flowsIter = flows_.keySet().iterator();
while(flowsIter.hasNext()) {
+ tempFlow = (FlowPacket) flows_.get(flowsIter.next());
// If change in bandwidth affects an existing flow i.e. is < current bottleneck
- if (this.getBaudRate() < ((FlowPacket) flows_.get(flowsIter.next())).getBandwidth_() &&
- ((FlowPacket) flows_.get(flowsIter.next())).getID() != np.getID()) {
+ if (this.getBaudRate() < tempFlow.getBandwidth_() && tempFlow.getID() != np.getID()) {
// Need to notify flow
System.out.println(super.get_name() + ".registerFlow(): flow #" + np.getID()
+ " bottleneck now " + this.getBaudRate() + " at time " + GridSim.clock());
- // I can notify directly as I have know the destId's!!!!
+ // I can notify directly as I know the destId's!!!!
+ System.out.println(super.get_name() + ".registerFlow(): updating flow #" + tempFlow.getID()
+ + " destination " + tempFlow.getDestID());
+ super.sim_schedule(GridSim.getEntityId("Output_" +
+ GridSim.getEntityName(tempFlow.getDestID())), GridSimTags.SCHEDULE_NOW,
+ GridSimTags.FLOW_UPDATE, new Integer(tempFlow.getID()));
}
}
@@ -448,10 +457,33 @@
private synchronized void deregisterFlow(Packet np) {
FlowPacket fp = null;
+ FlowPacket tempFlow;
+
if ((fp = (FlowPacket) flows_.remove(np.getID())) != null) {
System.out.println(super.get_name() + ".deregisterFlow() success flow # " + np.getID()
+ " " + fp.getBandwidth_());
+
+ // Check if this affects any existing flows
+ Iterator<Integer> flowsIter = flows_.keySet().iterator();
+ while(flowsIter.hasNext()) {
+ tempFlow = (FlowPacket) flows_.get(flowsIter.next());
+ // If change in bandwidth affects an existing flow i.e. is > current bottleneck
+ // AND this link is the flow's bottleneck
+ if (this.getBaudRate() > tempFlow.getBandwidth_() && tempFlow.getID() != np.getID() &&
+ tempFlow.getBottleneckID() == this.get_id()) {
+ // Need to notify flow
+ System.out.println(super.get_name() + ".registerFlow(): flow #" + np.getID()
+ + " bottleneck now " + this.getBaudRate() + " at time " + GridSim.clock());
+ // I can notify directly as I know the destId's!!!!
+ System.out.println(super.get_name() + ".registerFlow(): updating flow #" + tempFlow.getID()
+ + " destination " + tempFlow.getDestID());
+ super.sim_schedule(GridSim.getEntityId("Output_" +
+ GridSim.getEntityName(tempFlow.getDestID())), GridSimTags.SCHEDULE_NOW,
+ GridSimTags.FLOW_UPDATE, new Integer(tempFlow.getID()));
+ }
+
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|