Class PickFirstLeafLoadBalancer


  • final class PickFirstLeafLoadBalancer
    extends LoadBalancer
    A LoadBalancer that provides no load-balancing over the addresses from the NameResolver. The channel's default behavior is used, which is walking down the address list and sticking to the first that works.
    • Method Detail

      • isSerializingRetries

        static boolean isSerializingRetries()
      • acceptResolvedAddresses

        public Status acceptResolvedAddresses​(LoadBalancer.ResolvedAddresses resolvedAddresses)
        Description copied from class: LoadBalancer
        Accepts newly resolved addresses from the name resolution system. The EquivalentAddressGroup addresses should be considered equivalent but may be flattened into a single list if needed.

        Implementations can choose to reject the given addresses by returning false.

        Implementations should not modify the given addresses.

        Overrides:
        acceptResolvedAddresses in class LoadBalancer
        Parameters:
        resolvedAddresses - the resolved server addresses, attributes, and config.
        Returns:
        true if the resolved addresses were accepted. false if rejected.
      • handleNameResolutionError

        public void handleNameResolutionError​(Status error)
        Description copied from class: LoadBalancer
        Handles an error from the name resolution system.
        Specified by:
        handleNameResolutionError in class LoadBalancer
        Parameters:
        error - a non-OK status
      • scheduleBackoff

        private void scheduleBackoff()
        Only called after all addresses attempted and failed (TRANSIENT_FAILURE).
      • shutdown

        public void shutdown()
        Description copied from class: LoadBalancer
        The channel asks the load-balancer to shutdown. No more methods on this class will be called after this method. The implementation should shutdown all Subchannels and OOB channels, and do any other cleanup as necessary.
        Specified by:
        shutdown in class LoadBalancer
      • shutdownRemaining

        private void shutdownRemaining​(PickFirstLeafLoadBalancer.SubchannelData activeSubchannelData)
        Shuts down remaining subchannels. Called when a subchannel becomes ready, which means that all other subchannels must be shutdown.
      • requestConnection

        public void requestConnection()
        Requests a connection to the next applicable address' subchannel, creating one if necessary. Schedules a connection to next address in list as well. If the current channel has already attempted a connection, we attempt a connection to the next address/subchannel in our list. We assume that createNewSubchannel will never return null.
        Overrides:
        requestConnection in class LoadBalancer
      • scheduleNextConnection

        private void scheduleNextConnection()
        Happy Eyeballs Schedules connection attempt to happen after a delay to the next available address.
      • cancelScheduleTask

        private void cancelScheduleTask()
      • isPassComplete

        private boolean isPassComplete()
      • getGroupIndex

        int getGroupIndex()
      • isIndexValid

        boolean isIndexValid()