Class ExpiryQueue<E>

java.lang.Object
org.apache.zookeeper.server.ExpiryQueue<E>

public class ExpiryQueue<E> extends Object
ExpiryQueue tracks elements in time sorted fixed duration buckets. It's used by SessionTrackerImpl to expire sessions and NIOServerCnxnFactory to expire connections.
  • Constructor Details

    • ExpiryQueue

      public ExpiryQueue(int expirationInterval)
  • Method Details

    • remove

      public Long remove(E elem)
      Removes element from the queue.
      Parameters:
      elem - element to remove
      Returns:
      time at which the element was set to expire, or null if it wasn't present
    • update

      public Long update(E elem, int timeout)
      Adds or updates expiration time for element in queue, rounding the timeout to the expiry interval bucketed used by this queue.
      Parameters:
      elem - element to add/update
      timeout - timout in milliseconds
      Returns:
      time at which the element is now set to expire if changed, or null if unchanged
    • getWaitTime

      public long getWaitTime()
      Returns:
      milliseconds until next expiration time, or 0 if has already past
    • poll

      public Set<E> poll()
      Remove the next expired set of elements from expireMap. This method needs to be called frequently enough by checking getWaitTime(), otherwise there will be a backlog of empty sets queued up in expiryMap.
      Returns:
      next set of expired elements, or an empty set if none are ready
    • dump

      public void dump(PrintWriter pwriter)
    • getExpiryMap

      public Map<Long,Set<E>> getExpiryMap()
      Returns an unmodifiable view of the expiration time -> elements mapping.