Package com.oracle.coherence.grpc
Class RequestHolder<Req,Res>
java.lang.Object
com.oracle.coherence.grpc.RequestHolder<Req,Res>
- Type Parameters:
Req
- the type of the requestRes
- the result type
- Direct Known Subclasses:
CacheRequestHolder
A class that holds a gRPC request and
Binary
converters.- Since:
- 23.03
- Author:
- Jonathan Knight 2023.02.03
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
protected static class
protected static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Executor
TheExecutor
to use to hand off asynchronous tasks.protected final Req
The request.protected final Serializer
TheSerializer
used by the request.protected final Service
TheService
managing the resource.protected final String
The name of the serializer used to serialize the request payloads.protected Object
A result value. -
Constructor Summary
ConstructorDescriptionRequestHolder
(Req request, String sFormat, Serializer serializer, Service service, Executor executor) Create aRequestHolder
. -
Method Summary
Modifier and TypeMethodDescriptionconvertDown
(com.google.protobuf.ByteString bytes) Convert theByteString
data serialized in the request format to aBinary
serialized in the cache's serialization format.convertDown
(Binary binary) convertDown
(Supplier<com.google.protobuf.ByteString> supplier) Convert theByteString
data serialized in the request format to aBinary
serialized in the cache's serialization format.<T> T
deserialize
(Binary binary) Obtain the deserializedBinary
value using the cache's serializer.<T> T
deserializeRequest
(com.google.protobuf.ByteString bytes) Obtain the deserializedByteString
value using the request's serializer.com.google.protobuf.BytesValue
deserializeToBytesValue
(Binary binary) Convert theBinary
serialized in the cache's serialization format to aBytesValue
serialized in the request's serialization format.<T> T
fromBinary
(Binary binary) Obtain the value deserialized from the specifiedBinary
using the cache's serializer.static String
getCacheFormat
(Service service) Returns the serializer format name for the specifiedService
's serializer.<T> T
Obtain the holder's deserialized result value, assuming that the result value is a serializedBinary
.Obtain the cache request.Obtain the holder's result value.Obtain the request'sSerializer
.Obtain the cache'sSerializer
.<T> RequestHolder
<Req, T> setResult
(T t) Set the holder's result value.com.google.protobuf.ByteString
toByteString
(Binary binary) Convert theBinary
serialized in the cache's serialization format to aByteString
serialized in the request's serialization format.com.google.protobuf.BytesValue
toBytesValue
(Binary binary) Convert theBinary
serialized in the cache's serialization format to aBytesValue
serialized in the request's serialization format.com.oracle.coherence.grpc.Entry
com.oracle.coherence.grpc.EntryResult
toEntryResult
(Map.Entry<Binary, Binary> entry) com.oracle.coherence.grpc.OptionalValue
toOptionalValue
(Binary binary)
-
Field Details
-
f_request
The request. -
f_sFormat
The name of the serializer used to serialize the request payloads. -
f_executor
TheExecutor
to use to hand off asynchronous tasks. -
f_service
TheService
managing the resource. -
m_converterDown
-
m_converterUp
-
f_serializer
TheSerializer
used by the request. -
m_result
A result value.
-
-
Constructor Details
-
RequestHolder
public RequestHolder(Req request, String sFormat, Serializer serializer, Service service, Executor executor) Create aRequestHolder
.- Parameters:
request
- the cache requestsFormat
- the name of the serializer used to serialize the request payloadsserializer
- theSerializer
used by the requestexecutor
- the executor for asynchronous processing
-
-
Method Details
-
getRequest
Obtain the cache request.- Returns:
- the cache request
-
getResult
Obtain the holder's result value.- Returns:
- the holder's result value
-
getServiceSerializer
Obtain the cache'sSerializer
.- Returns:
- the cache's
Serializer
-
getDeserializedResult
public <T> T getDeserializedResult()Obtain the holder's deserialized result value, assuming that the result value is a serializedBinary
.- Type Parameters:
T
- the deserialized type- Returns:
- the holder's deserialized result value
-
fromBinary
Obtain the value deserialized from the specifiedBinary
using the cache's serializer.- Type Parameters:
T
- the deserialized type- Parameters:
binary
- theBinary
of the serialized object- Returns:
- the deserialized value
-
deserialize
Obtain the deserializedBinary
value using the cache's serializer. -
deserializeRequest
public <T> T deserializeRequest(com.google.protobuf.ByteString bytes) Obtain the deserializedByteString
value using the request's serializer.- Type Parameters:
T
- the deserialized type- Parameters:
bytes
- theByteString
of the serialized object- Returns:
- the deserialized
ByteString
value using the request's serializer
-
setResult
Set the holder's result value.- Type Parameters:
T
- the type of the result value- Parameters:
t
- the result value- Returns:
- this
RequestHolder
cast to the new result type
-
getSerializer
Obtain the request'sSerializer
.- Returns:
- the request's
Serializer
-
convertUp
-
convertDown
Convert theByteString
data serialized in the request format to aBinary
serialized in the cache's serialization format.- Parameters:
supplier
- the supplier of theByteString
to convert- Returns:
- a
Binary
in the cache's serialization format
-
convertDown
Convert theByteString
data serialized in the request format to aBinary
serialized in the cache's serialization format.- Parameters:
bytes
- theByteString
to convert- Returns:
- a
Binary
in the cache's serialization format
-
convertDown
-
deserializeToBytesValue
Convert theBinary
serialized in the cache's serialization format to aBytesValue
serialized in the request's serialization format.The assumption is that the
Binary
deserializes to anotherBinary
.- Parameters:
binary
- theBinary
to convert- Returns:
- a
BytesValue
in the request's serialization format
-
toBytesValue
Convert theBinary
serialized in the cache's serialization format to aBytesValue
serialized in the request's serialization format.- Parameters:
binary
- theBinary
to convert- Returns:
- a
BytesValue
in the request's serialization format
-
toByteString
Convert theBinary
serialized in the cache's serialization format to aByteString
serialized in the request's serialization format.- Parameters:
binary
- theBinary
to convert- Returns:
- a
ByteString
in the request's serialization format
-
toEntry
-
toEntryResult
Convert aMap.Entry
ofBinary
key and value serialized in the cache's serialization format into anEntryResult
with a key and value serialized in the request's serialization format.- Parameters:
entry
- theBinary
to convert- Returns:
- a
EntryResult
in the request's serialization format
-
toOptionalValue
Convert aBinary
serialized with the cache's serializer to anOptionalValue
containing an optionalBinary
serialized with the request's serializer.- Parameters:
binary
- the optionalBinary
value- Returns:
- a
OptionalValue
in the request's serialization format
-
ensureConverterDown
Obtain theConverter
used to convert between the request format and the cache format; creating theConverter
if required.- Returns:
- the
Converter
used to convert between the request format and the cache format
-
createConverterDown
-
getCacheFormat
Returns the serializer format name for the specifiedService
's serializer. -
ensureConverterUp
Obtain theConverter
used to convert between the cache format and the request format; creating theConverter
if required.- Returns:
- the
Converter
used to convert between the cache format and the request format
-