| java.lang.Object org.jivesoftware.database.SequenceManager
SequenceManager | public class SequenceManager (Code) | | Manages sequences of unique ID's that get stored in the database. Database support for sequences
varies widely; some don't use them at all. Instead, we handle unique ID generation with a
combination VM/database solution.
A special table in the database doles out blocks of unique ID's to each
virtual machine that interacts with Jive. This has the following consequences:
- There is no need to go to the database every time we want a new unique id.
- Multiple app servers can interact with the same db without id collision.
- The order of unique id's may not correspond to the creation date of objects.
- There can be gaps in ID's after server restarts since blocks will get "lost" if the block
size is greater than 1.
Each sequence type that this class manages has a different block size value. Objects that aren't
created often have a block size of 1, while frequently created objects such as entries and
comments have larger block sizes.
author: Matt Tucker author: Bruce Ritchie |
Constructor Summary | |
public | SequenceManager(int seqType, int size) Creates a new DbSequenceManager. |
Method Summary | |
public static long | nextID(int type) Returns the next ID of the specified type.
Parameters: type - the type of unique ID. | public static long | nextID(Object o) Returns the next id for an object that has defined the annotation
JiveID .
The JiveID annotation value is the synonymous for the type integer.
The annotation JiveID should contain the id type for the object (the same number you would
use to call nextID(int type)). | public synchronized long | nextUniqueID() Returns the next available unique ID. | public static void | setBlockSize(int type, int blockSize) Used to set the blocksize of a given SequenceManager. |
SequenceManager | public SequenceManager(int seqType, int size)(Code) | | Creates a new DbSequenceManager.
Parameters: seqType - the type of sequence. Parameters: size - the number of id's to "checkout" at a time. |
nextID | public static long nextID(int type)(Code) | | Returns the next ID of the specified type.
Parameters: type - the type of unique ID. the next unique ID of the specified type. |
nextID | public static long nextID(Object o)(Code) | | Returns the next id for an object that has defined the annotation
JiveID .
The JiveID annotation value is the synonymous for the type integer.
The annotation JiveID should contain the id type for the object (the same number you would
use to call nextID(int type)). Example class definition:
\@JiveID(10)
public class MyClass {
}
Parameters: o - object that has annotation JiveID. the next unique ID. throws: IllegalArgumentException - If the object passed in does not defined JiveID |
nextUniqueID | public synchronized long nextUniqueID()(Code) | | Returns the next available unique ID. Essentially this provides for the functionality of an
auto-increment database field.
|
setBlockSize | public static void setBlockSize(int type, int blockSize)(Code) | | Used to set the blocksize of a given SequenceManager. If no SequenceManager has
been registered for the type, the type is verified as valid and then a new
sequence manager is created.
Parameters: type - the type of unique id. Parameters: blockSize - how many blocks of ids we should. |
|
|