Class MongoDBUIDSequencer
- java.lang.Object
-
- org.nuxeo.ecm.core.uidgen.AbstractUIDSequencer
-
- org.nuxeo.ecm.core.mongodb.seqgen.MongoDBUIDSequencer
-
- All Implemented Interfaces:
UIDSequencer
public class MongoDBUIDSequencer extends AbstractUIDSequencer
MongoDB implementation ofUIDSequencer
.We use MongoDB upsert feature to provide a sequencer.
- Since:
- 9.1
-
-
Field Summary
Fields Modifier and Type Field Description protected com.mongodb.client.MongoCollection<org.bson.Document>
coll
static String
COLLECTION_NAME_PROPERTY
static String
DEFAULT_COLLECTION_NAME
static String
SEQUENCE_DATABASE_ID
static String
SEQUENCE_VALUE_FIELD
-
Fields inherited from class org.nuxeo.ecm.core.uidgen.AbstractUIDSequencer
name
-
-
Constructor Summary
Constructors Constructor Description MongoDBUIDSequencer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Cleanup callbackList<Long>
getNextBlock(String key, int blockSize)
Returns a block containingblockSize
sequences.long
getNextLong(String key)
ExtendsUIDSequencer.getNext(java.lang.String)
to return a long value.com.mongodb.client.MongoCollection<org.bson.Document>
getSequencerCollection()
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.-
Methods inherited from class org.nuxeo.ecm.core.uidgen.AbstractUIDSequencer
getName, getNext, initSequence, setName
-
-
-
-
Field Detail
-
SEQUENCE_DATABASE_ID
public static final String SEQUENCE_DATABASE_ID
- See Also:
- Constant Field Values
-
COLLECTION_NAME_PROPERTY
public static final String COLLECTION_NAME_PROPERTY
- See Also:
- Constant Field Values
-
DEFAULT_COLLECTION_NAME
public static final String DEFAULT_COLLECTION_NAME
- See Also:
- Constant Field Values
-
SEQUENCE_VALUE_FIELD
public static final String SEQUENCE_VALUE_FIELD
- See Also:
- Constant Field Values
-
coll
protected com.mongodb.client.MongoCollection<org.bson.Document> coll
-
-
Method Detail
-
init
public void init()
Description copied from interface:UIDSequencer
Init Sequencer
-
initSequence
public void initSequence(String key, long id)
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()
-
getNextLong
public long getNextLong(String key)
Description copied from interface:UIDSequencer
ExtendsUIDSequencer.getNext(java.lang.String)
to return a long value. This method is compatible with getNext in the integer range.
-
getNextBlock
public List<Long> getNextBlock(String key, int blockSize)
Description copied from interface:UIDSequencer
Returns a block containingblockSize
sequences.
-
incrementBy
protected long incrementBy(String key, int value)
-
dispose
public void dispose()
Description copied from interface:UIDSequencer
Cleanup callback
-
-