public interface TcpChannel extends Releasable
TcpTransport
and TransportService
. All tcp transport
implementations must return channels that adhere to the required method contracts.Modifier and Type | Method and Description |
---|---|
void |
addCloseListener(ActionListener<java.lang.Void> listener)
Adds a listener that will be executed when the channel is closed.
|
static void |
awaitConnected(DiscoveryNode discoveryNode,
java.util.List<ActionFuture<java.lang.Void>> connectionFutures,
TimeValue connectTimeout)
Awaits for all of the pending connections to complete.
|
static void |
blockOnFutures(java.util.List<ActionFuture<java.lang.Void>> futures) |
void |
close()
Closes the channel.
|
static <C extends TcpChannel> |
closeChannel(C channel,
boolean blocking)
Closes the channel.
|
static <C extends TcpChannel> |
closeChannels(java.util.List<C> channels,
boolean blocking)
Closes the channels.
|
java.net.InetSocketAddress |
getLocalAddress()
Returns the local address for this channel.
|
boolean |
isOpen()
Indicates whether a channel is currently open
|
void |
sendMessage(BytesReference reference,
ActionListener<java.lang.Void> listener)
Sends a tcp message to the channel.
|
void |
setSoLinger(int value)
This sets the low level socket option
StandardSocketOptions SO_LINGER on a channel. |
void close()
addCloseListener(ActionListener)
method
to implement logic that depends on knowing when the channel is closed.close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
close
in interface Releasable
void addCloseListener(ActionListener<java.lang.Void> listener)
listener
- to be executedvoid setSoLinger(int value) throws java.io.IOException
StandardSocketOptions
SO_LINGER on a channel.value
- to set for SO_LINGERjava.io.IOException
- that can be throw by the low level socket implementationboolean isOpen()
java.net.InetSocketAddress getLocalAddress()
void sendMessage(BytesReference reference, ActionListener<java.lang.Void> listener)
reference
- to send to channellistener
- to execute upon send completionstatic <C extends TcpChannel> void closeChannel(C channel, boolean blocking)
channel
- to closeblocking
- indicates if we should block on channel closestatic <C extends TcpChannel> void closeChannels(java.util.List<C> channels, boolean blocking)
channels
- to closeblocking
- indicates if we should block on channel closestatic void awaitConnected(DiscoveryNode discoveryNode, java.util.List<ActionFuture<java.lang.Void>> connectionFutures, TimeValue connectTimeout) throws ConnectTransportException
discoveryNode
- the node for the pending connectionsconnectionFutures
- representing the pending connectionsconnectTimeout
- to wait for a connectionConnectTransportException
- if one of the connections failsstatic void blockOnFutures(java.util.List<ActionFuture<java.lang.Void>> futures)