Class AsyncNamedCacheClient<K,V>
- java.lang.Object
-
- com.oracle.coherence.client.BaseGrpcClient<V>
-
- com.oracle.coherence.client.AsyncNamedCacheClient<K,V>
-
- Type Parameters:
K- the type of the cache keysV- the type of the cache values
- All Implemented Interfaces:
com.tangosol.net.AsyncNamedCache<K,V>,com.tangosol.net.AsyncNamedMap<K,V>
public class AsyncNamedCacheClient<K,V> extends BaseGrpcClient<V> implements com.tangosol.net.AsyncNamedCache<K,V>
Implementation of aNamedCache.- Since:
- 20.06
- Author:
- Jonathan Knight 2019.11.22
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAsyncNamedCacheClient.DefaultDependenciesThe dependencies used to create anAsyncNamedCacheClient.static interfaceAsyncNamedCacheClient.DependenciesThe dependencies used to create anAsyncNamedCacheClient.protected classAsyncNamedCacheClient.EventStreamObserverAEventStreamObserverthat processesMapListenerResponses.protected classAsyncNamedCacheClient.InvokeAllBiFunction<Kf,Rf>ABiFunctionthat completes aCompletableFuture.protected static classAsyncNamedCacheClient.WrapperDeactivationListener<K,V>ADeactivationListenerthat wraps clientNamedCacheDeactivationListener.
-
Field Summary
Fields Modifier and Type Field Description protected List<com.tangosol.internal.net.NamedCacheDeactivationListener>f_listCacheDeactivationListenersThe list ofNamedCacheDeactivationListenerinstances added to this client.protected List<DeactivationListener<AsyncNamedCacheClient<? super K,? super V>>>f_listDeactivationListenersThe list ofDeactivationListenerto be notified when thisAsyncNamedCacheClientis released or destroyed.protected Lockf_lockDeactivationListenersprotected NamedCacheGrpcClientf_serviceTheNamedCacheGrpcClientto delegate calls.protected NamedCacheClient<K,V>f_synchronousCacheThe synchronous version of this client.protected com.tangosol.util.LongArray<com.tangosol.util.Filter<?>>m_aEvtFilterThe array of filter.protected AsyncNamedCacheClient.EventStreamObserverm_evtResponseObserverThe event response observer.protected com.tangosol.util.MapListenerSupportm_listenerSupportThe map listener support.protected static VoidVOIDA constant value to use forVoidvalues.-
Fields inherited from class com.oracle.coherence.client.BaseGrpcClient
f_dependencies, f_dispatcher, f_executor, f_serializer, f_sFormat, f_sName, f_sScopeName, m_fDestroyed, m_fReleased
-
-
Constructor Summary
Constructors Constructor Description AsyncNamedCacheClient(AsyncNamedCacheClient.Dependencies dependencies)Creates anAsyncNamedCacheClientfrom the specifiedAsyncNamedCacheClient.Dependencies.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDeactivationListener(DeactivationListener<AsyncNamedCacheClient<? super K,? super V>> listener)Add aDeactivationListenerthat will be notified when thisAsyncNamedCacheClientis released or destroyed.voidaddDeactivationListener(com.tangosol.internal.net.NamedCacheDeactivationListener listener)Add aNamedCacheDeactivationListenerthat will be notified when thisAsyncNamedCacheClientis released or destroyed.protected CompletableFuture<Void>addFilterMapListener(com.tangosol.util.MapListener<? super K,? super V> listener, com.tangosol.util.Filter<?> filter, boolean fLite)Add a map listener that receives events based on a filter evaluation.protected <T,E>
CompletableFuture<Void>addIndex(com.tangosol.util.ValueExtractor<? super T,? extends E> extractor, boolean fOrdered, Comparator<? super E> comparator)Asynchronous implementation ofQueryMap.addIndex(com.tangosol.util.ValueExtractor<? super T, ? extends E>, boolean, java.util.Comparator<? super E>).protected CompletableFuture<Void>addKeyMapListener(com.tangosol.util.MapListener<? super K,? super V> listener, Object key, boolean fLite)Add a map listener for a specific key.protected CompletableFuture<Void>addMapListener(com.tangosol.util.MapListener<? super K,? super V> mapListener)Add a standard map listener that will receive all events (inserts, updates, deletes) that occur against the map, with the key, old-value and new-value includedprotected CompletableFuture<Void>addMapListener(com.tangosol.util.MapListener<? super K,? super V> mapListener, com.tangosol.util.Filter<?> filter, boolean fLite)Add a map listener that receives events based on a filter evaluation.protected CompletableFuture<Void>addMapListener(com.tangosol.util.MapListener<? super K,? super V> mapListener, K key, boolean fLite)Add a map listener for a specific key.protected CompletableFuture<Void>addRemoteFilterListener(com.google.protobuf.ByteString filterBytes, long nFilterId, boolean fLite, com.google.protobuf.ByteString triggerBytes)Sends the serializedFilterfor registration with the cache server.<R> CompletableFuture<R>aggregate(com.tangosol.util.Filter<?> filter, com.tangosol.util.InvocableMap.EntryAggregator<? super K,? super V,R> entryAggregator)<R> CompletableFuture<R>aggregate(Collection<? extends K> colKeys, com.tangosol.util.InvocableMap.EntryAggregator<? super K,? super V,R> entryAggregator)protected voidassertActive()Assert that thisAsyncNamedCacheClientis active.CompletableFuture<Void>clear()protected booleancontainsEntry(K key, V value)Determine whether en entry exists in the cache with the specified key and value.CompletableFuture<Boolean>containsKey(K key)protected CompletableFuture<Boolean>containsKeyInternal(Object oKey)Helper method forcontainsKey(Object)invocations.protected CompletableFuture<Boolean>containsValue(Object oValue)Helper method for confirm presence of the value within the cache.protected <Ke,Ve>
com.tangosol.net.cache.CacheEvent<Ke,Ve>createDeactivationEvent(boolean destroyed)Helper method to create a newCacheEventto signal cache truncation or destruction.protected CompletableFuture<Void>destroy()Destroys the cache.protected voiddispatch(MapEventResponse response)Dispatch the receivedMapEventResponsefor processing by local listeners.CompletableFuture<Set<Map.Entry<K,V>>>entrySet()protected <T> CompletableFuture<T>executeIfActive(Supplier<CompletableFuture<T>> supplier)If thisAsyncNamedCacheClientis active then return theCompletableFuturesupplied by the supplier otherwise return a failedCompletableFuture.CompletableFuture<V>get(K key)CompletableFuture<Map<K,V>>getAll(Collection<? extends K> colKeys)protected Stream<Entry>getAllInternal(Collection<? extends K> colKeys)protected Map<K,V>getAllInternalAsMap(Collection<? extends K> colKeys)Helper method to obtain aMapof the keys/values found within the cache matching the providedCollectionof keys.protected StringgetCacheName()Returns the cache name.protected com.tangosol.net.CacheServicegetCacheService()Get theCacheServiceassociated with this cache.protected Stream<EntryResult>getEntriesPage(com.google.protobuf.ByteString cookie)Obtain a page of cache entries.protected GrpcCacheLifecycleEventDispatchergetEventDispatcher()Returns the event dispatcher for this cache.protected longgetFilterId(com.tangosol.util.Filter<?> filter)Obtain the registration ID for the provided filter.protected StringgetFormat()Return the serialization format.protected CompletableFuture<V>getInternal(Object key, V defaultValue)Helper method for getting a value from the cache.protected Stream<com.google.protobuf.BytesValue>getKeysPage(com.google.protobuf.BytesValue cookie)Obtain a page of cache keys.intgetListenerCount()Return the number of listeners registered with this map.protected com.tangosol.util.MapListenerSupportgetMapListenerSupport()Return theMapListenerSupport.com.tangosol.net.NamedCache<K,V>getNamedCache()NamedCacheClient<K,V>getNamedCacheClient()Return the synchronous cache client.com.tangosol.net.NamedMap<K,V>getNamedMap()CompletableFuture<V>getOrDefault(K key, V defaultValue)protected StringgetScopeName()Returns the scope name.protected static <T> ThandleException(T result, Throwable t)Returns the arguments unmodified unless the error is aStatusRuntimeExceptionwith a status ofStatus.UNIMPLEMENTED, then an UnsupportedOperationException will be raised instead.protected voidinitEvents()Called by the constructor to initialize event support.<R> CompletableFuture<R>invoke(K k, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> entryProcessor)<R> CompletableFuture<Map<K,R>>invokeAll(com.tangosol.util.Filter<?> filter, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor)<R> CompletableFuture<Void>invokeAll(com.tangosol.util.Filter<?> filter, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor, BiConsumer<? super K,? super R> callback)<R> CompletableFuture<Void>invokeAll(com.tangosol.util.Filter<?> filter, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor, Consumer<? super Map.Entry<? extends K,? extends R>> callback)<R> CompletableFuture<Map<K,R>>invokeAll(com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor)<R> CompletableFuture<Void>invokeAll(com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor, BiConsumer<? super K,? super R> callback)<R> CompletableFuture<Void>invokeAll(com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor, Consumer<? super Map.Entry<? extends K,? extends R>> callback)<R> CompletableFuture<Map<K,R>>invokeAll(Collection<? extends K> colKeys, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor)<R> CompletableFuture<Void>invokeAll(Collection<? extends K> colKeys, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor, BiConsumer<? super K,? super R> callback)<R> CompletableFuture<Void>invokeAll(Collection<? extends K> colKeys, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor, Consumer<? super Map.Entry<? extends K,? extends R>> callback)protected voidinvokeAllInternal(InvokeAllRequest request, io.grpc.stub.StreamObserver<Entry> observer)Helper method to perform invokeAll operations.protected voidinvokeAllInternal(InvokeAllRequest request, io.grpc.stub.StreamObserver<Entry> observer, long nDeadline)Helper method to perform invokeAll operations.protected CompletableFuture<Boolean>isActive()Returntrueif the cache is still active.CompletableFuture<Boolean>isEmpty()protected CompletableFuture<Boolean>isReady()Returns whether this cache is ready to be used.CompletableFuture<Set<K>>keySet()CompletableFuture<Void>put(K key, V value)CompletableFuture<Void>put(K key, V value, long ttl)CompletableFuture<Void>putAll(Map<? extends K,? extends V> map)CompletableFuture<Void>putAll(Map<? extends K,? extends V> map, long cMillis)protected CompletableFuture<com.google.protobuf.Empty>putAllInternal(Map<? extends K,? extends V> map, long cMillis)Helper method for storing the contents of the provided map within the cache.CompletableFuture<V>putIfAbsent(K key, V value)protected CompletableFuture<V>putInternal(K key, V value, long cTtl)Helper method for storing a key/value pair within the cache.protected longregisterFilter(com.tangosol.util.Filter<?> filter)Register theFilterlocally.CompletableFuture<Void>release()Releases the cache.protected CompletableFuture<Void>releaseInternal(boolean destroy)Release or destroy thisAsyncNamedCacheClient, notifying any registeredDeactivationListeners.CompletableFuture<V>remove(K key)CompletableFuture<Boolean>remove(K key, V value)protected voidremoveDeactivationListener(DeactivationListener<AsyncNamedCacheClient<? super K,? super V>> listener)Remove aDeactivationListener.protected <T,E>
CompletableFuture<Void>removeIndex(com.tangosol.util.ValueExtractor<? super T,? extends E> valueExtractor)protected CompletableFuture<V>removeInternal(Object key)Remove the mapping for the given key, returning the associated value.protected CompletableFuture<Boolean>removeInternal(Object key, Object value)Removes the entry for the specified key only if it is currently mapped to the specified value.protected CompletableFuture<Void>removeMapListener(com.tangosol.util.MapListener<? super K,? super V> mapListener)Removes the specifiedMapListener.protected CompletableFuture<Void>removeMapListener(com.tangosol.util.MapListener<? super K,? super V> listener, com.tangosol.util.Filter<?> filter)Removes theMapListenerassociated with the specifiedFilter.protected CompletableFuture<Void>removeMapListener(com.tangosol.util.MapListener<? super K,? super V> listener, K key)Removes theMapListenerassociated with the specified key.protected CompletableFuture<Void>removeRemoteFilterListener(com.google.protobuf.ByteString filterBytes, long nFilterId, com.google.protobuf.ByteString triggerBytes)Sends the serializedFilterfor un-registration with the cache server.CompletableFuture<V>replace(K key, V value)CompletableFuture<Boolean>replace(K key, V oldValue, V newValue)protected voidsetCacheService(GrpcRemoteCacheService cacheService)Set theCacheServiceassociated with this cache.CompletableFuture<Integer>size()protected Stream<com.tangosol.util.InvocableMap.Entry<K,V>>stream()Streamall entries within the cache.protected Stream<com.tangosol.util.InvocableMap.Entry<K,V>>stream(com.tangosol.util.Filter<V> filter)Streamwhich filters the cache entries.StringtoString()protected CompletableFuture<Void>truncate()Removes all mappings from this map.CompletableFuture<Collection<V>>values()CompletableFuture<Collection<V>>values(com.tangosol.util.Filter<?> filter, Comparator<? super V> comparator)protected CompletableFuture<Collection<V>>valuesInternal(com.tangosol.util.Filter<?> filter, Comparator comparator)Helper method to return the values of the cache.-
Methods inherited from class com.oracle.coherence.client.BaseGrpcClient
createDefaultExecutor, createSerializer, failedFuture, fromByteString, fromBytesValue, getDefaultSerializerFormat, isActiveInternal, isDestroyed, isReleased, toByteString, toBytesValue, valueFromBytesValue, valueFromOptionalValue
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.tangosol.net.AsyncNamedMap
aggregate, compute, computeIfAbsent, computeIfPresent, entrySet, entrySet, entrySet, entrySet, entrySet, entrySet, getAll, getAll, getAll, getAll, getAll, keySet, keySet, keySet, merge, removeAll, removeAll, replaceAll, replaceAll, replaceAll, values, values, values
-
-
-
-
Field Detail
-
f_service
protected final NamedCacheGrpcClient f_service
TheNamedCacheGrpcClientto delegate calls.
-
f_synchronousCache
protected final NamedCacheClient<K,V> f_synchronousCache
The synchronous version of this client.
-
f_listDeactivationListeners
protected final List<DeactivationListener<AsyncNamedCacheClient<? super K,? super V>>> f_listDeactivationListeners
The list ofDeactivationListenerto be notified when thisAsyncNamedCacheClientis released or destroyed.
-
f_listCacheDeactivationListeners
protected final List<com.tangosol.internal.net.NamedCacheDeactivationListener> f_listCacheDeactivationListeners
The list ofNamedCacheDeactivationListenerinstances added to this client.
-
f_lockDeactivationListeners
protected final Lock f_lockDeactivationListeners
-
m_evtResponseObserver
protected AsyncNamedCacheClient.EventStreamObserver m_evtResponseObserver
The event response observer.
-
m_listenerSupport
protected com.tangosol.util.MapListenerSupport m_listenerSupport
The map listener support.
-
m_aEvtFilter
protected com.tangosol.util.LongArray<com.tangosol.util.Filter<?>> m_aEvtFilter
The array of filter.
-
-
Constructor Detail
-
AsyncNamedCacheClient
public AsyncNamedCacheClient(AsyncNamedCacheClient.Dependencies dependencies)
Creates anAsyncNamedCacheClientfrom the specifiedAsyncNamedCacheClient.Dependencies.- Parameters:
dependencies- theAsyncNamedCacheClient.Dependenciesto configure thisAsyncNamedCacheClient.
-
-
Method Detail
-
aggregate
public <R> CompletableFuture<R> aggregate(Collection<? extends K> colKeys, com.tangosol.util.InvocableMap.EntryAggregator<? super K,? super V,R> entryAggregator)
-
aggregate
public <R> CompletableFuture<R> aggregate(com.tangosol.util.Filter<?> filter, com.tangosol.util.InvocableMap.EntryAggregator<? super K,? super V,R> entryAggregator)
-
invoke
public <R> CompletableFuture<R> invoke(K k, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> entryProcessor)
-
invokeAll
public <R> CompletableFuture<Map<K,R>> invokeAll(Collection<? extends K> colKeys, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor)
-
invokeAll
public <R> CompletableFuture<Map<K,R>> invokeAll(com.tangosol.util.Filter<?> filter, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor)
-
invokeAll
public <R> CompletableFuture<Void> invokeAll(Collection<? extends K> colKeys, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor, Consumer<? super Map.Entry<? extends K,? extends R>> callback)
-
invokeAll
public <R> CompletableFuture<Void> invokeAll(com.tangosol.util.Filter<?> filter, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor, Consumer<? super Map.Entry<? extends K,? extends R>> callback)
-
clear
public CompletableFuture<Void> clear()
-
containsKey
public CompletableFuture<Boolean> containsKey(K key)
-
entrySet
public CompletableFuture<Set<Map.Entry<K,V>>> entrySet()
-
get
public CompletableFuture<V> get(K key)
-
getAll
public CompletableFuture<Map<K,V>> getAll(Collection<? extends K> colKeys)
-
getOrDefault
public CompletableFuture<V> getOrDefault(K key, V defaultValue)
-
invokeAll
public <R> CompletableFuture<Map<K,R>> invokeAll(com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor)
-
invokeAll
public <R> CompletableFuture<Void> invokeAll(com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor, Consumer<? super Map.Entry<? extends K,? extends R>> callback)
-
invokeAll
public <R> CompletableFuture<Void> invokeAll(com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor, BiConsumer<? super K,? super R> callback)
-
invokeAll
public <R> CompletableFuture<Void> invokeAll(Collection<? extends K> colKeys, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor, BiConsumer<? super K,? super R> callback)
-
invokeAll
public <R> CompletableFuture<Void> invokeAll(com.tangosol.util.Filter<?> filter, com.tangosol.util.InvocableMap.EntryProcessor<K,V,R> processor, BiConsumer<? super K,? super R> callback)
-
isEmpty
public CompletableFuture<Boolean> isEmpty()
-
keySet
public CompletableFuture<Set<K>> keySet()
-
put
public CompletableFuture<Void> put(K key, V value)
-
put
public CompletableFuture<Void> put(K key, V value, long ttl)
-
putIfAbsent
public CompletableFuture<V> putIfAbsent(K key, V value)
-
putAll
public CompletableFuture<Void> putAll(Map<? extends K,? extends V> map)
-
putAll
public CompletableFuture<Void> putAll(Map<? extends K,? extends V> map, long cMillis)
-
remove
public CompletableFuture<V> remove(K key)
-
remove
public CompletableFuture<Boolean> remove(K key, V value)
-
replace
public CompletableFuture<V> replace(K key, V value)
-
replace
public CompletableFuture<Boolean> replace(K key, V oldValue, V newValue)
-
size
public CompletableFuture<Integer> size()
-
values
public CompletableFuture<Collection<V>> values()
-
values
public CompletableFuture<Collection<V>> values(com.tangosol.util.Filter<?> filter, Comparator<? super V> comparator)
-
getAllInternal
protected Stream<Entry> getAllInternal(Collection<? extends K> colKeys)
-
getAllInternalAsMap
protected Map<K,V> getAllInternalAsMap(Collection<? extends K> colKeys)
Helper method to obtain aMapof the keys/values found within the cache matching the providedCollectionof keys.- Parameters:
colKeys- the keys to look up- Returns:
- a
Mapcontaining keys/values for the keys found within the cache
-
getScopeName
protected String getScopeName()
Returns the scope name.- Returns:
- the scope name
-
getCacheName
protected String getCacheName()
Returns the cache name.- Returns:
- the cache name
-
getCacheService
protected com.tangosol.net.CacheService getCacheService()
Get theCacheServiceassociated with this cache.- Returns:
- the
CacheServiceassociated with this cache
-
setCacheService
protected void setCacheService(GrpcRemoteCacheService cacheService)
Set theCacheServiceassociated with this cache.- Parameters:
cacheService- theCacheServiceassociated with this cache
-
getInternal
protected CompletableFuture<V> getInternal(Object key, V defaultValue)
Helper method for getting a value from the cache.- Parameters:
key- the keydefaultValue- the value to return if this cache doesn't contain the provided key- Returns:
- the value within the Cache, or
defaultValue
-
getNamedCacheClient
public NamedCacheClient<K,V> getNamedCacheClient()
Return the synchronous cache client.- Returns:
- the synchronous cache client
-
invokeAllInternal
protected void invokeAllInternal(InvokeAllRequest request, io.grpc.stub.StreamObserver<Entry> observer)
Helper method to perform invokeAll operations.- Parameters:
request- theInvokeAllRequestobserver- theStreamObserver
-
invokeAllInternal
protected void invokeAllInternal(InvokeAllRequest request, io.grpc.stub.StreamObserver<Entry> observer, long nDeadline)
Helper method to perform invokeAll operations.- Parameters:
request- theInvokeAllRequestobserver- theStreamObserver
-
isActive
protected CompletableFuture<Boolean> isActive()
Returntrueif the cache is still active.- Returns:
trueif the cache is still active
-
isReady
protected CompletableFuture<Boolean> isReady()
Returns whether this cache is ready to be used. An example of when this method would returnfalsewould be where a partitioned cache service that owns this cache has no store-enabled members.- Returns:
trueif the cache is ready- Since:
- 14.1.1.2206.5
-
putInternal
protected CompletableFuture<V> putInternal(K key, V value, long cTtl)
Helper method for storing a key/value pair within the cache.- Parameters:
key- the keyvalue- the valuecTtl- the time-to-live (may not be supported)- Returns:
- a
CompletableFuturereturning the value previously associated with the specified key, if any
-
putAllInternal
protected CompletableFuture<com.google.protobuf.Empty> putAllInternal(Map<? extends K,? extends V> map, long cMillis)
Helper method for storing the contents of the provided map within the cache.- Parameters:
map- theMapof key/value pairs to store in the cache.cMillis- the expiry delay t apply to the entries- Returns:
- a
CompletableFuture
-
release
public CompletableFuture<Void> release()
Releases the cache.- Returns:
- a
CompletableFuturereturningVoid
-
removeIndex
protected <T,E> CompletableFuture<Void> removeIndex(com.tangosol.util.ValueExtractor<? super T,? extends E> valueExtractor)
-
removeInternal
protected CompletableFuture<V> removeInternal(Object key)
Remove the mapping for the given key, returning the associated value.- Parameters:
key- key whose mapping is to be removed from the map- Returns:
- the value associated with the given key, or
nullif no mapping existed
-
removeInternal
protected CompletableFuture<Boolean> removeInternal(Object key, Object value)
Removes the entry for the specified key only if it is currently mapped to the specified value.- Parameters:
key- key with which the specified value is associatedvalue- value expected to be associated with the specified key- Returns:
- a
CompletableFuturereturning abooleanindicating whether the mapping was removed
-
removeMapListener
protected CompletableFuture<Void> removeMapListener(com.tangosol.util.MapListener<? super K,? super V> mapListener)
Removes the specifiedMapListener.- Parameters:
mapListener- theMapListenerto remove- Returns:
- a
CompletableFuturereturningVoid
-
removeMapListener
protected CompletableFuture<Void> removeMapListener(com.tangosol.util.MapListener<? super K,? super V> listener, K key)
Removes theMapListenerassociated with the specified key.- Parameters:
listener- theMapListenerto removekey- the key the listener is associated with- Returns:
- a
CompletableFuturereturningVoid
-
removeMapListener
protected CompletableFuture<Void> removeMapListener(com.tangosol.util.MapListener<? super K,? super V> listener, com.tangosol.util.Filter<?> filter)
Removes theMapListenerassociated with the specifiedFilter.- Parameters:
listener- theMapListenerto removefilter- the filter the listener is associated with- Returns:
- a
CompletableFuturereturningVoid
-
removeRemoteFilterListener
protected CompletableFuture<Void> removeRemoteFilterListener(com.google.protobuf.ByteString filterBytes, long nFilterId, com.google.protobuf.ByteString triggerBytes)
Sends the serializedFilterfor un-registration with the cache server.- Parameters:
filterBytes- the serialized bytes of theFilternFilterId- the ID of theFiltertriggerBytes- the serialized bytes of theMapTriggerListener; passByteString.EMPTYif there is no trigger listener.- Returns:
CompletableFuturereturning typeVoid
-
stream
protected Stream<com.tangosol.util.InvocableMap.Entry<K,V>> stream()
Streamall entries within the cache.- Returns:
- a
Streamfor processing entries within the cache.
-
stream
protected Stream<com.tangosol.util.InvocableMap.Entry<K,V>> stream(com.tangosol.util.Filter<V> filter)
Streamwhich filters the cache entries.- Parameters:
filter- the filter to apply to theStream- Returns:
- a
Streamfor processing entries within the cache. - Throws:
UnsupportedOperationException- this method is unsupported
-
truncate
protected CompletableFuture<Void> truncate()
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, orinterceptors. However, aCacheLifecycleEventis raised to notify subscribers of the execution of this operation.- Returns:
- a
CompletableFuturereturningVoid
-
valuesInternal
protected CompletableFuture<Collection<V>> valuesInternal(com.tangosol.util.Filter<?> filter, Comparator comparator)
Helper method to return the values of the cache.- Parameters:
filter- theFilterto applycomparator- theComparatorfor ordering- Returns:
- a
Collectionof values based on the providedFilterandComparator
-
containsKeyInternal
protected CompletableFuture<Boolean> containsKeyInternal(Object oKey)
Helper method forcontainsKey(Object)invocations.- Parameters:
oKey- the key to check- Returns:
- a
CompletableFuturereturningtrueif the cache contains the given key
-
containsValue
protected CompletableFuture<Boolean> containsValue(Object oValue)
Helper method for confirm presence of the value within the cache.- Parameters:
oValue- the value to check- Returns:
- a
CompletableFuturereturningtrueif the cache contains the given value
-
destroy
protected CompletableFuture<Void> destroy()
Destroys the cache.- Returns:
- a
CompletableFuturereturningVoid
-
getMapListenerSupport
protected com.tangosol.util.MapListenerSupport getMapListenerSupport()
Return theMapListenerSupport.- Returns:
- the
MapListenerSupport
-
initEvents
protected void initEvents()
Called by the constructor to initialize event support.
-
getFormat
protected String getFormat()
Return the serialization format.- Returns:
- the serialization format
-
getKeysPage
protected Stream<com.google.protobuf.BytesValue> getKeysPage(com.google.protobuf.BytesValue cookie)
Obtain a page of cache keys.- Parameters:
cookie- an opaque cooke used to determine the current page- Returns:
- a page of cache keys
-
getEntriesPage
protected Stream<EntryResult> getEntriesPage(com.google.protobuf.ByteString cookie)
Obtain a page of cache entries.- Parameters:
cookie- an opaque cooke used to determine the current page- Returns:
- a page of cache entries
-
containsEntry
protected boolean containsEntry(K key, V value)
Determine whether en entry exists in the cache with the specified key and value.- Parameters:
key- the cache keyvalue- the cache value- Returns:
- a page of cache keys
-
assertActive
protected void assertActive()
Assert that thisAsyncNamedCacheClientis active.- Throws:
IllegalStateException- if thisAsyncNamedCacheClientis not active
-
executeIfActive
protected <T> CompletableFuture<T> executeIfActive(Supplier<CompletableFuture<T>> supplier)
If thisAsyncNamedCacheClientis active then return theCompletableFuturesupplied by the supplier otherwise return a failedCompletableFuture.
-
releaseInternal
protected CompletableFuture<Void> releaseInternal(boolean destroy)
Release or destroy thisAsyncNamedCacheClient, notifying any registeredDeactivationListeners.- Parameters:
destroy-trueto destroy the cache,falseto release the cache- Returns:
- a
CompletableFuturethat will be complete when the operation is completed.
-
createDeactivationEvent
protected <Ke,Ve> com.tangosol.net.cache.CacheEvent<Ke,Ve> createDeactivationEvent(boolean destroyed)
Helper method to create a newCacheEventto signal cache truncation or destruction.- Type Parameters:
Ke- theCacheEventkey typeVe- theCacheEventvalue type- Parameters:
destroyed-trueif this event should represent a cache being destroyed- Returns:
- a new
CacheEventto signal cache truncation or destruction
-
addDeactivationListener
public void addDeactivationListener(DeactivationListener<AsyncNamedCacheClient<? super K,? super V>> listener)
Add aDeactivationListenerthat will be notified when thisAsyncNamedCacheClientis released or destroyed.- Parameters:
listener- the listener to add
-
addDeactivationListener
public void addDeactivationListener(com.tangosol.internal.net.NamedCacheDeactivationListener listener)
Add aNamedCacheDeactivationListenerthat will be notified when thisAsyncNamedCacheClientis released or destroyed.- Parameters:
listener- the listener to add
-
removeDeactivationListener
protected void removeDeactivationListener(DeactivationListener<AsyncNamedCacheClient<? super K,? super V>> listener)
Remove aDeactivationListener.- Parameters:
listener- the listener to remove
-
addIndex
protected <T,E> CompletableFuture<Void> addIndex(com.tangosol.util.ValueExtractor<? super T,? extends E> extractor, boolean fOrdered, Comparator<? super E> comparator)
Asynchronous implementation ofQueryMap.addIndex(com.tangosol.util.ValueExtractor<? super T, ? extends E>, boolean, java.util.Comparator<? super E>).- Type Parameters:
T- the type of the value to extract fromE- the type of value that will be extracted- Parameters:
extractor- the ValueExtractor object that is used to extract an indexable Object from a value stored in the indexed Map. Must not benullfOrdered- true iff the contents of the indexed information should be ordered; false otherwisecomparator- the Comparator object which imposes an ordering on entries in the indexed map; or null if the entries' values natural ordering should be used- Returns:
CompletableFuturereturning typeVoid
-
addMapListener
protected CompletableFuture<Void> addMapListener(com.tangosol.util.MapListener<? super K,? super V> mapListener)
Add a standard map listener that will receive all events (inserts, updates, deletes) that occur against the map, with the key, old-value and new-value included- Parameters:
mapListener- theMapEventlistener to add- Returns:
CompletableFuturereturning typeVoid
-
addMapListener
protected CompletableFuture<Void> addMapListener(com.tangosol.util.MapListener<? super K,? super V> mapListener, K key, boolean fLite)
Add a map listener for a specific key.The listeners will receive MapEvent objects, but if fLite is passed as true, they might not contain the OldValue and NewValue properties.
- Parameters:
mapListener- theMapEventlistener to addkey- the key that identifies the entry for which to raise eventsfLite-trueto indicate that theMapEventobjects do not have to include the OldValue and NewValue property values in order to allow optimizations- Returns:
CompletableFuturereturning typeVoid
-
addMapListener
protected CompletableFuture<Void> addMapListener(com.tangosol.util.MapListener<? super K,? super V> mapListener, com.tangosol.util.Filter<?> filter, boolean fLite)
Add a map listener that receives events based on a filter evaluation.The listeners will receive MapEvent objects, but if fLite is passed as true, they might not contain the OldValue and NewValue properties.
- Parameters:
mapListener- theMapEventlistener to addfilter- a filter that will be passedMapEventobjects to select from; aMapEventwill be delivered to the listener only if the filter evaluates totruefor thatMapEvent(seeMapEventFilter);nullis equivalent to a filter that always returnstruefLite-trueto indicate that theMapEventobjects do not have to include the OldValue and NewValue property values in order to allow optimizations- Returns:
CompletableFuturereturning typeVoid
-
addKeyMapListener
protected CompletableFuture<Void> addKeyMapListener(com.tangosol.util.MapListener<? super K,? super V> listener, Object key, boolean fLite)
Add a map listener for a specific key.The listeners will receive MapEvent objects, but if
fLiteis passed astrue, they might not contain the OldValue and NewValue properties.- Parameters:
listener- theMapEventlistener to addkey- the key that identifies the entry for which to raise eventsfLite-trueto indicate that theMapEventobjects do not have to include the OldValue and NewValue property values in order to allow optimizations- Returns:
CompletableFuturereturning typeVoid
-
addFilterMapListener
protected CompletableFuture<Void> addFilterMapListener(com.tangosol.util.MapListener<? super K,? super V> listener, com.tangosol.util.Filter<?> filter, boolean fLite)
Add a map listener that receives events based on a filter evaluation.The listeners will receive MapEvent objects, but if
fLiteis passed astrue, they might not contain the OldValue and NewValue properties.- Parameters:
listener- theMapEventlistener to addfilter- a filter that will be passedMapEventobjects to select from; aMapEventwill be delivered to the listener only if the filter evaluates totruefor thatMapEvent(seeMapEventFilter);nullis equivalent to a filter that always returnstruefLite-trueto indicate that theMapEventobjects do not have to include the OldValue and NewValue property values in order to allow optimizations- Returns:
CompletableFuturereturning typeVoid
-
addRemoteFilterListener
protected CompletableFuture<Void> addRemoteFilterListener(com.google.protobuf.ByteString filterBytes, long nFilterId, boolean fLite, com.google.protobuf.ByteString triggerBytes)
Sends the serializedFilterfor registration with the cache server.- Parameters:
filterBytes- the serialized bytes of theFilternFilterId- the ID of theFilterfLite-trueto indicate that theMapEventobjects do not have to include the OldValue and NewValue property values in order to allow optimizationstriggerBytes- the serialized bytes of theMapTriggerListener; passByteString.EMPTYif there is no trigger listener.- Returns:
CompletableFuturereturning typeVoid
-
registerFilter
protected long registerFilter(com.tangosol.util.Filter<?> filter)
Register theFilterlocally.- Parameters:
filter- theFilter- Returns:
- the registration ID of the
Filter
-
getFilterId
protected long getFilterId(com.tangosol.util.Filter<?> filter)
Obtain the registration ID for the provided filter.- Parameters:
filter- the filter whose ID it is to look up- Returns:
- the registration ID or zero if the filter hasn't been registered
-
dispatch
protected void dispatch(MapEventResponse response)
Dispatch the receivedMapEventResponsefor processing by local listeners.This method is taken from code in the TDE RemoteNamedCache.
- Parameters:
response- theMapEventResponseto process
-
getListenerCount
public int getListenerCount()
Return the number of listeners registered with this map.- Returns:
- the number of listeners registered with this map
-
getEventDispatcher
protected GrpcCacheLifecycleEventDispatcher getEventDispatcher()
Returns the event dispatcher for this cache.- Returns:
- the event dispatcher for this cache
-
handleException
protected static <T> T handleException(T result, Throwable t)Returns the arguments unmodified unless the error is aStatusRuntimeExceptionwith a status ofStatus.UNIMPLEMENTED, then an UnsupportedOperationException will be raised instead.- Type Parameters:
T- the result type- Parameters:
result- the result - ignoredt- the error, if any- Returns:
- the result unmodified, or if the error is
Status.UNIMPLEMENTEDanUnsupportedOperationExceptionwill be thrown - Since:
- 14.1.1.2206.5
-
-