Class MongoStore

java.lang.Object
me.ahoo.cosid.store.mongo.MongoStore
All Implemented Interfaces:
AutoCloseable, me.ahoo.cosid.store.Store

public final class MongoStore extends Object implements me.ahoo.cosid.store.Store
The MongoDB store (06-stores.md ยง2.3): MongoRangeStore and MongoSlotLeaseStore on one database, MongoDB 6.0 or later. Every operation reads with majority concern on the primary, writes with the configured write concern (majority by default, options.writeConcern) and runs under the driver's client-side operation timeout (timeoutMS); an operation that runs out of it fails with StoreTimeoutException.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The database when options.database is not set.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MongoStore(com.mongodb.client.MongoDatabase database, Duration timeout)
    A store on a database whose client the caller owns and closes.
    MongoStore(com.mongodb.client.MongoDatabase database, Duration timeout, com.mongodb.WriteConcern writeConcern)
    A store on a database whose client the caller owns and closes, writing with the given concern.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the client the store created itself; an injected one stays open.
    me.ahoo.cosid.segment.RangeStore
     
    me.ahoo.cosid.lease.SlotLeaseStore
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_DATABASE

      public static final String DEFAULT_DATABASE
      The database when options.database is not set.
      See Also:
  • Constructor Details

    • MongoStore

      public MongoStore(com.mongodb.client.MongoDatabase database, Duration timeout)
      A store on a database whose client the caller owns and closes.
      Parameters:
      database - the database
      timeout - the operation timeout (timeoutMS); zero means none
    • MongoStore

      public MongoStore(com.mongodb.client.MongoDatabase database, Duration timeout, com.mongodb.WriteConcern writeConcern)
      A store on a database whose client the caller owns and closes, writing with the given concern.
      Parameters:
      database - the database
      timeout - the operation timeout (timeoutMS); zero means none
      writeConcern - the write concern, acknowledged; anything weaker than majority can lose acknowledged writes on a failover and so hand out duplicate ids
  • Method Details

    • ranges

      public me.ahoo.cosid.segment.RangeStore ranges()
      Specified by:
      ranges in interface me.ahoo.cosid.store.Store
    • slots

      public me.ahoo.cosid.lease.SlotLeaseStore slots()
      Specified by:
      slots in interface me.ahoo.cosid.store.Store
    • close

      public void close()
      Closes the client the store created itself; an injected one stays open.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface me.ahoo.cosid.store.Store