Interface ChannelEndpoint


@InternalApi public interface ChannelEndpoint
Represents a Spanner server endpoint for location-aware routing.

Each instance wraps a gRPC ManagedChannel connected to a specific Spanner server. The ChannelEndpointCache creates and caches these instances.

Implementations must be thread-safe as instances may be shared across multiple concurrent operations.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Records that an application RPC finished on this endpoint.
    int
    Returns the number of currently active application RPCs on this endpoint.
    Returns the network address of this server.
    io.grpc.ManagedChannel
    Returns the gRPC channel for making RPCs to this server.
    void
    Records that an application RPC started on this endpoint.
    boolean
    Returns whether this server's channel is in READY state and can accept location-aware RPCs.
    boolean
    Returns whether this server's channel is in TRANSIENT_FAILURE state.
  • Method Details

    • getAddress

      String getAddress()
      Returns the network address of this server.
      Returns:
      the server address in "host:port" format
    • isHealthy

      boolean isHealthy()
      Returns whether this server's channel is in READY state and can accept location-aware RPCs.

      Only endpoints in READY state are eligible for location-aware routing. Endpoints in IDLE, CONNECTING, TRANSIENT_FAILURE, or SHUTDOWN are not considered healthy for location-aware routing purposes.

      Returns:
      true if the channel is in READY state
    • isTransientFailure

      boolean isTransientFailure()
      Returns whether this server's channel is in TRANSIENT_FAILURE state.

      When an endpoint is in transient failure, it should be reported as a skipped tablet in routing hints so the server can refresh the client cache.

      Returns:
      true if the channel is in TRANSIENT_FAILURE state
    • getChannel

      io.grpc.ManagedChannel getChannel()
      Returns the gRPC channel for making RPCs to this server.

      The returned channel is managed by the ChannelEndpointCache and should not be shut down directly by callers.

      Returns:
      the managed channel for this server
    • incrementActiveRequests

      void incrementActiveRequests()
      Records that an application RPC started on this endpoint.

      This is used for request-load-aware routing decisions. Implementations must keep the count scoped to this endpoint instance so evicted or recreated endpoints do not share inflight state.

    • decrementActiveRequests

      void decrementActiveRequests()
      Records that an application RPC finished on this endpoint.

      Implementations must not allow the count to go negative.

    • getActiveRequestCount

      int getActiveRequestCount()
      Returns the number of currently active application RPCs on this endpoint.