Class RowChangedSubscriptionManager
- java.lang.Object
-
- com.apama.correlator.memstore.notifications.RowChangedSubscriptionManager
-
public abstract class RowChangedSubscriptionManager extends java.lang.Object
A per-table helper object for managing each context's subscription to notifications about the table.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 Summary
Constructors Constructor Description RowChangedSubscriptionManager(java.lang.String storeName, java.lang.String tableName, java.lang.String[] schemaTypes)
Create a row changed subscription manager.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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()
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.<K,V>
voidfireRowChanged(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.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.
-
-
-
Constructor Detail
-
RowChangedSubscriptionManager
public RowChangedSubscriptionManager(java.lang.String storeName, java.lang.String tableName, java.lang.String[] schemaTypes)
Create a row changed subscription manager.- Parameters:
storeName
- the store nametableName
- the table nameschemaTypes
- the schema types, as passed to AbstractStore.createTable
-
-
Method Detail
-
addRowChangedListener
public abstract void addRowChangedListener()
Register with the distributed table so that row changed notifications can be fired on this object.Threading: Is allowed to call into provider code.
-
removeRowChangedListener
public abstract void removeRowChangedListener()
Remove registration with the distributed table for row changed notifications.
-
addSubscription
public final void addSubscription(long contextId, long subscriptionId)
Adds a subscription.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.
- Parameters:
contextId
- should never be nullsubscriptionId
- should never be null
-
removeSubscription
public final void removeSubscription(long contextId, long subscriptionId)
Removes and closes this subscription so long as we are not shutting down.This is used by distributed MemoryStore and does not need to be overridden or called by a driver implementation.
- Parameters:
contextId
- the id of the context from which the subscription to remove was madesubscriptionId
- the id of the subscription to remove
-
fireRowChanged
public <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.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.
- Parameters:
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.
-
fireRowChanged
public 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.fireRowChanged should be called every time a row has changed, be it as a result of an insert, update or remove.
- Parameters:
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 updates
-
fireMissedRowChanges
public void fireMissedRowChanges()
-
shutdown
public void shutdown()
Shuts the subscription manager down.No more subscriptions can be added or removed after this completes, and any existing subscriptions are guaranteed to have been closed.
-
-