Class ShutdownableChannelGroup

  • All Implemented Interfaces:
    Shutdownable, ShutdownableResource, io.netty.channel.group.ChannelGroup, java.lang.Comparable<io.netty.channel.group.ChannelGroup>, java.lang.Iterable<io.netty.channel.Channel>, java.util.Collection<io.netty.channel.Channel>, java.util.Set<io.netty.channel.Channel>

    public class ShutdownableChannelGroup
    extends io.netty.channel.group.DefaultChannelGroup
    implements ShutdownableResource
    • Constructor Summary

      Constructors 
      Constructor Description
      ShutdownableChannelGroup​(io.netty.util.concurrent.EventExecutor executor)
      Creates a new group with a generated name and the provided EventExecutor to notify the ChannelGroupFutures.
      ShutdownableChannelGroup​(io.netty.util.concurrent.EventExecutor executor, boolean stayClosed)
      Creates a new group with a generated name and the provided EventExecutor to notify the ChannelGroupFutures.
      ShutdownableChannelGroup​(java.lang.String name, io.netty.util.concurrent.EventExecutor executor)
      Creates a new group with the specified name and EventExecutor to notify the ChannelGroupFutures.
      ShutdownableChannelGroup​(java.lang.String name, io.netty.util.concurrent.EventExecutor executor, boolean stayClosed)
      Creates a new group with the specified name and EventExecutor to notify the ChannelGroupFutures.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      boolean isShutdown()
      Returns true if this resource has been shut down.
      boolean isTerminated()
      Returns true if the resource has completed shutting down.
      void shutdown()
      Starts the shutdown process.
      void waitForShutdown()
      Waits for shutdown to complete
      void waitForShutdown​(long timeoutInMs)
      Waits for shutdown to complete with a timeout
      • Methods inherited from class io.netty.channel.group.DefaultChannelGroup

        add, clear, close, close, compareTo, contains, deregister, deregister, disconnect, disconnect, find, flush, flush, flushAndWrite, flushAndWrite, isEmpty, iterator, name, newCloseFuture, newCloseFuture, remove, size, toArray, toArray, toString, write, write, write, writeAndFlush, writeAndFlush, writeAndFlush
      • Methods inherited from class java.util.AbstractSet

        removeAll
      • Methods inherited from class java.util.AbstractCollection

        addAll, containsAll, retainAll
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Set

        addAll, containsAll, removeAll, retainAll, spliterator
    • Constructor Detail

      • ShutdownableChannelGroup

        public ShutdownableChannelGroup​(io.netty.util.concurrent.EventExecutor executor)
        Creates a new group with a generated name and the provided EventExecutor to notify the ChannelGroupFutures.
        Parameters:
        executor -
      • ShutdownableChannelGroup

        public ShutdownableChannelGroup​(java.lang.String name,
                                        io.netty.util.concurrent.EventExecutor executor)
        Creates a new group with the specified name and EventExecutor to notify the ChannelGroupFutures. Please note that different groups can have the same name, which means no duplicate check is done against group names.
        Parameters:
        name -
        executor -
      • ShutdownableChannelGroup

        public ShutdownableChannelGroup​(io.netty.util.concurrent.EventExecutor executor,
                                        boolean stayClosed)
        Creates a new group with a generated name and the provided EventExecutor to notify the ChannelGroupFutures. stayClosed defines whether or not, this group can be closed more than once. Adding channels to a closed group will immediately close them, too. This makes it easy, to shutdown server and child channels at once.
        Parameters:
        executor -
        stayClosed -
      • ShutdownableChannelGroup

        public ShutdownableChannelGroup​(java.lang.String name,
                                        io.netty.util.concurrent.EventExecutor executor,
                                        boolean stayClosed)
        Creates a new group with the specified name and EventExecutor to notify the ChannelGroupFutures. stayClosed defines whether or not, this group can be closed more than once. Adding channels to a closed group will immediately close them, too. This makes it easy, to shutdown server and child channels at once. Please note that different groups can have the same name, which means no duplicate check is done against group names.
        Parameters:
        name -
        executor -
        stayClosed -
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<io.netty.channel.Channel>
        Specified by:
        equals in interface java.util.Set<io.netty.channel.Channel>
        Overrides:
        equals in class io.netty.channel.group.DefaultChannelGroup
      • isShutdown

        public boolean isShutdown()
        Description copied from interface: ShutdownableResource
        Returns true if this resource has been shut down.
        Specified by:
        isShutdown in interface ShutdownableResource
        Returns:
        true if this resource has been shut down
      • isTerminated

        public boolean isTerminated()
        Description copied from interface: ShutdownableResource
        Returns true if the resource has completed shutting down. Note that isTerminated is never true unless shutdown was called first.
        Specified by:
        isTerminated in interface ShutdownableResource
        Returns:
        true if the resource has completed shutting down.
      • shutdown

        public void shutdown()
        Description copied from interface: Shutdownable
        Starts the shutdown process. It is recommended to perform the actual shutdown activity in a separate thread from the thread that calls shutdown
        Specified by:
        shutdown in interface Shutdownable
      • waitForShutdown

        public void waitForShutdown()
                             throws java.lang.InterruptedException,
                                    java.lang.IllegalStateException
        Description copied from interface: Shutdownable
        Waits for shutdown to complete
        Specified by:
        waitForShutdown in interface Shutdownable
        Throws:
        java.lang.InterruptedException - when the wait is interrupted
        java.lang.IllegalStateException - when the method is invoked when the shutdown has yet to be started
      • waitForShutdown

        public void waitForShutdown​(long timeoutInMs)
                             throws java.lang.InterruptedException,
                                    java.lang.IllegalStateException,
                                    java.util.concurrent.TimeoutException
        Description copied from interface: Shutdownable
        Waits for shutdown to complete with a timeout
        Specified by:
        waitForShutdown in interface Shutdownable
        Parameters:
        timeoutInMs - number of milliseconds to wait before throwing TimeoutException
        Throws:
        java.lang.InterruptedException - when the wait is interrupted
        java.lang.IllegalStateException - when the method is invoked when the shutdown has yet to be started
        java.util.concurrent.TimeoutException - when the operation times out
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<io.netty.channel.Channel>
        Specified by:
        hashCode in interface java.util.Set<io.netty.channel.Channel>
        Overrides:
        hashCode in class io.netty.channel.group.DefaultChannelGroup