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 Classes Modifier and Type Class Description protected static class
MapListenerProxy.DeactivationListener
NamedCacheDeactivationListener
that will communicate cache truncation and destruction events over the proxy.protected static class
MapListenerProxy.FilterInfo
A holder for filter information.protected static class
MapListenerProxy.KeyConverter
Converter for cache key instances.static class
MapListenerProxy.WrapperPrimingListener
MapListenerSupport.PrimingListener
that delegates calls to the wrappedMapListener
.
-
Field Summary
Fields Modifier and Type Field Description protected MapListener<Object,Object>
f_listenerDeactivation
The listener used to detect cache deactivation.protected ConcurrentMap<Filter<?>,MapListenerProxy.FilterInfo>
f_mapFilter
The map ofFilters
that thisMapListenerProxy
was registered with.protected ConcurrentMap<Object,Integer>
f_mapKeys
The map of keys that thisMapListenerProxy
was registered with.protected SafeStreamObserver<com.oracle.coherence.grpc.MapListenerResponse>
f_observer
TheStreamObserver
to streamMapEvent
instances to.protected NamedCacheService
f_service
The owningNamedCacheService
.protected Set<Object>
f_setKeys
The set of keys that thisMapListenerProxy
was registered with.static int
LITE
Constant to indicate that the listener is registered for "lite" events.protected boolean
m_fCompleted
protected CacheRequestHolder<com.oracle.coherence.grpc.MapListenerRequest,Void>
m_holder
TheCacheRequestHolder
to hold theMapListenerRequest
that can convert between different serialization formats.protected MapListenerProxy.WrapperPrimingListener
m_primingListener
Wrapper map event listener.static int
PRIMING
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
Constructors Constructor Description MapListenerProxy(NamedCacheService service, io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerResponse> observer)
Create aMapListenerProxy
to handle aMapListener
subscription to a cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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>
ensurePrimingListener()
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
error(String uid, Throwable t)
Create aMapListenerErrorResponse
.MapListener<Object,Object>
getDeactivationListener()
Return theMapListenerProxy.DeactivationListener
for this proxy.void
onCompleted()
void
onError(Throwable throwable)
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 Detail
-
LITE
public static final int LITE
Constant to indicate that the listener is registered for "lite" events.- See Also:
- Constant Field Values
-
PRIMING
public static final int PRIMING
Constant to indicate that the listener is registered for "priming" events.- See Also:
- Constant Field Values
-
m_fCompleted
protected volatile boolean m_fCompleted
-
f_service
protected final NamedCacheService f_service
The owningNamedCacheService
.
-
f_observer
protected final SafeStreamObserver<com.oracle.coherence.grpc.MapListenerResponse> f_observer
TheStreamObserver
to streamMapEvent
instances to.
-
f_mapFilter
protected final ConcurrentMap<Filter<?>,MapListenerProxy.FilterInfo> f_mapFilter
The map ofFilters
that thisMapListenerProxy
was registered with.
-
f_mapKeys
protected final ConcurrentMap<Object,Integer> f_mapKeys
The map of keys that thisMapListenerProxy
was registered with.
-
f_setKeys
protected final Set<Object> f_setKeys
The set of keys that thisMapListenerProxy
was registered with.
-
f_listenerDeactivation
protected final MapListener<Object,Object> f_listenerDeactivation
The listener used to detect cache deactivation.
-
m_holder
protected CacheRequestHolder<com.oracle.coherence.grpc.MapListenerRequest,Void> m_holder
TheCacheRequestHolder
to hold theMapListenerRequest
that can convert between different serialization formats.
-
m_primingListener
protected volatile MapListenerProxy.WrapperPrimingListener m_primingListener
Wrapper map event listener. This listener registration should force a synthetic event containing the current value to the requesting client.
-
-
Constructor Detail
-
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 Detail
-
onNext
public void onNext(com.oracle.coherence.grpc.MapListenerRequest request)
- Specified by:
onNext
in interfaceio.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>
-
onError
public void onError(Throwable throwable)
- 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
public void entryInserted(MapEvent<Object,Object> mapEvent)
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
public void entryUpdated(MapEvent<Object,Object> mapEvent)
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
public void entryDeleted(MapEvent<Object,Object> mapEvent)
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
public MapListener<Object,Object> 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
protected void addListener(Filter<?> filter, long filterId, boolean lite, boolean priming)
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
protected void addListener(Object key, boolean lite, boolean priming)
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
protected void addListener(Object key, boolean lite, boolean priming, boolean register)
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
protected MapListenerSupport.PrimingListener<Object,Object> ensurePrimingListener()
Return the priming listener, or it not already cached, create it.- Returns:
- the priming listener
-
onMapEvent
protected void onMapEvent(MapEvent<?,?> event)
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
protected com.oracle.coherence.grpc.MapEventResponse createMapEventResponse(MapEvent<?,?> mapEvent)
Factory method to create newMapEventResponse
instances using the information in the suppliedMapEvent
.
-
-