Package com.oracle.coherence.grpc.proxy
Class MapListenerProxy
java.lang.Object
com.oracle.coherence.grpc.proxy.MapListenerProxy
- All Implemented Interfaces:
MapListener<Object,,Object> io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>,EventListener
public class MapListenerProxy
extends Object
implements io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>, MapListener<Object,Object>
A class to encapsulate bidirectional streaming of map events for a single cache.
- Since:
- 20.06
- Author:
- Jonathan Knight 2019.12.03
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classNamedCacheDeactivationListenerthat will communicate cache truncation and destruction events over the proxy.protected static classA holder for filter information.protected static classConverter for cache key instances.static classMapListenerSupport.PrimingListenerthat delegates calls to the wrappedMapListener. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final MapListener<Object, Object> The listener used to detect cache deactivation.protected final ConcurrentMap<Filter<?>, MapListenerProxy.FilterInfo> The map ofFiltersthat thisMapListenerProxywas registered with.protected final ConcurrentMap<Object, Integer> The map of keys that thisMapListenerProxywas registered with.protected final SafeStreamObserver<com.oracle.coherence.grpc.MapListenerResponse> TheStreamObserverto streamMapEventinstances to.protected final NamedCacheServiceThe owningNamedCacheService.The set of keys that thisMapListenerProxywas registered with.static final intConstant to indicate that the listener is registered for "lite" events.protected booleanprotected CacheRequestHolder<com.oracle.coherence.grpc.MapListenerRequest, Void> TheCacheRequestHolderto hold theMapListenerRequestthat can convert between different serialization formats.protected MapListenerProxy.WrapperPrimingListenerWrapper map event listener.static final intConstant to indicate that the listener is registered for "priming" events.Fields inherited from interface com.tangosol.util.MapListener
ASYNCHRONOUS, SYNCHRONOUS, VERSION_AWARE -
Constructor Summary
ConstructorsConstructorDescriptionMapListenerProxy(NamedCacheService service, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerResponse> observer) Create aMapListenerProxyto handle aMapListenersubscription to a cache. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddListener(Filter<?> filter, long filterId, boolean lite, boolean priming) Add this MapListenerProxy as a filter-based listener of the given NamedCache.protected voidaddListener(Object key, boolean lite, boolean priming) Add this MapListenerProxy as a key-based listener of the given NamedCache.protected voidaddListener(Object key, boolean lite, boolean priming, boolean register) Add this MapListenerProxy as a key-based listener of the given NamedCache.protected com.oracle.coherence.grpc.MapEventResponsecreateMapEventResponse(MapEvent<?, ?> mapEvent) Factory method to create newMapEventResponseinstances using the information in the suppliedMapEvent.protected MapListenerSupport.PrimingListener<Object, Object> Return the priming listener, or it not already cached, create it.voidentryDeleted(MapEvent<Object, Object> mapEvent) Invoked when a map entry has been removed.voidentryInserted(MapEvent<Object, Object> mapEvent) Invoked when a map entry has been inserted.voidentryUpdated(MapEvent<Object, Object> mapEvent) Invoked when a map entry has been updated.protected com.oracle.coherence.grpc.MapListenerErrorResponseCreate aMapListenerErrorResponse.Return theMapListenerProxy.DeactivationListenerfor this proxy.voidvoidprotected voidonFilterRequest(com.oracle.coherence.grpc.MapListenerRequest request, MapTrigger<Binary, Binary> trigger) Invoked whenMapListenerRequest.RequestTypeisKEY.protected voidonKeyRequest(com.oracle.coherence.grpc.MapListenerRequest request, MapTrigger<?, ?> trigger) Invoked whenMapListenerRequest.RequestTypeisKEY.protected voidonMapEvent(MapEvent<?, ?> event) voidonNext(com.oracle.coherence.grpc.MapListenerRequest request) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tangosol.util.MapListener
characteristics, isAsynchronous, isSynchronous, isVersionAware, synchronous
-
Field Details
-
LITE
public static final int LITEConstant to indicate that the listener is registered for "lite" events.- See Also:
-
PRIMING
public static final int PRIMINGConstant to indicate that the listener is registered for "priming" events.- See Also:
-
m_fCompleted
protected volatile boolean m_fCompleted -
f_service
The owningNamedCacheService. -
f_observer
TheStreamObserverto streamMapEventinstances to. -
f_mapFilter
The map ofFiltersthat thisMapListenerProxywas registered with. -
f_mapKeys
The map of keys that thisMapListenerProxywas registered with. -
f_setKeys
The set of keys that thisMapListenerProxywas registered with. -
f_listenerDeactivation
The listener used to detect cache deactivation. -
m_holder
TheCacheRequestHolderto hold theMapListenerRequestthat can convert between different serialization formats. -
m_primingListener
Wrapper map event listener. This listener registration should force a synthetic event containing the current value to the requesting client.
-
-
Constructor Details
-
MapListenerProxy
public MapListenerProxy(NamedCacheService service, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerResponse> observer) Create aMapListenerProxyto handle aMapListenersubscription to a cache.- Parameters:
service- theNamedCacheServiceto proxyobserver- theStreamObserverto streamMapEventinstances to
-
-
Method Details
-
onNext
public void onNext(com.oracle.coherence.grpc.MapListenerRequest request) - Specified by:
onNextin interfaceio.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>
-
onError
- Specified by:
onErrorin interfaceio.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>
-
onCompleted
public void onCompleted()- Specified by:
onCompletedin interfaceio.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>
-
entryInserted
Description copied from interface:MapListenerInvoked when a map entry has been inserted.- Specified by:
entryInsertedin interfaceMapListener<Object,Object> - Parameters:
mapEvent- the MapEvent carrying the insert information
-
entryUpdated
Description copied from interface:MapListenerInvoked when a map entry has been updated.- Specified by:
entryUpdatedin interfaceMapListener<Object,Object> - Parameters:
mapEvent- the MapEvent carrying the update information
-
entryDeleted
Description copied from interface:MapListenerInvoked when a map entry has been removed.- Specified by:
entryDeletedin interfaceMapListener<Object,Object> - Parameters:
mapEvent- the MapEvent carrying the delete information
-
getDeactivationListener
Return theMapListenerProxy.DeactivationListenerfor this proxy.- Returns:
- the
MapListenerProxy.DeactivationListenerfor this proxy
-
onKeyRequest
protected void onKeyRequest(com.oracle.coherence.grpc.MapListenerRequest request, MapTrigger<?, ?> trigger) Invoked whenMapListenerRequest.RequestTypeisKEY.- Parameters:
request- theMapListenerRequesttrigger- theMapTrigger
-
onFilterRequest
protected void onFilterRequest(com.oracle.coherence.grpc.MapListenerRequest request, MapTrigger<Binary, Binary> trigger) Invoked whenMapListenerRequest.RequestTypeisKEY.- Parameters:
request- theMapListenerRequesttrigger- theMapTrigger
-
addListener
Add this MapListenerProxy as a filter-based listener of the given NamedCache.- Parameters:
filter- the Filter to listen tofilterId- the unique positive identifier of the Filterlite- true to add a "lite" listenerpriming- true if the listener is a priming listener
-
addListener
Add this MapListenerProxy as a key-based listener of the given NamedCache.- Parameters:
key- the key to listen to deserialized in Object formlite-trueto add a "lite" listenerpriming-trueif the listener is a priming listener
-
addListener
Add this MapListenerProxy as a key-based listener of the given NamedCache.- Parameters:
key- the key to listen to deserialized in Object formlite-trueto add a "lite" listenerpriming-trueif the listener is a priming listenerregister-trueif the listener should be added to the underlying cache
-
ensurePrimingListener
Return the priming listener, or it not already cached, create it.- Returns:
- the priming listener
-
onMapEvent
Convert aMapEventinto aMapEventResponseand send it to theStreamObserver, converting theBinarykey and values if required.- Parameters:
event- the event to send to the observer
-
createMapEventResponse
Factory method to create newMapEventResponseinstances using the information in the suppliedMapEvent. -
error
Create aMapListenerErrorResponse.- Parameters:
uid- the UID of the requestt- the error that occurred- Returns:
- a
MapListenerErrorResponse.
-