public enum LiveTableMonitor extends Enum<LiveTableMonitor> implements LiveTableRegistrar, NotificationQueue
This class contains a thread which periodically updates a set of monitored LiveTables
at a specified target cycle time. The target cycle time can be configured
to reduce or increase the refresh rate of the monitored tables.
This class can be configured via the following Configuration
property
NotificationQueue.Dependency, NotificationQueue.IndexUpdateNotification, NotificationQueue.Notification<TYPE extends IntrusiveDoublyLinkedNode<TYPE>>
Modifier and Type | Method and Description |
---|---|
void |
addNotification(NotificationQueue.Notification notification)
Enqueue a notification to be flushed according to its priority.
|
void |
addTable(LiveTable table)
Add a table to the list of tables to refresh and mark it as
refreshing
if it was a DynamicNode . |
void |
checkInitiateTableOperation()
If we are establishing a new table operation, on a refreshing table without the LiveTableMonitor lock; then
we are likely committing a grievous error, but one that will only occasionally result in us getting the wrong
answer or if we are lucky an assertion.
|
void |
doUnchecked(Runnable runnable)
Execute the supplied code while table operations are unchecked.
|
<T> T |
doUnchecked(Supplier<T> supplier)
Execute the supplied code while table operations are unchecked.
|
AwareFunctionalLock |
exclusiveLock()
Get the exclusive lock for this
LiveTableMonitor . |
boolean |
maybeRefreshTable(LiveTable liveTable,
boolean onlyIfHaveLock)
Call
LiveTableMonitor.maybeRefreshTable(LiveTable) only if the calling thread already holds the lock. |
void |
removeTables(Collection<LiveTable> tablesToRemove)
Remove a collection of tables from the list of refreshing tables.
|
void |
requestRefresh(LiveTable table)
Request a refresh for a single table.
|
boolean |
setCheckTableOperations(boolean value)
If you know that the table operations you are performing are indeed safe, then call this method with false to
disable table operation checking.
|
AwareFunctionalLock |
sharedLock()
Get the shared lock for this
LiveTableMonitor . |
removeTable
public AwareFunctionalLock sharedLock()
Get the shared lock for this LiveTableMonitor
.
Using this lock will prevent refresh processing from proceeding concurrently, but will allow other read-only processing to proceed.
The shared lock implementation is expected to support reentrance.
This lock does not support Lock.newCondition()
. Use the exclusive
lock if you need to wait on events that are driven by refresh processing.
LiveTableMonitor
public AwareFunctionalLock exclusiveLock()
Get the exclusive lock for this LiveTableMonitor
.
Using this lock will prevent refresh or read-only processing from proceeding concurrently.
The exclusive lock implementation is expected to support reentrance.
Note that using the exclusive lock while the shared lock is held by the current thread will result in exceptions, as lock upgrade is not supported.
This lock does support Lock.newCondition()
.
LiveTableMonitor
public void checkInitiateTableOperation()
If we are establishing a new table operation, on a refreshing table without the LiveTableMonitor lock; then we are likely committing a grievous error, but one that will only occasionally result in us getting the wrong answer or if we are lucky an assertion. This method is called from various query operations that should not be established without the LTM lock.
The refresh thread pool threads are allowed to instantiate operations, even though that thread does not have the lock; because they are protected by the main refresh thread and dependency tracking.
If you are sure that you know what you are doing better than the query engine, you may call
LiveTableMonitor.setCheckTableOperations(boolean)
to set a thread local variable bypassing this check.
public boolean setCheckTableOperations(boolean value)
value
- the new value of check table operationspublic <T> T doUnchecked(Supplier<T> supplier)
supplier
- the function to runpublic void doUnchecked(Runnable runnable)
runnable
- the function to runpublic void addTable(@NotNull LiveTable table)
refreshing
if it was a DynamicNode
.addTable
in interface LiveTableRegistrar
table
- The table to be added to the refresh listunit test
mode other than mark the table as refreshing.public void removeTables(Collection<LiveTable> tablesToRemove)
tablesToRemove
- The tables to remove from the list of refreshing tablesnon-refreshing
.public void addNotification(NotificationQueue.Notification notification)
LiveTable.refresh()
or subsequent notification delivery.addNotification
in interface NotificationQueue
notification
- The notification to enqueueNotificationQueue.Notification.isTerminal()
,
LogicalClock.State
public boolean maybeRefreshTable(LiveTable liveTable, boolean onlyIfHaveLock)
LiveTableMonitor.maybeRefreshTable(LiveTable)
only if the calling thread already holds the lock.liveTable
- The LiveTable that we would like to refreshonlyIfHaveLock
- If true, check that the lock is held first and do nothing if it is notpublic void requestRefresh(@NotNull LiveTable table)
Request a refresh for a single table.
The update will occur on the LTM thread
table
- The table to refresh.