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 class
NamedCacheDeactivationListener
that will communicate cache truncation and destruction events over the proxy.protected static class
A holder for filter information.protected static class
Converter for cache key instances.static class
MapListenerSupport.PrimingListener
that 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 ofFilters
that thisMapListenerProxy
was registered with.protected final ConcurrentMap
<Object, Integer> The map of keys that thisMapListenerProxy
was registered with.protected final SafeStreamObserver
<com.oracle.coherence.grpc.MapListenerResponse> TheStreamObserver
to streamMapEvent
instances to.protected final NamedCacheService
The owningNamedCacheService
.The set of keys that thisMapListenerProxy
was registered with.static final int
Constant to indicate that the listener is registered for "lite" events.protected boolean
protected CacheRequestHolder
<com.oracle.coherence.grpc.MapListenerRequest, Void> TheCacheRequestHolder
to hold theMapListenerRequest
that can convert between different serialization formats.protected MapListenerProxy.WrapperPrimingListener
Wrapper map event listener.static final int
Constant 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 aMapListenerProxy
to handle aMapListener
subscription to a cache. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addListener
(Filter<?> filter, long filterId, boolean lite, boolean priming) Add this MapListenerProxy as a filter-based listener of the given NamedCache.protected void
addListener
(Object key, boolean lite, boolean priming) Add this MapListenerProxy as a key-based listener of the given NamedCache.protected void
addListener
(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.MapEventResponse
createMapEventResponse
(MapEvent<?, ?> mapEvent) Factory method to create newMapEventResponse
instances using the information in the suppliedMapEvent
.protected MapListenerSupport.PrimingListener
<Object, Object> Return the priming listener, or it not already cached, create it.void
entryDeleted
(MapEvent<Object, Object> mapEvent) Invoked when a map entry has been removed.void
entryInserted
(MapEvent<Object, Object> mapEvent) Invoked when a map entry has been inserted.void
entryUpdated
(MapEvent<Object, Object> mapEvent) Invoked when a map entry has been updated.protected com.oracle.coherence.grpc.MapListenerErrorResponse
Create aMapListenerErrorResponse
.Return theMapListenerProxy.DeactivationListener
for this proxy.void
void
protected void
onFilterRequest
(com.oracle.coherence.grpc.MapListenerRequest request, MapTrigger<Binary, Binary> trigger) Invoked whenMapListenerRequest.RequestType
isKEY
.protected void
onKeyRequest
(com.oracle.coherence.grpc.MapListenerRequest request, MapTrigger<?, ?> trigger) Invoked whenMapListenerRequest.RequestType
isKEY
.protected void
onMapEvent
(MapEvent<?, ?> event) void
onNext
(com.oracle.coherence.grpc.MapListenerRequest request) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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
TheStreamObserver
to streamMapEvent
instances to. -
f_mapFilter
The map ofFilters
that thisMapListenerProxy
was registered with. -
f_mapKeys
The map of keys that thisMapListenerProxy
was registered with. -
f_setKeys
The set of keys that thisMapListenerProxy
was registered with. -
f_listenerDeactivation
The listener used to detect cache deactivation. -
m_holder
TheCacheRequestHolder
to hold theMapListenerRequest
that 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 aMapListenerProxy
to handle aMapListener
subscription to a cache.- Parameters:
service
- theNamedCacheService
to proxyobserver
- theStreamObserver
to streamMapEvent
instances to
-
-
Method Details
-
onNext
public void onNext(com.oracle.coherence.grpc.MapListenerRequest request) - Specified by:
onNext
in interfaceio.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>
-
onError
- Specified by:
onError
in interfaceio.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>
-
onCompleted
public void onCompleted()- Specified by:
onCompleted
in interfaceio.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>
-
entryInserted
Description copied from interface:MapListener
Invoked when a map entry has been inserted.- Specified by:
entryInserted
in interfaceMapListener<Object,
Object> - Parameters:
mapEvent
- the MapEvent carrying the insert information
-
entryUpdated
Description copied from interface:MapListener
Invoked when a map entry has been updated.- Specified by:
entryUpdated
in interfaceMapListener<Object,
Object> - Parameters:
mapEvent
- the MapEvent carrying the update information
-
entryDeleted
Description copied from interface:MapListener
Invoked when a map entry has been removed.- Specified by:
entryDeleted
in interfaceMapListener<Object,
Object> - Parameters:
mapEvent
- the MapEvent carrying the delete information
-
getDeactivationListener
Return theMapListenerProxy.DeactivationListener
for this proxy.- Returns:
- the
MapListenerProxy.DeactivationListener
for this proxy
-
onKeyRequest
protected void onKeyRequest(com.oracle.coherence.grpc.MapListenerRequest request, MapTrigger<?, ?> trigger) Invoked whenMapListenerRequest.RequestType
isKEY
.- Parameters:
request
- theMapListenerRequest
trigger
- theMapTrigger
-
onFilterRequest
protected void onFilterRequest(com.oracle.coherence.grpc.MapListenerRequest request, MapTrigger<Binary, Binary> trigger) Invoked whenMapListenerRequest.RequestType
isKEY
.- Parameters:
request
- theMapListenerRequest
trigger
- 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
-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
-true
to add a "lite" listenerpriming
-true
if the listener is a priming listenerregister
-true
if 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 aMapEvent
into aMapEventResponse
and send it to theStreamObserver
, converting theBinary
key and values if required.- Parameters:
event
- the event to send to the observer
-
createMapEventResponse
Factory method to create newMapEventResponse
instances using the information in the suppliedMapEvent
. -
error
Create aMapListenerErrorResponse
.- Parameters:
uid
- the UID of the requestt
- the error that occurred- Returns:
- a
MapListenerErrorResponse
.
-