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 ClassesNested classes/interfaces inherited from interface io.deephaven.engine.updategraph.NotificationQueue
NotificationQueue.Dependency, NotificationQueue.ErrorNotification, NotificationQueue.Notification -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBaseUpdateGraph(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 resultingNotificationsusing aBaseUpdateGraph.NotificationProcessor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNotification(@NotNull NotificationQueue.Notification notification) Enqueue a notification to be flushed according to its priority.voidaddNotifications(@NotNull Collection<? extends NotificationQueue.Notification> notifications) Enqueue a collection of notifications to be flushed.voidAdd a table to the list of tables to run and mark it asrefreshingif it was aDynamicNode.static <T extends UpdateGraph>
TbuildOrThrow(String name, Supplier<T> construct) Builds and caches a new UpdateGraph namednameand provided byconstruct.clock()static @Nullable PerformanceEntrycreateUpdatePerformanceEntry(@Nullable UpdateGraph updateGraph, @Nullable String description, @Nullable Supplier<long[]> ancestors) If the provided update graph is aBaseUpdateGraphthen create a PerformanceEntry using the given description.booleanTest 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 providednameif one exists, else returns a new named UpdateGraph supplied byconstruct.static UpdateGraphgetInstance(String name) getName()booleanisCycleOnBudget(long cycleTimeNanos) Is the provided cycle time on budget?static voidlogPerformanceEntryAncestors(@Nullable UpdateGraph updateGraph, @Nullable PerformanceEntry performanceEntry, @Nullable Supplier<long[]> ancestors) booleanmaybeAddNotification(@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 booleanremoveInstance(String name) Remove a named UpdateGraph.voidremoveSource(@NotNull Runnable updateSource) Remove a source from this registrar.voidremoveSources(Collection<Runnable> sourcesToRemove) Remove a collection of sources from the list of refreshing sources.voidIn unit tests it can be convenient to force the update performance tracker to flush, without waiting for the complete REPORT_INTERVAL_MILLIS to elapse.booleansatisfied(long step) Is this ancestor satisfied? Note that this method must be safe to call on any thread.booleanTest if engine code executing on the current thread should assume safety for serial table operations.booleansetSerialTableOperationsSafe(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.intReturn the number of valid sources.booleanvoidtakeAccumulatedCycleStats(BaseUpdateGraph.AccumulatedCycleStats updateGraphAccumCycleStats) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.deephaven.base.log.LogOutputAppendable
appendMethods inherited from interface io.deephaven.engine.updategraph.NotificationQueue.Dependency
getUpdateGraphMethods inherited from interface io.deephaven.engine.updategraph.UpdateGraph
allowSerialTableOperations, allowSerialTableOperations, cast, checkInitiateSerialTableOperation, parallelismFactor, requestRefresh, requestSignal, runWhenIdle, 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 resultingNotificationsusing 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, @Nullable @Nullable Supplier<long[]> ancestors) If the provided update graph is aBaseUpdateGraphthen 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.
-
logPerformanceEntryAncestors
public static void logPerformanceEntryAncestors(@Nullable @Nullable UpdateGraph updateGraph, @Nullable @Nullable PerformanceEntry performanceEntry, @Nullable @Nullable Supplier<long[]> ancestors) -
getName
- Specified by:
getNamein interfaceUpdateGraph- Returns:
- The name of this UpdateGraph
-
getUpdateGraph
- Specified by:
getUpdateGraphin interfaceNotificationQueue.Dependency- Returns:
- the update graph that this dependency is a part of
-
toString
-
clock
- Specified by:
clockin interfaceUpdateGraph- Returns:
- The
LogicalClockto 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:
exclusiveLockin 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:
currentThreadProcessesUpdatesin interfaceUpdateGraph- Returns:
- whether this is one of our run threads.
-
serialTableOperationsSafe
public boolean serialTableOperationsSafe()Description copied from interface:UpdateGraphTest if engine code executing on the current thread should assume safety for serial table operations. Operations annotated as concurrent are always safe.- Specified by:
serialTableOperationsSafein 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:UpdateGraphUser 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:
setSerialTableOperationsSafein 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 asrefreshingif it was aDynamicNode.- Specified by:
addSourcein interfaceUpdateSourceRegistrar- Parameters:
updateSource- The table to be added to the run list
-
removeSource
Description copied from interface:UpdateSourceRegistrarRemove a source from this registrar.- Specified by:
removeSourcein interfaceUpdateSourceRegistrar- Parameters:
updateSource- The table to remove
-
removeSources
Remove a collection of sources from the list of refreshing sources.- Specified by:
removeSourcesin 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:
addNotificationin interfaceNotificationQueue- Parameters:
notification- The notification to enqueue- See Also:
-
maybeAddNotification
public boolean maybeAddNotification(@NotNull @NotNull NotificationQueue.Notification notification, long deliveryStep) Description copied from interface:NotificationQueueAdd 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:
maybeAddNotificationin 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.DependencyIs this ancestor satisfied? Note that this method must be safe to call on any thread.- Specified by:
satisfiedin 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:
addNotificationsin interfaceNotificationQueue- Parameters:
notifications- The notification to enqueue- See Also:
-
supportsRefreshing
public boolean supportsRefreshing()- Specified by:
supportsRefreshingin 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:
logDependenciesin 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 namednameand 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- ASupplierto 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 providednameif one exists, else returns a new named UpdateGraph supplied byconstruct.- Parameters:
construct- ASupplierto 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
-