Class DelayedProxyProvider

java.lang.Object
org.oxerr.webmagic.proxy.DelayedProxyProvider
All Implemented Interfaces:
Externalizable, Serializable, us.codecraft.webmagic.proxy.ProxyProvider

public class DelayedProxyProvider extends Object implements us.codecraft.webmagic.proxy.ProxyProvider, Externalizable
See Also:
  • Field Details

    • log

      private final transient org.apache.logging.log4j.Logger log
    • proxies

      private final transient DelayQueue<DelayedProxy> proxies
    • allProxies

      private final transient Map<us.codecraft.webmagic.proxy.Proxy,DelayedProxy> allProxies
    • minSuccessDelay

      private long minSuccessDelay
    • maxSuccessDelay

      private long maxSuccessDelay
    • minFailureDelay

      private long minFailureDelay
    • maxFailureDelay

      private long maxFailureDelay
    • waitTimeout

      private long waitTimeout
  • Constructor Details

    • DelayedProxyProvider

      public DelayedProxyProvider()
    • DelayedProxyProvider

      public DelayedProxyProvider(Duration minSuccessDelay, Duration maxSuccessDelay, Duration minFailureDelay, Duration maxFailureDelay)
    • DelayedProxyProvider

      public DelayedProxyProvider(Duration minSuccessDelay, Duration maxSuccessDelay, Duration minFailureDelay, Duration maxFailureDelay, Duration waitTimeout)
  • Method Details

    • returnProxy

      public void returnProxy(us.codecraft.webmagic.proxy.Proxy proxy, us.codecraft.webmagic.Page page, us.codecraft.webmagic.Task task)
      Specified by:
      returnProxy in interface us.codecraft.webmagic.proxy.ProxyProvider
    • getProxy

      public us.codecraft.webmagic.proxy.Proxy getProxy(us.codecraft.webmagic.Request request, us.codecraft.webmagic.Task task)
      Specified by:
      getProxy in interface us.codecraft.webmagic.proxy.ProxyProvider
    • put

      public void put(us.codecraft.webmagic.proxy.Proxy proxy)
    • getProxies

      public DelayQueue<DelayedProxy> getProxies()
    • getAllProxies

      public Map<us.codecraft.webmagic.proxy.Proxy,DelayedProxy> getAllProxies()
    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException
    • getDelay

      protected Duration getDelay(DelayedProxy delayedProxy, us.codecraft.webmagic.Page page, us.codecraft.webmagic.Task task, boolean success)
    • getDelayFactor

      protected float getDelayFactor(DelayedProxy delayedProxy, us.codecraft.webmagic.Page page, us.codecraft.webmagic.Task task, boolean success)
    • isSuccess

      protected boolean isSuccess(us.codecraft.webmagic.proxy.Proxy proxy, us.codecraft.webmagic.Page page, us.codecraft.webmagic.Task task)
    • printInfo

      protected void printInfo()