|
IBM WebSphereTM eXtreme Scale, Release 8.6 API Specification |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.websphere.objectgrid.jpa.dbupdate.TimeBasedDBUpdater
public class TimeBasedDBUpdater
A time-based database updater can be used to periodically get the latest inserts and updates to the ObjectGrid backend database. A time-based database updater interacts with Java Persistence API (JPA) to get the latest changes (inserts and updates) from the database using a specific timestamp field. Therefore, a JPA provider is required to use this feature. The database here can be any backend supported by the chosen JPA provider.
The time-based database updater periodically query the database using JPA interfaces to get the JPA entities which represent the newly inserted and updated records in the database. In order to do that, every record in the database should have a "timestamp" to identify the time or sequence when the record was last updated or inserted. The "timestamp" here does not have to be in a timestamp format. It can be in a an integer or long format, as long as it generates a unique increasing value.
Several commercial databases have provided this capability.
For example, in DB2 9.5, you can define a column using the ROW CHANGE TIMESTAMP format as follows:
ROWCHGTS TIMESTAMP NOT NULL GENERATED ALWAYS FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMPIn Oracle, you can use the pseudo-column ora_rowscn, which represents the system change number of the record.
Using this timestamp, the time-based database updater utilize the following two queries to get the latest database changes:
However, record removes to the backend database cannot be detected.
The time-based database updater can be launched in the following two ways:
Timestamp
,
BackingMap
Method Summary | |
---|---|
static TimeBasedDBUpdater |
instance()
|
void |
startDBUpdate(ObjectGrid objectGrid,
String mapName,
String punitName,
Class entityClass,
String timestampField,
TimeBasedDBUpdateConfig.DBUpdateMode mode)
Start a time-base database update thread to keep the ObjectGrid data updated from the database back end |
void |
stopDBUpdate(ObjectGrid objectGrid,
String mapName)
Stop the time-based database update thread |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static TimeBasedDBUpdater instance()
public void startDBUpdate(ObjectGrid objectGrid, String mapName, String punitName, Class entityClass, String timestampField, TimeBasedDBUpdateConfig.DBUpdateMode mode)
objectGrid
- the ObjectGrid instancemapName
- the map name to be updatedpunitName
- the JPA persistence unit nameentityClass
- the JPA entity class which represents the database tabletimestampField
- the timestamp field used by ObjectGrid to query the changesmode
- the database update mode.
ObjectGridException
public void stopDBUpdate(ObjectGrid objectGrid, String mapName)
objectGrid
- the ObjectGrid instancemapName
- the map name to be updated
IllegalArgumentException
- If there is no time-based database update thread started for this map.
|
IBM WebSphereTM eXtreme Scale, Release 8.6 API Specification |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |