Interface VersionAwareMapListener<K,V>
- All Superinterfaces:
EventListener
,MapListener<K,
V>
MapListener
implementations simply need to suggest that they are
version aware
. Coherence will automatically
create an implementation of this interface and track partition versions for
relevant partitions and re-register to replay missed events. A more detailed
description of the semantics for implementors of this interface is described
below.
Implementations of this interface suggest that they are aware of event versions
(partition
invalid input: '&'
version
), such that this
implementation can be asked for all partition version that were last received
or is interested in receiving. Additionally, there is a convenient current version
method, which
is generally applicable when there is a single partition being tracked.
The primary reason to be version aware is to allow the receiver/client to track the last event it received. If the receiver ever becomes disconnected from the source of events, it allows the receiver to ask the source for all events that were missed. The source may replay:
- all the events from the last event received to the latest
- only the events that were retained, if some were purged
- an event representing the latest modification
- no events if the source does not support event history
- Network disruption - event receiver becomes disconnected from the source / the rest of the cluster
- Proxy (Extend/gRPC) disruption - a proxy the client was connected to dies and therefore reconnects to a different proxy
- Client death - client process dies but the same logical process restarts
For the 3rd case it requires a call to addMapListener
passing an implementation of this interface that returns the
relevant versions. Clearly for the 3rd case it requires the client to persist
the partition version information such that it can be recovered and replay
requested from the event source.
- Since:
- Coherence 21.06
- Author:
- hr 2021.01.29
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
A constant that suggests to an event source to send all known versions (subject to the event source's retention policy) and all future versions.static final long
A constant that suggests to an event source to send all future events.static final long
A constant that suggests to an event source to send the current version and all future versions.Fields inherited from interface com.tangosol.util.MapListener
ASYNCHRONOUS, SYNCHRONOUS, VERSION_AWARE
-
Method Summary
Modifier and TypeMethodDescriptiondefault long
A convenience method that returns a single version with the same rules as describedhere
.Return a data structure that holds a mapping ofpartition -> version
.Methods inherited from interface com.tangosol.util.MapListener
characteristics, entryDeleted, entryInserted, entryUpdated, isAsynchronous, isSynchronous, isVersionAware, synchronous
-
Field Details
-
HEAD
static final long HEADA constant that suggests to an event source to send all future events.- See Also:
-
PRIMING
static final long PRIMINGA constant that suggests to an event source to send the current version and all future versions.- See Also:
-
ALL
static final long ALLA constant that suggests to an event source to send all known versions (subject to the event source's retention policy) and all future versions.- See Also:
-
-
Method Details
-
getVersions
VersionedPartitions getVersions()Return a data structure that holds a mapping ofpartition -> version
. The absence of a partition suggests no interest in receiving events emanating from said partition.The version represents the last version that was read. If this listener is being registered (either for the first or nth time) this method will be called and passed to the source to allow any missed events to be replayed. Additionally, implementations can return any of the following formally defined constants (the behavior is performed in addition to the registration of this listener with the source):
HEAD
- send all future versionsPRIMING
- send current and all future versionsALL
- send all known versions
A listener is always registered under the context of a key or a filter. A key maps to a single partition while a filter generally maps to all partitions, therefore the registrations are either targeted to a single node or multiple nodes respectively.
When replaying events if the listener was registered under the context of a key (or many keys) the events that are replayed will only be for said key(s) and not other keys owned by the same partition. Conversely, when events are replayed for filter-based registrations events relating to all keys for the returned partitions are replayed. In both cases, only future events for the given partition versions are replayed.
- Returns:
- a data structure that holds a mapping of
partition -> version
representing the last received versions thus can be sent to the source to replay missing events
-
getCurrentVersion
default long getCurrentVersion()A convenience method that returns a single version with the same rules as describedhere
. Callers of this method can generally assume the partition(s) this version relates to. Often this is due to the listener being registered with a key.- Returns:
- the last version received
-