java.lang.Object
org.elasticsearch.core.AbstractRefCounted
org.elasticsearch.transport.CloseableConnection
- All Implemented Interfaces:
Closeable,AutoCloseable,RefCounted,Transport.Connection
- Direct Known Subclasses:
TcpTransport.NodeChannels
public abstract class CloseableConnection
extends AbstractRefCounted
implements Transport.Connection
Abstract Transport.Connection that provides common close logic.
-
Field Summary
Fields inherited from class org.elasticsearch.core.AbstractRefCounted
ALREADY_CLOSED_MESSAGE, INVALID_DECREF_MESSAGEFields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCloseListener(ActionListener<Void> listener) The listener'sActionListener.onResponse(Object)method will be called when this connection is closed.voidaddRemovedListener(ActionListener<Void> listener) Similar toTransport.Connection.addCloseListener(org.elasticsearch.action.ActionListener<java.lang.Void>)except that these listeners are notified once the connection is removed from the transport service.voidclose()protected voidbooleanisClosed()voidCalled after this connection is removed from the transport service.Methods inherited from class org.elasticsearch.core.AbstractRefCounted
alreadyClosed, decRef, hasReferences, incRef, mustIncRef, of, refCount, touch, tryIncRefMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.core.RefCounted
decRef, hasReferences, incRef, mustIncRef, tryIncRefMethods inherited from interface org.elasticsearch.transport.Transport.Connection
getCacheKey, getNode, getTransportVersion, sendRequest
-
Constructor Details
-
CloseableConnection
public CloseableConnection()
-
-
Method Details
-
addCloseListener
Description copied from interface:Transport.ConnectionThe listener'sActionListener.onResponse(Object)method will be called when this connection is closed. No implementations currently throw an exception during close, soActionListener.onFailure(Exception)will not be called.- Specified by:
addCloseListenerin interfaceTransport.Connection- Parameters:
listener- to be called
-
addRemovedListener
Description copied from interface:Transport.ConnectionSimilar toTransport.Connection.addCloseListener(org.elasticsearch.action.ActionListener<java.lang.Void>)except that these listeners are notified once the connection is removed from the transport service.- Specified by:
addRemovedListenerin interfaceTransport.Connection
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfaceTransport.Connection
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceTransport.Connection
-
onRemoved
public void onRemoved()Description copied from interface:Transport.ConnectionCalled after this connection is removed from the transport service.- Specified by:
onRemovedin interfaceTransport.Connection
-
closeInternal
protected void closeInternal()- Specified by:
closeInternalin classAbstractRefCounted
-