Class InMemoryStore

java.lang.Object
me.ahoo.cosid.store.tck.InMemoryStore
All Implemented Interfaces:
AutoCloseable, me.ahoo.cosid.lease.SlotLeaseStore, me.ahoo.cosid.segment.RangeStore, me.ahoo.cosid.store.Store

public final class InMemoryStore extends Object implements me.ahoo.cosid.store.Store, me.ahoo.cosid.segment.RangeStore, me.ahoo.cosid.lease.SlotLeaseStore
The in-memory reference store (06-stores.md ยง3): passes every contract, for the unit tests of core and Spring. Instances are independent; ranges() and slots() return this store. Thread-safe: every operation is atomic on one key or one namespace, stamped by the store clock given at construction.
  • Constructor Summary

    Constructors
    Constructor
    Description
    A store on the system clock.
    InMemoryStore(me.ahoo.cosid.time.TimeSource storeClock)
    A store on its own clock, for tests that move the store clock apart from the client clock, such as a ManualClock.
  • Method Summary

    Modifier and Type
    Method
    Description
    me.ahoo.cosid.lease.AcquireResult
    acquire(String namespace, me.ahoo.cosid.lease.Owner owner, int limit, Duration ttl, Duration tolerance, int slotOffset, OptionalInt preferredSlot)
     
    void
     
    me.ahoo.cosid.segment.RangeStore
     
    boolean
    release(me.ahoo.cosid.lease.SlotLease lease, long lastIssued)
     
    Optional<me.ahoo.cosid.lease.SlotLease>
    renew(me.ahoo.cosid.lease.SlotLease lease, Duration ttl, Duration tolerance)
     
    me.ahoo.cosid.segment.Range
    reserve(String key, long size, long initialOffset)
     
    boolean
    seal(String key)
    Seals the key; a key that does not exist yet is sealed too, so it is never created (S6).
    me.ahoo.cosid.lease.SlotLeaseStore
     
    me.ahoo.cosid.time.TimeSource
    The clock that stamps every lease of this store.

    Methods inherited from class java.lang.Object

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

    • InMemoryStore

      public InMemoryStore()
      A store on the system clock.
    • InMemoryStore

      public InMemoryStore(me.ahoo.cosid.time.TimeSource storeClock)
      A store on its own clock, for tests that move the store clock apart from the client clock, such as a ManualClock.
      Parameters:
      storeClock - the store clock
  • Method Details

    • storeClock

      public me.ahoo.cosid.time.TimeSource storeClock()
      The clock that stamps every lease of this store.
      Returns:
      the store clock
    • 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
    • reserve

      public me.ahoo.cosid.segment.Range reserve(String key, long size, long initialOffset)
      Specified by:
      reserve in interface me.ahoo.cosid.segment.RangeStore
    • seal

      public boolean seal(String key)
      Seals the key; a key that does not exist yet is sealed too, so it is never created (S6).
      Specified by:
      seal in interface me.ahoo.cosid.segment.RangeStore
      Parameters:
      key - the range key
      Returns:
      true
    • acquire

      public me.ahoo.cosid.lease.AcquireResult acquire(String namespace, me.ahoo.cosid.lease.Owner owner, int limit, Duration ttl, Duration tolerance, int slotOffset, OptionalInt preferredSlot)
      Specified by:
      acquire in interface me.ahoo.cosid.lease.SlotLeaseStore
    • renew

      public Optional<me.ahoo.cosid.lease.SlotLease> renew(me.ahoo.cosid.lease.SlotLease lease, Duration ttl, Duration tolerance)
      Specified by:
      renew in interface me.ahoo.cosid.lease.SlotLeaseStore
    • release

      public boolean release(me.ahoo.cosid.lease.SlotLease lease, long lastIssued)
      Specified by:
      release in interface me.ahoo.cosid.lease.SlotLeaseStore
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface me.ahoo.cosid.segment.RangeStore
      Specified by:
      close in interface me.ahoo.cosid.lease.SlotLeaseStore
      Specified by:
      close in interface me.ahoo.cosid.store.Store