Package com.illumon.iris.db.v2
Class TableMapImpl
java.lang.Object
com.illumon.util.referencecounting.ReferenceCounted
com.illumon.iris.db.util.liveness.LivenessArtifact
com.illumon.iris.db.v2.TableMapImpl
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable
,Deflatable<TableMap>
,LivenessManager
,LivenessNode
,LivenessReferent
,DynamicNode
,TableMap
,TransformableTableMap
,Serializable
- Direct Known Subclasses:
LocalTableMap
,TableMapClient
public abstract class TableMapImpl extends LivenessArtifact implements TableMap, DynamicNode
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.TableMap
TableMap.KeyListener, TableMap.Listener
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.TransformableTableMap
TransformableTableMap.AsTableBuilder
-
Field Summary
-
Constructor Summary
Constructors Constructor Description TableMapImpl()
-
Method Summary
Modifier and Type Method Description void
addKeyListener(TableMap.KeyListener listener)
Listen to changes in the map's keys.void
addListener(TableMap.Listener listener)
Add a new listener for changes to the map.void
addParentReference(Object parent)
Called on a dependent node to ensure that a strong reference is maintained to any parent object that is required for the proper maintenance and functioning of the dependent.protected void
destroy()
Attempt to release (destructively when necessary) resources held by this object.void
dropReference()
Drop a previously-retained reference to this referent.WeakReference<? extends LivenessReferent>
getWeakReference()
Get aWeakReference
to this referent.void
initializeTransientFieldsForLiveness()
Package-private forSerializable
sub-classes to use inreadObject
only.boolean
isRefreshing()
Is the node updating?protected void
notifyKeyListeners(Object key)
NotifyTableMap.KeyListener
s of an inserted key.protected void
notifyListeners(Object key, Table table)
NotifyTableMap.Listener
s of an inserted table.protected void
onReferenceCountAtZero()
Callback method that will be invoked when the reference count returns to zero.void
removeKeyListener(TableMap.KeyListener listener)
Removes a key change listener.void
removeListener(TableMap.Listener listener)
Removes a map change listener.boolean
setRefreshing(boolean refreshing)
Change the node's refresh mode.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.Methods inherited from class com.illumon.iris.db.util.liveness.LivenessArtifact
manageWithCurrentScope, unmanage, unmanage
Methods inherited from class com.illumon.util.referencecounting.ReferenceCounted
append, decrementReferenceCount, incrementReferenceCount, resetReferenceCount, toString, 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.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.v2.TableMap
apply, asTableMap, deflate, entrySet, flatten, get, getKeySet, getWithTransform, populateKeys, preemptiveUpdatesTable, size, transformTables, transformTables, transformTablesWithKey, transformTablesWithKey, transformTablesWithMap, values
Methods inherited from interface com.illumon.iris.db.v2.TransformableTableMap
asTable, asTable, asTableBuilder, merge
-
Constructor Details
-
TableMapImpl
public TableMapImpl()
-
-
Method Details
-
addListener
Description copied from interface:TableMap
Add a new listener for changes to the map.- Specified by:
addListener
in interfaceTableMap
- Parameters:
listener
- map change listener
-
removeListener
Description copied from interface:TableMap
Removes a map change listener.- Specified by:
removeListener
in interfaceTableMap
- Parameters:
listener
- map change listener.
-
addKeyListener
Description copied from interface:TableMap
Listen to changes in the map's keys.- Specified by:
addKeyListener
in interfaceTableMap
- Parameters:
listener
- key change listener
-
removeKeyListener
Description copied from interface:TableMap
Removes a key change listener.- Specified by:
removeKeyListener
in interfaceTableMap
- Parameters:
listener
- key change listener to remove
-
notifyListeners
NotifyTableMap.Listener
s of an inserted table.- Parameters:
key
- the newly inserted keytable
- the corresponding table
-
notifyKeyListeners
NotifyTableMap.KeyListener
s of an inserted key.- Parameters:
key
- the newly inserted key
-
isRefreshing
public boolean isRefreshing()Description copied from interface:DynamicNode
Is the node updating?- Specified by:
isRefreshing
in interfaceDynamicNode
- Returns:
- true if the node is updating; false otherwise.
-
setRefreshing
public boolean setRefreshing(boolean refreshing)Description copied from interface:DynamicNode
Change the node's refresh mode.- Specified by:
setRefreshing
in interfaceDynamicNode
- Parameters:
refreshing
- true to cause the node to update; false otherwise.- Returns:
- new refreshing state
-
addParentReference
Description copied from interface:DynamicNode
Called on a dependent node to ensure that a strong reference is maintained to any parent object that is required for the proper maintenance and functioning of the dependent. In the most common case, the parent object is a child listener to a parent node. The parent node only keeps a weak reference to its child listener, but the listener maintains a strong reference to the parent node. In this scenario, the only strong reference to the listener (and thus indirectly to the parent node itself) is the reference kept by the dependent node.- Specified by:
addParentReference
in interfaceDynamicNode
- Parameters:
parent
- A parent of this node
-
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.
-
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
-