Package org.onosproject.segmentrouting
Class DefaultRoutingHandler
- java.lang.Object
-
- org.onosproject.segmentrouting.DefaultRoutingHandler
-
public class DefaultRoutingHandler extends Object
Default routing handler that is responsible for route computing and routing rule population.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classDefaultRoutingHandler.FullRerouteAfterPurgePerforms a full reroute of routing rules in all the switches.protected classDefaultRoutingHandler.MasterChangeprotected classDefaultRoutingHandler.RetryFiltersRetryFilters populates filtering objectives for a device and keeps retrying till the number of ports filtered are constant for a predefined number of attempts.static classDefaultRoutingHandler.StatusRepresents the default routing population status.
-
Field Summary
Fields Modifier and Type Field Description protected static Function<EdgePair,Long>HASH_FUNCTIONImplements the hash function for the shouldProgram logic.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquireRoutingLock()Acquires the lock used when making routing changes.com.google.common.collect.ImmutableMap<org.onosproject.net.DeviceId,EcmpShortestPathGraph>getCurrentEmcpSpgMap()Returns an immutable copy of the current ECMP shortest-path graph as computed by this controller instance.booleanisRoutingStable()Determines if routing in the network has been stable in the last STABILITY_THRESHOLD seconds, by comparing the current time to the last routing change timestamp.voidpopulateAllRoutingRules()Populates all routing rules to all switches.voidpopulateRoutingRulesForLinkStatusChange(org.onosproject.net.Link linkDown, org.onosproject.net.Link linkUp, org.onosproject.net.DeviceId switchDown, boolean seenBefore)Populates the routing rules or makes hash group changes according to the route-path changes due to link failure, switch failure or link up.protected voidpopulateSubnet(Set<org.onosproject.net.ConnectPoint> cpts, Set<org.onlab.packet.IpPrefix> subnets)Populate rules from all other edge devices to the connect-point(s) specified for the given subnets.voidreleaseRoutingLock()Releases the lock used when making routing changes.protected booleanrevokeSubnet(Set<org.onlab.packet.IpPrefix> subnets, org.onosproject.net.DeviceId destSw)Revoke rules of given subnet in all edge switches.protected booleanrevokeSubnet(Set<org.onosproject.net.DeviceId> targetSwitches, Set<org.onlab.packet.IpPrefix> subnets)Revoke rules of given subnets in the given switches.booleanshouldProgram(org.onosproject.net.DeviceId deviceId)Determines whether this controller instance should program the given deviceId, based on workPartitionService and pairDeviceId if one exists.voidshutdown()Gracefully shuts down the defaultRoutingHandler.voidstartPopulationProcess()Start the flow rule population process if it was never started.
-
-
-
Method Detail
-
getCurrentEmcpSpgMap
public com.google.common.collect.ImmutableMap<org.onosproject.net.DeviceId,EcmpShortestPathGraph> getCurrentEmcpSpgMap()
Returns an immutable copy of the current ECMP shortest-path graph as computed by this controller instance.- Returns:
- immutable copy of the current ECMP graph
-
acquireRoutingLock
public void acquireRoutingLock()
Acquires the lock used when making routing changes.
-
releaseRoutingLock
public void releaseRoutingLock()
Releases the lock used when making routing changes.
-
isRoutingStable
public boolean isRoutingStable()
Determines if routing in the network has been stable in the last STABILITY_THRESHOLD seconds, by comparing the current time to the last routing change timestamp.- Returns:
- true if stable
-
shutdown
public void shutdown()
Gracefully shuts down the defaultRoutingHandler. Typically called when the app is deactivated
-
populateAllRoutingRules
public void populateAllRoutingRules()
Populates all routing rules to all switches. Typically triggered at startup or after a configuration event.
-
populateSubnet
protected void populateSubnet(Set<org.onosproject.net.ConnectPoint> cpts, Set<org.onlab.packet.IpPrefix> subnets)
Populate rules from all other edge devices to the connect-point(s) specified for the given subnets.- Parameters:
cpts- connect point(s) of the subnets being addedsubnets- subnets being added
-
populateRoutingRulesForLinkStatusChange
public void populateRoutingRulesForLinkStatusChange(org.onosproject.net.Link linkDown, org.onosproject.net.Link linkUp, org.onosproject.net.DeviceId switchDown, boolean seenBefore)Populates the routing rules or makes hash group changes according to the route-path changes due to link failure, switch failure or link up. This method should only be called for one of these three possible event-types. Note that when a switch goes away, all of its links fail as well, but this is handled as a single switch removal event.- Parameters:
linkDown- the single failed link, or null for other conditions such as link-up or a removed switchlinkUp- the single link up, or null for other conditions such as link-down or a removed switchswitchDown- the removed switch, or null for other conditions such as link-down or link-upseenBefore- true if this event is for a linkUp or linkDown for a seen link
-
startPopulationProcess
public void startPopulationProcess()
Start the flow rule population process if it was never started. The process finishes successfully when all flow rules are set and stops with ABORTED status when any groups required for flows is not set yet.
-
revokeSubnet
protected boolean revokeSubnet(Set<org.onlab.packet.IpPrefix> subnets, org.onosproject.net.DeviceId destSw)
Revoke rules of given subnet in all edge switches. Use the destination switch (if it is provided) to provide coordination among the instances. Otherwise, only the leader of the target switch can remove this subnet.- Parameters:
subnets- subnet being removeddestSw- destination switch. It is null when it is called from RouteHandler, in this context we don't have a way to remember the old locations.- Returns:
- true if succeed
-
revokeSubnet
protected boolean revokeSubnet(Set<org.onosproject.net.DeviceId> targetSwitches, Set<org.onlab.packet.IpPrefix> subnets)
Revoke rules of given subnets in the given switches.- Parameters:
targetSwitches- switched from which subnets to be removedsubnets- subnet bring removed- Returns:
- true if succeed
-
shouldProgram
public boolean shouldProgram(org.onosproject.net.DeviceId deviceId)
Determines whether this controller instance should program the given deviceId, based on workPartitionService and pairDeviceId if one exists. Once an instance is elected, it will be the only instance responsible for programming both devices in the pair until it goes down.- Parameters:
deviceId- the device id- Returns:
- true if this instance leads the programming, false otherwise
-
-