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
public abstract class RequestHolder<Req,Res> extends Object
A class that holds a gRPC request andBinaryconverters.- Since:
- 23.03
- Author:
- Jonathan Knight 2023.02.03
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classRequestHolder.DownConverterprotected static classRequestHolder.ErrorHandlingConverter<F,T>protected static classRequestHolder.UpConverter
-
Field Summary
Fields Modifier and Type Field Description protected Executorf_executorTheExecutorto use to hand off asynchronous tasks.protected Reqf_requestThe request.protected Serializerf_serializerTheSerializerused by the request.protected Servicef_serviceTheServicemanaging the resource.protected Stringf_sFormatThe name of the serializer used to serialize the request payloads.protected Converter<Binary,Binary>m_converterDownprotected Converter<Binary,Binary>m_converterUpprotected Objectm_resultA result value.
-
Constructor Summary
Constructors Constructor Description RequestHolder(Req request, String sFormat, Serializer serializer, Service service, Executor executor)Create aRequestHolder.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description BinaryconvertDown(com.google.protobuf.ByteString bytes)Convert theByteStringdata serialized in the request format to aBinaryserialized in the cache's serialization format.BinaryconvertDown(Binary binary)BinaryconvertDown(Supplier<com.google.protobuf.ByteString> supplier)Convert theByteStringdata serialized in the request format to aBinaryserialized in the cache's serialization format.BinaryconvertUp(Binary binary)protected abstract Converter<Object,Binary>createConverterDown()<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.Converter<Binary,Binary>ensureConverterDown()Converter<Binary,Binary>ensureConverterUp()<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> TgetDeserializedResult()Obtain the holder's deserialized result value, assuming that the result value is a serializedBinary.ReqgetRequest()Obtain the cache request.ResgetResult()Obtain the holder's result value.SerializergetSerializer()Obtain the request'sSerializer.SerializergetServiceSerializer()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.EntrytoEntry(Binary binKey, Binary binValue)com.oracle.coherence.grpc.EntryResulttoEntryResult(Map.Entry<Binary,Binary> entry)com.oracle.coherence.grpc.OptionalValuetoOptionalValue(Binary binary)
-
-
-
Field Detail
-
f_request
protected final Req f_request
The request.
-
f_sFormat
protected final String f_sFormat
The name of the serializer used to serialize the request payloads.
-
f_serializer
protected final Serializer f_serializer
TheSerializerused by the request.
-
m_result
protected Object m_result
A result value.
-
-
Constructor Detail
-
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 Detail
-
getRequest
public Req getRequest()
Obtain the cache request.- Returns:
- the cache request
-
getResult
public Res getResult()
Obtain the holder's result value.- Returns:
- the holder's result value
-
getServiceSerializer
public Serializer 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
public <T> T fromBinary(Binary binary)
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
public <T> T deserialize(Binary binary)
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
public <T> RequestHolder<Req,T> setResult(T t)
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
public Serializer getSerializer()
Obtain the request'sSerializer.- Returns:
- the request's
Serializer
-
convertDown
public Binary convertDown(Supplier<com.google.protobuf.ByteString> supplier)
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
public Binary convertDown(com.google.protobuf.ByteString bytes)
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
-
deserializeToBytesValue
public com.google.protobuf.BytesValue deserializeToBytesValue(Binary binary)
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
public com.google.protobuf.BytesValue toBytesValue(Binary binary)
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
public com.google.protobuf.ByteString toByteString(Binary binary)
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
-
toEntryResult
public com.oracle.coherence.grpc.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
public com.oracle.coherence.grpc.OptionalValue toOptionalValue(Binary binary)
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
public Converter<Binary,Binary> 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
-
getCacheFormat
public static String getCacheFormat(Service service)
Returns the serializer format name for the specifiedService's serializer.
-
-