Class HttpIdleConnectionReaper


  • public class HttpIdleConnectionReaper
    extends java.lang.Object
    Class that embodies a Reaper thread that reaps idle connections. Note that the thread won't be started if the value of the idleCheckInterval parameter is equal to 0.
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpIdleConnectionReaper​(org.apache.http.client.HttpClient httpClient, long idleCheckInterval, long idleTimeout)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isStarted()
      Returns true if the reaper is started.
      boolean isStopped()
      Returns true if the reaper is stopped.
      void stop()
      Stops the Idle Connection Reaper if running.
      void waitForReaperStart​(long millis)
      Tells the reaper thread the maximum time to wait before starting.
      void waitForReaperStop​(long millis)
      Tells the reaper thread the maximum time to wait before stopping.
      • Methods inherited from class java.lang.Object

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

      • httpClient

        private final org.apache.http.client.HttpClient httpClient
        The HttpClient for which this is the reaper.
      • idleCheckInterval

        private final long idleCheckInterval
        The time to sleep between checks for idle connections.
      • idleTimeOut

        private final long idleTimeOut
        The age of connections to reap.
    • Constructor Detail

      • HttpIdleConnectionReaper

        public HttpIdleConnectionReaper​(org.apache.http.client.HttpClient httpClient,
                                        long idleCheckInterval,
                                        long idleTimeout)
        Constructor.
        Parameters:
        httpClient - The HttpClient for which this is the reaper.
        idleCheckInterval - The time to sleep between checks for idle connections. Note that if this is 0, then reaping won't occur.
        idleTimeout - The age of connections to reap.
    • Method Detail

      • isStarted

        public boolean isStarted()
        Returns true if the reaper is started.
        Returns:
        true If the reaper is started.
      • isStopped

        public boolean isStopped()
        Returns true if the reaper is stopped.
        Returns:
        true if the reaper is stopped.
      • stop

        public void stop()
                  throws java.lang.InterruptedException
        Stops the Idle Connection Reaper if running.
        Throws:
        java.lang.InterruptedException - If the call to stop was interrupted
      • waitForReaperStart

        public void waitForReaperStart​(long millis)
                                throws java.lang.InterruptedException
        Tells the reaper thread the maximum time to wait before starting.
        Parameters:
        millis - The maximum time to wait before starting the thread.
        Throws:
        java.lang.InterruptedException - If the current thread was interrupted.
      • waitForReaperStop

        public void waitForReaperStop​(long millis)
                               throws java.lang.InterruptedException
        Tells the reaper thread the maximum time to wait before stopping.
        Parameters:
        millis - The maximum time to wait before stopping the thread.
        Throws:
        java.lang.InterruptedException - If the current thread was interrupted.