Class AbstractChannelPoolMap<K,P extends ChannelPool>

java.lang.Object
io.netty.channel.pool.AbstractChannelPoolMap<K,P>
All Implemented Interfaces:
ChannelPoolMap<K,P>, Closeable, AutoCloseable, Iterable<Map.Entry<K,P>>

public abstract class AbstractChannelPoolMap<K,P extends ChannelPool> extends Object implements ChannelPoolMap<K,P>, Iterable<Map.Entry<K,P>>, Closeable
A skeletal ChannelPoolMap implementation. To find the right ChannelPool the Object.hashCode() and Object.equals(Object) is used.
  • Field Details

  • Constructor Details

    • AbstractChannelPoolMap

      public AbstractChannelPoolMap()
  • Method Details

    • get

      public final P get(K key)
      Description copied from interface: ChannelPoolMap
      Return the ChannelPool for the code. This will never return null, but create a new ChannelPool if non exists for they requested key. Please note that null keys are not allowed.
      Specified by:
      get in interface ChannelPoolMap<K,P extends ChannelPool>
    • remove

      public final boolean remove(K key)
      Remove the ChannelPool from this AbstractChannelPoolMap. Returns true if removed, false otherwise. If the removed pool extends SimpleChannelPool it will be closed asynchronously to avoid blocking in this method. Please note that null keys are not allowed.
    • removeAsyncIfSupported

      private Future<Boolean> removeAsyncIfSupported(K key)
      Remove the ChannelPool from this AbstractChannelPoolMap. Returns a future that comletes with a true result if the pool has been removed by this call, otherwise the result is false. If the removed pool extends SimpleChannelPool it will be closed asynchronously to avoid blocking in this method. The returned future will be completed once this asynchronous pool close operation completes.
    • poolCloseAsyncIfSupported

      private static Future<Void> poolCloseAsyncIfSupported(ChannelPool pool)
      If the pool implementation supports asynchronous close, then use it to avoid a blocking close call in case the ChannelPoolMap operations are called from an EventLoop.
      Parameters:
      pool - the ChannelPool to be closed
    • iterator

      public final Iterator<Map.Entry<K,P>> iterator()
      Specified by:
      iterator in interface Iterable<K>
    • size

      public final int size()
      Returns the number of ChannelPools currently in this AbstractChannelPoolMap.
    • isEmpty

      public final boolean isEmpty()
      Returns true if the AbstractChannelPoolMap is empty, otherwise false.
    • contains

      public final boolean contains(K key)
      Description copied from interface: ChannelPoolMap
      Returns true if a ChannelPool exists for the given key. Please note that null keys are not allowed.
      Specified by:
      contains in interface ChannelPoolMap<K,P extends ChannelPool>
    • newPool

      protected abstract P newPool(K key)
      Called once a new ChannelPool needs to be created as non exists yet for the key.
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable