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 LockThe lock to control access to state.protected ExtensibleConfigurableCacheFactoryTheExtensibleConfigurableCacheFactoryowning the cache.protected com.tangosol.coherence.component.net.extend.ConnectionTheConnectionto use to send responses.A bit-set containing destroyed cache identifiers.protected io.grpc.stub.StreamObserver<Resp> AStreamObserverfor processing event messages.protected com.tangosol.coherence.component.net.extend.proxy.serviceProxy.CacheServiceProxyTheCacheServiceProxy.protected SerializerThe client's serializer.protected GrpcServiceThe parentGrpcService.Fields inherited from interface com.oracle.coherence.grpc.GrpcServiceProtocol
PRIORITY_NORMAL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close this protocol.protected voidSend a response containing aBoolValueto aStreamObserverand then complete the observer.protected voidSend a response containing anInt32Valueto aStreamObserverand then complete the observer.protected voidSend a response containing aBytesValueto aStreamObserverand then complete the observer.protected voidcomplete(com.tangosol.coherence.component.net.extend.message.Request request, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing aBinaryKeyAndValueto aStreamObserverand then complete the observer.protected voidSend a response containing aBytesValueto aStreamObserverand then complete the observer.protected voidcomplete(Binary binKey, com.tangosol.coherence.component.net.extend.message.Request request, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing aBinaryKeyAndValueto aStreamObserverand then complete the observer.protected voidcompleteKeyValue(Binary binKey, Binary binValue, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing aBinaryKeyAndValueto aStreamObserverand then complete the observer.protected voidcompleteMapStream(com.tangosol.coherence.component.net.extend.message.Request request, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing a stream ofBinaryKeyAndValueto aStreamObserverand then complete the observer.protected voidcompleteMapStream(Map<Binary, Binary> map, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing a stream ofBinaryKeyAndValueto aStreamObserverand then complete the observer.protected voidcompleteSetStream(com.tangosol.coherence.component.net.extend.message.Request request, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing a stream ofBinaryKeyAndValueto aStreamObserverand then complete the observer.protected voidcompleteSetStream(Set<Binary> set, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing a stream ofBinaryKeyAndValueto aStreamObserverand then complete the observer.protected <T> TfromBinary(Binary binary) Deserialize aBinaryvalue using this proxy's serializer.protected <T> TfromByteString(com.google.protobuf.ByteString bytes) Deserialize aByteStringvalue using this proxy's serializer.protected <T> TfromByteString(com.google.protobuf.ByteString bytes, T defaultValue) Deserialize aByteStringvalue using this proxy's serializer, or a default value if the deserialized result isnull.protected abstract com.google.protobuf.AnygetMessage(Req request) Return theSerializerto use to serialize response data.voidinit(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 voidinitInternal(GrpcService service, com.oracle.coherence.grpc.messages.proxy.v1.InitRequest request, int nVersion, UUID clientUUID) voidHandle a request.protected abstract voidonRequestInternal(Req request, io.grpc.stub.StreamObserver<Resp> observer) protected abstract Respresponse(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, waitMethods 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
TheExtensibleConfigurableCacheFactoryowning 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_connectionTheConnectionto use to send responses. -
m_destroyedIds
A bit-set containing destroyed cache identifiers. -
m_eventObserver
AStreamObserverfor processing event messages.
-
-
Constructor Details
-
BaseProxyProtocol
public BaseProxyProtocol()
-
-
Method Details
-
getSerializer
Description copied from interface:GrpcServiceProtocolReturn theSerializerto use to serialize response data.- Specified by:
getSerializerin interfaceGrpcServiceProtocol<Req extends com.google.protobuf.Message,Resp extends com.google.protobuf.Message> - Returns:
- the
Serializerto 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:GrpcServiceProtocolInitialise this protocol.- Specified by:
initin interfaceGrpcServiceProtocol<Req extends com.google.protobuf.Message,Resp extends com.google.protobuf.Message> - Parameters:
service- the parentGrpcServicerequest- the init request to use to initialise the protocolnVersion- the actual version of the protocol to useclientUUID- the clientUUIDobserver- theStreamObserverto 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:GrpcServiceProtocolHandle a request.- Specified by:
onRequestin interfaceGrpcServiceProtocol<Req extends com.google.protobuf.Message,Resp extends com.google.protobuf.Message> - Parameters:
request- the request to handleobserver- theStreamObserverto send the responses to
-
onRequestInternal
-
close
public void close()Description copied from interface:GrpcServiceProtocolClose this protocol.- Specified by:
closein interfaceGrpcServiceProtocol<Req extends com.google.protobuf.Message,Resp extends com.google.protobuf.Message>
-
complete
Send a response containing aBoolValueto aStreamObserverand then complete the observer.- Parameters:
f- the boolean value to use to send a response before completingid- the resource identifierobserver- theStreamObserverto complete
-
complete
Send a response containing anInt32Valueto aStreamObserverand then complete the observer.- Parameters:
n- the int value to use to send a response before completingid- the resource identifierobserver- theStreamObserverto complete
-
complete
Send a response containing aBytesValueto aStreamObserverand then complete the observer.- Parameters:
binary- the binary value to use to send a response before completingid- the resource identifierobserver- theStreamObserverto complete
-
complete
protected void complete(com.tangosol.coherence.component.net.extend.message.Request request, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing aBinaryKeyAndValueto aStreamObserverand then complete the observer.- Parameters:
request- theRequestcontaining the resultobserver- theStreamObserverto 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 aBinaryKeyAndValueto aStreamObserverand then complete the observer.- Parameters:
binKey- the binary key to use to send a response before completingrequest- theRequestcontaining the resultid- the resource identifierobserver- theStreamObserverto complete
-
completeKeyValue
protected void completeKeyValue(Binary binKey, Binary binValue, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing aBinaryKeyAndValueto aStreamObserverand then complete the observer.- Parameters:
binKey- the binary key to use to send a response before completingbinValue- theBinaryvalueid- the resource identifierobserver- theStreamObserverto complete
-
complete
protected void complete(com.google.protobuf.Message message, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing aBytesValueto aStreamObserverand then complete the observer.- Parameters:
message- theMessagevalue to use to send a response before completingid- the resource identifierobserver- theStreamObserverto 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 ofBinaryKeyAndValueto aStreamObserverand then complete the observer.- Parameters:
request- theRequestcontaining the resultid- the resource identifierobserver- theStreamObserverto complete
-
completeMapStream
protected void completeMapStream(Map<Binary, Binary> map, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing a stream ofBinaryKeyAndValueto aStreamObserverand then complete the observer.- Parameters:
map- the map of binary keys and values to stream to the observerid- the resource identifierobserver- theStreamObserverto 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 ofBinaryKeyAndValueto aStreamObserverand then complete the observer.- Parameters:
request- theRequestcontaining the resultid- the resource identifierobserver- theStreamObserverto complete
-
completeSetStream
protected void completeSetStream(Set<Binary> set, int id, io.grpc.stub.StreamObserver<Resp> observer) Send a response containing a stream ofBinaryKeyAndValueto aStreamObserverand then complete the observer.- Parameters:
set- the set of binary instances to stream to the observerid- the resource identifierobserver- theStreamObserverto 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 aBinaryvalue using this proxy's serializer.- Type Parameters:
T- the expected deserialized type- Parameters:
binary- theBinaryto deserialize- Returns:
- the deserialized value or
nullif the binary value isnull
-
fromByteString
protected <T> T fromByteString(com.google.protobuf.ByteString bytes) Deserialize aByteStringvalue using this proxy's serializer.- Type Parameters:
T- the expected deserialized type- Parameters:
bytes- theByteStringto deserialize- Returns:
- the deserialized value or
nullif theByteStringvalue isnull
-
fromByteString
protected <T> T fromByteString(com.google.protobuf.ByteString bytes, T defaultValue) Deserialize aByteStringvalue using this proxy's serializer, or a default value if the deserialized result isnull.- Type Parameters:
T- the expected deserialized type- Parameters:
bytes- theByteStringto 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
-