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 bi-directional 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 classMapListenerProxy.DeactivationListenerNamedCacheDeactivationListenerthat will communicate cache truncation and destruction events over the proxy.protected static classMapListenerProxy.FilterInfoA holder for filter information.protected static classMapListenerProxy.KeyConverterConverter for cache key instances.static classMapListenerProxy.WrapperPrimingListenerMapListenerSupport.PrimingListenerthat delegates calls to the wrappedMapListener.
-
Field Summary
Fields Modifier and Type Field Description protected MapListener<Object,Object>f_listenerDeactivationThe listener used to detect cache deactivation.protected ConcurrentMap<Filter<?>,MapListenerProxy.FilterInfo>f_mapFilterThe map ofFiltersthat thisMapListenerProxywas registered with.protected ConcurrentMap<Object,Integer>f_mapKeysThe map of keys that thisMapListenerProxywas registered with.protected io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerResponse>f_observerTheStreamObserverto streamMapEventinstances to.protected NamedCacheServicef_serviceThe owningNamedCacheService.protected Set<Object>f_setKeysThe set of keys that thisMapListenerProxywas registered with.static intLITEConstant to indicate that the listener is registered for "lite" events.protected booleanm_fCompletedprotected CacheRequestHolder<com.oracle.coherence.grpc.MapListenerRequest,Void>m_holderTheCacheRequestHolderto hold theMapListenerRequestthat can convert between different serialization formats.protected MapListenerProxy.WrapperPrimingListenerm_primingListenerWrapper map event listener.static intPRIMINGConstant 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 aMapListenerProxyto handle aMapListenersubscription to a cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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>ensurePrimingListener()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.MapListenerErrorResponseerror(String uid, Throwable t)Create aMapListenerErrorResponse.MapListener<Object,Object>getDeactivationListener()Return theMapListenerProxy.DeactivationListenerfor this proxy.voidonCompleted()voidonError(Throwable throwable)protected 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, 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 io.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerResponse> f_observer
TheStreamObserverto streamMapEventinstances to.
-
f_mapFilter
protected final ConcurrentMap<Filter<?>,MapListenerProxy.FilterInfo> f_mapFilter
The map ofFiltersthat thisMapListenerProxywas registered with.
-
f_mapKeys
protected final ConcurrentMap<Object,Integer> f_mapKeys
The map of keys that thisMapListenerProxywas registered with.
-
f_setKeys
protected final Set<Object> f_setKeys
The set of keys that thisMapListenerProxywas 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
TheCacheRequestHolderto hold theMapListenerRequestthat 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 aMapListenerProxyto handle aMapListenersubscription to a cache.- Parameters:
service- theNamedCacheServiceto proxyobserver- theStreamObserverto streamMapEventinstances to
-
-
Method Detail
-
onNext
public void onNext(com.oracle.coherence.grpc.MapListenerRequest request)
- Specified by:
onNextin interfaceio.grpc.stub.StreamObserver<com.oracle.coherence.grpc.MapListenerRequest>
-
onError
public void onError(Throwable throwable)
- 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
public void entryInserted(MapEvent<Object,Object> mapEvent)
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
public void entryUpdated(MapEvent<Object,Object> mapEvent)
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
public void entryDeleted(MapEvent<Object,Object> mapEvent)
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
public MapListener<Object,Object> 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
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-trueto add a "lite" listenerpriming-trueif 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-trueto add a "lite" listenerpriming-trueif the listener is a priming listenerregister-trueif 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 aMapEventinto aMapEventResponseand send it to theStreamObserver, converting theBinarykey 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 newMapEventResponseinstances using the information in the suppliedMapEvent.
-
-