Package org.opensearch.common.network
Interface CloseableChannel
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Subinterfaces:
HttpChannel
,HttpServerChannel
,StreamingHttpChannel
,TcpChannel
,TcpServerChannel
- All Known Implementing Classes:
TraceableHttpChannel
Channel that can be closed
- Opensearch.internal:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCloseListener
(org.opensearch.core.action.ActionListener<Void> listener) Adds a listener that will be executed when the channel is closed.static void
blockOnFutures
(List<org.opensearch.common.action.ActionFuture<Void>> futures) void
close()
Closes the channel.static <C extends CloseableChannel>
voidcloseChannel
(C channel) Closes the channel without blocking.static <C extends CloseableChannel>
voidcloseChannel
(C channel, boolean blocking) Closes the channel.static <C extends CloseableChannel>
voidcloseChannels
(List<C> channels, boolean blocking) Closes the channels.boolean
isOpen()
Indicates whether a channel is currently open
-
Method Details
-
close
void close()Closes the channel. For most implementations, this will be be an asynchronous process. For this reason, this method does not throwIOException
There is no guarantee that the channel will be closed when this method returns. Use theaddCloseListener(ActionListener)
method to implement logic that depends on knowing when the channel is closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
addCloseListener
Adds a listener that will be executed when the channel is closed. If the channel is still open when this listener is added, the listener will be executed by the thread that eventually closes the channel. If the channel is already closed when the listener is added the listener will immediately be executed by the thread that is attempting to add the listener.- Parameters:
listener
- to be executed
-
isOpen
boolean isOpen()Indicates whether a channel is currently open- Returns:
- boolean indicating if channel is open
-
closeChannel
Closes the channel without blocking.- Parameters:
channel
- to close
-
closeChannel
Closes the channel.- Parameters:
channel
- to closeblocking
- indicates if we should block on channel close
-
closeChannels
Closes the channels.- Parameters:
channels
- to closeblocking
- indicates if we should block on channel close
-
blockOnFutures
-