Package com.oracle.coherence.grpc.v0
Class RequestHolder<Req,Res>
java.lang.Object
com.oracle.coherence.grpc.v0.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
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ExecutorTheExecutorto use to hand off asynchronous tasks.protected final ReqThe request.protected final SerializerTheSerializerused by the request.protected final ServiceTheServicemanaging the resource.protected final StringThe name of the serializer used to serialize the request payloads.protected ObjectA result value. -
Constructor Summary
ConstructorsConstructorDescriptionRequestHolder(Req request, String sFormat, Serializer serializer, Service service, Executor executor) Create aRequestHolder. -
Method Summary
Modifier and TypeMethodDescriptionconvertDown(com.google.protobuf.ByteString bytes) Convert theByteStringdata serialized in the request format to aBinaryserialized in the cache's serialization format.convertDown(Binary binary) convertDown(Supplier<com.google.protobuf.ByteString> supplier) Convert theByteStringdata serialized in the request format to aBinaryserialized in the cache's serialization format.<T> Tdeserialize(Binary binary) Obtain the deserializedBinaryvalue using the cache's serializer.<T> TdeserializeRequest(com.google.protobuf.ByteString bytes) Obtain the deserializedByteStringvalue using the request's serializer.com.google.protobuf.BytesValuedeserializeToBytesValue(Binary binary) Convert theBinaryserialized in the cache's serialization format to aBytesValueserialized in the request's serialization format.<T> TfromBinary(Binary binary) Obtain the value deserialized from the specifiedBinaryusing the cache's serializer.static StringgetCacheFormat(Service service) Returns the serializer format name for the specifiedService's serializer.<T> TObtain 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.ByteStringtoByteString(Binary binary) Convert theBinaryserialized in the cache's serialization format to aByteStringserialized in the request's serialization format.com.google.protobuf.BytesValuetoBytesValue(Binary binary) Convert theBinaryserialized in the cache's serialization format to aBytesValueserialized in the request's serialization format.com.oracle.coherence.grpc.messages.cache.v0.Entrycom.oracle.coherence.grpc.messages.cache.v0.EntryResulttoEntryResult(Map.Entry<Binary, Binary> entry) com.oracle.coherence.grpc.messages.cache.v0.OptionalValuetoOptionalValue(Binary binary)
-
Field Details
-
f_request
The request. -
f_sFormat
The name of the serializer used to serialize the request payloads. -
f_executor
TheExecutorto use to hand off asynchronous tasks. -
f_service
TheServicemanaging the resource. -
m_converterDown
-
m_converterUp
-
f_serializer
TheSerializerused 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- theSerializerused 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 specifiedBinaryusing the cache's serializer.- Type Parameters:
T- the deserialized type- Parameters:
binary- theBinaryof the serialized object- Returns:
- the deserialized value
-
deserialize
Obtain the deserializedBinaryvalue using the cache's serializer. -
deserializeRequest
public <T> T deserializeRequest(com.google.protobuf.ByteString bytes) Obtain the deserializedByteStringvalue using the request's serializer.- Type Parameters:
T- the deserialized type- Parameters:
bytes- theByteStringof the serialized object- Returns:
- the deserialized
ByteStringvalue 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
RequestHoldercast to the new result type
-
getSerializer
Obtain the request'sSerializer.- Returns:
- the request's
Serializer
-
convertUp
-
convertDown
Convert theByteStringdata serialized in the request format to aBinaryserialized in the cache's serialization format.- Parameters:
supplier- the supplier of theByteStringto convert- Returns:
- a
Binaryin the cache's serialization format
-
convertDown
Convert theByteStringdata serialized in the request format to aBinaryserialized in the cache's serialization format.- Parameters:
bytes- theByteStringto convert- Returns:
- a
Binaryin the cache's serialization format
-
convertDown
-
deserializeToBytesValue
Convert theBinaryserialized in the cache's serialization format to aBytesValueserialized in the request's serialization format.The assumption is that the
Binarydeserializes to anotherBinary.- Parameters:
binary- theBinaryto convert- Returns:
- a
BytesValuein the request's serialization format
-
toBytesValue
Convert theBinaryserialized in the cache's serialization format to aBytesValueserialized in the request's serialization format.- Parameters:
binary- theBinaryto convert- Returns:
- a
BytesValuein the request's serialization format
-
toByteString
Convert theBinaryserialized in the cache's serialization format to aByteStringserialized in the request's serialization format.- Parameters:
binary- theBinaryto convert- Returns:
- a
ByteStringin the request's serialization format
-
toEntry
-
toEntryResult
public com.oracle.coherence.grpc.messages.cache.v0.EntryResult toEntryResult(Map.Entry<Binary, Binary> entry) Convert aMap.EntryofBinarykey and value serialized in the cache's serialization format into anEntryResultwith a key and value serialized in the request's serialization format.- Parameters:
entry- theBinaryto convert- Returns:
- a
EntryResultin the request's serialization format
-
toOptionalValue
Convert aBinaryserialized with the cache's serializer to anOptionalValuecontaining an optionalBinaryserialized with the request's serializer.- Parameters:
binary- the optionalBinaryvalue- Returns:
- a
OptionalValuein the request's serialization format
-
ensureConverterDown
Obtain theConverterused to convert between the request format and the cache format; creating theConverterif required.- Returns:
- the
Converterused to convert between the request format and the cache format
-
createConverterDown
-
getCacheFormat
Returns the serializer format name for the specifiedService's serializer. -
ensureConverterUp
Obtain theConverterused to convert between the cache format and the request format; creating theConverterif required.- Returns:
- the
Converterused to convert between the cache format and the request format
-