Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
floodlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
croft1
floodlight
Commits
e717d5d9
Commit
e717d5d9
authored
12 years ago
by
Shudong Zhou
Browse files
Options
Downloads
Patches
Plain Diff
BSC-3414: Implement writeThrottle()
parent
6ecf0829
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/net/floodlightcontroller/core/OFSwitchBase.java
+40
-6
40 additions, 6 deletions
...main/java/net/floodlightcontroller/core/OFSwitchBase.java
with
40 additions
and
6 deletions
src/main/java/net/floodlightcontroller/core/OFSwitchBase.java
+
40
−
6
View file @
e717d5d9
...
...
@@ -36,6 +36,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import
net.floodlightcontroller.core.IFloodlightProviderService.Role
;
import
net.floodlightcontroller.core.annotations.LogMessageDoc
;
import
net.floodlightcontroller.core.annotations.LogMessageDocs
;
import
net.floodlightcontroller.core.internal.Controller
;
import
net.floodlightcontroller.core.internal.OFFeaturesReplyFuture
;
import
net.floodlightcontroller.core.internal.OFStatisticsFuture
;
...
...
@@ -110,6 +111,8 @@ public abstract class OFSwitchBase implements IOFSwitch {
private
final
ReentrantReadWriteLock
listenerLock
;
private
final
ConcurrentMap
<
Short
,
AtomicLong
>
portBroadcastCacheHitMap
;
// Private members for throttling
private
boolean
writeThrottleEnabled
=
false
;
protected
final
static
ThreadLocal
<
Map
<
IOFSwitch
,
List
<
OFMessage
>>>
local_msg_buffer
=
new
ThreadLocal
<
Map
<
IOFSwitch
,
List
<
OFMessage
>>>()
{
...
...
@@ -182,19 +185,50 @@ public abstract class OFSwitchBase implements IOFSwitch {
public
void
setChannel
(
Channel
channel
)
{
this
.
channel
=
channel
;
}
// For driver subclass to set throttling
public
void
enableWriteThrottle
(
boolean
enable
)
{
this
.
writeThrottleEnabled
=
enable
;
}
@Override
@LogMessageDocs
({
@LogMessageDoc
(
level
=
"WARN"
,
message
=
"Drop throttled OF message to switch {switch}"
,
explanation
=
"The controller is sending more messages"
+
"than the switch can handle. Some messages are dropped"
+
"to prevent switch outage"
,
recommendation
=
LogMessageDoc
.
REPORT_CONTROLLER_BUG
)
})
public
void
writeThrottled
(
OFMessage
m
,
FloodlightContext
bc
)
throws
IOException
{
// By default, there is no throttling
write
(
m
,
bc
);
/**
* By default, channel uses an unbounded send queue. Enable throttling
* prevents the queue from growing big.
*
* channel.isWritable() returns true when queue length is less than
* high water mark (64 kbytes). Once exceeded, isWritable() becomes
* false after queue length drops below low water mark (32 kbytes).
*/
if
(!
writeThrottleEnabled
||
channel
.
isWritable
())
{
write
(
m
,
bc
);
}
else
{
// Let logback duplicate filtering take care of excessive logs
// TODO Convert to counter and events
log
.
warn
(
"Drop throttled OF message to switch {}"
,
this
);
}
}
@Override
public
void
writeThrottled
(
List
<
OFMessage
>
msglist
,
FloodlightContext
bc
)
throws
IOException
{
// By default, there is no throttling
write
(
msglist
,
bc
);
if
(!
writeThrottleEnabled
||
channel
.
isWritable
())
{
write
(
msglist
,
bc
);
}
else
{
// Let logback duplicate filtering take care of excessive logs
// TODO Convert to counter and events
log
.
warn
(
"Drop throttled OF message to switch {}"
,
this
);
}
}
@Override
...
...
@@ -249,7 +283,7 @@ public abstract class OFSwitchBase implements IOFSwitch {
* @param msglist
* @throws IOException
*/
p
ublic
void
write
(
List
<
OFMessage
>
msglist
)
throws
IOException
{
p
rivate
void
write
(
List
<
OFMessage
>
msglist
)
throws
IOException
{
this
.
channel
.
write
(
msglist
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment