Package com.illumon.iris.db.v2.remote
Class PreemptiveUpdatesTable
java.lang.Object
com.illumon.util.referencecounting.ReferenceCounted
com.illumon.iris.db.util.liveness.LivenessArtifact
com.illumon.iris.db.v2.BaseTable
com.illumon.iris.db.v2.remote.WrappedDelegatingTable
com.illumon.iris.db.v2.remote.PreemptiveUpdatesTable
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable
,NotificationQueue.Dependency
,Deflatable<Table>
,Table
,LivenessManager
,LivenessNode
,LivenessReferent
,LongSizedDataStructure
,DynamicNode
,DynamicTable
,NotificationStepReceiver
,NotificationStepSource
,SubscribableTable
,SystemicObject
,Serializable
public class PreemptiveUpdatesTable extends WrappedDelegatingTable implements SubscribableTable
The server side representation of a preemptive updates table, which wraps an original table.
When a client subscribes initially, a snapshot of the table is sent. The snapshot is obtained using either get()
or getPrev() based on the state of the LogicalClock. On each subsequent update, the client is given the deltas
between the last update propagation and the next.
On the client side, this table will be represented by a
ReplicatedTable
.- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PreemptiveUpdatesTable.Operation
static class
PreemptiveUpdatesTable.SnapshotType
Nested classes/interfaces inherited from class com.illumon.iris.db.v2.remote.WrappedDelegatingTable
WrappedDelegatingTable.DoNotWrap
Nested classes/interfaces inherited from class com.illumon.iris.db.v2.BaseTable
BaseTable.CopyAttributeOperation, BaseTable.ListenerImpl, BaseTable.ShiftAwareListenerImpl, BaseTable.SwapListenerFactory<T extends SwapListenerBase>
Nested classes/interfaces inherited from interface com.illumon.iris.db.tables.Table
Table.AsOfMatchRule, Table.GroupStrategy, Table.RenameFunction
-
Field Summary
Fields inherited from class com.illumon.iris.db.v2.BaseTable
attributes, definition, description, PRINT_SERIALIZED_UPDATE_OVERLAPS, sharedAttributes
Fields inherited from interface com.illumon.iris.db.v2.NotificationStepReceiver
NULL_NOTIFICATION_STEP
Fields inherited from interface com.illumon.iris.db.tables.Table
ACL_ATTRIBUTE, ADD_ONLY_TABLE_ATTRIBUTE, COLUMN_DESCRIPTIONS_ATTRIBUTE, COLUMN_RENDERERS_ATTRIBUTE, CUSTOM_ACTIONS_ATTRIBUTE, DO_NOT_MAKE_REMOTE_ATTRIBUTE, EMPTY_SOURCE_TABLE_ATTRIBUTE, FILTERABLE_COLUMNS_ATTRIBUTE, HIERARCHICAL_CHILDREN_TABLE_MAP_ATTRIBUTE, HIERARCHICAL_SOURCE_INFO_ATTRIBUTE, HIERARCHICAL_SOURCE_TABLE_ATTRIBUTE, INPUT_TABLE_ATTRIBUTE, KEY_COLUMNS_ATTRIBUTE, LAYOUT_HINTS_ATTRIBUTE, MERGED_TABLE_ATTRIBUTE, NON_DISPLAY_TABLE, PLUGIN_NAME, PREDEFINED_ROLLUP_ATTRIBUTE, PREEMPTIVE_VIEWPORT_TYPE, PREPARED_RLL_ATTRIBUTE, PREVIEW_PARENT_TABLE, REVERSE_LOOKUP_ATTRIBUTE, ROLLUP_LEAF_ATTRIBUTE, SNAPSHOT_VIEWPORT_TYPE, SORTABLE_COLUMNS_ATTRIBUTE, SORTED_COLUMNS_ATTRIBUTE, SYSTEMIC_TABLE_ATTRIBUTE, TABLE_DESCRIPTION_ATTRIBUTE, TOTALS_TABLE_ATTRIBUTE, TREE_TABLE_FILTER_REVERSE_LOOKUP_ATTRIBUTE, UNIQUE_KEYS_ATTRIBUTE, UNTRACKED_LASTBY_TABLE_ATTRIBUTE, VIEWPORT_TYPE_ATTRIBUTE, ZERO_LENGTH_TABLE_ARRAY
-
Method Summary
Modifier and Type Method Description boolean
addSubscription(com.fishlib.net.api.CommandSender client, int handleId, BitSet columnsToSubscribe, boolean isViewport)
Add a subscription to this table.Table
applyPreview()
static void
copyPartialColumns(Index sourceIndex, Index destIndex, Object[] sourceDataColumns, Object[] destDataColumns)
protected void
destroy()
Attempt to release (destructively when necessary) resources held by this object.void
dropReference()
Drop a previously-retained reference to this referent.Index
getIndex()
WeakReference<? extends LivenessReferent>
getWeakReference()
Get aWeakReference
to this referent.void
initializeTransientFieldsForLiveness()
Package-private forSerializable
sub-classes to use inreadObject
only.boolean
isFlat()
Return true if this table is guaranteed to be flat.boolean
isSnapshot()
True if this table is a snapshot table (as opposed to a preemptive updates table); used byRemoteQueryProcessor
to set the isSnapshot flag onExportedTableCreationMessage
messages, so that a client knows if it has an appropriate type of table for its viewport.static void
logPremptiveUpdateTableStatistics(com.fishlib.io.logger.Logger log)
Log the count of created, destroyed, and subscribed PreemptiveUpdatesTables in this worker.void
markSystemic()
Mark this object as systemically important.protected void
onReferenceCountAtZero()
Callback method that will be invoked when the reference count returns to zero.Table
preemptiveSnapshotTable(long updateInterval)
Table
preemptiveUpdatesTable(long updateInterval)
boolean
removeSubscription(com.fishlib.net.api.CommandSender client, int subscriptionId)
Remove a subscription.HierarchicalTable
rollup(ComboAggregateFactory comboAggregateFactory, boolean includeConstituents, SelectColumn... columns)
void
setAttribute(String key, Object object)
Set the value of an attribute.void
setLastNotificationStep(long lastNotificationStep)
Deliver a last notification step to this receiver.long
size()
The size of this data structure.long
sizeForInstrumentation()
HierarchicalTable
treeTable(String idColumn, String parentColumn)
Create a hierarchical tree table.boolean
tryManage(LivenessReferent referent)
Attempt to add the specified referent to this manager.boolean
tryRetainReference()
If this referent is "live", behave asLivenessReferent.retainReference()
and return true.boolean
updateSubscription(com.fishlib.net.api.CommandSender client, int subscriptionId, BitSet newSubscribedColumns)
Update the subscription's columns.boolean
updateViewport(com.fishlib.net.api.CommandSender client, int subscriptionId, Index newViewPort)
Update the subscription's viewport (rows).boolean
updateViewportAndColumns(com.fishlib.net.api.CommandSender client, int subscriptionId, Index newViewPort, BitSet columnsToSubscribe)
Update the subscription's columns and viewport (rows).Methods inherited from class com.illumon.iris.db.v2.remote.WrappedDelegatingTable
absSumBy, aj, apply, applyToAllBy, avgBy, by, byExternal, countBy, dropColumns, exactJoin, firstBy, flatten, getColumn, getColumnSource, getColumnSourceMap, getColumnSources, getRecord, getSubTable, head, headBy, headPct, join, lastBy, lazyUpdate, leftJoin, maxBy, medianBy, minBy, naturalJoin, raj, renameColumns, reverse, select, selectDistinct, silent, slice, snapshot, snapshotHistory, snapshotIncremental, sort, stdBy, sumBy, tail, tailBy, tailPct, ungroup, update, updateBy, updateView, validateSelect, varBy, view, wavgBy, where, whereIn, wouldMatch, wsumBy
Methods inherited from class com.illumon.iris.db.v2.BaseTable
addParentReference, append, awaitUpdate, awaitUpdate, clearSortingRestrictions, copy, copyAttributes, copyAttributes, createSwapListenerIfRefreshing, getAttribute, getAttributeNames, getAttributes, getDefinition, getDescription, getLastNotificationStep, getNotificationQueue, hasAttribute, initializeWithSnapshot, isAddOnly, isAddOnly, isFailed, isRefreshing, isSystemicObject, layoutHints, listenForDirectUpdates, listenForUpdates, listenForUpdates, notifyListeners, notifyListenersOnError, removeDirectUpdateListener, removeUpdateListener, removeUpdateListener, restrictSortTo, satisfied, setColumnRenderers, setRefreshing, setTotalsTable, shouldCopyAttribute, toString, withColumnDescription, withKeys, withTableDescription, withUniqueKeys
Methods inherited from class com.illumon.iris.db.util.liveness.LivenessArtifact
manageWithCurrentScope, unmanage, unmanage
Methods inherited from class com.illumon.util.referencecounting.ReferenceCounted
decrementReferenceCount, incrementReferenceCount, resetReferenceCount, tryDecrementReferenceCount, tryIncrementReferenceCount
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.illumon.iris.db.v2.DynamicTable
listenForUpdates, newModifiedColumnSet, newModifiedColumnSetIdentityTransformer, newModifiedColumnSetIdentityTransformer, newModifiedColumnSetTransformer, newModifiedColumnSetTransformer, newModifiedColumnSetTransformer, notifyListeners
Methods inherited from interface com.illumon.iris.db.util.liveness.LivenessManager
manage, tryManage
Methods inherited from interface com.illumon.iris.db.util.liveness.LivenessReferent
dropReference, getReferentDescription, getWeakReference, retainReference, tryRetainReference
Methods inherited from interface com.illumon.iris.db.tables.Table
absSumBy, absSumBy, absSumBy, aj, aj, aj, aj, aj, applyToAllBy, applyToAllBy, applyToAllBy, avgBy, avgBy, avgBy, by, by, by, by, by, by, byExternal, byteColumnIterator, characterColumnIterator, close, coalesce, columnIterator, countBy, countBy, countBy, dateTimeColumnAsNanos, dateTimeColumnAsNanos, deflate, deflate, doubleColumnIterator, dropColumnFormats, dropColumns, exactJoin, exactJoin, exactJoin, exactJoin, firstBy, firstBy, firstBy, floatColumnIterator, formatColumns, formatColumnWhere, formatRowWhere, getAttributes, getColumn, getColumns, getColumnSource, getMeta, getViewPort, hasColumns, hasColumns, headBy, headBy, integerColumnIterator, isEmpty, isLive, join, join, join, join, join, join, join, join, join, lastBy, lastBy, lastBy, layoutHints, lazyUpdate, lazyUpdate, leftJoin, leftJoin, leftJoin, leftJoin, leftJoin, longColumnIterator, maxBy, maxBy, maxBy, medianBy, medianBy, medianBy, minBy, minBy, minBy, moveColumns, moveColumns, moveDownColumns, moveUpColumns, naturalJoin, naturalJoin, naturalJoin, naturalJoin, preemptiveSnapshotTable, raj, raj, raj, raj, raj, releaseCachedResources, renameAllColumns, renameColumns, renameColumns, rollup, rollup, rollup, rollup, rollup, rollup, rollup, select, select, select, selectDistinct, selectDistinct, selectDistinct, shortColumnIterator, snapshot, snapshotIncremental, sort, sort, sortDescending, sortDescending, stdBy, stdBy, stdBy, subscribeToPreemptiveUpdates, sumBy, sumBy, sumBy, supportsPreemptiveSubscription, tailBy, tailBy, ungroup, ungroup, ungroup, ungroupAllBut, update, update, updateBy, updateBy, updateBy, updateBy, updateBy, updateView, updateView, validateSelect, varBy, varBy, varBy, view, view, wavgBy, wavgBy, wavgBy, where, where, where, whereIn, whereIn, whereIn, whereNotIn, whereNotIn, whereOneOf, whereOneOf, whereOneOf, withColumnDescription, wouldMatch, wsumBy, wsumBy, wsumBy
-
Method Details
-
destroy
protected void destroy()Attempt to release (destructively when necessary) resources held by this object. This may render the object unusable for subsequent operations. Implementations should be sure to call super.destroy().
This is intended to only ever be used as a side effect of decreasing the reference count to 0.
-
logPremptiveUpdateTableStatistics
public static void logPremptiveUpdateTableStatistics(com.fishlib.io.logger.Logger log)Log the count of created, destroyed, and subscribed PreemptiveUpdatesTables in this worker. -
markSystemic
public void markSystemic()Description copied from interface:SystemicObject
Mark this object as systemically important.- Specified by:
markSystemic
in interfaceSystemicObject
- Overrides:
markSystemic
in classBaseTable
-
addSubscription
public boolean addSubscription(com.fishlib.net.api.CommandSender client, int handleId, BitSet columnsToSubscribe, boolean isViewport)Description copied from interface:SubscribableTable
Add a subscription to this table.- Specified by:
addSubscription
in interfaceSubscribableTable
- Parameters:
client
- the client requesting the subscription, used to uniquely identify he handleId and send deltas, snapshots and responseshandleId
- the ID of our subscriptioncolumnsToSubscribe
- the bitset of columns to subscribe toisViewport
- true if the subscription is a viewport, false if it is a full subscription- Returns:
- true if the subscription was added
-
updateSubscription
public boolean updateSubscription(com.fishlib.net.api.CommandSender client, int subscriptionId, BitSet newSubscribedColumns)Description copied from interface:SubscribableTable
Update the subscription's columns.- Specified by:
updateSubscription
in interfaceSubscribableTable
- Parameters:
client
- the client requesting the subscription, used to send deltas, snapshots and responsessubscriptionId
- the ID of our subscriptionnewSubscribedColumns
- the bitset of columns to subscribe to- Returns:
- true if the subscription was found and updated
-
updateViewport
public boolean updateViewport(com.fishlib.net.api.CommandSender client, int subscriptionId, Index newViewPort)Description copied from interface:SubscribableTable
Update the subscription's viewport (rows).- Specified by:
updateViewport
in interfaceSubscribableTable
- Parameters:
client
- the client requesting the subscription, used to send deltas, snapshots and responsessubscriptionId
- the ID of our subscriptionnewViewPort
- the index representing which rows to subscribe to (in position space)- Returns:
- true if the subscription was found and updated
-
updateViewportAndColumns
public boolean updateViewportAndColumns(com.fishlib.net.api.CommandSender client, int subscriptionId, Index newViewPort, BitSet columnsToSubscribe)Description copied from interface:SubscribableTable
Update the subscription's columns and viewport (rows).- Specified by:
updateViewportAndColumns
in interfaceSubscribableTable
- Parameters:
client
- the client requesting the subscription, used to send deltas, snapshots and responsessubscriptionId
- the ID of our subscriptionnewViewPort
- the index representing which rows to subscribe to (in position space)columnsToSubscribe
- the bitset of columns to subscribe to- Returns:
- true if the subscription was found and updated
-
removeSubscription
public boolean removeSubscription(com.fishlib.net.api.CommandSender client, int subscriptionId)Description copied from interface:SubscribableTable
Remove a subscription.- Specified by:
removeSubscription
in interfaceSubscribableTable
- Parameters:
client
- the client requesting the subscription, used to send responsessubscriptionId
- the ID of our subscription- Returns:
- true if the subscription was found and updated
-
copyPartialColumns
-
setLastNotificationStep
public void setLastNotificationStep(long lastNotificationStep)Description copied from interface:NotificationStepReceiver
Deliver a last notification step to this receiver.- Specified by:
setLastNotificationStep
in interfaceNotificationStepReceiver
- Overrides:
setLastNotificationStep
in classBaseTable
- Parameters:
lastNotificationStep
- The last notification step to be delivered
-
setAttribute
Description copied from interface:Table
Set the value of an attribute.- Specified by:
setAttribute
in interfaceTable
- Overrides:
setAttribute
in classBaseTable
- Parameters:
key
- the name of the attributeobject
- the value
-
getIndex
-
size
public long size()Description copied from interface:LongSizedDataStructure
The size of this data structure.- Specified by:
size
in interfaceLongSizedDataStructure
- Returns:
- The size
-
isFlat
public boolean isFlat()Description copied from interface:Table
Return true if this table is guaranteed to be flat. The index of a flat table will be from 0...numRows-1. -
isSnapshot
public boolean isSnapshot()Description copied from interface:SubscribableTable
True if this table is a snapshot table (as opposed to a preemptive updates table); used byRemoteQueryProcessor
to set the isSnapshot flag onExportedTableCreationMessage
messages, so that a client knows if it has an appropriate type of table for its viewport.- Specified by:
isSnapshot
in interfaceSubscribableTable
- Returns:
- true if this is a subscription snapshot table.
-
sizeForInstrumentation
public long sizeForInstrumentation()- Specified by:
sizeForInstrumentation
in interfaceTable
-
preemptiveSnapshotTable
- Specified by:
preemptiveSnapshotTable
in interfaceTable
- Overrides:
preemptiveSnapshotTable
in classWrappedDelegatingTable
-
rollup
public HierarchicalTable rollup(ComboAggregateFactory comboAggregateFactory, boolean includeConstituents, SelectColumn... columns)- Specified by:
rollup
in interfaceTable
- Overrides:
rollup
in classWrappedDelegatingTable
- ImplNote:
- The Preemptive version of this method will return a non-preemptive table
-
treeTable
Create a hierarchical tree table. The structure of the table is encoded by an "id" and a "parent" column. The id column should represent a unique identifier for a given row, and the parent column indicates which row is the parent for a given row. Rows that have a null parent, are shown in the main table. It is possible for rows to be "orphaned", if their parent reference is non-null and does not exist in the table.- Specified by:
treeTable
in interfaceTable
- Overrides:
treeTable
in classWrappedDelegatingTable
- Parameters:
idColumn
- the name of a column containing a unique identifier for a particular row in the tableparentColumn
- the name of a column containing the parent's identifier, null for elements that are part of the root table- Returns:
- a hierarchical table grouped according to the parentColumn
- ImplNote:
- The Preemptive version of this method will return a non-preemptive table
-
preemptiveUpdatesTable
- Specified by:
preemptiveUpdatesTable
in interfaceTable
- Overrides:
preemptiveUpdatesTable
in classWrappedDelegatingTable
-
applyPreview
-
initializeTransientFieldsForLiveness
Package-private forSerializable
sub-classes to use inreadObject
only. Public to allow unit tests in another package to work around mock issues where the constructor is never invoked. -
tryRetainReference
public final boolean tryRetainReference()Description copied from interface:LivenessReferent
If this referent is "live", behave asLivenessReferent.retainReference()
and return true. Otherwise, returns false rather than throwing an exception.- Specified by:
tryRetainReference
in interfaceLivenessReferent
- Returns:
- True if this referent was retained, false otherwise
-
dropReference
public final void dropReference()Description copied from interface:LivenessReferent
Drop a previously-retained reference to this referent.- Specified by:
dropReference
in interfaceLivenessReferent
-
getWeakReference
Description copied from interface:LivenessReferent
Get aWeakReference
to this referent. This may be cached, or newly created.- Specified by:
getWeakReference
in interfaceLivenessReferent
- Returns:
- A new or cached reference to this referent
-
tryManage
Description copied from interface:LivenessManager
Attempt to add the specified referent to this manager.- Specified by:
tryManage
in interfaceLivenessManager
- Parameters:
referent
- The referent to add- Returns:
- Whether the referent was in fact added
-
onReferenceCountAtZero
protected final void onReferenceCountAtZero()Description copied from class:ReferenceCounted
Callback method that will be invoked when the reference count returns to zero.- Specified by:
onReferenceCountAtZero
in classReferenceCounted
-