public abstract class RowChangedSubscriptionManager
extends java.lang.Object
Distributed store driver writers who wish to support notifications can do so by providing an instance of this class in their provider AbstractTable subclass, which should provide implementations for addRowChangedListener and removeRowChangedListener, which are invoked on the first subscription and on the last subscription being removed respectively. After addRowChangedListener has been called, the provider should call fireRowChanged on the RowChangedSubscriptionManager.
Threading: this class is thread-safe.
Constructor and Description |
---|
RowChangedSubscriptionManager(java.lang.String storeName,
java.lang.String tableName,
java.lang.String[] schemaTypes)
Create a row changed subscription manager.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
addRowChangedListener()
Register with the distributed table so that row changed notifications can be fired on this object.
|
void |
addSubscription(long contextId,
long subscriptionId)
Adds a subscription.
|
void |
fireMissedRowChanges() |
<K,V> void |
fireRowChanged(RowChangedType rowChangedType,
K keyObject,
V oldValue,
V newValue,
RowKeyValueConverter<K,V> converter)
Notifies subscribed contexts of a change to a table row, using the specified converter to translate
key and value types from custom application-specific classes K and V into String, RowValue pairs.
|
void |
fireRowChanged(RowChangedType rowChangedType,
java.lang.String key,
RowValue oldValue,
RowValue newValue)
Notifies subscribed contexts of a change to a table row, using key and values described using the standard
String/RowValue types.
|
abstract void |
removeRowChangedListener()
Remove registration with the distributed table for row changed notifications.
|
void |
removeSubscription(long contextId,
long subscriptionId)
Removes and closes this subscription so long as we are not shutting down.
|
void |
shutdown()
Shuts the subscription manager down.
|
public RowChangedSubscriptionManager(java.lang.String storeName, java.lang.String tableName, java.lang.String[] schemaTypes)
storeName
- the store nametableName
- the table nameschemaTypes
- the schema types, as passed to AbstractStore.createTablepublic abstract void addRowChangedListener()
Threading: Is allowed to call into provider code.
public abstract void removeRowChangedListener()
public final void addSubscription(long contextId, long subscriptionId)
This is used by distributed MemoryStore and does not need to be overridden or called by a driver implementation.
RowChangedSubscriptionManager will reference count the subscriptions, calling addRowChangedListener on the first subscription.
None of our code should be holding locks when this method is called, since we will be calling into the 3rd party provider code and it may acquires its own locks.
contextId
- should never be nullsubscriptionId
- should never be nullpublic final void removeSubscription(long contextId, long subscriptionId)
This is used by distributed MemoryStore and does not need to be overridden or called by a driver implementation.
contextId
- the id of the context from which the subscription to remove was madesubscriptionId
- the id of the subscription to removepublic <K,V> void fireRowChanged(RowChangedType rowChangedType, K keyObject, V oldValue, V newValue, RowKeyValueConverter<K,V> converter)
Applications should normally use the alternative fireRowChanged(RowChangedType, String, RowValue, RowValue)
override, unless they are using custom application-specific classes to represent keys and values in the map.
fireRowChanged should be called every time a row has changed, be it as a result of an insert, update or remove.
rowChangedType
- The type of action that resulted in this change request being fired, ie. Update, Insert, removekeyObject
- The key that represents this Row. Must not be null.oldValue
- In some cases this will be set to indicate the oldValue, ie. before it was changed, eg. on updates and removesnewValue
- In some cases this will be set to indicate a new value for the row, eg. on Inserts and updatesconverter
- Converter object for translating the specified key and values into standard String,RowValue
objects.public void fireRowChanged(RowChangedType rowChangedType, java.lang.String key, RowValue oldValue, RowValue newValue)
fireRowChanged should be called every time a row has changed, be it as a result of an insert, update or remove.
rowChangedType
- The type of action that resulted in this change request being fired, ie. Update, Insert, removekey
- The key that represents this RowoldValue
- In some cases this will be set to indicate the oldValue, ie. before it was changed, eg. on updates and removesnewValue
- In some cases this will be set to indicate a new value for the row, eg. on Inserts and updatespublic void fireMissedRowChanges()
public void shutdown()
No more subscriptions can be added or removed after this completes, and any existing subscriptions are guaranteed to have been closed.
Submit a bug or feature
Copyright (c) 2013-2020 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.