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_MESSAGE
Fields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCED
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCloseListener
(ActionListener<Void> listener) The listener'sActionListener.onResponse(Object)
method will be called when this connection is closed.void
addRemovedListener
(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.void
close()
protected void
boolean
isClosed()
void
Called after this connection is removed from the transport service.Methods inherited from class org.elasticsearch.core.AbstractRefCounted
alreadyClosed, decRef, hasReferences, incRef, of, refCount, touch, tryIncRef
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.core.RefCounted
decRef, hasReferences, incRef, mustIncRef, tryIncRef
Methods 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.Connection
The 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:
addCloseListener
in interfaceTransport.Connection
- Parameters:
listener
- to be called
-
addRemovedListener
Description copied from interface:Transport.Connection
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.- Specified by:
addRemovedListener
in interfaceTransport.Connection
-
isClosed
public boolean isClosed()- Specified by:
isClosed
in interfaceTransport.Connection
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceTransport.Connection
-
onRemoved
public void onRemoved()Description copied from interface:Transport.Connection
Called after this connection is removed from the transport service.- Specified by:
onRemoved
in interfaceTransport.Connection
-
closeInternal
protected void closeInternal()- Specified by:
closeInternal
in classAbstractRefCounted
-