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
e1cb19aa
Commit
e1cb19aa
authored
12 years ago
by
Andreas Wundsam
Browse files
Options
Downloads
Patches
Plain Diff
OFSwitchBase: fix broadcast portBroadcastCacheHitMap
parent
1f07bfc2
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/OFSwitchBase.java
+32
-24
32 additions, 24 deletions
...main/java/net/floodlightcontroller/core/OFSwitchBase.java
with
32 additions
and
24 deletions
src/main/java/net/floodlightcontroller/core/OFSwitchBase.java
+
32
−
24
View file @
e1cb19aa
...
...
@@ -30,14 +30,11 @@ import java.util.concurrent.ConcurrentHashMap;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicLong
;
import
java.util.concurrent.locks.Lock
;
import
java.util.concurrent.locks.ReentrantReadWriteLock
;
import
net.floodlightcontroller.core.FloodlightContext
;
import
net.floodlightcontroller.core.IFloodlightProviderService
;
import
net.floodlightcontroller.core.IOFMessageListener
;
import
net.floodlightcontroller.core.IFloodlightProviderService.Role
;
import
net.floodlightcontroller.core.IOFSwitch
;
import
net.floodlightcontroller.core.annotations.LogMessageDoc
;
import
net.floodlightcontroller.core.internal.Controller
;
import
net.floodlightcontroller.core.internal.OFFeaturesReplyFuture
;
...
...
@@ -56,11 +53,11 @@ import org.openflow.protocol.OFFlowMod;
import
org.openflow.protocol.OFMatch
;
import
org.openflow.protocol.OFMessage
;
import
org.openflow.protocol.OFPhysicalPort
;
import
org.openflow.protocol.OFPort
;
import
org.openflow.protocol.OFType
;
import
org.openflow.protocol.OFPhysicalPort.OFPortConfig
;
import
org.openflow.protocol.OFPhysicalPort.OFPortState
;
import
org.openflow.protocol.OFPort
;
import
org.openflow.protocol.OFStatisticsRequest
;
import
org.openflow.protocol.OFType
;
import
org.openflow.protocol.statistics.OFStatistics
;
import
org.openflow.util.HexString
;
import
org.openflow.util.U16
;
...
...
@@ -93,8 +90,8 @@ public abstract class OFSwitchBase implements IOFSwitch {
* Members hidden from subclasses
*/
private
Channel
channel
;
private
AtomicInteger
transactionIdSource
;
// Lock to protect modification of the port maps. We only need to
private
final
AtomicInteger
transactionIdSource
;
// Lock to protect modification of the port maps. We only need to
// synchronize on modifications. For read operations we are fine since
// we rely on ConcurrentMaps which works for our use case.
protected
Object
portLock
;
...
...
@@ -102,18 +99,18 @@ public abstract class OFSwitchBase implements IOFSwitch {
protected
ConcurrentHashMap
<
Short
,
OFPhysicalPort
>
portsByNumber
;
// Map port names to the appropriate OFPhyiscalPort
// XXX: The OF spec doesn't specify if port names need to be unique but
// according it's always the case in practice.
private
ConcurrentHashMap
<
String
,
OFPhysicalPort
>
portsByName
;
private
Map
<
Integer
,
OFStatisticsFuture
>
statsFutureMap
;
private
Map
<
Integer
,
IOFMessageListener
>
iofMsgListenersMap
;
private
Map
<
Integer
,
OFFeaturesReplyFuture
>
featuresFutureMap
;
// according it's always the case in practice.
private
final
ConcurrentHashMap
<
String
,
OFPhysicalPort
>
portsByName
;
private
final
Map
<
Integer
,
OFStatisticsFuture
>
statsFutureMap
;
private
final
Map
<
Integer
,
IOFMessageListener
>
iofMsgListenersMap
;
private
final
Map
<
Integer
,
OFFeaturesReplyFuture
>
featuresFutureMap
;
private
volatile
boolean
connected
;
private
TimedCache
<
Long
>
timedCache
;
private
ReentrantReadWriteLock
listenerLock
;
private
ConcurrentMap
<
Short
,
Long
>
portBroadcastCacheHitMap
;
private
final
TimedCache
<
Long
>
timedCache
;
private
final
ReentrantReadWriteLock
listenerLock
;
private
final
ConcurrentMap
<
Short
,
AtomicLong
>
portBroadcastCacheHitMap
;
protected
static
ThreadLocal
<
Map
<
IOFSwitch
,
List
<
OFMessage
>>>
local_msg_buffer
=
protected
final
static
ThreadLocal
<
Map
<
IOFSwitch
,
List
<
OFMessage
>>>
local_msg_buffer
=
new
ThreadLocal
<
Map
<
IOFSwitch
,
List
<
OFMessage
>>>()
{
@Override
protected
Map
<
IOFSwitch
,
List
<
OFMessage
>>
initialValue
()
{
...
...
@@ -139,8 +136,8 @@ public abstract class OFSwitchBase implements IOFSwitch {
this
.
role
=
null
;
this
.
timedCache
=
new
TimedCache
<
Long
>(
100
,
5
*
1000
);
// 5 seconds interval
this
.
listenerLock
=
new
ReentrantReadWriteLock
();
this
.
portBroadcastCacheHitMap
=
new
ConcurrentHashMap
<
Short
,
Long
>();
this
.
portBroadcastCacheHitMap
=
new
ConcurrentHashMap
<
Short
,
Atomic
Long
>();
// Defaults properties for an ideal switch
this
.
setAttribute
(
PROP_FASTWILDCARDS
,
OFMatch
.
OFPFW_ALL
);
this
.
setAttribute
(
PROP_SUPPORTS_OFPP_FLOOD
,
new
Boolean
(
true
));
...
...
@@ -524,10 +521,17 @@ public abstract class OFSwitchBase implements IOFSwitch {
@Override
public
boolean
updateBroadcastCache
(
Long
entry
,
Short
port
)
{
if
(
timedCache
.
update
(
entry
))
{
Long
count
=
portBroadcastCacheHitMap
.
putIfAbsent
(
port
,
new
Long
(
1
));
if
(
count
!=
null
)
{
count
++;
AtomicLong
count
=
portBroadcastCacheHitMap
.
get
(
port
);
if
(
count
==
null
)
{
AtomicLong
newCount
=
new
AtomicLong
(
0
);
AtomicLong
retrieved
;
if
((
retrieved
=
portBroadcastCacheHitMap
.
putIfAbsent
(
port
,
newCount
))
==
null
)
{
count
=
newCount
;
}
else
{
count
=
retrieved
;
}
}
count
.
incrementAndGet
();
return
true
;
}
else
{
return
false
;
...
...
@@ -537,7 +541,11 @@ public abstract class OFSwitchBase implements IOFSwitch {
@Override
@JsonIgnore
public
Map
<
Short
,
Long
>
getPortBroadcastHits
()
{
return
this
.
portBroadcastCacheHitMap
;
Map
<
Short
,
Long
>
res
=
new
HashMap
<
Short
,
Long
>();
for
(
Map
.
Entry
<
Short
,
AtomicLong
>
entry
:
portBroadcastCacheHitMap
.
entrySet
())
{
res
.
put
(
entry
.
getKey
(),
entry
.
getValue
().
get
());
}
return
res
;
}
...
...
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