Class NamedCacheServiceImpl

java.lang.Object
com.oracle.coherence.grpc.proxy.BaseGrpcServiceImpl
com.oracle.coherence.grpc.proxy.NamedCacheServiceImpl
All Implemented Interfaces:
GrpcProxyService, NamedCacheService

public class NamedCacheServiceImpl extends BaseGrpcServiceImpl implements NamedCacheService
A gRPC NamedCache service.

This class uses AsyncNamedCache and asynchronous CompletionStage wherever possible. This makes the code more complex but the advantages of not blocking the gRPC request thread or the Coherence service thread will outweigh the downside of complexity.

The asynchronous processing of CompletionStages is done using an DaemonPoolExecutor so as not to consume or block threads in the Fork Join Pool. The DaemonPoolExecutor is configurable so that its thread counts can be controlled.

Since:
20.06
Author:
Jonathan Knight 2020.09.22
  • Field Details

  • Constructor Details

  • Method Details

    • newInstance

      public static NamedCacheServiceImpl newInstance(NamedCacheService.Dependencies deps)
      Create an instance of NamedCacheServiceImpl using the default dependencies configuration.
      Parameters:
      deps - the NamedCacheService.Dependencies to use to create the service
      Returns:
      an instance of NamedCacheServiceImpl
    • newInstance

      public static NamedCacheServiceImpl newInstance()
      Create an instance of NamedCacheServiceImpl using the default dependencies configuration.
      Returns:
      an instance of NamedCacheServiceImpl
    • addIndex

      public CompletionStage<com.google.protobuf.Empty> addIndex(com.oracle.coherence.grpc.AddIndexRequest request)
      Description copied from interface: NamedCacheService
      Add an index to a cache.
      Specified by:
      addIndex in interface NamedCacheService
      Parameters:
      request - the AddIndexRequest containing the name of the cache to add the index to, the serialized ValueExtractor to use to create the index and the optional serialized Comparator to sort the index
      Returns:
      a CompletionStage that will complete when the index is created
    • addIndex

      protected com.google.protobuf.Empty addIndex(CacheRequestHolder<com.oracle.coherence.grpc.AddIndexRequest,Void> holder)
      Execute the AddIndexRequest request.
      Parameters:
      holder - the CacheRequestHolder containing the AddIndexRequest request
      Returns:
      BinaryHelper.EMPTY
    • aggregate

      public CompletionStage<com.google.protobuf.BytesValue> aggregate(com.oracle.coherence.grpc.AggregateRequest request)
      Description copied from interface: NamedCacheService
      Execute an AggregateRequest against a cache and return the result serialized in a BytesValue.
      Specified by:
      aggregate in interface NamedCacheService
      Parameters:
      request - the AggregateRequest to execute
      Returns:
      the serialized aggregation result
    • aggregateWithFilter

      protected CompletionStage<com.google.protobuf.BytesValue> aggregateWithFilter(com.oracle.coherence.grpc.AggregateRequest request)
      Execute the filtered AggregateRequest request.
      Parameters:
      request - the AggregateRequest
      Returns:
      a CompletionStage that completes with a CacheRequestHolder containing the serialized result of executing request
    • aggregateWithFilter

      protected CompletionStage<com.google.protobuf.BytesValue> aggregateWithFilter(CacheRequestHolder<com.oracle.coherence.grpc.AggregateRequest,Void> holder)
      Execute the filtered AggregateRequest request.
      Parameters:
      holder - the CacheRequestHolder containing the ContainsEntryRequest request
      Returns:
      a CompletionStage that completes with a CacheRequestHolder containing the serialized result of executing request
    • aggregateWithKeys

      protected CompletionStage<com.google.protobuf.BytesValue> aggregateWithKeys(com.oracle.coherence.grpc.AggregateRequest request)
      Execute the key-based AggregateRequest request.
      Parameters:
      request - the AggregateRequest
      Returns:
      a CompletionStage that completes with a CacheRequestHolder containing the serialized result of executing request
    • aggregateWithKeys

      protected CompletionStage<com.google.protobuf.BytesValue> aggregateWithKeys(CacheRequestHolder<com.oracle.coherence.grpc.AggregateRequest,Void> holder)
      Execute the filtered AggregateRequest request.
      Parameters:
      holder - the CacheRequestHolder containing the ContainsEntryRequest request
      Returns:
      a CompletionStage that completes with a CacheRequestHolder containing the serialized result of executing request
    • clear

      public CompletionStage<com.google.protobuf.Empty> clear(com.oracle.coherence.grpc.ClearRequest request)
      Description copied from interface: NamedCacheService
      Clear a cache.
      Specified by:
      clear in interface NamedCacheService
      Parameters:
      request - the ClearRequest to execute
      Returns:
      a CompletionStage that will complete when the cache has been cleared.
      See Also:
    • containsEntry

      public CompletionStage<com.google.protobuf.BoolValue> containsEntry(com.oracle.coherence.grpc.ContainsEntryRequest request)
      Description copied from interface: NamedCacheService
      Returns true if this map contains a mapping for the specified key to the specified value.
      Specified by:
      containsEntry in interface NamedCacheService
      Parameters:
      request - the request which contains the key and value whose presence in this map is to be tested
      Returns:
      a CompletionStage that will complete with {code true} if this map contains a mapping for the specified key to the specified value
      See Also:
    • containsEntry

      protected CompletionStage<CacheRequestHolder<com.oracle.coherence.grpc.ContainsEntryRequest,Binary>> containsEntry(CacheRequestHolder<com.oracle.coherence.grpc.ContainsEntryRequest,Void> holder)
      Execute the ContainsEntryRequest request and return a CompletionStage that will complete when the AsyncNamedCache request completes and will contain a CacheRequestHolder holding the result of the contains entry request as a serialized Boolean.
      Parameters:
      holder - the CacheRequestHolder containing the ContainsEntryRequest request
      Returns:
      a CompletionStage that completes with a CacheRequestHolder containing the serialized Boolean result of executing the ContainsEntryRequest request
    • containsKey

      public CompletionStage<com.google.protobuf.BoolValue> containsKey(com.oracle.coherence.grpc.ContainsKeyRequest request)
      Description copied from interface: NamedCacheService
      Returns true if this map contains a mapping for the specified key.
      Specified by:
      containsKey in interface NamedCacheService
      Parameters:
      request - the request which contains the key whose presence in this map is to be tested
      Returns:
      a CompletionStage that will complete with {code true} if this map contains a mapping for the specified key
      See Also:
    • containsKey

      protected CompletionStage<CacheRequestHolder<com.oracle.coherence.grpc.ContainsKeyRequest,Boolean>> containsKey(CacheRequestHolder<com.oracle.coherence.grpc.ContainsKeyRequest,Void> holder)
      Execute the ContainsKeyRequest request and return a CompletionStage that will complete when the AsyncNamedCache request completes and will contain a CacheRequestHolder holding the result of the contains key request.
      Parameters:
      holder - the CacheRequestHolder containing the ContainsKeyRequest request
      Returns:
      a CompletionStage that completes with a CacheRequestHolder containing the Boolean result of executing the ContainsKeyRequest request
    • containsValue

      public CompletionStage<com.google.protobuf.BoolValue> containsValue(com.oracle.coherence.grpc.ContainsValueRequest request)
      Description copied from interface: NamedCacheService
      Returns true if this map contains a mapping for the specified value.
      Specified by:
      containsValue in interface NamedCacheService
      Parameters:
      request - the request which contains the value whose presence in this map is to be tested
      Returns:
      a CompletionStage that will complete with {code true} if this map contains a mapping for the specified value
      See Also:
    • containsValue

      protected CompletionStage<CacheRequestHolder<com.oracle.coherence.grpc.ContainsValueRequest,Integer>> containsValue(CacheRequestHolder<com.oracle.coherence.grpc.ContainsValueRequest,Void> holder)
      Execute the ContainsValueRequest request and return a CompletionStage that will complete when the AsyncNamedCache request completes and will contain a CacheRequestHolder holding the result of the contains value request as a serialized Boolean.
      Parameters:
      holder - the CacheRequestHolder containing the ContainsValueRequest request
      Returns:
      a CompletionStage that completes with a CacheRequestHolder containing the serialized Boolean result of executing the ContainsValueRequest request
    • destroy

      public CompletionStage<com.google.protobuf.Empty> destroy(com.oracle.coherence.grpc.DestroyRequest request)
      Description copied from interface: NamedCacheService
      Destroy a cache.
      Specified by:
      destroy in interface NamedCacheService
      Parameters:
      request - the DestroyRequest containing the name of the cache to destroy
      Returns:
      a CompletionStage that will complete when the cache is destroyed
    • entrySet

      public void entrySet(com.oracle.coherence.grpc.EntrySetRequest request, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer)
      Description copied from interface: NamedCacheService
      Stream a set of cache entries to a StreamObserver.
      Specified by:
      entrySet in interface NamedCacheService
      Parameters:
      request - the EntrySetRequest to execute
      observer - the StreamObserver to stream the entries to
      See Also:
    • entrySet

      protected Void entrySet(CacheRequestHolder<com.oracle.coherence.grpc.EntrySetRequest,Void> holder, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer)
      Execute the EntrySetRequest request and send the results to the StreamObserver.
      Parameters:
      holder - the CacheRequestHolder containing the EntrySetRequest request
      observer - the StreamObserver which will receive results
      Returns:
      always return Void
    • events

      public io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest> events(io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerResponse> observer)
      Description copied from interface: NamedCacheService
      Add a MapListener to a cache and stream the events received to the StreamObserver.
      Specified by:
      events in interface NamedCacheService
      Parameters:
      observer - the StreamObserver to receive events
      Returns:
      a StreamObserver that will be closed by the client to end event subscription
    • get

      public CompletionStage<com.oracle.coherence.grpc.OptionalValue> get(com.oracle.coherence.grpc.GetRequest request)
      Description copied from interface: NamedCacheService
      Get a value for a given key from a cache.
      Specified by:
      get in interface NamedCacheService
      Parameters:
      request - the GetRequest to execute
      Returns:
      a CompletionStage that will complete with the result of the Map.get(Object)
      See Also:
    • get

      protected CompletionStage<CacheRequestHolder<com.oracle.coherence.grpc.GetRequest,Binary>> get(CacheRequestHolder<com.oracle.coherence.grpc.GetRequest,Void> holder)
      Execute the GetRequest request and return a CompletionStage that will complete when the AsyncNamedCache request completes and will contain a CacheRequestHolder holding the result of the GetRequest request as a serialized Boolean.
      Parameters:
      holder - the CacheRequestHolder containing the GetRequest request
      Returns:
      a CompletionStage that completes with a CacheRequestHolder containing the serialized Binary result of executing the GetRequest request
    • getAll

      public void getAll(com.oracle.coherence.grpc.GetAllRequest request, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer)
      Description copied from interface: NamedCacheService
      Obtain a stream of mappings of keys to values for all of the specified keys.
      Specified by:
      getAll in interface NamedCacheService
      Parameters:
      request - the GetAllRequest request containing the cache name and collection of keys to obtain the mappings for
      observer - the StreamObserver to stream the results back to
    • getAll

      protected Void getAll(CacheRequestHolder<com.oracle.coherence.grpc.GetAllRequest,Void> holder, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer)
      Execute the GetAllRequest request and send the results to the StreamObserver.
      Parameters:
      holder - the CacheRequestHolder containing the GetAllRequest request
      observer - the StreamObserver which will receive results
      Returns:
      always return Void
    • convertKeys

      protected CompletionStage<List<Binary>> convertKeys(CacheRequestHolder<com.oracle.coherence.grpc.GetAllRequest,Void> holder)
      Convert the keys for a GetAllRequest from the request's serialization format to the cache's serialization format.
      Parameters:
      holder - the CacheRequestHolder containing the GetAllRequest containing the keys to convert
      Returns:
      A CompletionStage that completes with the converted keys
    • invoke

      public CompletionStage<com.google.protobuf.BytesValue> invoke(com.oracle.coherence.grpc.InvokeRequest request)
      Description copied from interface: NamedCacheService
      Invoke an InvocableMap.EntryProcessor against an entry in a cache.
      Specified by:
      invoke in interface NamedCacheService
      Parameters:
      request - the InvokeRequest containing the serialized key of the entry and the serialized InvocableMap.EntryProcessor
      Returns:
      the serialized result of the InvocableMap.EntryProcessor invocation
    • invoke

      protected CompletionStage<CacheRequestHolder<com.oracle.coherence.grpc.InvokeRequest,Binary>> invoke(CacheRequestHolder<com.oracle.coherence.grpc.InvokeRequest,Void> holder)
      Execute the InvokeRequest request and return a CompletionStage that will complete when the AsyncNamedCache request completes and will contain a CacheRequestHolder holding the result of the InvokeRequest request as a serialized Boolean.
      Parameters:
      holder - the CacheRequestHolder containing the InvokeRequest request
      Returns:
      a CompletionStage that completes with a CacheRequestHolder containing the serialized Binary result of executing the InvokeRequest request
    • invokeAll

      public void invokeAll(com.oracle.coherence.grpc.InvokeAllRequest request, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer)
      Description copied from interface: NamedCacheService
      Invoke an InvocableMap.EntryProcessor against multiple entries in a cache.
      Specified by:
      invokeAll in interface NamedCacheService
      Parameters:
      request - the InvokeRequest containing the serialized keys or serialized Filter to use to identify the entries and the serialized InvocableMap.EntryProcessor
      observer - the StreamObserver to observer the invocation results
    • invokeAllWithFilter

      protected CompletionStage<Void> invokeAllWithFilter(com.oracle.coherence.grpc.InvokeAllRequest request, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer)
      Execute the filtered InvokeAllRequest request passing the results to the provided StreamObserver.
      Parameters:
      request - the InvokeAllRequest
      observer - the StreamObserver which will receive the results
      Returns:
      always returns a CompletionStage returning Void
    • invokeAllWithFilter

      protected CompletionStage<Void> invokeAllWithFilter(CacheRequestHolder<com.oracle.coherence.grpc.InvokeAllRequest,Void> holder, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer)
      Execute the filtered InvokeAllRequest request passing the results to the provided StreamObserver.
      Parameters:
      holder - the CacheRequestHolder containing the InvokeAllRequest
      observer - the StreamObserver which will receive the results
      Returns:
      always returns a CompletionStage returning Void
    • invokeAllWithKeys

      protected CompletionStage<Void> invokeAllWithKeys(com.oracle.coherence.grpc.InvokeAllRequest request, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer)
      Execute the key-based InvokeAllRequest request passing the results to the provided StreamObserver.
      Parameters:
      request - the InvokeAllRequest
      observer - the StreamObserver which will receive the results
      Returns:
      always returns a CompletionStage returning Void
    • invokeAllWithKeys

      protected CompletionStage<Void> invokeAllWithKeys(CacheRequestHolder<com.oracle.coherence.grpc.InvokeAllRequest,Void> holder, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.Entry> observer)
      Execute the key-based InvokeAllRequest request passing the results to the provided StreamObserver.
      Parameters:
      holder - the CacheRequestHolder containing the InvokeAllRequest
      observer - the StreamObserver which will receive the results
      Returns:
      always returns a CompletionStage returning Void
    • isEmpty

      public CompletionStage<com.google.protobuf.BoolValue> isEmpty(com.oracle.coherence.grpc.IsEmptyRequest request)
      Description copied from interface: NamedCacheService
      Determine whether a cache is empty.
      Specified by:
      isEmpty in interface NamedCacheService
      Parameters:
      request - the IsEmptyRequest to execute
      Returns:
      a CompletionStage that will complete with the result of the Map.isEmpty()
      See Also:
    • isReady

      public CompletionStage<com.google.protobuf.BoolValue> isReady(com.oracle.coherence.grpc.IsReadyRequest request)
      Description copied from interface: NamedCacheService
      Determine whether a cache is Ready.
      Specified by:
      isReady in interface NamedCacheService
      Parameters:
      request - the IsReadyRequest to execute
      Returns:
      a CompletionStage that will complete with the result of the NamedMap.isReady()
      See Also:
    • keySet

      public void keySet(com.oracle.coherence.grpc.KeySetRequest request, io.grpc.stub.StreamObserver<com.google.protobuf.BytesValue> observer)
      Description copied from interface: NamedCacheService
      Stream a set of cache keys to a StreamObserver.
      Specified by:
      keySet in interface NamedCacheService
      Parameters:
      request - the KeySetRequest to execute
      observer - the StreamObserver to stream the keys to
      See Also:
    • keySet

      protected Void keySet(CacheRequestHolder<com.oracle.coherence.grpc.KeySetRequest,Void> holder, io.grpc.stub.StreamObserver<com.google.protobuf.BytesValue> observer)
      Execute the key-based KeySetRequest request passing the results to the provided StreamObserver.
      Parameters:
      holder - the CacheRequestHolder containing the KeySetRequest
      observer - the StreamObserver which will receive the results
      Returns:
      always returns Void
    • nextKeySetPage

      public void nextKeySetPage(com.oracle.coherence.grpc.PageRequest request, io.grpc.stub.StreamObserver<com.google.protobuf.BytesValue> observer)
      Description copied from interface: NamedCacheService
      Obtain the next page of a paged key set request.
      Specified by:
      nextKeySetPage in interface NamedCacheService
      Parameters:
      request - the PageRequest to execute
      observer - the StreamObserver that will receive the responses
    • nextEntrySetPage

      public void nextEntrySetPage(com.oracle.coherence.grpc.PageRequest request, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.EntryResult> observer)
      Description copied from interface: NamedCacheService
      Obtain the next page of a paged entry set request.
      Specified by:
      nextEntrySetPage in interface NamedCacheService
      Parameters:
      request - the PageRequest to execute
      observer - the StreamObserver that will receive the responses
    • put

      public CompletionStage<com.google.protobuf.BytesValue> put(com.oracle.coherence.grpc.PutRequest request)
      Description copied from interface: NamedCacheService
      Associate the specified value with the specified key in this cache. If the cache previously contained a mapping for the key, the old value is replaced by the specified value.
      Specified by:
      put in interface NamedCacheService
      Parameters:
      request - the PutRequest to execute
      Returns:
      a CompletionStage that will complete with the result of the Map.put(Object, Object)
      See Also:
    • put

      protected CompletionStage<com.google.protobuf.BytesValue> put(CacheRequestHolder<com.oracle.coherence.grpc.PutRequest,Void> holder)
      Execute a put request.
      Parameters:
      holder - the CacheRequestHolder containing the PutRequest request
      Returns:
      a CompletionStage that completes with a BytesValue containing the serialized result of executing the PutRequest request
    • putAll

      public CompletionStage<com.google.protobuf.Empty> putAll(com.oracle.coherence.grpc.PutAllRequest request)
      Description copied from interface: NamedCacheService
      Add the specified key value pair mappings to this cache. If the cache previously contained a mappings for the keys, the old value is replaced by the specified value.
      Specified by:
      putAll in interface NamedCacheService
      Parameters:
      request - the PutAllRequest to execute
      Returns:
      a CompletionStage that will complete with the result of the Map.putAll(java.util.Map)
      See Also:
    • putAll

      protected CompletionStage<com.google.protobuf.Empty> putAll(CacheRequestHolder<com.oracle.coherence.grpc.PutAllRequest,Void> holder)
      Execute a putAll request.
      Parameters:
      holder - the CacheRequestHolder containing the PutAllRequest request
      Returns:
      a CompletionStage that completes after executing the PutAllRequest request
    • partitionedPutAll

      protected CompletionStage<com.google.protobuf.Empty> partitionedPutAll(CacheRequestHolder<com.oracle.coherence.grpc.PutAllRequest,Void> holder, Map<Binary,Binary> map)
      Perform a putAll operation 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 - the CacheRequestHolder containing the PutAllRequest request
      map - the map of Binary keys and values to put into the cache
      Returns:
      a CompletionStage that 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 a putAll operation on a partitioned cache.
      Parameters:
      cache - the AsyncNamedCache to update
      map - the map of Binary keys and values to put into the cache
      cMillis - the expiry delay to set on the entries
      Returns:
      a CompletionStage that completes when the putAll operation completes
    • putIfAbsent

      public CompletionStage<com.google.protobuf.BytesValue> putIfAbsent(com.oracle.coherence.grpc.PutIfAbsentRequest request)
      Description copied from interface: NamedCacheService
      If the specified key is not already associated with a value (or is mapped to null) associate it with the given value and returns null, else return the current value.
      Specified by:
      putIfAbsent in interface NamedCacheService
      Parameters:
      request - the PutIfAbsentRequest to execute
      Returns:
      a CompletionStage that will complete with the previous value associated with the specified key, or null if there was no mapping for the key. A null return can also indicate that the map previously associated null with the key, if the implementation supports null values
      See Also:
    • putIfAbsent

      protected CompletableFuture<com.google.protobuf.BytesValue> putIfAbsent(CacheRequestHolder<com.oracle.coherence.grpc.PutIfAbsentRequest,Void> holder)
      Execute a PutIfAbsentRequest request.
      Parameters:
      holder - the CacheRequestHolder containing the PutIfAbsentRequest request
      Returns:
      a CompletionStage that completes with a BytesValue containing the serialized result of executing the PutIfAbsentRequest request
    • remove

      public CompletionStage<com.google.protobuf.BytesValue> remove(com.oracle.coherence.grpc.RemoveRequest request)
      Description copied from interface: NamedCacheService
      Remove the mapping that is associated with the specified key.
      Specified by:
      remove in interface NamedCacheService
      Parameters:
      request - the RemoveRequest to execute
      Returns:
      a CompletionStage that will complete with the previous value associated with specified key, or null if there was no mapping for key.
      See Also:
    • remove

      protected CompletableFuture<Binary> remove(CacheRequestHolder<com.oracle.coherence.grpc.RemoveRequest,Void> holder)
      Execute a RemoveRequest request.
      Parameters:
      holder - the CacheRequestHolder containing the RemoveRequest request
      Returns:
      a CompletionStage that completes with a Binary containing the serialized result of executing the RemoveRequest request
    • removeIndex

      public CompletionStage<com.google.protobuf.Empty> removeIndex(com.oracle.coherence.grpc.RemoveIndexRequest request)
      Description copied from interface: NamedCacheService
      Remove an index from a cache.
      Specified by:
      removeIndex in interface NamedCacheService
      Parameters:
      request - the RemoveIndexRequest containing the name of the cache to remove the index from, the serialized ValueExtractor that was used to create the index
      Returns:
      a CompletionStage that will complete when the index is removed
    • removeIndex

      protected com.google.protobuf.Empty removeIndex(CacheRequestHolder<com.oracle.coherence.grpc.RemoveIndexRequest,Void> holder)
      Execute the RemoveIndexRequest request.
      Parameters:
      holder - the CacheRequestHolder containing the RemoveIndexRequest request
      Returns:
      BinaryHelper.EMPTY
    • removeMapping

      public CompletionStage<com.google.protobuf.BoolValue> removeMapping(com.oracle.coherence.grpc.RemoveMappingRequest request)
      Description copied from interface: NamedCacheService
      Remove the mapping that is associated with the specified key only if the mapping exists in the cache.
      Specified by:
      removeMapping in interface NamedCacheService
      Parameters:
      request - the RemoveMappingRequest to execute
      Returns:
      a CompletionStage that will complete with true if the removal was successful, false otherwise
      See Also:
    • removeMapping

      protected CompletionStage<CacheRequestHolder<com.oracle.coherence.grpc.RemoveMappingRequest,Boolean>> removeMapping(CacheRequestHolder<com.oracle.coherence.grpc.RemoveMappingRequest,Void> holder)
      Execute the RemoveMappingRequest request and return a CompletionStage that will complete when the AsyncNamedCache request completes and will contain a CacheRequestHolder holding the result of the RemoveMappingRequest request as a serialized Boolean.
      Parameters:
      holder - the CacheRequestHolder containing the RemoveMappingRequest request
      Returns:
      a CompletionStage that completes with a CacheRequestHolder containing the serialized Binary result of executing the RemoveMappingRequest request
    • replace

      public CompletionStage<com.google.protobuf.BytesValue> replace(com.oracle.coherence.grpc.ReplaceRequest request)
      Description copied from interface: NamedCacheService
      Replace the entry for the specified key only if it is currently mapped to some value.
      Specified by:
      replace in interface NamedCacheService
      Parameters:
      request - the ReplaceRequest to execute
      Returns:
      a CompletionStage that will complete with the previous value associated with specified key, or null if there was no mapping for key.
      See Also:
    • replace

      protected CompletableFuture<Binary> replace(CacheRequestHolder<com.oracle.coherence.grpc.ReplaceRequest,Void> holder)
      Execute a ReplaceRequest request.
      Parameters:
      holder - the CacheRequestHolder containing the ReplaceRequest request
      Returns:
      a CompletionStage that completes with a Binary containing the serialized result of executing the ReplaceRequest request
    • replaceMapping

      public CompletionStage<com.google.protobuf.BoolValue> replaceMapping(com.oracle.coherence.grpc.ReplaceMappingRequest request)
      Description copied from interface: NamedCacheService
      Replace the mapping for the specified key only if currently mapped to the specified value.
      Specified by:
      replaceMapping in interface NamedCacheService
      Parameters:
      request - the ReplaceMappingRequest to execute
      Returns:
      a CompletionStage that will complete with the previous value associated with the specified key, or null if there was no mapping for the key. A null return can also indicate that the map previously associated null with the key, if the implementation supports null values
      See Also:
    • replaceMapping

      protected CompletableFuture<Binary> replaceMapping(CacheRequestHolder<com.oracle.coherence.grpc.ReplaceMappingRequest,Void> holder)
      Execute a ReplaceMappingRequest request.
      Parameters:
      holder - the CacheRequestHolder containing the ReplaceMappingRequest request
      Returns:
      a CompletionStage that completes with a Binary containing the serialized result of executing the ReplaceMappingRequest request
    • size

      public CompletionStage<com.google.protobuf.Int32Value> size(com.oracle.coherence.grpc.SizeRequest request)
      Description copied from interface: NamedCacheService
      Determine the number of entries in a cache.
      Specified by:
      size in interface NamedCacheService
      Parameters:
      request - the SizeRequest to execute
      Returns:
      a CompletionStage that will complete with the result of the Map.size()
      See Also:
    • truncate

      public CompletionStage<com.google.protobuf.Empty> truncate(com.oracle.coherence.grpc.TruncateRequest request)
      Description copied from interface: NamedCacheService
      Removes all mappings from this map.

      Note: the removal of entries caused by this truncate operation will not be observable. This includes any registered listeners, triggers, or interceptors. However, a CacheLifecycleEvent is raised to notify subscribers of the execution of this operation.

      Specified by:
      truncate in interface NamedCacheService
      Parameters:
      request - the TruncateRequest containing the name of the cache to truncate
      Returns:
      a CompletionStage that completes when the truncate operation has completed
    • values

      public void values(com.oracle.coherence.grpc.ValuesRequest request, io.grpc.stub.StreamObserver<com.google.protobuf.BytesValue> observer)
      Execute the ValuesRequest request passing the results to the provided StreamObserver.
      Specified by:
      values in interface NamedCacheService
      Parameters:
      request - the ValuesRequest
      observer - the StreamObserver which will receive the results
      See Also:
    • values

      protected Void values(CacheRequestHolder<com.oracle.coherence.grpc.ValuesRequest,Void> holder, io.grpc.stub.StreamObserver<com.google.protobuf.BytesValue> observer)
      Execute the ValuesRequest request passing the results to the provided StreamObserver.
      Parameters:
      holder - the CacheRequestHolder containing the ValuesRequest
      observer - the StreamObserver which will receive the results
      Returns:
      always returns Void
    • empty

      protected <V> com.google.protobuf.Empty empty(V value)
      A helper method that always returns Empty.

      This method is to make CompletionStage handler code a little more elegant as it can use this method as a method reference.

      Type Parameters:
      V - the type of the value
      Parameters:
      value - the value
      Returns:
      an Empty instance.
    • execute

      protected com.google.protobuf.Empty execute(Runnable task)
      Execute the Runnable and return an Empty instance.
      Parameters:
      task - the runnable to execute
      Returns:
      always returns an Empty instance
    • execute

      protected <T> T execute(Callable<T> task)
      Execute the Callable and return the result.
      Type Parameters:
      T - the result type
      Parameters:
      task - the runnable to execute
      Returns:
      the result of executing the Callable
    • toBoolValue

      protected com.google.protobuf.BoolValue toBoolValue(Binary binary, Serializer serializer)
      Deserialize a Binary to a boolean value.
      Parameters:
      binary - the Binary to deserialize
      serializer - the Serializer to use
      Returns:
      the deserialized boolean value
    • ensureValueExtractor

      public ValueExtractor<?,?> ensureValueExtractor(com.google.protobuf.ByteString bytes, Serializer serializer)
      Obtain a ValueExtractor from the serialized data in a ByteString.
      Parameters:
      bytes - the ByteString containing the serialized ValueExtractor
      serializer - the serializer to use
      Returns:
      a deserialized ValueExtractor
      Throws:
      io.grpc.StatusRuntimeException - if the ByteString is null or empty
    • ensureFilter

      public <T> Filter<T> ensureFilter(com.google.protobuf.ByteString bytes, Serializer serializer)
      Obtain a Filter from the serialized data in a ByteString.

      If the ByteString is null or ByteString.EMPTY then an AlwaysFilter is returned.

      Specified by:
      ensureFilter in interface NamedCacheService
      Type Parameters:
      T - the Filter type
      Parameters:
      bytes - the ByteString containing the serialized Filter
      serializer - the serializer to use
      Returns:
      a deserialized Filter
    • getFilter

      public <T> Filter<T> getFilter(com.google.protobuf.ByteString bytes, Serializer serializer)
      Obtain a Filter from the serialized data in a ByteString.
      Specified by:
      getFilter in interface NamedCacheService
      Type Parameters:
      T - the Filter type
      Parameters:
      bytes - the ByteString containing the serialized Filter
      serializer - the serializer to use
      Returns:
      a deserialized Filter or null if no filter is set
    • deserializeComparator

      public <T> Comparator<T> deserializeComparator(com.google.protobuf.ByteString bytes, Serializer serializer)
      Obtain a Comparator from the serialized data in a ByteString.
      Type Parameters:
      T - the Comparator type
      Parameters:
      bytes - the ByteString containing the serialized Comparator
      serializer - the serializer to use
      Returns:
      a deserialized Comparator or null if the ByteString is null or ByteString.EMPTY
    • getAsyncCache

      protected CompletionStage<AsyncNamedCache<Binary,Binary>> getAsyncCache(String scope, String cacheName)
      Obtain an AsyncNamedCache.
      Parameters:
      scope - the scope name to use to obtain the CCF to get the cache from
      cacheName - the name of the cache
      Returns:
      the AsyncNamedCache with the specified name
    • getPassThroughCache

      protected NamedCache<Binary,Binary> getPassThroughCache(String scope, String cacheName)
      Obtain an NamedCache.
      Parameters:
      scope - the scope name to use to obtain the CCF to get the cache from
      cacheName - the name of the cache
      Returns:
      the NamedCache with the specified name
    • getCCF

      protected ConfigurableCacheFactory getCCF(String sScope)
    • getCache

      protected NamedCache<Binary,Binary> getCache(String sScope, String sCacheName, boolean fPassThru)
      Obtain an NamedCache.
      Parameters:
      sScope - the scope name to use to obtain the CCF to get the cache from
      sCacheName - the name of the cache
      fPassThru - true to use a binary pass-thru cache
      Returns:
      the NamedCache with the specified name
    • castProcessor

      Parameters:
      ep - the InvocableMap.EntryProcessor to cast
      Returns:
      a InvocableMap.EntryProcessor that returns a Binary result
    • createHolderAsync

      public <Req> CompletionStage<CacheRequestHolder<Req,Void>> createHolderAsync(Req request, String sScope, String sCacheName, String format)
      Asynchronously create a CacheRequestHolder for a given request.
      Type Parameters:
      Req - the type of the request
      Parameters:
      request - the request object to add to the holder
      sScope - the scope name to use to identify the CCF to obtain the cache from
      sCacheName - the name of the cache that the request executes against
      format - the optional serialization format used by requests that contain a payload
      Returns:
      a CompletionStage that completes when the CacheRequestHolder has been created
    • createRequestHolder

      public <Req> CacheRequestHolder<Req,Void> createRequestHolder(Req request, String sScope, String sCacheName, String format)
      Create a CacheRequestHolder for a given request.
      Specified by:
      createRequestHolder in interface NamedCacheService
      Type Parameters:
      Req - the type of the request
      Parameters:
      request - the request object to add to the holder
      sScope - the scope name to use to identify the CCF to obtain the cache from
      sCacheName - the name of the cache that the request executes against
      format - the optional serialization format used by requests that contain a payload
      Returns:
      the CacheRequestHolder holding the request