Package com.oracle.coherence.client
Class BaseGrpcClient<V>
- java.lang.Object
-
- com.oracle.coherence.client.BaseGrpcClient<V>
-
- Type Parameters:
V- the type of value this client contains
- Direct Known Subclasses:
AsyncNamedCacheClient
public abstract class BaseGrpcClient<V> extends Object
A base class for gRPC clients.- Since:
- 23.03
- Author:
- Jonathan Knight 2023.02.02
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBaseGrpcClient.DefaultDependenciesThe default dependencies implementation.static interfaceBaseGrpcClient.DependenciesThe dependencies used to create anAsyncNamedCacheClient.
-
Field Summary
Fields Modifier and Type Field Description protected BaseGrpcClient.Dependenciesf_dependenciesThe service dependencies.protected com.tangosol.net.events.EventDispatcherf_dispatcherThe event dispatcher for this cache.protected Executorf_executorTheExecutorto use to dispatch events.protected com.tangosol.io.Serializerf_serializerTheSerializerto use.protected Stringf_sFormatThe serialization format.protected Stringf_sNameThe cache name.protected Stringf_sScopeNameThe scope name to use for requests.protected booleanm_fDestroyedA flag indicating whether this client has been destroyed.protected booleanm_fReleasedA flag indicating whether this client has been released.
-
Constructor Summary
Constructors Constructor Description BaseGrpcClient(BaseGrpcClient.Dependencies dependencies)Creates anAsyncNamedCacheClientfrom the specifiedAsyncNamedCacheClient.Dependencies.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static ExecutorcreateDefaultExecutor()Obtain the defaultExecutorto be used by the cache.protected static com.tangosol.io.SerializercreateSerializer(String sFormat)Obtain the defaultSerializerto be used by the cache.protected <T> CompletableFuture<T>failedFuture(Throwable t)Create a failedCompletableFuture.protected <T> TfromByteString(com.google.protobuf.ByteString bytes)A utility method to deserialize aByteStringto an Object.protected <T> TfromBytesValue(com.google.protobuf.BytesValue bytes)A utility method to deserialize aBytesValueto an Object.protected static StringgetDefaultSerializerFormat()Return the default serialization format.booleanisActiveInternal()Helper method for cache active checks.booleanisDestroyed()Returntrueif the cache has been destroyed.booleanisReleased()Returntrueif the cache has been released.protected com.google.protobuf.ByteStringtoByteString(Object obj)A utility method to serialize an Object toByteString.protected com.google.protobuf.BytesValuetoBytesValue(Object obj)A utility method to serialize an Object toBytesValue.protected VvalueFromBytesValue(com.google.protobuf.BytesValue bv)A utility method to deserialize aBytesValueto an Object.protected VvalueFromOptionalValue(OptionalValue optional, V defaultValue)A utility method to deserialize anOptionalValueto an Object.
-
-
-
Field Detail
-
f_sScopeName
protected final String f_sScopeName
The scope name to use for requests.
-
f_sName
protected final String f_sName
The cache name.
-
f_serializer
protected final com.tangosol.io.Serializer f_serializer
TheSerializerto use.
-
f_sFormat
protected final String f_sFormat
The serialization format.
-
m_fReleased
protected volatile boolean m_fReleased
A flag indicating whether this client has been released.
-
m_fDestroyed
protected volatile boolean m_fDestroyed
A flag indicating whether this client has been destroyed.
-
f_dispatcher
protected final com.tangosol.net.events.EventDispatcher f_dispatcher
The event dispatcher for this cache.
-
f_dependencies
protected final BaseGrpcClient.Dependencies f_dependencies
The service dependencies.
-
-
Constructor Detail
-
BaseGrpcClient
public BaseGrpcClient(BaseGrpcClient.Dependencies dependencies)
Creates anAsyncNamedCacheClientfrom the specifiedAsyncNamedCacheClient.Dependencies.- Parameters:
dependencies- theAsyncNamedCacheClient.Dependenciesto configure thisAsyncNamedCacheClient.
-
-
Method Detail
-
isReleased
public boolean isReleased()
Returntrueif the cache has been released.- Returns:
trueif the cache has been released
-
isDestroyed
public boolean isDestroyed()
Returntrueif the cache has been destroyed.- Returns:
trueif the cache has been destroyed
-
isActiveInternal
public boolean isActiveInternal()
Helper method for cache active checks.- Returns:
trueif the cache is still active
-
createSerializer
protected static com.tangosol.io.Serializer createSerializer(String sFormat)
Obtain the defaultSerializerto be used by the cache.- Returns:
- the default
Serializerto be used by the cache
-
getDefaultSerializerFormat
protected static String getDefaultSerializerFormat()
Return the default serialization format.The default format will be Java serialization unless the
coherence.pof.enabledproperty is set when it will be POF.- Returns:
- the default serialization format
-
createDefaultExecutor
protected static Executor createDefaultExecutor()
Obtain the defaultExecutorto be used by the cache.- Returns:
- the default
Executorto be used by the cache
-
toBytesValue
protected com.google.protobuf.BytesValue toBytesValue(Object obj)
A utility method to serialize an Object toBytesValue.- Parameters:
obj- the object to convert toBytesValue.- Returns:
- the
BytesValuefor the specified object
-
toByteString
protected com.google.protobuf.ByteString toByteString(Object obj)
A utility method to serialize an Object toByteString.- Parameters:
obj- the object to convert toByteString.- Returns:
- the
ByteStringfor the specified object
-
valueFromOptionalValue
protected V valueFromOptionalValue(OptionalValue optional, V defaultValue)
A utility method to deserialize anOptionalValueto an Object.If no value is present in the
OptionalValuethen the default value is returned.- Parameters:
optional- theOptionalValueto deserialize an Object.defaultValue- the value to return if the {link @OptionalValue} does not contain a value- Returns:
- an object from the specified
BytesValue
-
valueFromBytesValue
protected V valueFromBytesValue(com.google.protobuf.BytesValue bv)
A utility method to deserialize aBytesValueto an Object.- Parameters:
bv- theBytesValueto deserialize an Object.- Returns:
- an object from the specified
BytesValue
-
fromBytesValue
protected <T> T fromBytesValue(com.google.protobuf.BytesValue bytes)
A utility method to deserialize aBytesValueto an Object.- Parameters:
bytes- theBytesValueto deserialize an Object.- Returns:
- an object from the specified
BytesValue
-
fromByteString
protected <T> T fromByteString(com.google.protobuf.ByteString bytes)
A utility method to deserialize aByteStringto an Object.- Parameters:
bytes- theByteStringto deserialize an Object.- Returns:
- an object from the specified
ByteString
-
failedFuture
protected <T> CompletableFuture<T> failedFuture(Throwable t)
Create a failedCompletableFuture.- Type Parameters:
T- the type of the future- Parameters:
t- the error to use- Returns:
- a failed
CompletableFuture
-
-