public class DefaultChannelGroup extends AbstractSet<Channel> implements ChannelGroup
ChannelGroup
implementation.Constructor and Description |
---|
DefaultChannelGroup(EventExecutor executor)
Creates a new group with a generated name and the provided
EventExecutor to notify the
ChannelGroupFuture s. |
DefaultChannelGroup(EventExecutor executor,
boolean stayClosed)
Creates a new group with a generated name and the provided
EventExecutor to notify the
ChannelGroupFuture s. |
DefaultChannelGroup(String name,
EventExecutor executor)
|
DefaultChannelGroup(String name,
EventExecutor executor,
boolean stayClosed)
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(Channel channel) |
void |
clear() |
ChannelGroupFuture |
close()
Closes all
Channel s in this group. |
ChannelGroupFuture |
close(ChannelMatcher matcher)
Closes all
Channel s in this group that are matched by the given ChannelMatcher . |
int |
compareTo(ChannelGroup o) |
boolean |
contains(Object o) |
ChannelGroupFuture |
deregister() |
ChannelGroupFuture |
deregister(ChannelMatcher matcher) |
ChannelGroupFuture |
disconnect()
Disconnects all
Channel s in this group from their remote peers. |
ChannelGroupFuture |
disconnect(ChannelMatcher matcher)
Disconnects all
Channel s in this group from their remote peers,
that are matched by the given ChannelMatcher . |
boolean |
equals(Object o) |
Channel |
find(ChannelId id)
|
ChannelGroup |
flush()
Flush all
Channel s in this
group. |
ChannelGroup |
flush(ChannelMatcher matcher)
Flush all
Channel s in this group that are matched by the given ChannelMatcher . |
ChannelGroupFuture |
flushAndWrite(Object message) |
ChannelGroupFuture |
flushAndWrite(Object message,
ChannelMatcher matcher) |
int |
hashCode() |
boolean |
isEmpty() |
Iterator<Channel> |
iterator() |
String |
name()
Returns the name of this group.
|
ChannelGroupFuture |
newCloseFuture()
Returns the
ChannelGroupFuture which will be notified when all Channel s that are part of this
ChannelGroup , at the time of calling, are closed. |
ChannelGroupFuture |
newCloseFuture(ChannelMatcher matcher)
Returns the
ChannelGroupFuture which will be notified when all Channel s that are part of this
ChannelGroup , at the time of calling, are closed. |
boolean |
remove(Object o) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
String |
toString() |
ChannelGroupFuture |
write(Object message)
Writes the specified
message to all Channel s in this
group. |
ChannelGroupFuture |
write(Object message,
ChannelMatcher matcher)
Writes the specified
message to all Channel s in this
group that are matched by the given ChannelMatcher . |
ChannelGroupFuture |
write(Object message,
ChannelMatcher matcher,
boolean voidPromise)
Writes the specified
message to all Channel s in this
group that are matched by the given ChannelMatcher . |
ChannelGroupFuture |
writeAndFlush(Object message)
Shortcut for calling
ChannelGroup.write(Object) and ChannelGroup.flush() . |
ChannelGroupFuture |
writeAndFlush(Object message,
ChannelMatcher matcher)
Shortcut for calling
ChannelGroup.write(Object) and ChannelGroup.flush() and only act on
Channel s that are matched by the ChannelMatcher . |
ChannelGroupFuture |
writeAndFlush(Object message,
ChannelMatcher matcher,
boolean voidPromise)
Shortcut for calling
ChannelGroup.write(Object, ChannelMatcher, boolean) and ChannelGroup.flush() and only act on
Channel s that are matched by the ChannelMatcher . |
removeAll
addAll, containsAll, retainAll
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, containsAll, removeAll, retainAll, spliterator
parallelStream, removeIf, stream
public DefaultChannelGroup(EventExecutor executor)
EventExecutor
to notify the
ChannelGroupFuture
s.public DefaultChannelGroup(String name, EventExecutor executor)
name
and EventExecutor
to notify the
ChannelGroupFuture
s. Please note that different groups can have the same name, which means no
duplicate check is done against group names.public DefaultChannelGroup(EventExecutor executor, boolean stayClosed)
EventExecutor
to notify the
ChannelGroupFuture
s. 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.public DefaultChannelGroup(String name, EventExecutor executor, boolean stayClosed)
name
and EventExecutor
to notify the
ChannelGroupFuture
s. 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.public String name()
ChannelGroup
name
in interface ChannelGroup
public Channel find(ChannelId id)
ChannelGroup
find
in interface ChannelGroup
Channel
if found. null
otherwise.public boolean isEmpty()
isEmpty
in interface Collection<Channel>
isEmpty
in interface Set<Channel>
isEmpty
in class AbstractCollection<Channel>
public int size()
size
in interface Collection<Channel>
size
in interface Set<Channel>
size
in class AbstractCollection<Channel>
public boolean contains(Object o)
contains
in interface Collection<Channel>
contains
in interface Set<Channel>
contains
in class AbstractCollection<Channel>
public boolean add(Channel channel)
add
in interface Collection<Channel>
add
in interface Set<Channel>
add
in class AbstractCollection<Channel>
public boolean remove(Object o)
remove
in interface Collection<Channel>
remove
in interface Set<Channel>
remove
in class AbstractCollection<Channel>
public void clear()
clear
in interface Collection<Channel>
clear
in interface Set<Channel>
clear
in class AbstractCollection<Channel>
public Object[] toArray()
toArray
in interface Collection<Channel>
toArray
in interface Set<Channel>
toArray
in class AbstractCollection<Channel>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<Channel>
toArray
in interface Set<Channel>
toArray
in class AbstractCollection<Channel>
public ChannelGroupFuture close()
ChannelGroup
Channel
s in this group. If the Channel
is
connected to a remote peer or bound to a local address, it is
automatically disconnected and unbound.close
in interface ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture disconnect()
ChannelGroup
Channel
s in this group from their remote peers.disconnect
in interface ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture deregister()
deregister
in interface ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture write(Object message)
ChannelGroup
message
to all Channel
s in this
group. If the specified message
is an instance of
ByteBuf
, it is automatically
duplicated to avoid a race
condition. The same is true for ByteBufHolder
. Please note that this operation is asynchronous as
ChannelOutboundInvoker.write(Object)
is.write
in interface ChannelGroup
public ChannelGroupFuture write(Object message, ChannelMatcher matcher)
ChannelGroup
message
to all Channel
s in this
group that are matched by the given ChannelMatcher
. If the specified message
is an instance of
ByteBuf
, it is automatically
duplicated to avoid a race
condition. The same is true for ByteBufHolder
. Please note that this operation is asynchronous as
ChannelOutboundInvoker.write(Object)
is.write
in interface ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture write(Object message, ChannelMatcher matcher, boolean voidPromise)
ChannelGroup
message
to all Channel
s in this
group that are matched by the given ChannelMatcher
. If the specified message
is an instance of
ByteBuf
, it is automatically
duplicated to avoid a race
condition. The same is true for ByteBufHolder
. Please note that this operation is asynchronous as
ChannelOutboundInvoker.write(Object)
is.
If voidPromise
is true
ChannelOutboundInvoker.voidPromise()
is used for the writes and so the same
restrictions to the returned ChannelGroupFuture
apply as to a void promise.write
in interface ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroup flush()
ChannelGroup
Channel
s in this
group. If the specified messages
are an instance of
ByteBuf
, it is automatically
duplicated to avoid a race
condition. Please note that this operation is asynchronous as
ChannelOutboundInvoker.write(Object)
is.flush
in interface ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture flushAndWrite(Object message)
flushAndWrite
in interface ChannelGroup
public ChannelGroupFuture writeAndFlush(Object message)
ChannelGroup
ChannelGroup.write(Object)
and ChannelGroup.flush()
.writeAndFlush
in interface ChannelGroup
public ChannelGroupFuture disconnect(ChannelMatcher matcher)
ChannelGroup
Channel
s in this group from their remote peers,
that are matched by the given ChannelMatcher
.disconnect
in interface ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture close(ChannelMatcher matcher)
ChannelGroup
Channel
s in this group that are matched by the given ChannelMatcher
.
If the Channel
is connected to a remote peer or bound to a local address, it is
automatically disconnected and unbound.close
in interface ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture deregister(ChannelMatcher matcher)
deregister
in interface ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroup flush(ChannelMatcher matcher)
ChannelGroup
Channel
s in this group that are matched by the given ChannelMatcher
.
If the specified messages
are an instance of
ByteBuf
, it is automatically
duplicated to avoid a race
condition. Please note that this operation is asynchronous as
ChannelOutboundInvoker.write(Object)
is.flush
in interface ChannelGroup
ChannelGroupFuture
instance that notifies when
the operation is done for all channelspublic ChannelGroupFuture flushAndWrite(Object message, ChannelMatcher matcher)
flushAndWrite
in interface ChannelGroup
public ChannelGroupFuture writeAndFlush(Object message, ChannelMatcher matcher)
ChannelGroup
ChannelGroup.write(Object)
and ChannelGroup.flush()
and only act on
Channel
s that are matched by the ChannelMatcher
.writeAndFlush
in interface ChannelGroup
public ChannelGroupFuture writeAndFlush(Object message, ChannelMatcher matcher, boolean voidPromise)
ChannelGroup
ChannelGroup.write(Object, ChannelMatcher, boolean)
and ChannelGroup.flush()
and only act on
Channel
s that are matched by the ChannelMatcher
.writeAndFlush
in interface ChannelGroup
public ChannelGroupFuture newCloseFuture()
ChannelGroup
ChannelGroupFuture
which will be notified when all Channel
s that are part of this
ChannelGroup
, at the time of calling, are closed.newCloseFuture
in interface ChannelGroup
public ChannelGroupFuture newCloseFuture(ChannelMatcher matcher)
ChannelGroup
ChannelGroupFuture
which will be notified when all Channel
s that are part of this
ChannelGroup
, at the time of calling, are closed.newCloseFuture
in interface ChannelGroup
public int hashCode()
hashCode
in interface Collection<Channel>
hashCode
in interface Set<Channel>
hashCode
in class AbstractSet<Channel>
public boolean equals(Object o)
equals
in interface Collection<Channel>
equals
in interface Set<Channel>
equals
in class AbstractSet<Channel>
public int compareTo(ChannelGroup o)
compareTo
in interface Comparable<ChannelGroup>
public String toString()
toString
in class AbstractCollection<Channel>
Copyright © 2008–2017 The Netty Project. All rights reserved.