Class BaseNamedCacheServiceImpl
java.lang.Object
com.oracle.coherence.grpc.proxy.common.BaseGrpcServiceImpl
com.oracle.coherence.grpc.proxy.common.v0.BaseNamedCacheServiceImpl
- All Implemented Interfaces:
GrpcService,GrpcProxyService,NamedCacheService
- Direct Known Subclasses:
HelidonNamedCacheService,NettyNamedCacheService
public abstract class BaseNamedCacheServiceImpl
extends BaseGrpcServiceImpl
implements NamedCacheService
A base class for gRPC
NamedCacheService implementations.- Author:
- Jonathan Knight 2024.02.08
-
Nested Class Summary
Nested classes/interfaces inherited from class com.oracle.coherence.grpc.proxy.common.BaseGrpcServiceImpl
BaseGrpcServiceImpl.DefaultDependencies, BaseGrpcServiceImpl.DependenciesNested classes/interfaces inherited from interface com.oracle.coherence.grpc.proxy.common.v0.NamedCacheService
NamedCacheService.DefaultDependencies, NamedCacheService.Dependencies -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StringThe name to use for the management MBean.static final Stringstatic final Stringstatic final StringFields inherited from class com.oracle.coherence.grpc.proxy.common.BaseGrpcServiceImpl
DEFAULT_TRANSFER_THRESHOLD, f_cacheFactorySupplier, f_dependencies, f_executor, f_metrics, f_serializerProducer, INVALID_CACHE_NAME_MESSAGE, transferThreshold, VOID -
Constructor Summary
ConstructorsConstructorDescriptionBaseNamedCacheServiceImpl(NamedCacheService.Dependencies dependencies) Create aBaseNamedCacheServiceImpl. -
Method Summary
Modifier and TypeMethodDescriptionprotected com.google.protobuf.EmptyaddIndex(CacheRequestHolder<com.oracle.coherence.grpc.messages.cache.v0.AddIndexRequest, Void> holder) Execute theAddIndexRequestrequest.protected CompletionStage<com.google.protobuf.BytesValue> aggregateWithFilter(com.oracle.coherence.grpc.messages.cache.v0.AggregateRequest request, Executor executor) Execute the filteredAggregateRequestrequest.protected CompletionStage<com.google.protobuf.BytesValue> aggregateWithFilter(CacheRequestHolder<com.oracle.coherence.grpc.messages.cache.v0.AggregateRequest, Void> holder, Executor executor) Execute the filteredAggregateRequestrequest.protected CompletionStage<com.google.protobuf.BytesValue> aggregateWithKeys(com.oracle.coherence.grpc.messages.cache.v0.AggregateRequest request, Executor executor) Execute the key-basedAggregateRequestrequest.protected CompletionStage<com.google.protobuf.BytesValue> aggregateWithKeys(CacheRequestHolder<com.oracle.coherence.grpc.messages.cache.v0.AggregateRequest, Void> holder, Executor executor) Execute the filteredAggregateRequestrequest.protected InvocableMap.EntryProcessor<Binary, Binary, Binary> voidclear(com.oracle.coherence.grpc.messages.cache.v0.ClearRequest request, io.grpc.stub.StreamObserver<com.google.protobuf.Empty> observer) Clear a cache.convertKeysToBinary(CacheRequestHolder<com.oracle.coherence.grpc.messages.cache.v0.GetAllRequest, Void> holder) Convert the keys for aGetAllRequestfrom the request's serialization format to the cache's serialization format.<Req> CompletionStage<CacheRequestHolder<Req, Void>> createHolderAsync(Req request, String sScope, String sCacheName, String format) Asynchronously create aCacheRequestHolderfor a given request.<Req> CacheRequestHolder<Req, Void> createRequestHolder(Req request, String sScope, String sCacheName, String format) Create aCacheRequestHolderfor a given request.<T> Comparator<T> deserializeComparator(com.google.protobuf.ByteString bytes, Serializer serializer) Obtain aComparatorfrom the serialized data in aByteString.voiddestroy(com.oracle.coherence.grpc.messages.cache.v0.DestroyRequest request, io.grpc.stub.StreamObserver<com.google.protobuf.Empty> observer) Destroy a cache.protected <V> com.google.protobuf.Emptyempty(V ignored) A helper method that always returnsEmpty.<T> Filter<T> ensureFilter(com.google.protobuf.ByteString bytes, Serializer serializer) Obtain aFilterfrom the serialized data in aByteString.ValueExtractor<?, ?> ensureValueExtractor(com.google.protobuf.ByteString bytes, Serializer serializer) Obtain aValueExtractorfrom the serialized data in aByteString.io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.cache.v0.MapListenerRequest> events(io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.cache.v0.MapListenerResponse> observer) Add aMapListenerto a cache and stream the events received to theStreamObserver.protected com.google.protobuf.EmptyExecute theRunnableand return anEmptyinstance.protected <T> TExecute theCallableand return the result.protected CompletionStage<AsyncNamedCache<Binary, Binary>> getAsyncCache(String scope, String cacheName) Obtain anAsyncNamedCache.<T> Filter<T> getFilter(com.google.protobuf.ByteString bytes, Serializer serializer) Obtain aFilterfrom the serialized data in aByteString.protected CompletionStage<com.google.protobuf.Empty> partitionedPutAll(CacheRequestHolder<com.oracle.coherence.grpc.messages.cache.v0.PutAllRequest, Void> holder, Map<Binary, Binary> map) Perform aputAlloperation on a partitioned cache.protected CompletionStage<com.google.protobuf.Empty> plainPutAll(AsyncNamedCache<Binary, Binary> cache, Map<Binary, Binary> map, long cMillis) Perform aputAlloperation on a partitioned cache.protected com.google.protobuf.EmptyremoveIndex(CacheRequestHolder<com.oracle.coherence.grpc.messages.cache.v0.RemoveIndexRequest, Void> holder) Execute theRemoveIndexRequestrequest.protected com.google.protobuf.BoolValuetoBoolValue(Binary binary, Serializer serializer) Deserialize aBinaryto a boolean value.Methods inherited from class com.oracle.coherence.grpc.proxy.common.BaseGrpcServiceImpl
createDefaultExecutor, getCache, getCCF, getDependencies, getExecutor, getMetrics, getPassThroughCache, getSerializer, getSerializer, getTransferThresholdMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.oracle.coherence.grpc.proxy.common.GrpcProxyService
getMetricsMethods inherited from interface com.oracle.coherence.grpc.proxy.common.v0.NamedCacheService
addIndex, aggregate, containsEntry, containsKey, containsValue, entrySet, get, getAll, invoke, invokeAll, isEmpty, isReady, keySet, nextEntrySetPage, nextKeySetPage, put, putAll, putIfAbsent, remove, removeIndex, removeMapping, replace, replaceMapping, size, truncate, values
-
Field Details
-
MBEAN_NAME
The name to use for the management MBean.- See Also:
-
INVALID_REQUEST_MESSAGE
- See Also:
-
MISSING_PROCESSOR_MESSAGE
- See Also:
-
MISSING_EXTRACTOR_MESSAGE
- See Also:
-
MISSING_AGGREGATOR_MESSAGE
- See Also:
-
-
Constructor Details
-
BaseNamedCacheServiceImpl
Create aBaseNamedCacheServiceImpl.- Parameters:
dependencies- theNamedCacheService.Dependenciesto use to configure the service
-
-
Method Details
-
addIndex
protected com.google.protobuf.Empty addIndex(CacheRequestHolder<com.oracle.coherence.grpc.messages.cache.v0.AddIndexRequest, Void> holder) Execute theAddIndexRequestrequest.- Parameters:
holder- theCacheRequestHoldercontaining theAddIndexRequestrequest- Returns:
BinaryHelper.EMPTY
-
aggregateWithFilter
protected CompletionStage<com.google.protobuf.BytesValue> aggregateWithFilter(com.oracle.coherence.grpc.messages.cache.v0.AggregateRequest request, Executor executor) Execute the filteredAggregateRequestrequest.- Parameters:
request- theAggregateRequest- Returns:
- a
CompletionStagethat completes with aCacheRequestHoldercontaining the serialized result of executing request
-
aggregateWithFilter
protected CompletionStage<com.google.protobuf.BytesValue> aggregateWithFilter(CacheRequestHolder<com.oracle.coherence.grpc.messages.cache.v0.AggregateRequest, Void> holder, Executor executor) Execute the filteredAggregateRequestrequest.- Parameters:
holder- theCacheRequestHoldercontaining theContainsEntryRequestrequest- Returns:
- a
CompletionStagethat completes with aCacheRequestHoldercontaining the serialized result of executing request
-
aggregateWithKeys
protected CompletionStage<com.google.protobuf.BytesValue> aggregateWithKeys(com.oracle.coherence.grpc.messages.cache.v0.AggregateRequest request, Executor executor) Execute the key-basedAggregateRequestrequest.- Parameters:
request- theAggregateRequest- Returns:
- a
CompletionStagethat completes with aCacheRequestHoldercontaining the serialized result of executing request
-
aggregateWithKeys
protected CompletionStage<com.google.protobuf.BytesValue> aggregateWithKeys(CacheRequestHolder<com.oracle.coherence.grpc.messages.cache.v0.AggregateRequest, Void> holder, Executor executor) Execute the filteredAggregateRequestrequest.- Parameters:
holder- theCacheRequestHoldercontaining theContainsEntryRequestrequest- Returns:
- a
CompletionStagethat completes with aCacheRequestHoldercontaining the serialized result of executing request
-
clear
public void clear(com.oracle.coherence.grpc.messages.cache.v0.ClearRequest request, io.grpc.stub.StreamObserver<com.google.protobuf.Empty> observer) Description copied from interface:NamedCacheServiceClear a cache.- Specified by:
clearin interfaceNamedCacheService- Parameters:
request- theClearRequestto executeobserver- theStreamObserverto receive the response- See Also:
-
destroy
public void destroy(com.oracle.coherence.grpc.messages.cache.v0.DestroyRequest request, io.grpc.stub.StreamObserver<com.google.protobuf.Empty> observer) Description copied from interface:NamedCacheServiceDestroy a cache.- Specified by:
destroyin interfaceNamedCacheService- Parameters:
request- theDestroyRequestcontaining the name of the cache to destroyobserver- theStreamObserverto receive the response
-
events
public io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.cache.v0.MapListenerRequest> events(io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.messages.cache.v0.MapListenerResponse> observer) Description copied from interface:NamedCacheServiceAdd aMapListenerto a cache and stream the events received to theStreamObserver.- Specified by:
eventsin interfaceNamedCacheService- Parameters:
observer- theStreamObserverto receive events- Returns:
- a
StreamObserverthat will be closed by the client to end event subscription
-
convertKeysToBinary
protected List<Binary> convertKeysToBinary(CacheRequestHolder<com.oracle.coherence.grpc.messages.cache.v0.GetAllRequest, Void> holder) Convert the keys for aGetAllRequestfrom the request's serialization format to the cache's serialization format.- Parameters:
holder- theCacheRequestHoldercontaining theGetAllRequestcontaining the keys to convert- Returns:
- A
CompletionStagethat completes with the converted keys
-
partitionedPutAll
protected CompletionStage<com.google.protobuf.Empty> partitionedPutAll(CacheRequestHolder<com.oracle.coherence.grpc.messages.cache.v0.PutAllRequest, Void> holder, Map<Binary, Binary> map) Perform aputAlloperation on a partitioned cache.This method will split the map of entries into a map per storage member and execute the putAll invocation for each member separately. This is more efficient than sending the map of entries to all members.
- Parameters:
holder- theCacheRequestHoldercontaining thePutAllRequestrequestmap- the map ofBinarykeys and values to put into the cache- Returns:
- a
CompletionStagethat completes when the putAll operation completes
-
plainPutAll
protected CompletionStage<com.google.protobuf.Empty> plainPutAll(AsyncNamedCache<Binary, Binary> cache, Map<Binary, Binary> map, long cMillis) Perform aputAlloperation on a partitioned cache.- Parameters:
cache- theAsyncNamedCacheto updatemap- the map ofBinarykeys and values to put into the cachecMillis- the expiry delay to set on the entries- Returns:
- a
CompletionStagethat completes when theputAlloperation completes
-
removeIndex
protected com.google.protobuf.Empty removeIndex(CacheRequestHolder<com.oracle.coherence.grpc.messages.cache.v0.RemoveIndexRequest, Void> holder) Execute theRemoveIndexRequestrequest.- Parameters:
holder- theCacheRequestHoldercontaining theRemoveIndexRequestrequest- Returns:
BinaryHelper.EMPTY
-
empty
protected <V> com.google.protobuf.Empty empty(V ignored) A helper method that always returnsEmpty.This method is to make
CompletionStagehandler code a little more elegant as it can use this method as a method reference.- Type Parameters:
V- the type of the value- Parameters:
ignored- the value- Returns:
- an
Emptyinstance.
-
execute
Execute theRunnableand return anEmptyinstance.- Parameters:
task- the runnable to execute- Returns:
- always returns an
Emptyinstance
-
execute
Execute theCallableand return the result.- Type Parameters:
T- the result type- Parameters:
task- the runnable to execute- Returns:
- the result of executing the
Callable
-
toBoolValue
Deserialize aBinaryto a boolean value.- Parameters:
binary- theBinaryto deserializeserializer- theSerializerto use- Returns:
- the deserialized boolean value
-
ensureValueExtractor
public ValueExtractor<?,?> ensureValueExtractor(com.google.protobuf.ByteString bytes, Serializer serializer) Obtain aValueExtractorfrom the serialized data in aByteString.- Parameters:
bytes- theByteStringcontaining the serializedValueExtractorserializer- the serializer to use- Returns:
- a deserialized
ValueExtractor - Throws:
io.grpc.StatusRuntimeException- if theByteStringis null or empty
-
ensureFilter
Obtain aFilterfrom the serialized data in aByteString.If the
ByteStringisnullorByteString.EMPTYthen anAlwaysFilteris returned.- Specified by:
ensureFilterin interfaceNamedCacheService- Type Parameters:
T- theFiltertype- Parameters:
bytes- theByteStringcontaining the serializedFilterserializer- the serializer to use- Returns:
- a deserialized
Filter
-
getFilter
Obtain aFilterfrom the serialized data in aByteString.- Specified by:
getFilterin interfaceNamedCacheService- Type Parameters:
T- theFiltertype- Parameters:
bytes- theByteStringcontaining the serializedFilterserializer- the serializer to use- Returns:
- a deserialized
Filterornullif no filter is set
-
deserializeComparator
public <T> Comparator<T> deserializeComparator(com.google.protobuf.ByteString bytes, Serializer serializer) Obtain aComparatorfrom the serialized data in aByteString.- Type Parameters:
T- theComparatortype- Parameters:
bytes- theByteStringcontaining the serializedComparatorserializer- the serializer to use- Returns:
- a deserialized
Comparatorornullif theByteStringisnullorByteString.EMPTY
-
getAsyncCache
protected CompletionStage<AsyncNamedCache<Binary,Binary>> getAsyncCache(String scope, String cacheName) Obtain anAsyncNamedCache.- Parameters:
scope- the scope name to use to obtain the CCF to get the cache fromcacheName- the name of the cache- Returns:
- the
AsyncNamedCachewith the specified name
-
castProcessor
protected InvocableMap.EntryProcessor<Binary,Binary, castProcessorBinary> (InvocableMap.EntryProcessor<Binary, Binary, ?> ep) - Parameters:
ep- theInvocableMap.EntryProcessorto cast- Returns:
- a
InvocableMap.EntryProcessorthat returns aBinaryresult
-
createHolderAsync
public <Req> CompletionStage<CacheRequestHolder<Req,Void>> createHolderAsync(Req request, String sScope, String sCacheName, String format) Asynchronously create aCacheRequestHolderfor a given request.- Type Parameters:
Req- the type of the request- Parameters:
request- the request object to add to the holdersScope- the scope name to use to identify the CCF to obtain the cache fromsCacheName- the name of the cache that the request executes againstformat- the optional serialization format used by requests that contain a payload- Returns:
- a
CompletionStagethat completes when theCacheRequestHolderhas been created
-
createRequestHolder
public <Req> CacheRequestHolder<Req,Void> createRequestHolder(Req request, String sScope, String sCacheName, String format) Create aCacheRequestHolderfor a given request.- Specified by:
createRequestHolderin interfaceNamedCacheService- Type Parameters:
Req- the type of the request- Parameters:
request- the request object to add to the holdersScope- the scope name to use to identify the CCF to obtain the cache fromsCacheName- the name of the cache that the request executes againstformat- the optional serialization format used by requests that contain a payload- Returns:
- the
CacheRequestHolderholding the request
-