Skip to content
Snippets Groups Projects
Commit 62656fe2 authored by Shudong Zhou's avatar Shudong Zhou
Browse files

BSC-3397 Add IOFSwitch.writeThrottled() and make OFMessageDamper call it

parent a955edcb
No related branches found
No related tags found
No related merge requests found
...@@ -107,7 +107,17 @@ public interface IOFSwitch { ...@@ -107,7 +107,17 @@ public interface IOFSwitch {
public void setChannel(Channel channel); public void setChannel(Channel channel);
/** /**
* Writes to the OFMessage to the output stream. * Write OFMessage to the output stream, subject to switch rate limiting.
* The message will be handed to the floodlightProvider for possible filtering
* and processing by message listeners
* @param msg
* @param cntx
* @throws IOException
*/
public void writeThrottled(OFMessage msg, FloodlightContext cntx) throws IOException;
/**
* Writes to the OFMessage to the output stream, bypassing rate limiting.
* The message will be handed to the floodlightProvider for possible filtering * The message will be handed to the floodlightProvider for possible filtering
* and processing by message listeners * and processing by message listeners
* @param m * @param m
......
...@@ -183,6 +183,13 @@ public abstract class OFSwitchBase implements IOFSwitch { ...@@ -183,6 +183,13 @@ public abstract class OFSwitchBase implements IOFSwitch {
this.channel = channel; this.channel = channel;
} }
@Override
public void writeThrottled(OFMessage m, FloodlightContext bc)
throws IOException {
// By default, there is no throttling
write(m, bc);
}
@Override @Override
public void write(OFMessage m, FloodlightContext bc) public void write(OFMessage m, FloodlightContext bc)
throws IOException { throws IOException {
......
...@@ -134,7 +134,7 @@ public class OFMessageDamper { ...@@ -134,7 +134,7 @@ public class OFMessageDamper {
FloodlightContext cntx, boolean flush) FloodlightContext cntx, boolean flush)
throws IOException { throws IOException {
if (! msgTypesToCache.contains(msg.getType())) { if (! msgTypesToCache.contains(msg.getType())) {
sw.write(msg, cntx); sw.writeThrottled(msg, cntx);
if (flush) { if (flush) {
sw.flush(); sw.flush();
} }
...@@ -146,7 +146,7 @@ public class OFMessageDamper { ...@@ -146,7 +146,7 @@ public class OFMessageDamper {
// entry exists in cache. Dampening. // entry exists in cache. Dampening.
return false; return false;
} else { } else {
sw.write(msg, cntx); sw.writeThrottled(msg, cntx);
if (flush) { if (flush) {
sw.flush(); sw.flush();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment