Class ShutdownableChannelGroup
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<io.netty.channel.Channel>
-
- io.netty.channel.group.DefaultChannelGroup
-
- com.linkedin.alpini.netty4.handlers.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 providedEventExecutorto notify theChannelGroupFutures.ShutdownableChannelGroup(io.netty.util.concurrent.EventExecutor executor, boolean stayClosed)Creates a new group with a generated name and the providedEventExecutorto notify theChannelGroupFutures.ShutdownableChannelGroup(java.lang.String name, io.netty.util.concurrent.EventExecutor executor)Creates a new group with the specifiednameandEventExecutorto notify theChannelGroupFutures.ShutdownableChannelGroup(java.lang.String name, io.netty.util.concurrent.EventExecutor executor, boolean stayClosed)Creates a new group with the specifiednameandEventExecutorto notify theChannelGroupFutures.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)inthashCode()booleanisShutdown()Returns true if this resource has been shut down.booleanisTerminated()Returns true if the resource has completed shutting down.voidshutdown()Starts the shutdown process.voidwaitForShutdown()Waits for shutdown to completevoidwaitForShutdown(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
-
-
-
-
Constructor Detail
-
ShutdownableChannelGroup
public ShutdownableChannelGroup(io.netty.util.concurrent.EventExecutor executor)
Creates a new group with a generated name and the providedEventExecutorto notify theChannelGroupFutures.- Parameters:
executor-
-
ShutdownableChannelGroup
public ShutdownableChannelGroup(java.lang.String name, io.netty.util.concurrent.EventExecutor executor)Creates a new group with the specifiednameandEventExecutorto notify theChannelGroupFutures. 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 providedEventExecutorto notify theChannelGroupFutures.stayCloseddefines 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 specifiednameandEventExecutorto notify theChannelGroupFutures.stayCloseddefines 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:
equalsin interfacejava.util.Collection<io.netty.channel.Channel>- Specified by:
equalsin interfacejava.util.Set<io.netty.channel.Channel>- Overrides:
equalsin classio.netty.channel.group.DefaultChannelGroup
-
isShutdown
public boolean isShutdown()
Description copied from interface:ShutdownableResourceReturns true if this resource has been shut down.- Specified by:
isShutdownin interfaceShutdownableResource- Returns:
- true if this resource has been shut down
-
isTerminated
public boolean isTerminated()
Description copied from interface:ShutdownableResourceReturns true if the resource has completed shutting down. Note that isTerminated is never true unless shutdown was called first.- Specified by:
isTerminatedin interfaceShutdownableResource- Returns:
- true if the resource has completed shutting down.
-
shutdown
public void shutdown()
Description copied from interface:ShutdownableStarts the shutdown process. It is recommended to perform the actual shutdown activity in a separate thread from the thread that calls shutdown- Specified by:
shutdownin interfaceShutdownable
-
waitForShutdown
public void waitForShutdown() throws java.lang.InterruptedException, java.lang.IllegalStateExceptionDescription copied from interface:ShutdownableWaits for shutdown to complete- Specified by:
waitForShutdownin interfaceShutdownable- Throws:
java.lang.InterruptedException- when the wait is interruptedjava.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.TimeoutExceptionDescription copied from interface:ShutdownableWaits for shutdown to complete with a timeout- Specified by:
waitForShutdownin interfaceShutdownable- Parameters:
timeoutInMs- number of milliseconds to wait before throwing TimeoutException- Throws:
java.lang.InterruptedException- when the wait is interruptedjava.lang.IllegalStateException- when the method is invoked when the shutdown has yet to be startedjava.util.concurrent.TimeoutException- when the operation times out
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Collection<io.netty.channel.Channel>- Specified by:
hashCodein interfacejava.util.Set<io.netty.channel.Channel>- Overrides:
hashCodein classio.netty.channel.group.DefaultChannelGroup
-
-