Class DefaultChannelGroup
- All Implemented Interfaces:
ChannelGroup, Comparable<ChannelGroup>, Iterable<Channel>, Collection<Channel>, Set<Channel>
The default
ChannelGroup implementation.-
Constructor Summary
ConstructorsConstructorDescriptionDefaultChannelGroup(EventExecutor executor) Creates a new group with a generated name and the providedEventExecutorto notify theChannelGroupFutures.DefaultChannelGroup(EventExecutor executor, boolean stayClosed) Creates a new group with a generated name and the providedEventExecutorto notify theChannelGroupFutures.DefaultChannelGroup(String name, EventExecutor executor) DefaultChannelGroup(String name, EventExecutor executor, boolean stayClosed) -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclear()close()Closes allChannels in this group.close(ChannelMatcher matcher) Closes allChannels in this group that are matched by the givenChannelMatcher.intbooleanderegister(ChannelMatcher matcher) Disconnects allChannels in this group from their remote peers.disconnect(ChannelMatcher matcher) Disconnects allChannels in this group from their remote peers, that are matched by the givenChannelMatcher.booleanflush()Flush allChannels in this group.flush(ChannelMatcher matcher) Flush allChannels in this group that are matched by the givenChannelMatcher.flushAndWrite(Object message) flushAndWrite(Object message, ChannelMatcher matcher) inthashCode()booleanisEmpty()iterator()name()Returns the name of this group.Returns theChannelGroupFuturewhich will be notified when allChannels that are part of thisChannelGroup, at the time of calling, are closed.newCloseFuture(ChannelMatcher matcher) Returns theChannelGroupFuturewhich will be notified when allChannels that are part of thisChannelGroup, at the time of calling, are closed.booleanintsize()Object[]toArray()<T> T[]toArray(T[] a) toString()Writes the specifiedmessageto allChannels in this group.write(Object message, ChannelMatcher matcher) Writes the specifiedmessageto allChannels in this group that are matched by the givenChannelMatcher.write(Object message, ChannelMatcher matcher, boolean voidPromise) Writes the specifiedmessageto allChannels in this group that are matched by the givenChannelMatcher.writeAndFlush(Object message) Shortcut for callingChannelGroup.write(Object)andChannelGroup.flush().writeAndFlush(Object message, ChannelMatcher matcher) Shortcut for callingChannelGroup.write(Object)andChannelGroup.flush()and only act onChannels that are matched by theChannelMatcher.writeAndFlush(Object message, ChannelMatcher matcher, boolean voidPromise) Shortcut for callingChannelGroup.write(Object, ChannelMatcher, boolean)andChannelGroup.flush()and only act onChannels that are matched by theChannelMatcher.Methods inherited from class AbstractSet
removeAllMethods inherited from class AbstractCollection
addAll, containsAll, retainAllMethods inherited from interface Collection
parallelStream, removeIf, streamMethods inherited from interface Set
addAll, containsAll, removeAll, retainAll, spliterator
-
Constructor Details
-
DefaultChannelGroup
Creates a new group with a generated name and the providedEventExecutorto notify theChannelGroupFutures. -
DefaultChannelGroup
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. -
DefaultChannelGroup
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. -
DefaultChannelGroup
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.
-
-
Method Details
-
name
Description copied from interface:ChannelGroupReturns the name of this group. A group name is purely for helping you to distinguish one group from others.- Specified by:
namein interfaceChannelGroup
-
find
Description copied from interface:ChannelGroup- Specified by:
findin interfaceChannelGroup- Returns:
- the matching
Channelif found.nullotherwise.
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<Channel>- Specified by:
isEmptyin interfaceSet<Channel>- Overrides:
isEmptyin classAbstractCollection<Channel>
-
size
public int size()- Specified by:
sizein interfaceCollection<Channel>- Specified by:
sizein interfaceSet<Channel>- Specified by:
sizein classAbstractCollection<Channel>
-
contains
- Specified by:
containsin interfaceCollection<Channel>- Specified by:
containsin interfaceSet<Channel>- Overrides:
containsin classAbstractCollection<Channel>
-
add
- Specified by:
addin interfaceCollection<Channel>- Specified by:
addin interfaceSet<Channel>- Overrides:
addin classAbstractCollection<Channel>
-
remove
- Specified by:
removein interfaceCollection<Channel>- Specified by:
removein interfaceSet<Channel>- Overrides:
removein classAbstractCollection<Channel>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<Channel>- Specified by:
clearin interfaceSet<Channel>- Overrides:
clearin classAbstractCollection<Channel>
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection<Channel>- Specified by:
toArrayin interfaceSet<Channel>- Overrides:
toArrayin classAbstractCollection<Channel>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<Channel>- Specified by:
toArrayin interfaceSet<Channel>- Overrides:
toArrayin classAbstractCollection<Channel>
-
close
Description copied from interface:ChannelGroupCloses allChannels in this group. If theChannelis connected to a remote peer or bound to a local address, it is automatically disconnected and unbound.- Specified by:
closein interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
disconnect
Description copied from interface:ChannelGroupDisconnects allChannels in this group from their remote peers.- Specified by:
disconnectin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
deregister
- Specified by:
deregisterin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
write
Description copied from interface:ChannelGroupWrites the specifiedmessageto allChannels in this group. If the specifiedmessageis an instance ofByteBuf, it is automatically duplicated to avoid a race condition. The same is true forByteBufHolder. Please note that this operation is asynchronous asChannel.write(Object)is.- Specified by:
writein interfaceChannelGroup- Returns:
- itself
-
write
Description copied from interface:ChannelGroupWrites the specifiedmessageto allChannels in this group that are matched by the givenChannelMatcher. If the specifiedmessageis an instance ofByteBuf, it is automatically duplicated to avoid a race condition. The same is true forByteBufHolder. Please note that this operation is asynchronous asChannel.write(Object)is.- Specified by:
writein interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
write
Description copied from interface:ChannelGroupWrites the specifiedmessageto allChannels in this group that are matched by the givenChannelMatcher. If the specifiedmessageis an instance ofByteBuf, it is automatically duplicated to avoid a race condition. The same is true forByteBufHolder. Please note that this operation is asynchronous asChannel.write(Object)is. IfvoidPromiseistrueChannel.voidPromise()is used for the writes and so the same restrictions to the returnedChannelGroupFutureapply as to a void promise.- Specified by:
writein interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
flush
Description copied from interface:ChannelGroupFlush allChannels in this group. If the specifiedmessagesare an instance ofByteBuf, it is automatically duplicated to avoid a race condition. Please note that this operation is asynchronous asChannel.write(Object)is.- Specified by:
flushin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
flushAndWrite
- Specified by:
flushAndWritein interfaceChannelGroup
-
writeAndFlush
Description copied from interface:ChannelGroupShortcut for callingChannelGroup.write(Object)andChannelGroup.flush().- Specified by:
writeAndFlushin interfaceChannelGroup
-
disconnect
Description copied from interface:ChannelGroupDisconnects allChannels in this group from their remote peers, that are matched by the givenChannelMatcher.- Specified by:
disconnectin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
close
Description copied from interface:ChannelGroupCloses allChannels in this group that are matched by the givenChannelMatcher. If theChannelis connected to a remote peer or bound to a local address, it is automatically disconnected and unbound.- Specified by:
closein interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
deregister
- Specified by:
deregisterin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
flush
Description copied from interface:ChannelGroupFlush allChannels in this group that are matched by the givenChannelMatcher. If the specifiedmessagesare an instance ofByteBuf, it is automatically duplicated to avoid a race condition. Please note that this operation is asynchronous asChannel.write(Object)is.- Specified by:
flushin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
flushAndWrite
- Specified by:
flushAndWritein interfaceChannelGroup
-
writeAndFlush
Description copied from interface:ChannelGroupShortcut for callingChannelGroup.write(Object)andChannelGroup.flush()and only act onChannels that are matched by theChannelMatcher.- Specified by:
writeAndFlushin interfaceChannelGroup
-
writeAndFlush
public ChannelGroupFuture writeAndFlush(Object message, ChannelMatcher matcher, boolean voidPromise) Description copied from interface:ChannelGroupShortcut for callingChannelGroup.write(Object, ChannelMatcher, boolean)andChannelGroup.flush()and only act onChannels that are matched by theChannelMatcher.- Specified by:
writeAndFlushin interfaceChannelGroup
-
newCloseFuture
Description copied from interface:ChannelGroupReturns theChannelGroupFuturewhich will be notified when allChannels that are part of thisChannelGroup, at the time of calling, are closed.- Specified by:
newCloseFuturein interfaceChannelGroup
-
newCloseFuture
Description copied from interface:ChannelGroupReturns theChannelGroupFuturewhich will be notified when allChannels that are part of thisChannelGroup, at the time of calling, are closed.- Specified by:
newCloseFuturein interfaceChannelGroup
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<Channel>- Specified by:
hashCodein interfaceSet<Channel>- Overrides:
hashCodein classAbstractSet<Channel>
-
equals
- Specified by:
equalsin interfaceCollection<Channel>- Specified by:
equalsin interfaceSet<Channel>- Overrides:
equalsin classAbstractSet<Channel>
-
compareTo
- Specified by:
compareToin interfaceComparable<ChannelGroup>
-
toString
- Overrides:
toStringin classAbstractCollection<Channel>
-