Packages

c

lerna.util.sequence

CassandraSequenceFactory

abstract class CassandraSequenceFactory extends SequenceFactory with AppLogging

A sequence factory using Cassandra

Overview

  • Manage sequences using (seqId,subId) as a key
  • Reduce overhead by generating and persisting sequence beforehand
  • For each key (seqId,subId), hold the next IDs in memory

seqID concept is introduced by this implementation. It can be thought of as a sub-namespace.

Details

Define an increment value as max server count (name it n) beforehand. Assign the different initial values (that is in the range [1 to n]) to each server. We can generate a unique ID using the above condition.

For example, suppose we have 3 servers initially and scale it out to 5 servers in the future.

Assign initial values as follows

  • Server A: (Assign an initial value = 1)
  • Server B: (Assign an initial value = 2)
  • Server C: (Assign an initial value = 3)

Each server generates a sequence like the below

  • Server A generates a sequence 1, 6, 11, ..., Ai = 1 + n * i
  • Server B generates a sequence 2, 7, 12, ..., Bi = 2 + n * i
  • Server C generates a sequence 3, 8, 13, ..., Ci = 3 + n * i

In the future, we can add two servers (named Server D and Server E).

  • Server D is assigned 4 as an initial value. It generates a sequence 4, 9, 14, ..., Di = 4 + n * i.
  • Server E is assigned 5 as an initial value. It generates a sequence 5, 10, 15, ..., Ei = 5 + n * i.

Therefore, as we see the above, we can generate unique IDs.

Annotations
@SuppressWarnings()
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CassandraSequenceFactory
  2. AppLogging
  3. SequenceFactory
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new CassandraSequenceFactory()

Abstract Value Members

  1. abstract val config: Config

    The configuration that is used for reading settings

  2. abstract def maxSequence: BigInt

    The maximum ID that can be generated

    The maximum ID that can be generated

    returns

    The maximum ID

    Definition Classes
    SequenceFactory
  3. abstract def seqId: String

    The sequence ID for this factory

    The sequence ID for this factory

    returns

    The sequence ID

  4. abstract def sequenceCacheSize: Int

    The number of IDs that the factory generates before it receives a generating request

  5. abstract def supportedTenants: Seq[Tenant]

    List of supported tenants.

    List of supported tenants.

    Used to create SequenceFactorySupervisor at initialization. If a numbering request is made for a tenant not included in this list, Future.failed(new IllegalArgumentException) will be returned.

  6. abstract val system: ActorSystem

    The actor system that is used for creating internal actors

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. lazy val logger: AppLogger
    Definition Classes
    AppLogging
  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def nextId(subId: Option[String])(implicit tenant: Tenant): Future[BigInt]

    Generate the next ID for the given sub ID

    Generate the next ID for the given sub ID

    subId

    The namespace. If it is scala.None, a default sub ID is used.

    returns

    A scala.concurrent.Future containing the generated ID

    Definition Classes
    CassandraSequenceFactorySequenceFactory
  15. final def nextId()(implicit tenant: Tenant): Future[BigInt]

    Generate the next ID for a default sub ID

    Generate the next ID for a default sub ID

    returns

    The generated ID

    Definition Classes
    SequenceFactory
  16. final def nextId(subId: String)(implicit tenant: Tenant): Future[BigInt]

    Generate the next ID for the given sub ID

    Generate the next ID for the given sub ID

    subId

    The sub ID

    returns

    A scala.concurrent.Future containing the generated ID

    Definition Classes
    SequenceFactory
  17. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  20. def toString(): String
    Definition Classes
    AnyRef → Any
  21. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AppLogging

Inherited from SequenceFactory

Inherited from AnyRef

Inherited from Any

Ungrouped