Class AlfrescoGrpcChannelPool

java.lang.Object
io.grpc.Channel
org.saidone.unrest.client.AlfrescoGrpcChannelPool
All Implemented Interfaces:
AutoCloseable

public final class AlfrescoGrpcChannelPool extends io.grpc.Channel implements AutoCloseable
Owns a fixed set of reusable gRPC channels to one Alfresco endpoint.

Each new RPC selects a channel in round-robin order. A streaming RPC keeps that channel for its entire lifetime; individual messages are never routed separately. Selection is thread-safe and forwards call options unchanged. The pool bounds channel count, not concurrent calls: each channel still multiplexes HTTP/2 streams. Authentication remains the responsibility of the clients' shared TicketProvider.

Use this channel for ContentServiceClient and primary() for metadata and authentication. The pool owns every underlying channel. Close it once after stopping callers; service clients and callers borrowing the primary channel must not close channels individually.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Maximum configured channel count, validated before any channel is allocated.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    void
    Stops admitting calls, allows at most five seconds in total for active calls, then cancels remaining work.
    void
    close(Duration grace)
    Closes all channels with one shared grace budget rather than waiting that duration for every channel.
    <RequestT, ResponseT>
    io.grpc.ClientCall<RequestT,ResponseT>
    newCall(io.grpc.MethodDescriptor<RequestT,ResponseT> method, io.grpc.CallOptions callOptions)
    Selects an underlying channel once for the complete RPC, preserving all configured call options.
    io.grpc.ManagedChannel
    Returns the first channel for shared metadata and authentication clients.
    int
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_CHANNELS

      public static final int MAX_CHANNELS
      Maximum configured channel count, validated before any channel is allocated.
      See Also:
  • Method Details

    • primary

      public io.grpc.ManagedChannel primary()
      Returns the first channel for shared metadata and authentication clients.
      Returns:
      a borrowed channel owned by this pool; do not shut it down separately
    • size

      public int size()
      Returns:
      the fixed number of underlying channels, including the primary channel
    • authority

      public String authority()
      Specified by:
      authority in class io.grpc.Channel
      Returns:
      the authority of the common endpoint
    • newCall

      public <RequestT, ResponseT> io.grpc.ClientCall<RequestT,ResponseT> newCall(io.grpc.MethodDescriptor<RequestT,ResponseT> method, io.grpc.CallOptions callOptions)
      Selects an underlying channel once for the complete RPC, preserving all configured call options.
      Specified by:
      newCall in class io.grpc.Channel
      Type Parameters:
      RequestT - request message type
      ResponseT - response message type
      Parameters:
      method - RPC descriptor
      callOptions - credentials, compression, deadlines and other caller options
      Returns:
      the call from the selected channel
      Throws:
      io.grpc.StatusRuntimeException - with UNAVAILABLE if the pool has been closed
    • close

      public void close()
      Stops admitting calls, allows at most five seconds in total for active calls, then cancels remaining work. This operation is idempotent. An interrupted wait forces shutdown and restores the interrupt flag.
      Specified by:
      close in interface AutoCloseable
    • close

      public void close(Duration grace)
      Closes all channels with one shared grace budget rather than waiting that duration for every channel.
      Parameters:
      grace - non-negative total graceful-shutdown duration; zero cancels active calls immediately
      Throws:
      IllegalArgumentException - if grace is negative