Class AbstractClientConnection<T extends BackendInfo>
- java.lang.Object
-
- org.opendaylight.controller.cluster.access.client.AbstractClientConnection<T>
-
- Direct Known Subclasses:
ConnectedClientConnection
,ConnectingClientConnection
,ReconnectingClientConnection
public abstract class AbstractClientConnection<T extends BackendInfo> extends Object
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
Fields Modifier and Type Field Description static long
DEFAULT_BACKEND_ALIVE_TIMEOUT_NANOS
Backend aliveness timer.static long
DEFAULT_NO_PROGRESS_TIMEOUT_NANOS
No progress timeout.static long
DEFAULT_REQUEST_TIMEOUT_NANOS
Request timeout.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ClientActorContext
context()
@NonNull Long
cookie()
long
currentTime()
void
enqueueEntry(ConnectionEntry entry, long now)
Enqueue an entry, possibly also transmitting it.void
enqueueRequest(Request<?,?> request, Consumer<Response<?,?>> callback, long enqueuedTicks)
Send a request to the backend and invoke a specified callback when it finishes.abstract Optional<T>
getBackendInfo()
ActorRef
localActor()
void
sendRequest(Request<?,?> request, Consumer<Response<?,?>> callback)
Send a request to the backend and invoke a specified callback when it finishes.String
toString()
-
-
-
Field Detail
-
DEFAULT_BACKEND_ALIVE_TIMEOUT_NANOS
public static final long DEFAULT_BACKEND_ALIVE_TIMEOUT_NANOS
Backend 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_NANOS
Request 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_NANOS
No progress timeout. A client fails to make any forward progress in this time, it will terminate itself.
-
-
Method Detail
-
context
public final ClientActorContext context()
-
cookie
public final @NonNull Long cookie()
-
localActor
public final ActorRef localActor()
-
currentTime
public final long currentTime()
-
sendRequest
public final void sendRequest(Request<?,?> request, Consumer<Response<?,?>> callback)
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
public final void enqueueEntry(ConnectionEntry entry, long now)
Enqueue an entry, possibly also transmitting it.
-
-