|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.apama.correlator.memstore.notifications.RowChangedSubscriptionManager
public abstract class RowChangedSubscriptionManager
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 | |
---|---|
RowChangedSubscriptionManager(java.lang.String storeName,
java.lang.String tableName,
java.lang.String[] schemaTypes)
Create a row changed subscription manager. |
Method Summary | ||
---|---|---|
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. |
|
|
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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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.createTableMethod Detail |
---|
public 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 shutdown()
No more subscriptions can be added or removed after this completes, and any existing subscriptions are guaranteed to have been closed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |