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
55602b48
Commit
55602b48
authored
8 years ago
by
Geddings Barrineau
Browse files
Options
Downloads
Patches
Plain Diff
Added getRoutesFast and getRoutesSlow.
parent
00b3ab01
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
+61
-3
61 additions, 3 deletions
...a/net/floodlightcontroller/topology/TopologyInstance.java
with
61 additions
and
3 deletions
src/main/java/net/floodlightcontroller/topology/TopologyInstance.java
+
61
−
3
View file @
55602b48
...
...
@@ -109,8 +109,9 @@ public class TopologyInstance {
// routecache contains n (specified in floodlightdefault.properties) routes
// in order between every switch. Calculated using Yen's algorithm.
protected
Map
<
RouteId
,
ArrayList
<
Route
>>
routecache
=
new
HashMap
<>();
protected
Map
<
RouteId
,
ArrayList
<
Route
>>
routecache
;
protected
static
volatile
int
maximumRouteEntriesStored
=
10
;
public
TopologyInstance
(
Map
<
DatapathId
,
Set
<
OFPort
>>
switchPorts
,
Set
<
NodePortTuple
>
blockedPorts
,
Map
<
NodePortTuple
,
Set
<
Link
>>
switchPortLinks
,
...
...
@@ -171,6 +172,9 @@ public class TopologyInstance {
return
pathCacheLoader
.
load
(
rid
);
}
});
this
.
routecache
=
new
HashMap
<
RouteId
,
ArrayList
<
Route
>>();
}
public
void
compute
()
{
...
...
@@ -918,7 +922,7 @@ public class TopologyInstance {
for
(
DatapathId
src
:
switches
)
{
for
(
DatapathId
dst
:
switches
)
{
routes
=
getRoutes
(
src
,
dst
,
5
);
// Hard coded value needs to be replaced.
routes
=
getRoutes
(
src
,
dst
,
maximumRouteEntriesStored
);
routeId
=
new
RouteId
(
src
,
dst
);
routecache
.
put
(
routeId
,
routes
);
}
...
...
@@ -1163,6 +1167,60 @@ public class TopologyInstance {
return
linkDpidMap
;
}
/**
*
* This function returns K number of routes between a source and destination IF THEY EXIST IN THE ROUTECACHE.
* If the user requests more routes than available, only the routes already stored in memory will be returned.
* This value can be adjusted in floodlightdefault.properties.
*
*
* @param src: DatapathId of the route source.
* @param dst: DatapathId of the route destination.
* @param K: The number of routes that you want. Must be positive integer.
* @return ArrayList of Routes or null if bad parameters
*/
protected
ArrayList
<
Route
>
getRoutesFast
(
DatapathId
src
,
DatapathId
dst
,
Integer
K
)
{
// TODO: Think about using int instead of Integer
RouteId
routeId
=
new
RouteId
(
src
,
dst
);
ArrayList
<
Route
>
routes
=
routecache
.
get
(
routeId
);
if
(
routes
==
null
||
K
<
1
)
return
null
;
if
(
K
>=
maximumRouteEntriesStored
||
K
>=
routes
.
size
())
{
return
routes
;
}
else
{
return
new
ArrayList
<
Route
>(
routes
.
subList
(
0
,
K
));
}
}
/**
*
* This function returns K number of routes between a source and destination. It will attempt to retrieve
* these routes from the routecache. If the user requests more routes than are stored, Yen's algorithm will be
* run using the K value passed in.
*
*
* @param src: DatapathId of the route source.
* @param dst: DatapathId of the route destination.
* @param K: The number of routes that you want. Must be positive integer.
* @return ArrayList of Routes or null if bad parameters
*/
protected
ArrayList
<
Route
>
getRoutesSlow
(
DatapathId
src
,
DatapathId
dst
,
Integer
K
)
{
// TODO: Think about using int instead of Integer
RouteId
routeId
=
new
RouteId
(
src
,
dst
);
ArrayList
<
Route
>
routes
=
routecache
.
get
(
routeId
);
if
(
routes
==
null
||
K
<
1
)
return
null
;
if
(
K
>=
maximumRouteEntriesStored
||
K
>=
routes
.
size
())
{
return
getRoutes
(
src
,
dst
,
K
);
}
else
{
return
new
ArrayList
<
Route
>(
routes
.
subList
(
0
,
K
));
}
}
protected
void
setRouteCosts
(
Route
r
)
{
U64
cost
=
U64
.
ZERO
;
...
...
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