Class/Object

com.avsystem.commons.redis

ClusterState

Related Docs: object ClusterState | package redis

Permalink

case class ClusterState(mapping: IndexedSeq[(SlotRange, RedisNodeClient)], masters: commons.BMap[NodeAddress, RedisNodeClient], nonClustered: commons.Opt[RedisNodeClient] = Opt.Empty) extends Product with Serializable

Current cluster state known by RedisClusterClient.

mapping

mapping between slot ranges and node clients that serve them, sorted by slot ranges

masters

direct mapping between master addresses and node clients

nonClustered

non-empty if there's actually only one, non-clustered Redis node - see fallbackToSingleNode

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ClusterState
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ClusterState(mapping: IndexedSeq[(SlotRange, RedisNodeClient)], masters: commons.BMap[NodeAddress, RedisNodeClient], nonClustered: commons.Opt[RedisNodeClient] = Opt.Empty)

    Permalink

    mapping

    mapping between slot ranges and node clients that serve them, sorted by slot ranges

    masters

    direct mapping between master addresses and node clients

    nonClustered

    non-empty if there's actually only one, non-clustered Redis node - see fallbackToSingleNode

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clientForSlot(slot: Int): RedisNodeClient

    Permalink

    Obtains a RedisNodeClient that currently serves particular hash slot.

    Obtains a RedisNodeClient that currently serves particular hash slot. This is primarily used to execute WATCH-MULTI-EXEC transactions on a Redis Cluster deployment (RedisClusterClient cannot directly execute them). For example:

    import scala.concurrent.duration._
    implicit val actorSystem: ActorSystem = ActorSystem()
    implicit val timeout: Timeout = 10.seconds
    val clusterClient = new RedisClusterClient
    import RedisApi.Batches.StringTyped._
    import scala.concurrent.ExecutionContext.Implicits._
    
    // transactionally divide number stored under "key" by 3
    val transaction: RedisOp[Unit] = for {
      // this causes WATCH and GET to be sent in a single batch
      value <- watch("key") *> get("key").map(_.fold(0)(_.toInt))
      // this causes SET wrapped in a MULTI-EXEC block to be sent
      _ <- set("key", (value / 3).toString).transaction
    } yield ()
    
    val executedTransaction: Future[Unit] =
      clusterClient.initialized.map(_.currentState).flatMap { state =>
        state.clientForSlot(keySlot("key")).executeOp(transaction)
      }

    However, be aware that when executing transactions on node clients obtained from ClusterState, you must manually handle cluster redirections and cluster state changes (NodeRemovedException)

  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  11. val mapping: IndexedSeq[(SlotRange, RedisNodeClient)]

    Permalink

    mapping between slot ranges and node clients that serve them, sorted by slot ranges

  12. val masters: commons.BMap[NodeAddress, RedisNodeClient]

    Permalink

    direct mapping between master addresses and node clients

  13. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  14. val nonClustered: commons.Opt[RedisNodeClient]

    Permalink

    non-empty if there's actually only one, non-clustered Redis node - see fallbackToSingleNode

  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  18. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped