Package me.ahoo.cosid.store.mongo
Class MongoRangeStore
java.lang.Object
me.ahoo.cosid.store.mongo.MongoRangeStore
- All Implemented Interfaces:
AutoCloseable,me.ahoo.cosid.segment.RangeStore
RangeStore on the cosid_range collection, {_id: key, next, sealed} (06-stores.md ยง2.3).
A reservation is one findOneAndUpdate: an upsert with the pipeline update
next = ifNull(next, initialOffset) + size, filtered on sealed != true and on next leaving room
for size, returning the updated document; the range is [next - size, next). When the filter matches
nothing on an existing key the upsert fails with E11000, as it does when a concurrent first reservation created
the key: the store then reads the key, reports a sealed or exhausted one, and otherwise retries.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMongoRangeStore(com.mongodb.client.MongoDatabase database, Duration timeout) A range store on a database whose client the caller owns.MongoRangeStore(com.mongodb.client.MongoDatabase database, Duration timeout, com.mongodb.WriteConcern writeConcern) A range store on a database whose client the caller owns, writing with the given concern. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.ahoo.cosid.segment.RangeStore
close
-
Field Details
-
COLLECTION
The collection.- See Also:
-
-
Constructor Details
-
MongoRangeStore
A range store on a database whose client the caller owns.- Parameters:
database- the databasetimeout- the operation timeout (timeoutMS); zero means none
-
MongoRangeStore
public MongoRangeStore(com.mongodb.client.MongoDatabase database, Duration timeout, com.mongodb.WriteConcern writeConcern) A range store on a database whose client the caller owns, writing with the given concern.- Parameters:
database- the databasetimeout- the operation timeout (timeoutMS); zero means nonewriteConcern- the write concern, acknowledged (majoritykeeps ranges across a failover)
-
-
Method Details
-
reserve
- Specified by:
reservein interfaceme.ahoo.cosid.segment.RangeStore
-
seal
Seals the key with an upsert, so a key that does not exist yet is sealed too and never created (S6).- Specified by:
sealin interfaceme.ahoo.cosid.segment.RangeStore- Parameters:
key- the range key- Returns:
- true
-