Package ome.services.eventlogs
Class EventBacklog
- java.lang.Object
-
- ome.services.eventlogs.EventBacklog
-
public class EventBacklog extends java.lang.Object
Thread-safe java.util-like Container for storingEventLog
instances for later parsing. This container, however, will not add more than twologs
with the same (id, eventType, action) tuple. Further, the container can only either be in the adding state or the removing state. A newly createdEventBacklog
is in the adding state. The popping state is entered the first time thatremove()
is called. And the adding state will only be re-entered, onceremove()
has returned null andlogs
is empty. All calls toadd(EventLog)
while in the popping state will return false.- Since:
- 3.0-Beta3.1
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
adding
Switch between the adding and the removing states.
-
Constructor Summary
Constructors Constructor Description EventBacklog()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(ome.model.meta.EventLog log)
Adds the givenEventLog
instance to the end of a queue for laterpopping
if no equivalentEventLog
is present.void
flipState()
Flips theEventBacklog
to the "adding" state if it is empty, otherwise to the "removing" state.ome.model.meta.EventLog
remove()
Removes and returns the nextEventLog
instance or null if none is present.boolean
removingOnly()
Check the current state of theEventBacklog
.
-
-
-
Method Detail
-
add
public boolean add(ome.model.meta.EventLog log)
Adds the givenEventLog
instance to the end of a queue for laterpopping
if no equivalentEventLog
is present. Equivalence is based on the entityType, entityId, and action fields. Records tracking information to prevent the sameEventLog
from being re-added before the last instance is removed.
-
remove
public ome.model.meta.EventLog remove()
Removes and returns the nextEventLog
instance or null if none is present. Also cleans up any tracking information for the givenEventLog
.- Returns:
- See above.
-
flipState
public void flipState()
Flips theEventBacklog
to the "adding" state if it is empty, otherwise to the "removing" state. This is necessary since the indexing happens only at flush time in theFullTextIndexer
. This restriction means in any one batch only either backlog or new event logs will be processed.- See Also:
EventLogLoader.hasNext()
-
removingOnly
public boolean removingOnly()
Check the current state of theEventBacklog
. If in the "removingOnly" state, then any calls toadd(EventLog)
will return false.
-
-