Class BaseUpdateGraph
java.lang.Object
io.deephaven.engine.updategraph.impl.BaseUpdateGraph
- All Implemented Interfaces:
LogOutputAppendable
,NotificationQueue
,NotificationQueue.Dependency
,UpdateGraph
,UpdateSourceRegistrar
- Direct Known Subclasses:
EventDrivenUpdateGraph
,PeriodicUpdateGraph
The BaseUpdateGraph contains common code for other UpdateGraph implementations and a map of named UpdateGraph
instances.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.deephaven.engine.updategraph.NotificationQueue
NotificationQueue.Dependency, NotificationQueue.ErrorNotification, NotificationQueue.Notification
-
Field Summary
-
Constructor Summary
ConstructorDescriptionBaseUpdateGraph
(String name, boolean allowUnitTestMode, Logger log, long minimumCycleDurationToLogNanos) The BaseUpdateGraph is an abstract class that is suitable for extension by UpdateGraphs that process a set of sources and then the resultingNotifications
using aBaseUpdateGraph.NotificationProcessor
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNotification
(@NotNull NotificationQueue.Notification notification) Enqueue a notification to be flushed according to its priority.void
addNotifications
(@NotNull Collection<? extends NotificationQueue.Notification> notifications) Enqueue a collection of notifications to be flushed.void
Add a table to the list of tables to run and mark it asrefreshing
if it was aDynamicNode
.static <T extends UpdateGraph>
TbuildOrThrow
(String name, Supplier<T> construct) Builds and caches a new UpdateGraph namedname
and provided byconstruct
.clock()
static @Nullable PerformanceEntry
createUpdatePerformanceEntry
(@Nullable UpdateGraph updateGraph, @Nullable String description) If the provided update graph is aBaseUpdateGraph
then create a PerformanceEntry using the given description.boolean
Test if this thread is part of our run thread executor service.Get the exclusive lock for thisUpdateGraph
.static <T extends UpdateGraph>
TexistingOrBuild
(String name, Supplier<T> construct) Returns an existing UpdateGraph with the providedname
if one exists, else returns a new named UpdateGraph supplied byconstruct
.static UpdateGraph
getInstance
(String name) getName()
boolean
isCycleOnBudget
(long cycleTimeNanos) Is the provided cycle time on budget?boolean
maybeAddNotification
(@NotNull NotificationQueue.Notification notification, long deliveryStep) Add a notification for this NotificationQueue to deliver (by invoking its run() method), iff the delivery step is the current step and the update cycle for that step is still in process.static boolean
removeInstance
(String name) Remove a named UpdateGraph.void
removeSource
(@NotNull Runnable updateSource) Remove a source from this registrar.void
removeSources
(Collection<Runnable> sourcesToRemove) Remove a collection of sources from the list of refreshing sources.void
In unit tests it can be convenient to force the update performance tracker to flush, without waiting for the complete REPORT_INTERVAL_MILLIS to elapse.boolean
satisfied
(long step) Is this ancestor satisfied? Note that this method must be safe to call on any thread.boolean
Test if engine code executing on the current thread should assume safety for serial table operations.boolean
setSerialTableOperationsSafe
(boolean newValue) User or engine code that makes its own determination about the safety of initiating serial table operations on the current thread may use this method to override default behavior.Get the shared lock for thisUpdateGraph
.int
Return the number of valid sources.boolean
void
takeAccumulatedCycleStats
(BaseUpdateGraph.AccumulatedCycleStats updateGraphAccumCycleStats) toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.deephaven.base.log.LogOutputAppendable
append
Methods inherited from interface io.deephaven.engine.updategraph.NotificationQueue.Dependency
getUpdateGraph
Methods inherited from interface io.deephaven.engine.updategraph.UpdateGraph
allowSerialTableOperations, allowSerialTableOperations, cast, checkInitiateSerialTableOperation, parallelismFactor, requestRefresh, requestSignal, stop
-
Field Details
-
DEFAULT_UPDATE_GRAPH_NAME
- See Also:
-
MINIMUM_CYCLE_DURATION_TO_LOG_MILLIS_PROP
- See Also:
-
DEFAULT_MINIMUM_CYCLE_DURATION_TO_LOG_NANOSECONDS
public static final long DEFAULT_MINIMUM_CYCLE_DURATION_TO_LOG_NANOSECONDS -
accumulatedCycleStats
-
-
Constructor Details
-
BaseUpdateGraph
public BaseUpdateGraph(String name, boolean allowUnitTestMode, Logger log, long minimumCycleDurationToLogNanos) The BaseUpdateGraph is an abstract class that is suitable for extension by UpdateGraphs that process a set of sources and then the resultingNotifications
using aBaseUpdateGraph.NotificationProcessor
.- Parameters:
name
- the name of the update graph, which must be uniqueallowUnitTestMode
- is unit test mode allowed, used for configuring the locklog
- the logger for this update graphminimumCycleDurationToLogNanos
- the minimum cycle time, in nanoseconds, that results in cycle times being logged to at an INFO level
-
-
Method Details
-
createUpdatePerformanceEntry
@Nullable public static @Nullable PerformanceEntry createUpdatePerformanceEntry(@Nullable @Nullable UpdateGraph updateGraph, @Nullable @Nullable String description) If the provided update graph is aBaseUpdateGraph
then create a PerformanceEntry using the given description. Otherwise, return null.- Parameters:
updateGraph
- The update graph to create a performance entry for.description
- The description for the performance entry.- Returns:
- The performance entry, or null if the update graph is not a
BaseUpdateGraph
.
-
getName
- Specified by:
getName
in interfaceUpdateGraph
- Returns:
- The name of this UpdateGraph
-
getUpdateGraph
- Specified by:
getUpdateGraph
in interfaceNotificationQueue.Dependency
- Returns:
- the update graph that this dependency is a part of
-
toString
-
clock
- Specified by:
clock
in interfaceUpdateGraph
- Returns:
- The
LogicalClock
to use with this update graph
-
exclusiveLock
Get the exclusive lock for this
UpdateGraph
.Using this lock will prevent run 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()
.- Specified by:
exclusiveLock
in interfaceUpdateGraph
- Returns:
- The exclusive lock for this
UpdateGraph
-
currentThreadProcessesUpdates
public boolean currentThreadProcessesUpdates()Test if this thread is part of our run thread executor service.- Specified by:
currentThreadProcessesUpdates
in interfaceUpdateGraph
- Returns:
- whether this is one of our run threads.
-
serialTableOperationsSafe
public boolean serialTableOperationsSafe()Description copied from interface:UpdateGraph
Test if engine code executing on the current thread should assume safety for serial table operations. Operations annotated as concurrent are always safe.- Specified by:
serialTableOperationsSafe
in interfaceUpdateGraph
- Returns:
- Whether code on this thread should assume serial table operation safety
- See Also:
-
setSerialTableOperationsSafe
public boolean setSerialTableOperationsSafe(boolean newValue) Description copied from interface:UpdateGraph
User or engine code that makes its own determination about the safety of initiating serial table operations on the current thread may use this method to override default behavior. The previous value should be restored immediately after use, typically with the following pattern:boolean oldValue = assumeSerialTableOperations(true); try { // ... safe table operations here } finally { assumeSerialTableOperations(oldValue); }
- Specified by:
setSerialTableOperationsSafe
in interfaceUpdateGraph
- Parameters:
newValue
- the new value- Returns:
- the old value
- See Also:
-
addSource
Add a table to the list of tables to run and mark it asrefreshing
if it was aDynamicNode
.- Specified by:
addSource
in interfaceUpdateSourceRegistrar
- Parameters:
updateSource
- The table to be added to the run list
-
removeSource
Description copied from interface:UpdateSourceRegistrar
Remove a source from this registrar.- Specified by:
removeSource
in interfaceUpdateSourceRegistrar
- Parameters:
updateSource
- The table to remove
-
removeSources
Remove a collection of sources from the list of refreshing sources.- Specified by:
removeSources
in interfaceUpdateSourceRegistrar
- Parameters:
sourcesToRemove
- The sources to remove from the list of refreshing sources- ImplNote:
- This will not set the sources as
non-refreshing
.
-
sourceCount
public int sourceCount()Return the number of valid sources.- Returns:
- the number of valid sources
-
addNotification
Enqueue a notification to be flushed according to its priority. Non-terminal notifications should only be enqueued during the updating phase of a cycle. That is, they should be enqueued from an update source or subsequent notification delivery.- Specified by:
addNotification
in interfaceNotificationQueue
- Parameters:
notification
- The notification to enqueue- See Also:
-
maybeAddNotification
public boolean maybeAddNotification(@NotNull @NotNull NotificationQueue.Notification notification, long deliveryStep) Description copied from interface:NotificationQueue
Add a notification for this NotificationQueue to deliver (by invoking its run() method), iff the delivery step is the current step and the update cycle for that step is still in process. This is only supported for non-terminal notifications.- Specified by:
maybeAddNotification
in interfaceNotificationQueue
- Parameters:
notification
- The notification to adddeliveryStep
- The step to deliver this notification on
-
satisfied
public boolean satisfied(long step) Description copied from interface:NotificationQueue.Dependency
Is this ancestor satisfied? Note that this method must be safe to call on any thread.- Specified by:
satisfied
in interfaceNotificationQueue.Dependency
- Parameters:
step
- The step for which we are testing satisfaction- Returns:
- Whether the dependency is satisfied on
step
(and will not fire subsequent notifications)
-
addNotifications
public void addNotifications(@NotNull @NotNull Collection<? extends NotificationQueue.Notification> notifications) Enqueue a collection of notifications to be flushed.- Specified by:
addNotifications
in interfaceNotificationQueue
- Parameters:
notifications
- The notification to enqueue- See Also:
-
supportsRefreshing
public boolean supportsRefreshing()- Specified by:
supportsRefreshing
in interfaceUpdateGraph
- Returns:
- Whether this UpdateGraph has a mechanism that supports refreshing
-
isCycleOnBudget
public boolean isCycleOnBudget(long cycleTimeNanos) Is the provided cycle time on budget?- Parameters:
cycleTimeNanos
- the cycle time, in nanoseconds- Returns:
- true if the cycle time is within the desired budget
-
resetNextFlushTime
In unit tests it can be convenient to force the update performance tracker to flush, without waiting for the complete REPORT_INTERVAL_MILLIS to elapse. -
logDependencies
- Specified by:
logDependencies
in interfaceUpdateGraph
- Returns:
- A LogEntry that may be prefixed with UpdateGraph information
-
takeAccumulatedCycleStats
public void takeAccumulatedCycleStats(BaseUpdateGraph.AccumulatedCycleStats updateGraphAccumCycleStats) -
getInstance
-
removeInstance
Remove a named UpdateGraph.In addition to removing the UpdateGraph from the instances, an attempt is made to
UpdateGraph.stop()
it.- Parameters:
name
- the name of the UpdateGraph to remove- Returns:
- true if the update graph was found
-
buildOrThrow
Builds and caches a new UpdateGraph namedname
and provided byconstruct
. It is an error if there is already an UpdateGraph with the same name.- Parameters:
name
- the name of the new update graphconstruct
- ASupplier
to construct an UpdateGraph if no update graph with the name already exists. The Supplier must provide an update graph with the given name.- Throws:
IllegalStateException
- if an UpdateGraph with the provided name already exists
-
existingOrBuild
Returns an existing UpdateGraph with the providedname
if one exists, else returns a new named UpdateGraph supplied byconstruct
.- Parameters:
construct
- ASupplier
to construct an UpdateGraph if no update graph with the name already exists. The Supplier must provide an update graph with the given name.- Returns:
- the UpdateGraph
-