Package ome.services.eventlogs
Class EventLogQueue
- java.lang.Object
-
- ome.services.eventlogs.EventLogLoader
-
- ome.services.eventlogs.PersistentEventLogLoader
-
- ome.services.eventlogs.EventLogQueue
-
- All Implemented Interfaces:
java.lang.Iterable<ome.model.meta.EventLog>
,java.util.EventListener
,java.util.Iterator<ome.model.meta.EventLog>
,org.springframework.context.ApplicationListener
public class EventLogQueue extends PersistentEventLogLoader
PersistentEventLogLoader
implementation which loads many rows at the same time, culling out duplicates in order to speed up indexing. Many of the methods used by eitherPersistentEventLogLoader
or its super-classes are not intended for use here. Instead, theIterator
interface is most critical. As with other implementations,hasNext()
is used for loading data if necessary, whilenext()
simply returns an object. In some cases, nulls may be returned, which consumers must contend with.- Since:
- 5.0.3
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX
Default maximum for the number of rows that will be loaded in a single call toSqlAction.getEventLogPartitions(java.util.Collection, java.util.Collection, long, long)
.-
Fields inherited from class ome.services.eventlogs.PersistentEventLogLoader
key, sql
-
Fields inherited from class ome.services.eventlogs.EventLogLoader
batchSize, DEFAULT_BATCH_SIZE, excludes, log, query, queryService
-
-
Constructor Summary
Constructors Constructor Description EventLogQueue()
EventLogQueue(ome.system.metrics.Metrics metrics, int max, java.lang.String[] types, java.lang.String[] actions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addEventLog(java.lang.Class<? extends ome.model.IObject> cls, long id)
Only schedule a new backlog event if there is no currently registered event of that type.boolean
hasNext()
Checks if either anyEventLogQueue.Entry
instances are available or tries to load them if not.void
initialize()
Do nothing.protected boolean
load(java.lang.Long eventLogId, java.lang.String type, java.lang.Long objId, java.lang.String action, java.lang.Integer skipped)
Guarantees that the given arguments are available somewhere in the queue returning true if they were newly added.protected int
load(java.util.List<java.lang.Object[]> rows)
protected java.util.List<java.lang.Object[]>
lookup()
long
more()
In general,EventLogQueue
will intend to use much larger batch sizes, and so further loops should likely not be attempted.ome.model.meta.EventLog
next()
Return a wrapped version ofEventLogQueue.Data.next()
which could possibly be null.void
onApplicationEvent(org.springframework.context.ApplicationEvent arg0)
protected ome.model.meta.EventLog
query()
-
Methods inherited from class ome.services.eventlogs.PersistentEventLogLoader
deleteCurrentId, getCurrentId, getKey, setCurrentId, setKey, setSqlAction, setTypes
-
Methods inherited from class ome.services.eventlogs.EventLogLoader
getBatchSize, isStopSet, iterator, lastEventLog, nextEventLog, remove, rollback, setBatchSize, setExcludes, setQueryService, setStop
-
-
-
-
Field Detail
-
DEFAULT_MAX
public static final int DEFAULT_MAX
Default maximum for the number of rows that will be loaded in a single call toSqlAction.getEventLogPartitions(java.util.Collection, java.util.Collection, long, long)
. Currently 1 million.- See Also:
- Constant Field Values
-
-
Method Detail
-
lookup
protected java.util.List<java.lang.Object[]> lookup()
-
load
protected int load(java.util.List<java.lang.Object[]> rows)
-
load
protected boolean load(java.lang.Long eventLogId, java.lang.String type, java.lang.Long objId, java.lang.String action, java.lang.Integer skipped)
Guarantees that the given arguments are available somewhere in the queue returning true if they were newly added.
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent arg0)
- Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener
- Overrides:
onApplicationEvent
in classEventLogLoader
-
hasNext
public boolean hasNext()
Checks if either anyEventLogQueue.Entry
instances are available or tries to load them if not. Conditions which will lead this to return false include: "stop" being set, the batch size being met, the current id in the database being equivalent to the newest event log.- Specified by:
hasNext
in interfacejava.util.Iterator<ome.model.meta.EventLog>
- Overrides:
hasNext
in classEventLogLoader
-
next
public ome.model.meta.EventLog next()
Return a wrapped version ofEventLogQueue.Data.next()
which could possibly be null.- Specified by:
next
in interfacejava.util.Iterator<ome.model.meta.EventLog>
- Overrides:
next
in classEventLogLoader
-
query
protected ome.model.meta.EventLog query()
- Overrides:
query
in classPersistentEventLogLoader
-
more
public long more()
In general,EventLogQueue
will intend to use much larger batch sizes, and so further loops should likely not be attempted.- Overrides:
more
in classPersistentEventLogLoader
-
initialize
public void initialize()
Do nothing.- Specified by:
initialize
in classPersistentEventLogLoader
-
addEventLog
public boolean addEventLog(java.lang.Class<? extends ome.model.IObject> cls, long id)
Only schedule a new backlog event if there is no currently registered event of that type.- Overrides:
addEventLog
in classEventLogLoader
-
-