Class AbstractClientConnection<T extends BackendInfo>
java.lang.Object
org.opendaylight.controller.cluster.access.client.AbstractClientConnection<T>
- Direct Known Subclasses:
ConnectedClientConnection
,ConnectingClientConnection
,ReconnectingClientConnection
Base class for a connection to the backend. Responsible to queueing and dispatch of requests toward the backend.
Can be in three conceptual states: Connecting, Connected and Reconnecting, which are represented by public final
classes exposed from this package. This class NOT thread-safe, not are its subclasses expected to be thread-safe.
- Author:
- Robert Varga
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
Backend aliveness timer.static final long
No progress timeout.static final long
Request timeout. -
Method Summary
Modifier and TypeMethodDescriptionfinal @NonNull ClientActorContext
context()
final @NonNull Long
cookie()
final long
final void
enqueueEntry
(ConnectionEntry entry, long now) Enqueue an entry, possibly also transmitting it.final void
enqueueRequest
(Request<?, ?> request, Consumer<Response<?, ?>> callback, long enqueuedTicks) Send a request to the backend and invoke a specified callback when it finishes.final @NonNull ActorRef
final void
sendRequest
(Request<?, ?> request, Consumer<Response<?, ?>> callback) Send a request to the backend and invoke a specified callback when it finishes.final String
toString()
-
Field Details
-
DEFAULT_BACKEND_ALIVE_TIMEOUT_NANOS
public static final long DEFAULT_BACKEND_ALIVE_TIMEOUT_NANOSBackend aliveness timer. This is reset whenever we receive a response from the backend and kept armed whenever we have an outstanding request. If when this time expires, we tear down this connection and attempt to reconnect it. -
DEFAULT_REQUEST_TIMEOUT_NANOS
public static final long DEFAULT_REQUEST_TIMEOUT_NANOSRequest timeout. If the request fails to complete within this time since it was originally enqueued, we time the request out. -
DEFAULT_NO_PROGRESS_TIMEOUT_NANOS
public static final long DEFAULT_NO_PROGRESS_TIMEOUT_NANOSNo progress timeout. A client fails to make any forward progress in this time, it will terminate itself.
-
-
Method Details
-
context
-
cookie
-
localActor
-
currentTime
public final long currentTime() -
sendRequest
Send a request to the backend and invoke a specified callback when it finishes. This method is safe to invoke from any thread.This method may put the caller thread to sleep in order to throttle the request rate. The callback may be called before the sleep finishes.
- Parameters:
request
- Request to sendcallback
- Callback to invoke
-
enqueueRequest
public final void enqueueRequest(Request<?, ?> request, Consumer<Response<?, ?>> callback, long enqueuedTicks) Send a request to the backend and invoke a specified callback when it finishes. This method is safe to invoke from any thread.Note that unlike
sendRequest(Request, Consumer)
, this method does not exert backpressure, hence it should never be called from an application thread and serves mostly for moving requests between queues.- Parameters:
request
- Request to sendcallback
- Callback to invokeenqueuedTicks
- Time (according tocurrentTime()
of request enqueue
-
enqueueEntry
Enqueue an entry, possibly also transmitting it. -
getBackendInfo
-
toString
-