Class RotatingIpRoutePlanner

  • All Implemented Interfaces:
    org.apache.http.conn.routing.HttpRoutePlanner

    public final class RotatingIpRoutePlanner
    extends AbstractRoutePlanner
    • Constructor Detail

      • RotatingIpRoutePlanner

        public RotatingIpRoutePlanner​(java.util.List<IpBlock> ipBlocks)
        Parameters:
        ipBlocks - the block to perform balancing over.
      • RotatingIpRoutePlanner

        public RotatingIpRoutePlanner​(java.util.List<IpBlock> ipBlocks,
                                      java.util.function.Predicate<java.net.InetAddress> ipFilter)
        Parameters:
        ipBlocks - the block to perform balancing over.
        ipFilter - function to filter out certain IP addresses picked from the IP block, causing another random to be chosen.
      • RotatingIpRoutePlanner

        public RotatingIpRoutePlanner​(java.util.List<IpBlock> ipBlocks,
                                      java.util.function.Predicate<java.net.InetAddress> ipFilter,
                                      boolean handleSearchFailure)
        Parameters:
        ipBlocks - the block to perform balancing over.
        ipFilter - function to filter out certain IP addresses picked from the IP block, causing another random to be chosen.
        handleSearchFailure - whether a search 429 should trigger the ip as failing
    • Method Detail

      • next

        public void next()
      • getCurrentAddress

        public java.net.InetAddress getCurrentAddress()
      • getIndex

        public java.math.BigInteger getIndex()
      • getRotateIndex

        public java.math.BigInteger getRotateIndex()
      • determineAddressPair

        protected Tuple<java.net.InetAddress,​java.net.InetAddress> determineAddressPair​(Tuple<java.net.Inet4Address,​java.net.Inet6Address> remoteAddresses)
                                                                                       throws org.apache.http.HttpException
        Description copied from class: AbstractRoutePlanner
        Determines the local and remote address pair to use
        Specified by:
        determineAddressPair in class AbstractRoutePlanner
        Parameters:
        remoteAddresses - The remote address pair containing IPv4 and IPv6 addresses - which can be null
        Returns:
        a Tuple which contains l = localAddress & r = remoteAddress
        Throws:
        org.apache.http.HttpException - when no route can be determined
      • onAddressFailure

        protected void onAddressFailure​(java.net.InetAddress address)
        Description copied from class: AbstractRoutePlanner
        Called when an address is marked as failing
        Overrides:
        onAddressFailure in class AbstractRoutePlanner
        Parameters:
        address - the failing address