Chapter 10. Secondary Stores

Lifecycle
Transaction management
Extent notifier
Record notifier
Query notifier
Atomic create or select
Chaining notifiers

This chapter describes how to transparently integrate managed objects with a secondary store such as an RDBMS, files, or long-term archival storage. The secondary store API defines a set of notifiers that are triggered as applications perform actions against managed objects such as creating, deleting, modifying, or querying. Applications use the normal managed object APIs - they are not aware that the managed objects are being externalized or read from a secondary store.

While the primary use of the secondary store notifiers is to integrate with external stores, there is nothing preventing them from being used for other functions such as auditing, change notification, etc.

The secondary store notifiers are defined in the com.kabira.store package. These abstract classes define the supported notifiers:

There is no requirement to implement all notifiers. Only the notifiers required to support the desired functionality must be implemented. Secondary store notifiers must be installed on all nodes that are interested in receiving notifications.

Notifiers are always called in the same transaction in which the application action was performed that triggered the notifier.

Distributed queries cause query notifiers, Extent<T> or Query<T>, to be executed on all nodes that are part of the distributed query. The notifiers must be installed on all remote nodes that are involved in the distributed query.

Object modifications cause Record<T> notifiers to be executed on the current active node for the object being modified. The notifier must be installed on the active node to be executed.

The Extent<T> and Query<T> notifiers make objects available to the application query by creating, updating, or deleting managed objects as required to satisfy the application request. For example, an Extent<T> notifier that integrates with an external RDBMS might perform a select * from <T> query against the database and create objects for all returned rows.

Managed object creates, deletes, modifications, or queries, done by the implementation of a notifier do not cause any notifier methods to be triggered. Secondary store notifiers are only triggered by application actions. The only exception to this rule is if a notifier implementation performs a distributed query. In that case any installed query notifiers, Extent<T> or Query<T>, on remote nodes involved in the distributed query will be executed.