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 Details

    • 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 Details

    • context

      public final @NonNull ClientActorContext context()
    • cookie

      public final @NonNull Long cookie()
    • localActor

      public final @NonNull 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 send
      callback - 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 send
      callback - Callback to invoke
      enqueuedTicks - Time (according to currentTime() of request enqueue
    • enqueueEntry

      public final void enqueueEntry(ConnectionEntry entry, long now)
      Enqueue an entry, possibly also transmitting it.
    • getBackendInfo

      public abstract Optional<T> getBackendInfo()
    • toString

      public final String toString()
      Overrides:
      toString in class Object