From bfed2d4570d46b59f099580ba9fb5c9013c37c7b Mon Sep 17 00:00:00 2001 From: Shudong Zhou <shudongzhou@gmail.com> Date: Fri, 5 Apr 2013 06:57:15 -0700 Subject: [PATCH] BSC-3397 Add writeThrottled() for list of messages --- .../net/floodlightcontroller/core/IOFSwitch.java | 14 ++++++++++++-- .../floodlightcontroller/core/OFSwitchBase.java | 8 +++++++- .../util/OFMessageDamperMockSwitch.java | 7 +++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java index 5678035f4..6bc92c98f 100644 --- a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java +++ b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java @@ -116,6 +116,17 @@ public interface IOFSwitch { */ public void writeThrottled(OFMessage msg, FloodlightContext cntx) throws IOException; + /** + * Writes the list of messages to the output stream, subject to rate limiting. + * The message will be handed to the floodlightProvider for possible filtering + * and processing by message listeners. + * @param msglist + * @param bc + * @throws IOException + */ + void writeThrottled(List<OFMessage> msglist, FloodlightContext bc) + throws IOException; + /** * Writes to the OFMessage to the output stream, bypassing rate limiting. * The message will be handed to the floodlightProvider for possible filtering @@ -127,7 +138,7 @@ public interface IOFSwitch { public void write(OFMessage m, FloodlightContext bc) throws IOException; /** - * Writes the list of messages to the output stream + * Writes the list of messages to the output stream, bypassing rate limiting. * The message will be handed to the floodlightProvider for possible filtering * and processing by message listeners. * @param msglist @@ -498,5 +509,4 @@ public interface IOFSwitch { * @return */ public List<Short> getUplinkPorts(); - } diff --git a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java index 6e9941961..31c1ae075 100644 --- a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java +++ b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java @@ -190,6 +190,13 @@ public abstract class OFSwitchBase implements IOFSwitch { write(m, bc); } + @Override + public void writeThrottled(List<OFMessage> msglist, FloodlightContext bc) + throws IOException { + // By default, there is no throttling + write(msglist, bc); + } + @Override public void write(OFMessage m, FloodlightContext bc) throws IOException { @@ -209,7 +216,6 @@ public abstract class OFSwitchBase implements IOFSwitch { msg_buffer.clear(); } } - @Override @LogMessageDoc(level="WARN", message="Sending OF message that modifies switch " + diff --git a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java index 14a92d1fe..29191365c 100644 --- a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java +++ b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java @@ -111,6 +111,13 @@ public class OFMessageDamperMockSwitch implements IOFSwitch { //------------------------------------------------------- // IOFSwitch: not-implemented methods + + @Override + public void writeThrottled(List<OFMessage> msglist, FloodlightContext bc) + throws IOException { + assertTrue("Unexpected method call", false); + } + @Override public void write(List<OFMessage> msglist, FloodlightContext bc) throws IOException { -- GitLab