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
FieldsModifier and TypeFieldDescriptionprotected com.mongodb.client.MongoCollection<org.bson.Document>static final Stringstatic final Stringprotected static final intstatic final Stringstatic final StringFields inherited from class org.nuxeo.ecm.core.uidgen.AbstractUIDSequencer
nameFields inherited from interface org.nuxeo.ecm.core.uidgen.UIDSequencer
SEQUENCE_DOES_NOT_EXIST -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Cleanup callbacklonggetCurrent(String key) getKeys()getNextBlock(String key, int blockSize) Returns a block containingblockSizesequences.longgetNextLong(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 longincrementBy(String key, int value) voidinit()Init SequencervoidinitSequence(String key, long id) Initializes the sequencer with the given key to at least the given long id.protected static voidvalidateKey(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:UIDSequencerInit Sequencer -
initSequence
Description copied from interface:UIDSequencerInitializes 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:
initSequencein interfaceUIDSequencer- Overrides:
initSequencein 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_EXISTif the sequence doesn't exist
-
getNextLong
Description copied from interface:UIDSequencerFor 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:UIDSequencerReturns a block containingblockSizesequences. -
incrementBy
-
dispose
public void dispose()Description copied from interface:UIDSequencerCleanup callback -
validateKey
-