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
FieldsModifier and TypeFieldDescriptionprotected static final Lock
The lock to control access to state.protected ExtensibleConfigurableCacheFactory
TheExtensibleConfigurableCacheFactory
owning the cache.protected com.tangosol.coherence.component.net.extend.Connection
TheConnection
to use to send responses.A bit-set containing destroyed cache identifiers.protected io.grpc.stub.StreamObserver
<Resp> AStreamObserver
for processing event messages.protected com.tangosol.coherence.component.net.extend.proxy.serviceProxy.CacheServiceProxy
TheCacheServiceProxy
.protected Serializer
The client's serializer.protected GrpcService
The parentGrpcService
.Fields inherited from interface com.oracle.coherence.grpc.GrpcServiceProtocol
PRIORITY_NORMAL
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this protocol.protected void
Send a response containing aBoolValue
to aStreamObserver
and then complete the observer.protected void
Send a response containing anInt32Value
to aStreamObserver
and then complete the observer.protected void
Send a response containing aBytesValue
to aStreamObserver
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 aBinaryKeyAndValue
to aStreamObserver
and then complete the observer.protected void
Send a response containing aBytesValue
to aStreamObserver
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 aBinaryKeyAndValue
to aStreamObserver
and then complete the observer.protected void
completeKeyValue
(Binary binKey, Binary binValue, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing aBinaryKeyAndValue
to aStreamObserver
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 ofBinaryKeyAndValue
to aStreamObserver
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 ofBinaryKeyAndValue
to aStreamObserver
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 ofBinaryKeyAndValue
to aStreamObserver
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 ofBinaryKeyAndValue
to aStreamObserver
and then complete the observer.protected <T> T
fromBinary
(Binary binary) Deserialize aBinary
value using this proxy's serializer.protected <T> T
fromByteString
(com.google.protobuf.ByteString bytes) Deserialize aByteString
value using this proxy's serializer.protected <T> T
fromByteString
(com.google.protobuf.ByteString bytes, T defaultValue) Deserialize aByteString
value using this proxy's serializer, or a default value if the deserialized result isnull
.protected abstract com.google.protobuf.Any
getMessage
(Req request) Return theSerializer
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
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>
TUnpack 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
The lock to control access to state. -
m_service
The parentGrpcService
. -
m_ccf
TheExtensibleConfigurableCacheFactory
owning the cache. -
m_proxy
protected com.tangosol.coherence.component.net.extend.proxy.serviceProxy.CacheServiceProxy m_proxyTheCacheServiceProxy
. -
m_serializer
The client's serializer. -
m_connection
protected com.tangosol.coherence.component.net.extend.Connection m_connectionTheConnection
to use to send responses. -
m_destroyedIds
A bit-set containing destroyed cache identifiers. -
m_eventObserver
AStreamObserver
for processing event messages.
-
-
Constructor Details
-
BaseProxyProtocol
public BaseProxyProtocol()
-
-
Method Details
-
getSerializer
Description copied from interface:GrpcServiceProtocol
Return theSerializer
to use to serialize response data.- Specified by:
getSerializer
in interfaceGrpcServiceProtocol<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 interfaceGrpcServiceProtocol<Req extends com.google.protobuf.Message,
Resp extends com.google.protobuf.Message> - Parameters:
service
- the parentGrpcService
request
- the init request to use to initialise the protocolnVersion
- the actual version of the protocol to useclientUUID
- the clientUUID
observer
- theStreamObserver
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
Description copied from interface:GrpcServiceProtocol
Handle a request.- Specified by:
onRequest
in interfaceGrpcServiceProtocol<Req extends com.google.protobuf.Message,
Resp extends com.google.protobuf.Message> - Parameters:
request
- the request to handleobserver
- theStreamObserver
to send the responses to
-
onRequestInternal
-
close
public void close()Description copied from interface:GrpcServiceProtocol
Close this protocol.- Specified by:
close
in interfaceGrpcServiceProtocol<Req extends com.google.protobuf.Message,
Resp extends com.google.protobuf.Message>
-
complete
Send a response containing aBoolValue
to aStreamObserver
and then complete the observer.- Parameters:
f
- the boolean value to use to send a response before completingid
- the resource identifierobserver
- theStreamObserver
to complete
-
complete
Send a response containing anInt32Value
to aStreamObserver
and then complete the observer.- Parameters:
n
- the int value to use to send a response before completingid
- the resource identifierobserver
- theStreamObserver
to complete
-
complete
Send a response containing aBytesValue
to aStreamObserver
and then complete the observer.- Parameters:
binary
- the binary value to use to send a response before completingid
- the resource identifierobserver
- theStreamObserver
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 aBinaryKeyAndValue
to aStreamObserver
and then complete the observer.- Parameters:
request
- theRequest
containing the resultobserver
- theStreamObserver
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 aBinaryKeyAndValue
to aStreamObserver
and then complete the observer.- Parameters:
binKey
- the binary key to use to send a response before completingrequest
- theRequest
containing the resultid
- the resource identifierobserver
- theStreamObserver
to complete
-
completeKeyValue
protected void completeKeyValue(Binary binKey, Binary binValue, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing aBinaryKeyAndValue
to aStreamObserver
and then complete the observer.- Parameters:
binKey
- the binary key to use to send a response before completingbinValue
- theBinary
valueid
- the resource identifierobserver
- theStreamObserver
to complete
-
complete
protected void complete(com.google.protobuf.Message message, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing aBytesValue
to aStreamObserver
and then complete the observer.- Parameters:
message
- theMessage
value to use to send a response before completingid
- the resource identifierobserver
- theStreamObserver
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 ofBinaryKeyAndValue
to aStreamObserver
and then complete the observer.- Parameters:
request
- theRequest
containing the resultid
- the resource identifierobserver
- theStreamObserver
to complete
-
completeMapStream
protected void completeMapStream(Map<Binary, Binary> map, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing a stream ofBinaryKeyAndValue
to aStreamObserver
and then complete the observer.- Parameters:
map
- the map of binary keys and values to stream to the observerid
- the resource identifierobserver
- theStreamObserver
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 ofBinaryKeyAndValue
to aStreamObserver
and then complete the observer.- Parameters:
request
- theRequest
containing the resultid
- the resource identifierobserver
- theStreamObserver
to complete
-
completeSetStream
protected void completeSetStream(Set<Binary> set, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing a stream ofBinaryKeyAndValue
to aStreamObserver
and then complete the observer.- Parameters:
set
- the set of binary instances to stream to the observerid
- the resource identifierobserver
- theStreamObserver
to complete
-
response
-
unpack
Unpack the message field from a request.- Type Parameters:
T
- the expected type of the message- Parameters:
request
- the request to get the message fromtype
- the expected type of the message- Returns:
- the unpacked message
-
getMessage
-
fromBinary
Deserialize aBinary
value using this proxy's serializer.- Type Parameters:
T
- the expected deserialized type- Parameters:
binary
- theBinary
to deserialize- Returns:
- the deserialized value or
null
if the binary value isnull
-
fromByteString
protected <T> T fromByteString(com.google.protobuf.ByteString bytes) Deserialize aByteString
value using this proxy's serializer.- Type Parameters:
T
- the expected deserialized type- Parameters:
bytes
- theByteString
to deserialize- Returns:
- the deserialized value or
null
if theByteString
value isnull
-
fromByteString
protected <T> T fromByteString(com.google.protobuf.ByteString bytes, T defaultValue) Deserialize aByteString
value using this proxy's serializer, or a default value if the deserialized result isnull
.- Type Parameters:
T
- the expected deserialized type- Parameters:
bytes
- theByteString
to deserializedefaultValue
- 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
-