public class MongoDBUIDSequencer extends AbstractUIDSequencer
UIDSequencer
.
We use MongoDB upsert feature to provide a sequencer.
Modifier and Type | Field and Description |
---|---|
protected com.mongodb.client.MongoCollection<org.bson.Document> |
coll |
static String |
COLLECTION_NAME_PROPERTY |
static String |
DEFAULT_COLLECTION_NAME |
static Long |
ONE |
static String |
SEQUENCE_DATABASE_ID |
static String |
SEQUENCE_VALUE_FIELD |
name
Constructor and Description |
---|
MongoDBUIDSequencer() |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Cleanup callback
|
long |
getNextLong(String key)
Extends
UIDSequencer.getNext(java.lang.String) to return a long value. |
com.mongodb.client.MongoCollection<org.bson.Document> |
getSequencerCollection() |
void |
init()
Init Sequencer
|
void |
initSequence(String key,
long id)
Initializes the sequencer with the given key to at least the given long id.
|
getName, getNext, initSequence, setName
public static final String SEQUENCE_DATABASE_ID
public static final String COLLECTION_NAME_PROPERTY
public static final String DEFAULT_COLLECTION_NAME
public static final String SEQUENCE_VALUE_FIELD
protected com.mongodb.client.MongoCollection<org.bson.Document> coll
public MongoDBUIDSequencer()
public void init()
UIDSequencer
public void initSequence(String key, long id)
UIDSequencer
A sequence can only be incremented, so if its current id is greater than the given id the sequence won't be decremented to reach the given id.
initSequence
in interface UIDSequencer
initSequence
in class AbstractUIDSequencer
public com.mongodb.client.MongoCollection<org.bson.Document> getSequencerCollection()
public long getNextLong(String key)
UIDSequencer
UIDSequencer.getNext(java.lang.String)
to return a long value. This method is compatible
with getNext in the integer range.public void dispose()
UIDSequencer
Copyright © 2018 Nuxeo. All rights reserved.