Class BaseProxyProtocol<Req extends com.google.protobuf.Message,Resp extends com.google.protobuf.Message>

java.lang.Object
com.oracle.coherence.grpc.proxy.common.BaseProxyProtocol<Req,Resp>
All Implemented Interfaces:
GrpcServiceProtocol<Req,Resp>
Direct Known Subclasses:
NamedCacheProxyProtocol, NamedQueueProxyProtocol

public abstract class BaseProxyProtocol<Req extends com.google.protobuf.Message,Resp extends com.google.protobuf.Message> extends Object implements GrpcServiceProtocol<Req,Resp>
A base class for server side gRPC protocol implementations.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final Lock
    The lock to control access to state.
    protected com.tangosol.coherence.component.net.extend.Connection
    The Connection to use to send responses.
    protected final Set<Integer>
    A bit-set containing destroyed cache identifiers.
    protected io.grpc.stub.StreamObserver<Resp>
    A StreamObserver for processing event messages.
    protected com.tangosol.coherence.component.net.extend.proxy.serviceProxy.CacheServiceProxy
    The CacheServiceProxy.
    protected Serializer
    The client's serializer.
    protected GrpcService
    The parent GrpcService.

    Fields inherited from interface com.oracle.coherence.grpc.GrpcServiceProtocol

    PRIORITY_NORMAL
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close this protocol.
    protected void
    complete(boolean f, int id, io.grpc.stub.StreamObserver<Resp> observer)
    Send a response containing a BoolValue to a StreamObserver and then complete the observer.
    protected void
    complete(int n, int id, io.grpc.stub.StreamObserver<Resp> observer)
    Send a response containing an Int32Value to a StreamObserver and then complete the observer.
    protected void
    complete(com.google.protobuf.Message message, int id, io.grpc.stub.StreamObserver<Resp> observer)
    Send a response containing a BytesValue to a StreamObserver and then complete the observer.
    protected void
    complete(com.tangosol.coherence.component.net.extend.message.Request request, io.grpc.stub.StreamObserver<Resp> observer)
    Send a response containing a BinaryKeyAndValue to a StreamObserver and then complete the observer.
    protected void
    complete(Binary binary, int id, io.grpc.stub.StreamObserver<Resp> observer)
    Send a response containing a BytesValue to a StreamObserver and then complete the observer.
    protected void
    complete(Binary binKey, com.tangosol.coherence.component.net.extend.message.Request request, int id, io.grpc.stub.StreamObserver<Resp> observer)
    Send a response containing a BinaryKeyAndValue to a StreamObserver and then complete the observer.
    protected void
    completeKeyValue(Binary binKey, Binary binValue, int id, io.grpc.stub.StreamObserver<Resp> observer)
    Send a response containing a BinaryKeyAndValue to a StreamObserver and then complete the observer.
    protected void
    completeMapStream(com.tangosol.coherence.component.net.extend.message.Request request, int id, io.grpc.stub.StreamObserver<Resp> observer)
    Send a response containing a stream of BinaryKeyAndValue to a StreamObserver and then complete the observer.
    protected void
    completeMapStream(Map<Binary,Binary> map, int id, io.grpc.stub.StreamObserver<Resp> observer)
    Send a response containing a stream of BinaryKeyAndValue to a StreamObserver and then complete the observer.
    protected void
    completeSetStream(com.tangosol.coherence.component.net.extend.message.Request request, int id, io.grpc.stub.StreamObserver<Resp> observer)
    Send a response containing a stream of BinaryKeyAndValue to a StreamObserver and then complete the observer.
    protected void
    completeSetStream(Set<Binary> set, int id, io.grpc.stub.StreamObserver<Resp> observer)
    Send a response containing a stream of BinaryKeyAndValue to a StreamObserver and then complete the observer.
    protected <T> T
    Deserialize a Binary value using this proxy's serializer.
    protected <T> T
    fromByteString(com.google.protobuf.ByteString bytes)
    Deserialize a ByteString value using this proxy's serializer.
    protected <T> T
    fromByteString(com.google.protobuf.ByteString bytes, T defaultValue)
    Deserialize a ByteString value using this proxy's serializer, or a default value if the deserialized result is null.
    protected abstract com.google.protobuf.Any
    getMessage(Req request)
     
    Return the Serializer to use to serialize response data.
    void
    init(GrpcService service, com.oracle.coherence.grpc.messages.proxy.v1.InitRequest request, int nVersion, UUID clientUUID, io.grpc.stub.StreamObserver<Resp> observer)
    Initialise this protocol.
    protected abstract void
    initInternal(GrpcService service, com.oracle.coherence.grpc.messages.proxy.v1.InitRequest request, int nVersion, UUID clientUUID)
     
    void
    onRequest(Req request, io.grpc.stub.StreamObserver<Resp> observer)
    Handle a request.
    protected abstract void
    onRequestInternal(Req request, io.grpc.stub.StreamObserver<Resp> observer)
     
    protected abstract Resp
    response(int id, com.google.protobuf.Any any)
     
    protected <T extends com.google.protobuf.Message>
    T
    unpack(Req request, Class<T> type)
    Unpack the message field from a request.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.oracle.coherence.grpc.GrpcServiceProtocol

    getPriority, getProtocol, getRequestType, getResponseType, getSupportedVersion, getVersion, onError
  • Field Details

    • f_lock

      protected static final Lock f_lock
      The lock to control access to state.
    • m_service

      protected GrpcService m_service
      The parent GrpcService.
    • m_ccf

    • m_proxy

      protected com.tangosol.coherence.component.net.extend.proxy.serviceProxy.CacheServiceProxy m_proxy
      The CacheServiceProxy.
    • m_serializer

      protected Serializer m_serializer
      The client's serializer.
    • m_connection

      protected com.tangosol.coherence.component.net.extend.Connection m_connection
      The Connection to use to send responses.
    • m_destroyedIds

      protected final Set<Integer> m_destroyedIds
      A bit-set containing destroyed cache identifiers.
    • m_eventObserver

      protected io.grpc.stub.StreamObserver<Resp extends com.google.protobuf.Message> m_eventObserver
      A StreamObserver for processing event messages.
  • Constructor Details

    • BaseProxyProtocol

      public BaseProxyProtocol()
  • Method Details

    • getSerializer

      public Serializer getSerializer()
      Description copied from interface: GrpcServiceProtocol
      Return the Serializer to use to serialize response data.
      Specified by:
      getSerializer in interface GrpcServiceProtocol<Req extends com.google.protobuf.Message,Resp extends com.google.protobuf.Message>
      Returns:
      the Serializer to use to serialize response data
    • init

      public void init(GrpcService service, com.oracle.coherence.grpc.messages.proxy.v1.InitRequest request, int nVersion, UUID clientUUID, io.grpc.stub.StreamObserver<Resp> observer)
      Description copied from interface: GrpcServiceProtocol
      Initialise this protocol.
      Specified by:
      init in interface GrpcServiceProtocol<Req extends com.google.protobuf.Message,Resp extends com.google.protobuf.Message>
      Parameters:
      service - the parent GrpcService
      request - the init request to use to initialise the protocol
      nVersion - the actual version of the protocol to use
      clientUUID - the client UUID
      observer - the StreamObserver to send non-request related responses (e.g. events)
    • initInternal

      protected abstract void initInternal(GrpcService service, com.oracle.coherence.grpc.messages.proxy.v1.InitRequest request, int nVersion, UUID clientUUID)
    • onRequest

      public void onRequest(Req request, io.grpc.stub.StreamObserver<Resp> observer)
      Description copied from interface: GrpcServiceProtocol
      Handle a request.
      Specified by:
      onRequest in interface GrpcServiceProtocol<Req extends com.google.protobuf.Message,Resp extends com.google.protobuf.Message>
      Parameters:
      request - the request to handle
      observer - the StreamObserver to send the responses to
    • onRequestInternal

      protected abstract void onRequestInternal(Req request, io.grpc.stub.StreamObserver<Resp> observer)
    • close

      public void close()
      Description copied from interface: GrpcServiceProtocol
      Close this protocol.
      Specified by:
      close in interface GrpcServiceProtocol<Req extends com.google.protobuf.Message,Resp extends com.google.protobuf.Message>
    • complete

      protected void complete(boolean f, int id, io.grpc.stub.StreamObserver<Resp> observer)
      Send a response containing a BoolValue to a StreamObserver and then complete the observer.
      Parameters:
      f - the boolean value to use to send a response before completing
      id - the resource identifier
      observer - the StreamObserver to complete
    • complete

      protected void complete(int n, int id, io.grpc.stub.StreamObserver<Resp> observer)
      Send a response containing an Int32Value to a StreamObserver and then complete the observer.
      Parameters:
      n - the int value to use to send a response before completing
      id - the resource identifier
      observer - the StreamObserver to complete
    • complete

      protected void complete(Binary binary, int id, io.grpc.stub.StreamObserver<Resp> observer)
      Send a response containing a BytesValue to a StreamObserver and then complete the observer.
      Parameters:
      binary - the binary value to use to send a response before completing
      id - the resource identifier
      observer - the StreamObserver to complete
    • complete

      protected void complete(com.tangosol.coherence.component.net.extend.message.Request request, io.grpc.stub.StreamObserver<Resp> observer)
      Send a response containing a BinaryKeyAndValue to a StreamObserver and then complete the observer.
      Parameters:
      request - the Request containing the result
      observer - the StreamObserver to complete
    • complete

      protected void complete(Binary binKey, com.tangosol.coherence.component.net.extend.message.Request request, int id, io.grpc.stub.StreamObserver<Resp> observer)
      Send a response containing a BinaryKeyAndValue to a StreamObserver and then complete the observer.
      Parameters:
      binKey - the binary key to use to send a response before completing
      request - the Request containing the result
      id - the resource identifier
      observer - the StreamObserver to complete
    • completeKeyValue

      protected void completeKeyValue(Binary binKey, Binary binValue, int id, io.grpc.stub.StreamObserver<Resp> observer)
      Send a response containing a BinaryKeyAndValue to a StreamObserver and then complete the observer.
      Parameters:
      binKey - the binary key to use to send a response before completing
      binValue - the Binary value
      id - the resource identifier
      observer - the StreamObserver to complete
    • complete

      protected void complete(com.google.protobuf.Message message, int id, io.grpc.stub.StreamObserver<Resp> observer)
      Send a response containing a BytesValue to a StreamObserver and then complete the observer.
      Parameters:
      message - the Message value to use to send a response before completing
      id - the resource identifier
      observer - the StreamObserver to complete
    • completeMapStream

      protected void completeMapStream(com.tangosol.coherence.component.net.extend.message.Request request, int id, io.grpc.stub.StreamObserver<Resp> observer)
      Send a response containing a stream of BinaryKeyAndValue to a StreamObserver and then complete the observer.
      Parameters:
      request - the Request containing the result
      id - the resource identifier
      observer - the StreamObserver to complete
    • completeMapStream

      protected void completeMapStream(Map<Binary,Binary> map, int id, io.grpc.stub.StreamObserver<Resp> observer)
      Send a response containing a stream of BinaryKeyAndValue to a StreamObserver and then complete the observer.
      Parameters:
      map - the map of binary keys and values to stream to the observer
      id - the resource identifier
      observer - the StreamObserver to complete
    • completeSetStream

      protected void completeSetStream(com.tangosol.coherence.component.net.extend.message.Request request, int id, io.grpc.stub.StreamObserver<Resp> observer)
      Send a response containing a stream of BinaryKeyAndValue to a StreamObserver and then complete the observer.
      Parameters:
      request - the Request containing the result
      id - the resource identifier
      observer - the StreamObserver to complete
    • completeSetStream

      protected void completeSetStream(Set<Binary> set, int id, io.grpc.stub.StreamObserver<Resp> observer)
      Send a response containing a stream of BinaryKeyAndValue to a StreamObserver and then complete the observer.
      Parameters:
      set - the set of binary instances to stream to the observer
      id - the resource identifier
      observer - the StreamObserver to complete
    • response

      protected abstract Resp response(int id, com.google.protobuf.Any any)
    • unpack

      protected <T extends com.google.protobuf.Message> T unpack(Req request, Class<T> type)
      Unpack the message field from a request.
      Type Parameters:
      T - the expected type of the message
      Parameters:
      request - the request to get the message from
      type - the expected type of the message
      Returns:
      the unpacked message
    • getMessage

      protected abstract com.google.protobuf.Any getMessage(Req request)
    • fromBinary

      protected <T> T fromBinary(Binary binary)
      Deserialize a Binary value using this proxy's serializer.
      Type Parameters:
      T - the expected deserialized type
      Parameters:
      binary - the Binary to deserialize
      Returns:
      the deserialized value or null if the binary value is null
    • fromByteString

      protected <T> T fromByteString(com.google.protobuf.ByteString bytes)
      Deserialize a ByteString value using this proxy's serializer.
      Type Parameters:
      T - the expected deserialized type
      Parameters:
      bytes - the ByteString to deserialize
      Returns:
      the deserialized value or null if the ByteString value is null
    • fromByteString

      protected <T> T fromByteString(com.google.protobuf.ByteString bytes, T defaultValue)
      Deserialize a ByteString value using this proxy's serializer, or a default value if the deserialized result is null.
      Type Parameters:
      T - the expected deserialized type
      Parameters:
      bytes - the ByteString to deserialize
      defaultValue - the default value to return if the deserialized value is null
      Returns:
      the deserialized value or the default value if the deserialized value is null