- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<Channel>
-
- io.netty5.channel.group.DefaultChannelGroup
-
- All Implemented Interfaces:
ChannelGroup,Comparable<ChannelGroup>,Iterable<Channel>,Collection<Channel>,Set<Channel>
public class DefaultChannelGroup extends AbstractSet<Channel> implements ChannelGroup
The defaultChannelGroupimplementation.
-
-
Constructor Summary
Constructors Constructor Description DefaultChannelGroup(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(Channel channel)voidclear()ChannelGroupFutureclose()Closes allChannels in this group.ChannelGroupFutureclose(ChannelMatcher matcher)Closes allChannels in this group that are matched by the givenChannelMatcher.intcompareTo(ChannelGroup o)booleancontains(Object o)ChannelGroupFuturederegister()ChannelGroupFuturederegister(ChannelMatcher matcher)ChannelGroupFuturedisconnect()Disconnects allChannels in this group from their remote peers.ChannelGroupFuturedisconnect(ChannelMatcher matcher)Disconnects allChannels in this group from their remote peers, that are matched by the givenChannelMatcher.booleanequals(Object o)Channelfind(ChannelId id)ChannelGroupflush()Flush allChannels in this group.ChannelGroupflush(ChannelMatcher matcher)Flush allChannels in this group that are matched by the givenChannelMatcher.ChannelGroupFutureflushAndWrite(Object message)ChannelGroupFutureflushAndWrite(Object message, ChannelMatcher matcher)inthashCode()booleanisEmpty()Iterator<Channel>iterator()Stringname()Returns the name of this group.ChannelGroupFuturenewCloseFuture()Returns theChannelGroupFuturewhich will be notified when allChannels that are part of thisChannelGroup, at the time of calling, are closed.ChannelGroupFuturenewCloseFuture(ChannelMatcher matcher)Returns theChannelGroupFuturewhich will be notified when allChannels that are part of thisChannelGroup, at the time of calling, are closed.booleanremove(Object o)intsize()Object[]toArray()<T> T[]toArray(T[] a)StringtoString()ChannelGroupFuturewrite(Object message)Writes the specifiedmessageto allChannels in this group.ChannelGroupFuturewrite(Object message, ChannelMatcher matcher)Writes the specifiedmessageto allChannels in this group that are matched by the givenChannelMatcher.ChannelGroupFuturewriteAndFlush(Object message)Shortcut for callingChannelGroup.write(Object)andChannelGroup.flush().ChannelGroupFuturewriteAndFlush(Object message, ChannelMatcher matcher)Shortcut for callingChannelGroup.write(Object)andChannelGroup.flush()and only act onChannels that are matched by theChannelMatcher.-
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.util.Set
addAll, containsAll, removeAll, retainAll, spliterator
-
-
-
-
Constructor Detail
-
DefaultChannelGroup
public DefaultChannelGroup(EventExecutor executor)
Creates a new group with a generated name and the providedEventExecutorto notify theChannelGroupFutures.
-
DefaultChannelGroup
public DefaultChannelGroup(String name, 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.
-
DefaultChannelGroup
public DefaultChannelGroup(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.
-
DefaultChannelGroup
public DefaultChannelGroup(String name, 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.
-
-
Method Detail
-
name
public String 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
public Channel find(ChannelId id)
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
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<Channel>- Specified by:
containsin interfaceSet<Channel>- Overrides:
containsin classAbstractCollection<Channel>
-
add
public boolean add(Channel channel)
- Specified by:
addin interfaceCollection<Channel>- Specified by:
addin interfaceSet<Channel>- Overrides:
addin classAbstractCollection<Channel>
-
remove
public boolean remove(Object o)
- 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>
-
toArray
public Object[] 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
public ChannelGroupFuture 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
public ChannelGroupFuture 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
public ChannelGroupFuture deregister()
- Specified by:
deregisterin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
write
public ChannelGroupFuture write(Object message)
Description copied from interface:ChannelGroupWrites the specifiedmessageto allChannels in this group. If the specifiedmessageis an instance ofBuffer, it is automatically copied to avoid a race condition. Please note that this operation is asynchronous asChannel.write(Object)is.- Specified by:
writein interfaceChannelGroup- Returns:
- itself
-
write
public ChannelGroupFuture write(Object message, ChannelMatcher matcher)
Description copied from interface:ChannelGroupWrites the specifiedmessageto allChannels in this group that are matched by the givenChannelMatcher. If the specifiedmessageis an instance ofBuffer, it is automatically copied to avoid a race condition. 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
-
flush
public ChannelGroup flush()
Description copied from interface:ChannelGroupFlush allChannels in this group. If the specifiedmessageis an instance ofBuffer, it is automatically copied to avoid a race condition. Please note that this operation is asynchronous asChannel.flush()is.- Specified by:
flushin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
flushAndWrite
public ChannelGroupFuture flushAndWrite(Object message)
- Specified by:
flushAndWritein interfaceChannelGroup
-
writeAndFlush
public ChannelGroupFuture writeAndFlush(Object message)
Description copied from interface:ChannelGroupShortcut for callingChannelGroup.write(Object)andChannelGroup.flush().- Specified by:
writeAndFlushin interfaceChannelGroup
-
disconnect
public ChannelGroupFuture disconnect(ChannelMatcher matcher)
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
public ChannelGroupFuture close(ChannelMatcher matcher)
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
public ChannelGroupFuture deregister(ChannelMatcher matcher)
- Specified by:
deregisterin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
flush
public ChannelGroup flush(ChannelMatcher matcher)
Description copied from interface:ChannelGroupFlush allChannels in this group that are matched by the givenChannelMatcher. If the specifiedmessageis an instance ofBuffer, it is automatically copied to avoid a race condition. Please note that this operation is asynchronous asChannel.flush()is.- Specified by:
flushin interfaceChannelGroup- Returns:
- the
ChannelGroupFutureinstance that notifies when the operation is done for all channels
-
flushAndWrite
public ChannelGroupFuture flushAndWrite(Object message, ChannelMatcher matcher)
- Specified by:
flushAndWritein interfaceChannelGroup
-
writeAndFlush
public ChannelGroupFuture writeAndFlush(Object message, ChannelMatcher matcher)
Description copied from interface:ChannelGroupShortcut for callingChannelGroup.write(Object)andChannelGroup.flush()and only act onChannels that are matched by theChannelMatcher.- Specified by:
writeAndFlushin interfaceChannelGroup
-
newCloseFuture
public ChannelGroupFuture 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
public ChannelGroupFuture newCloseFuture(ChannelMatcher matcher)
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
public boolean equals(Object o)
- Specified by:
equalsin interfaceCollection<Channel>- Specified by:
equalsin interfaceSet<Channel>- Overrides:
equalsin classAbstractSet<Channel>
-
compareTo
public int compareTo(ChannelGroup o)
- Specified by:
compareToin interfaceComparable<ChannelGroup>
-
toString
public String toString()
- Overrides:
toStringin classAbstractCollection<Channel>
-
-