Package com.atlassian.crowd.event
Class TimestampBasedEventStore
java.lang.Object
com.atlassian.crowd.event.TimestampBasedEventStore
- All Implemented Interfaces:
EventStore
A cluster-safe implementation of EventStore that uses the entity creation and update timestamp,
and the persisted tombstone information to create an event stream. The produced event streams may
be different than the ones produced by @link com.atlassian.crowd.event.EventStoreGeneric,
but should lead to creating the same state to the caller replaying the stream (i.e. doing an
incremental sync), assuming all operations are idempotent (i.e. adding an entity that's added
is not an error, but causes an update; deleting a missing entity is not an error).
Some caveats:
- to alleviate for timestamp skew and operations that are not committed when fetching the events,
the implementation produces a sync token that will cause events from a few minutes before the sync to be returned
again during the next sync. As long as events are idempotent this shouldn't change the state of the caller.
- some events make recreating the event stream impossible, and will throw EventTokenExpiredException as per contract
because of the replaying this will make incremental sync impossible for the duration of the backoff
- alias events are returned in a simplified form, that's different from EventStoreGeneric - as the only usage
is to abort incremental sync when an aliasing event occurs, they're all transformed into alias tombstones, and
returned a alias deletions
- to limit the size of the list materialized in memory, there's a limit to how many events the implementation will
return before throwing EventTokenExpiredException. The implementation MIGHT return larger lists if they are
already materialized and there's no point in throwing them away.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTimestampBasedEventStore(com.atlassian.crowd.embedded.spi.UserDao userDao, TombstoneDao tombstoneDao, com.atlassian.crowd.embedded.spi.GroupDao groupDao, InternalMembershipDao membershipDao, int eventCountLimit) TimestampBasedEventStore(com.atlassian.crowd.embedded.spi.UserDao userDao, com.atlassian.crowd.embedded.spi.GroupDao groupDao, InternalMembershipDao membershipDao, TombstoneDao tombstoneDao, Clock clock, int eventCountLimit) -
Method Summary
Modifier and TypeMethodDescriptiongetCurrentEventToken(List<Long> directoryIds) getNewEvents(String eventToken, Application application) getNewEvents(String eventToken, List<Long> directoryIds) voidhandleApplicationEvent(Object event) void
-
Field Details
-
TIMESTAMP_SLOP_TOLERANCE
public static final long TIMESTAMP_SLOP_TOLERANCE
-
-
Constructor Details
-
TimestampBasedEventStore
public TimestampBasedEventStore(com.atlassian.crowd.embedded.spi.UserDao userDao, TombstoneDao tombstoneDao, com.atlassian.crowd.embedded.spi.GroupDao groupDao, InternalMembershipDao membershipDao, int eventCountLimit) -
TimestampBasedEventStore
public TimestampBasedEventStore(com.atlassian.crowd.embedded.spi.UserDao userDao, com.atlassian.crowd.embedded.spi.GroupDao groupDao, InternalMembershipDao membershipDao, TombstoneDao tombstoneDao, Clock clock, int eventCountLimit)
-
-
Method Details
-
getCurrentEventToken
- Specified by:
getCurrentEventTokenin interfaceEventStore
-
getNewEvents
@Transactional public Events getNewEvents(String eventToken, List<Long> directoryIds) throws EventTokenExpiredException - Specified by:
getNewEventsin interfaceEventStore- Throws:
EventTokenExpiredException
-
getNewEvents
@Transactional public Events getNewEvents(String eventToken, Application application) throws EventTokenExpiredException - Specified by:
getNewEventsin interfaceEventStore- Throws:
EventTokenExpiredException
-
storeOperationEvent
- Specified by:
storeOperationEventin interfaceEventStore
-
handleApplicationEvent
- Specified by:
handleApplicationEventin interfaceEventStore
-