Class AbstractRoutePlanner

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​java.lang.Long> failingAddresses  
      protected IpBlock ipBlock  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractRoutePlanner​(java.util.List<IpBlock> ipBlocks, boolean handleSearchFailure)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract Tuple<java.net.InetAddress,​java.net.InetAddress> determineAddressPair​(Tuple<java.net.Inet4Address,​java.net.Inet6Address> remoteAddresses)
      Determines the local and remote address pair to use
      org.apache.http.conn.routing.HttpRoute determineRoute​(org.apache.http.HttpHost host, org.apache.http.HttpRequest request, org.apache.http.protocol.HttpContext context)  
      void freeAddress​(java.net.InetAddress address)  
      void freeAllAddresses()  
      java.util.Map<java.lang.String,​java.lang.Long> getFailingAddresses()  
      protected long getFailingIpsCacheDuration()
      How long a failing address should not be reused in milliseconds
      IpBlock getIpBlock()  
      java.net.InetAddress getLastAddress​(org.apache.http.client.protocol.HttpClientContext context)  
      protected boolean isValidAddress​(java.net.InetAddress address)  
      void markAddressFailing​(org.apache.http.client.protocol.HttpClientContext context)  
      protected void onAddressFailure​(java.net.InetAddress address)
      Called when an address is marked as failing
      boolean shouldHandleSearchFailure()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ipBlock

        protected final IpBlock ipBlock
      • failingAddresses

        protected final java.util.Map<java.lang.String,​java.lang.Long> failingAddresses
    • Constructor Detail

      • AbstractRoutePlanner

        protected AbstractRoutePlanner​(java.util.List<IpBlock> ipBlocks,
                                       boolean handleSearchFailure)
    • Method Detail

      • getIpBlock

        public IpBlock getIpBlock()
      • shouldHandleSearchFailure

        public boolean shouldHandleSearchFailure()
      • getFailingAddresses

        public java.util.Map<java.lang.String,​java.lang.Long> getFailingAddresses()
      • getLastAddress

        public final java.net.InetAddress getLastAddress​(org.apache.http.client.protocol.HttpClientContext context)
      • markAddressFailing

        public final void markAddressFailing​(org.apache.http.client.protocol.HttpClientContext context)
      • freeAddress

        public final void freeAddress​(java.net.InetAddress address)
      • freeAllAddresses

        public final void freeAllAddresses()
      • isValidAddress

        protected final boolean isValidAddress​(java.net.InetAddress address)
      • determineRoute

        public org.apache.http.conn.routing.HttpRoute determineRoute​(org.apache.http.HttpHost host,
                                                                     org.apache.http.HttpRequest request,
                                                                     org.apache.http.protocol.HttpContext context)
                                                              throws org.apache.http.HttpException
        Specified by:
        determineRoute in interface org.apache.http.conn.routing.HttpRoutePlanner
        Throws:
        org.apache.http.HttpException
      • onAddressFailure

        protected void onAddressFailure​(java.net.InetAddress address)
        Called when an address is marked as failing
        Parameters:
        address - the failing address
      • getFailingIpsCacheDuration

        protected long getFailingIpsCacheDuration()
        How long a failing address should not be reused in milliseconds
        Returns:
        duration in milliseconds
      • determineAddressPair

        protected abstract Tuple<java.net.InetAddress,​java.net.InetAddress> determineAddressPair​(Tuple<java.net.Inet4Address,​java.net.Inet6Address> remoteAddresses)
                                                                                                throws org.apache.http.HttpException
        Determines the local and remote address pair to use
        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