|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sandev.tools.JDBC.THD_TableKeyCounter
A UniqueIDManager that finds the lowest unused uniqueID across all
tables in the database, and then keeps track of the next available
uniqueID via a counter kept in memory. It is nearly optimal with
respect to overall keyspace utilization, but does not recycle keys.
AUTOGENERATED FILE, DO NOT EDIT DIRECTLY.
source: declared in build
generator: org.sandev.generator.TableKeyCounterGenerator
time: Dec 2, 2005 6:38:59 PM
The TableKeyCounter is not appropriate for use in situations where the in-memory counter value may overlap with other database users. This could lead to primary key conflicts if additional rows are inserted while the app is running, since the in-memory will not be updated.
The TableKeyCounter assumes that the uniqueID values will write directly into the target database. If the storage of a java long value is smaller than 64bits, then target database will be limited to that maximum number of records. In the case where the target db holds smaller values (such as 32bits), then the recommended alternative is to use a UniqueIDManager with numbered tables and a separate counter for each table. IDs in high usage tables can then be rolled over without affecting the keys for other tables, allowing overall data growth to be contained within the limited keyspace while preserving critical data.
For example you might use the top 6 bits for the persistent message type (table ID), to allow for up to 64 different persistent object types, and the bottom 26 bits for the persistent message uniqueID values, to provide for up to 67,108,864 object instances per message type. By archiving and deleting older data over the working life of the app, the high usage tables can safely wrap back to zero while maintaining data integrity. It is also possible to use this approach only for the high volume tables and use a TableKeyCounter approach for the rest. Custom UniqueIDManagers are developed and optimized on a per application basis since the design tradeoffs are application specific.
| Field Summary | |
protected long |
highest
The current highest ID in use. |
| Constructor Summary | |
THD_TableKeyCounter()
default ctor, does nothing |
|
| Method Summary | |
protected long |
getMessageID(org.sandev.basics.structs.SandUpdateMessage sum)
Gets the instance out of the given update message, downcasts it to a SandPeristMessage and returns its uniqueID. |
protected long |
getNextID()
Return the next available uniqueID for this message class. |
long |
getNextID(org.sandev.basics.structs.SandUpdateMessage msg)
Return the next available uniqueID for this message class. |
void |
init(org.sandev.basics.DataManager.DataManagerNode dm)
Set up for work. |
void |
notifyImport(org.sandev.basics.structs.SandPersistMessage spm)
Make sure our uniqueID counter is one more than the given value, and update if not. |
void |
remapIDs(long oldID,
org.sandev.basics.structs.SandUpdateMessage msg,
org.sandev.basics.structs.SandUpdateMessage[] remaps)
Walk through the remap messages specified and change any oldID references to the new ID. |
protected void |
setMessageID(org.sandev.basics.structs.SandUpdateMessage sum,
long val)
Gets the instance out of the given update message, downcasts it to a SandPeristMessage and sets its uniqueID. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected long highest
| Constructor Detail |
public THD_TableKeyCounter()
| Method Detail |
protected long getNextID()
protected long getMessageID(org.sandev.basics.structs.SandUpdateMessage sum)
protected void setMessageID(org.sandev.basics.structs.SandUpdateMessage sum,
long val)
public void init(org.sandev.basics.DataManager.DataManagerNode dm)
throws org.sandev.basics.DataManager.PersisterException
init in interface org.sandev.basics.DataManager.UniqueIDManagerorg.sandev.basics.DataManager.PersisterException
public long getNextID(org.sandev.basics.structs.SandUpdateMessage msg)
throws org.sandev.basics.DataManager.PersisterException
getNextID in interface org.sandev.basics.DataManager.UniqueIDManagerorg.sandev.basics.DataManager.PersisterException
public void remapIDs(long oldID,
org.sandev.basics.structs.SandUpdateMessage msg,
org.sandev.basics.structs.SandUpdateMessage[] remaps)
throws org.sandev.basics.DataManager.PersisterException
remapIDs in interface org.sandev.basics.DataManager.UniqueIDManagerorg.sandev.basics.DataManager.PersisterException
public void notifyImport(org.sandev.basics.structs.SandPersistMessage spm)
throws org.sandev.basics.DataManager.PersisterException
notifyImport in interface org.sandev.basics.DataManager.UniqueIDManagerorg.sandev.basics.DataManager.PersisterException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||