Class MongoDBUIDSequencer
java.lang.Object
org.nuxeo.ecm.core.uidgen.AbstractUIDSequencer
org.nuxeo.ecm.core.mongodb.seqgen.MongoDBUIDSequencer
- All Implemented Interfaces:
UIDSequencer
MongoDB implementation of
UIDSequencer
.
We use MongoDB upsert feature to provide a sequencer.
- Since:
- 9.1
-
Field Summary
Modifier and TypeFieldDescriptionprotected com.mongodb.client.MongoCollection<org.bson.Document>
static final String
static final String
protected static final int
static final String
static final String
Fields inherited from class org.nuxeo.ecm.core.uidgen.AbstractUIDSequencer
name
Fields inherited from interface org.nuxeo.ecm.core.uidgen.UIDSequencer
SEQUENCE_DOES_NOT_EXIST
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Cleanup callbacklong
getCurrent
(String key) getKeys()
getNextBlock
(String key, int blockSize) Returns a block containingblockSize
sequences.long
getNextLong
(String key) For the given key returns the incremented UID which is also stored in the same sequence entry.com.mongodb.client.MongoCollection<org.bson.Document>
protected long
incrementBy
(String key, int value) void
init()
Init Sequencervoid
initSequence
(String key, long id) Initializes the sequencer with the given key to at least the given long id.protected static void
validateKey
(String key) Methods inherited from class org.nuxeo.ecm.core.uidgen.AbstractUIDSequencer
getName, setName
-
Field Details
-
SEQUENCE_DATABASE_ID
- See Also:
-
COLLECTION_NAME_PROPERTY
- See Also:
-
DEFAULT_COLLECTION_NAME
- See Also:
-
SEQUENCE_VALUE_FIELD
- See Also:
-
ERROR_IMMUTABLE_FIELD
protected static final int ERROR_IMMUTABLE_FIELD- See Also:
-
coll
protected com.mongodb.client.MongoCollection<org.bson.Document> coll
-
-
Constructor Details
-
MongoDBUIDSequencer
public MongoDBUIDSequencer()
-
-
Method Details
-
init
public void init()Description copied from interface:UIDSequencer
Init Sequencer -
initSequence
Description copied from interface:UIDSequencer
Initializes the sequencer with the given key to at least the given long id.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.
- Specified by:
initSequence
in interfaceUIDSequencer
- Overrides:
initSequence
in classAbstractUIDSequencer
-
getSequencerCollection
public com.mongodb.client.MongoCollection<org.bson.Document> getSequencerCollection() -
getKeys
- Returns:
- all keys known to this sequencer
-
getCurrent
- Returns:
- the current sequence value for the given key, or
UIDSequencer.SEQUENCE_DOES_NOT_EXIST
if the sequence doesn't exist
-
getNextLong
Description copied from interface:UIDSequencer
For the given key returns the incremented UID which is also stored in the same sequence entry. This is a "one time use" function for a document. -
getNextBlock
Description copied from interface:UIDSequencer
Returns a block containingblockSize
sequences. -
incrementBy
-
dispose
public void dispose()Description copied from interface:UIDSequencer
Cleanup callback -
validateKey
-