Class NamedCacheServiceImpl

    • Method Detail

      • 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
      • 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
      • 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:
        Map.containsKey(Object)
      • 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:
        Map.containsKey(Object)
      • 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:
        Map.containsKey(Object)
      • 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

        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
      • 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
      • 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
      • 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:
        QueryMap.keySet(com.tangosol.util.Filter)
      • 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:
        Map.put(Object, Object)
      • 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
      • 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
      • 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:
        Map.putIfAbsent(Object, Object)
      • 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:
        Map.remove(Object)
      • 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:
        Map.remove(Object, Object)
      • 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:
        Map.replace(Object, Object)
      • 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:
        Map.replace(Object, Object, Object)
      • 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
      • 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

        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
      • 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
      • 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
      • 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