|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.amazon.carbonado.sequence.AbstractSequenceValueProducer
com.amazon.carbonado.sequence.SequenceValueGenerator
public class SequenceValueGenerator
General purpose implementation of a sequence value generator.
Sequence,
StoredSequence| Field Summary | |
|---|---|
static int |
DEFAULT_INCREMENT
|
static int |
DEFAULT_INITIAL_VALUE
|
static int |
DEFAULT_RESERVE_AMOUNT
|
| Constructor Summary | |
|---|---|
SequenceValueGenerator(Repository repo,
String name)
Construct a new SequenceValueGenerator which might create persistent sequence data if it does not exist. |
|
SequenceValueGenerator(Repository repo,
String name,
long initialValue,
int increment)
Construct a new SequenceValueGenerator which might create persistent sequence data if it does not exist. |
|
SequenceValueGenerator(Repository repo,
String name,
long initialValue,
int increment,
int reserveAmount)
Construct a new SequenceValueGenerator which might create persistent sequence data if it does not exist. |
|
| Method Summary | |
|---|---|
int |
nextIntValue()
Returns the next value from the sequence, which may wrap negative if all positive values are exhausted. |
long |
nextLongValue()
Returns the next value from the sequence, which may wrap negative if all positive values are exhausted. |
void |
reset(int initialValue)
Reset the sequence. |
boolean |
returnReservedValues()
Allow any unused reserved values to be returned for re-use. |
| Methods inherited from class com.amazon.carbonado.sequence.AbstractSequenceValueProducer |
|---|
nextDecimalValue, nextNumericalValue |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_RESERVE_AMOUNT
public static final int DEFAULT_INITIAL_VALUE
public static final int DEFAULT_INCREMENT
| Constructor Detail |
|---|
public SequenceValueGenerator(Repository repo,
String name)
throws RepositoryException
repo - repository to persist sequence dataname - name of sequence
RepositoryException
public SequenceValueGenerator(Repository repo,
String name,
long initialValue,
int increment)
throws RepositoryException
repo - repository to persist sequence dataname - name of sequenceinitialValue - initial sequence value, if sequence needs to be createdincrement - amount to increment sequence by
RepositoryException
public SequenceValueGenerator(Repository repo,
String name,
long initialValue,
int increment,
int reserveAmount)
throws RepositoryException
repo - repository to persist sequence dataname - name of sequenceinitialValue - initial sequence value, if sequence needs to be createdincrement - amount to increment sequence byreserveAmount - amount of sequence values to reserve
RepositoryException| Method Detail |
|---|
public void reset(int initialValue)
throws FetchException,
PersistException
initialValue - first value produced by sequence
FetchException
PersistException
public long nextLongValue()
throws PersistException
Note: this method throws PersistException even for fetch failures since this method is called by insert operations. Insert operations can only throw a PersistException.
PersistException - for fetch/persist failure or if sequence is exhausted.
public int nextIntValue()
throws PersistException
Note: this method throws PersistException even for fetch failures since this method is called by insert operations. Insert operations can only throw a PersistException.
nextIntValue in interface SequenceValueProducernextIntValue in class AbstractSequenceValueProducerPersistException - for fetch/persist failure or if sequence is
exhausted for int values.
public boolean returnReservedValues()
throws FetchException,
PersistException
This method should be called during the shutdown process of a repository, although calling it does not invalidate this SequenceValueGenerator. If getNextValue is called again, it will reserve values again.
FetchException
PersistException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||