Class IdleConnectionSweeper

    • Field Detail

      • destroyed

        private boolean destroyed
        Whether this sweeper has been destroyed.
      • createdTimer

        private boolean createdTimer
        Whether this sweeper created a TimerTask to use and thus should destroy when destroy() is invoked.
      • executionTime

        @Nullable
        private Instant executionTime
        Time at which the sweeper last executed.
      • connectionManager

        @Nonnull
        private final org.apache.http.conn.HttpClientConnectionManager connectionManager
        HttpClientConnectionManager whose connections will be swept.
      • taskTimer

        @Nonnull
        private final Timer taskTimer
        Timer used to schedule and execute the sweeping task.
      • sweeper

        @Nonnull
        private final TimerTask sweeper
        Sweeping task executed by the timer.
    • Constructor Detail

      • IdleConnectionSweeper

        public IdleConnectionSweeper​(@Nonnull
                                     org.apache.http.conn.HttpClientConnectionManager manager,
                                     @Nonnull
                                     Duration idleTimeout,
                                     @Nonnull
                                     Duration sweepInterval)
        Constructor. This method will create a daemon Timer and use it to periodically sweep connections.
        Parameters:
        manager - HTTP client connection manager whose connections will be swept
        idleTimeout - length of time connection may be idle before being closed down
        sweepInterval - length of time between sweeps
      • IdleConnectionSweeper

        public IdleConnectionSweeper​(@Nonnull
                                     org.apache.http.conn.HttpClientConnectionManager manager,
                                     @Nonnull
                                     Duration idleTimeout,
                                     @Nonnull
                                     Duration sweepInterval,
                                     @Nonnull
                                     Timer backgroundTimer)
        Constructor.
        Parameters:
        manager - HTTP client connection manager whose connections will be swept
        idleTimeout - length of time connection may be idle before being closed down
        sweepInterval - length of time between sweeps
        backgroundTimer - timer used to schedule the background sweeping task
    • Method Detail

      • scheduledExecutionTime

        @Nonnull
        public Instant scheduledExecutionTime()
        Gets the time when the sweeper last executed or, if it has not yet executed, when it was first scheduled to run.
        Returns:
        the time when the sweeper last executed or when it was first scheduled to run
      • isDestroyed

        public boolean isDestroyed()
        Gets whether this component has been destroyed. Normally, once a component has been destroyed it cannot be used.
        Specified by:
        isDestroyed in interface DestructableComponent
        Returns:
        true iff the component has been destroyed