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
1beded8a
Commit
1beded8a
authored
12 years ago
by
Srinivasan Ramasubramanian
Browse files
Options
Downloads
Patches
Plain Diff
Make path cache to be a LoadingCache, to make it multi-thread safe.
parent
3a80fd14
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/topology/TopologyInstance.java
+40
-8
40 additions, 8 deletions
...a/net/floodlightcontroller/topology/TopologyInstance.java
with
40 additions
and
8 deletions
src/main/java/net/floodlightcontroller/topology/TopologyInstance.java
+
40
−
8
View file @
1beded8a
...
...
@@ -36,7 +36,7 @@ import net.floodlightcontroller.routing.BroadcastTree;
import
net.floodlightcontroller.routing.Link
;
import
net.floodlightcontroller.routing.Route
;
import
net.floodlightcontroller.routing.RouteId
;
import
net.floodlightcontroller.util.LRUHashMap
;
import
com.google.common.cache.*
;
/**
* A representation of a network topology. Used internally by
...
...
@@ -76,7 +76,23 @@ public class TopologyInstance {
protected
Map
<
Long
,
BroadcastTree
>
destinationRootedTrees
;
protected
Map
<
Long
,
Set
<
NodePortTuple
>>
clusterBroadcastNodePorts
;
protected
Map
<
Long
,
BroadcastTree
>
clusterBroadcastTrees
;
protected
LRUHashMap
<
RouteId
,
Route
>
pathcache
;
protected
class
PathCacheLoader
extends
CacheLoader
<
RouteId
,
Route
>
{
TopologyInstance
ti
;
PathCacheLoader
(
TopologyInstance
ti
)
{
this
.
ti
=
ti
;
}
@Override
public
Route
load
(
RouteId
rid
)
{
return
ti
.
buildroute
(
rid
);
}
}
// Path cache loader is defined for loading a path when it not present
// in the cache.
private
final
PathCacheLoader
pathCacheLoader
=
new
PathCacheLoader
(
this
);
protected
LoadingCache
<
RouteId
,
Route
>
pathcache
;
public
TopologyInstance
()
{
this
.
switches
=
new
HashSet
<
Long
>();
...
...
@@ -132,7 +148,15 @@ public class TopologyInstance {
destinationRootedTrees
=
new
HashMap
<
Long
,
BroadcastTree
>();
clusterBroadcastTrees
=
new
HashMap
<
Long
,
BroadcastTree
>();
clusterBroadcastNodePorts
=
new
HashMap
<
Long
,
Set
<
NodePortTuple
>>();
pathcache
=
new
LRUHashMap
<
RouteId
,
Route
>(
PATH_CACHE_SIZE
);
pathcache
=
CacheBuilder
.
newBuilder
().
concurrencyLevel
(
4
)
.
maximumSize
(
1000L
)
.
build
(
new
CacheLoader
<
RouteId
,
Route
>()
{
public
Route
load
(
RouteId
rid
)
{
return
pathCacheLoader
.
load
(
rid
);
}
});
}
public
void
compute
()
{
...
...
@@ -511,7 +535,7 @@ public class TopologyInstance {
}
protected
void
calculateShortestPathTreeInClusters
()
{
pathcache
.
clear
();
pathcache
.
invalidateAll
();
destinationRootedTrees
.
clear
();
Map
<
Link
,
Integer
>
linkCost
=
new
HashMap
<
Link
,
Integer
>();
...
...
@@ -664,15 +688,23 @@ public class TopologyInstance {
return
r
;
}
// NOTE: Return a null route if srcId equals dstId. The null route
// need not be stored in the cache. Moreover, the LoadingCache will
// throw an exception if null route is returned.
protected
Route
getRoute
(
long
srcId
,
long
dstId
,
long
cookie
)
{
// Return null route if srcId equals dstId
if
(
srcId
==
dstId
)
return
null
;
RouteId
id
=
new
RouteId
(
srcId
,
dstId
);
Route
result
=
null
;
if
(
pathcache
.
containsKey
(
id
))
{
try
{
result
=
pathcache
.
get
(
id
);
}
else
{
result
=
buildroute
(
id
);
pathcache
.
put
(
id
,
result
);
}
catch
(
Exception
e
)
{
log
.
error
(
"{}"
,
e
);
}
if
(
log
.
isTraceEnabled
())
{
log
.
trace
(
"getRoute: {} -> {}"
,
id
,
result
);
}
...
...
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