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
6efcb2ef
Commit
6efcb2ef
authored
12 years ago
by
Shudong Zhou
Browse files
Options
Downloads
Patches
Plain Diff
Dampen frequency of HA role transitions
parent
078cc7e0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/net/floodlightcontroller/core/internal/Controller.java
+24
-3
24 additions, 3 deletions
...va/net/floodlightcontroller/core/internal/Controller.java
with
24 additions
and
3 deletions
src/main/java/net/floodlightcontroller/core/internal/Controller.java
+
24
−
3
View file @
6efcb2ef
...
...
@@ -41,6 +41,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.RejectedExecutionException
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
import
net.floodlightcontroller.core.FloodlightContext
;
import
net.floodlightcontroller.core.IFloodlightProviderService
;
...
...
@@ -57,6 +59,7 @@ import net.floodlightcontroller.core.annotations.LogMessageDoc;
import
net.floodlightcontroller.core.annotations.LogMessageDocs
;
import
net.floodlightcontroller.core.internal.OFChannelState.HandshakeState
;
import
net.floodlightcontroller.core.util.ListenerDispatcher
;
import
net.floodlightcontroller.core.util.SingletonTask
;
import
net.floodlightcontroller.core.web.CoreWebRoutable
;
import
net.floodlightcontroller.counter.ICounterStoreService
;
import
net.floodlightcontroller.flowcache.IFlowCacheService
;
...
...
@@ -186,9 +189,12 @@ public class Controller implements IFloodlightProviderService,
// this role and then notify, on a transition to master we first notify
// and then set the role. We then use it to make sure we don't forward
// OF messages while the modules are in slave role.
protected
volatile
Role
notifiedRole
;
// The pendingRole is a role change just received, but not sent out
// notifications yet.
protected
Role
pendingRole
;
protected
volatile
Role
notifiedRole
;
// A helper that handles sending and timeout handling for role requests
protected
RoleChanger
roleChanger
;
protected
SingletonTask
roleChangeDamper
;
// Start time of the controller
protected
long
systemStartTime
;
...
...
@@ -382,19 +388,26 @@ public class Controller implements IFloodlightProviderService,
public
void
setRole
(
Role
role
)
{
if
(
role
==
null
)
throw
new
NullPointerException
(
"Role can not be null."
);
// If role is changed in quick succession for some reason,
// the 2 second delay will dampen the frequency.
this
.
pendingRole
=
role
;
roleChangeDamper
.
reschedule
(
2000
,
TimeUnit
.
MILLISECONDS
);
}
protected
void
doSetRole
()
{
// Need to synchronize to ensure a reliable ordering on role request
// messages send and to ensure the list of connected switches is stable
// RoleChanger will handle the actual sending of the message and
// timeout handling
// @see RoleChanger
synchronized
(
roleChanger
)
{
if
(
r
ole
.
equals
(
this
.
role
))
{
if
(
pendingR
ole
.
equals
(
this
.
role
))
{
log
.
debug
(
"Ignoring role change: role is already {}"
,
role
);
return
;
}
Role
oldRole
=
this
.
role
;
this
.
role
=
r
ole
;
this
.
role
=
pendingR
ole
;
log
.
debug
(
"Submitting role change request to role {}"
,
role
);
roleChanger
.
submitRequest
(
connectedSwitches
,
role
);
...
...
@@ -1768,6 +1781,14 @@ public class Controller implements IFloodlightProviderService,
this
.
roleChanger
=
new
RoleChanger
(
this
);
initVendorMessages
();
this
.
systemStartTime
=
System
.
currentTimeMillis
();
ScheduledExecutorService
ses
=
threadPool
.
getScheduledExecutor
();
roleChangeDamper
=
new
SingletonTask
(
ses
,
new
Runnable
()
{
@Override
public
void
run
()
{
doSetRole
();
}
});
}
/**
...
...
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