Class DefaultRoutingHandler


  • public class DefaultRoutingHandler
    extends Object
    Default routing handler that is responsible for route computing and routing rule population.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static Function<EdgePair,​Long> HASH_FUNCTION
      Implements the hash function for the shouldProgram logic.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void acquireRoutingLock()
      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.
      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.
      void populateAllRoutingRules()
      Populates all routing rules to all switches.
      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.
      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.
      void releaseRoutingLock()
      Releases the lock used when making routing changes.
      protected boolean revokeSubnet​(Set<org.onlab.packet.IpPrefix> subnets, org.onosproject.net.DeviceId destSw)
      Revoke rules of given subnet in all edge switches.
      protected boolean revokeSubnet​(Set<org.onosproject.net.DeviceId> targetSwitches, Set<org.onlab.packet.IpPrefix> subnets)
      Revoke rules of given subnets in the given switches.
      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.
      void shutdown()
      Gracefully shuts down the defaultRoutingHandler.
      void startPopulationProcess()
      Start the flow rule population process if it was never started.
    • Field Detail

      • HASH_FUNCTION

        protected static final Function<EdgePair,​Long> HASH_FUNCTION
        Implements the hash function for the shouldProgram logic.
    • 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 added
        subnets - 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 switch
        linkUp - the single link up, or null for other conditions such as link-down or a removed switch
        switchDown - the removed switch, or null for other conditions such as link-down or link-up
        seenBefore - 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 removed
        destSw - 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 removed
        subnets - 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