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
- Alphabetic
- By Inheritance
- ClusterState
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
ClusterState(mapping: IndexedSeq[(SlotRange, RedisNodeClient)], masters: commons.BMap[NodeAddress, RedisNodeClient], nonClustered: commons.Opt[RedisNodeClient] = Opt.Empty)
- 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
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clientForSlot(slot: Int): RedisNodeClient
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)
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val mapping: IndexedSeq[(SlotRange, RedisNodeClient)]
- val masters: commons.BMap[NodeAddress, RedisNodeClient]
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- val nonClustered: commons.Opt[RedisNodeClient]
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )