Class ShardCoordinator
- Direct Known Subclasses:
PersistentShardCoordinator
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classJava API: Java implementations of custom shard allocation and rebalancing logic used by theShardCoordinatorshould extend this abstract class and implement the two methods.static interfaceShard allocation strategy where start is called by the shard coordinator before any calls to rebalance or allocate shard.static classINTERNAL APIstatic classUsepekko.cluster.sharding.ShardCoordinator.ShardAllocationStrategy.leastShardAllocationStrategyinstead.static classstatic interfaceInterface of the pluggable shard allocation and rebalancing logic used by theShardCoordinator.static classstatic interfaceShard allocation strategy where start is called by the shard coordinator before any calls to rebalance or allocate shard.Nested classes/interfaces inherited from interface org.apache.pekko.actor.Actor
Actor.emptyBehavior$, Actor.ignoringBehavior$ -
Constructor Summary
ConstructorsConstructorDescriptionShardCoordinator(ClusterShardingSettings settings, ShardCoordinator.ShardAllocationStrategy allocationStrategy) -
Method Summary
Modifier and TypeMethodDescriptionscala.PartialFunction<Object,scala.runtime.BoxedUnit> active()scala.collection.immutable.Set<ActorRef>voidaliveRegions_$eq(scala.collection.immutable.Set<ActorRef> x$1) voidbooleanvoidallRegionsRegistered_$eq(boolean x$1) cluster()context()Scala API: Stores the context for this actor, including self, and sender.voidcontinueGetShardHome(String shard, ActorRef region, ActorRef getShardHomeSender) voidcontinueRebalance(scala.collection.immutable.Set<String> shards) scala.collection.immutable.Set<ActorRef>voidgracefulShutdownInProgress_$eq(scala.collection.immutable.Set<ActorRef> x$1) booleanhandleGetShardHome(String shard) booleanbooleanleastShardAllocationStrategy(int absoluteLimit, double relativeLimit) Java API:ShardAllocationStrategythat allocates new shards to theShardRegion(node) with least number of previously allocated shards.log()intprotected voidScala API: Stores the context for this actor, including self, and sender.protected final voidThe 'self' field holds the ActorRef for this actor.voidpostStop()User overridable callback.booleanvoidpreparingForShutdown_$eq(boolean x$1) voidpreStart()User overridable callback.voidrebalanceInProgress_$eq(scala.collection.immutable.Map<String, scala.collection.immutable.Set<ActorRef>> x$1) scala.collection.immutable.Set<ActorRef>voidrebalanceWorkers_$eq(scala.collection.immutable.Set<ActorRef> x$1) scala.PartialFunction<Object,scala.runtime.BoxedUnit> voidvoidregionTerminated(ActorRef ref) scala.collection.immutable.Set<ActorRef>voidregionTerminationInProgress_$eq(scala.collection.immutable.Set<ActorRef> x$1) scala.concurrent.duration.FiniteDurationfinal ActorRefself()The 'self' field holds the ActorRef for this actor.voidsendHostShardMsg(String shard, ActorRef region) voidshutdownShards(ActorRef shuttingDownRegion, scala.collection.immutable.Set<String> shards) scala.PartialFunction<Object,scala.runtime.BoxedUnit> org.apache.pekko.cluster.sharding.ShardCoordinator.Internal.Statestate()voidstate_$eq(org.apache.pekko.cluster.sharding.ShardCoordinator.Internal.State x$1) voidprotected abstract StringtypeName()scala.collection.immutable.Map<String,Cancellable> voidunAckedHostShards_$eq(scala.collection.immutable.Map<String, Cancellable> x$1) protected abstract voidabstract <E extends org.apache.pekko.cluster.sharding.ShardCoordinator.Internal.DomainEvent>
voidupdate(E evt, scala.Function1<E, scala.runtime.BoxedUnit> f) booleanvoidwaitingForLocalRegionToTerminate_$eq(boolean x$1) voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.pekko.actor.Actor
aroundPostRestart, aroundPreStart, postRestart, preRestart, receive, sender, supervisorStrategy, unhandledMethods inherited from interface org.apache.pekko.actor.Timers
actorCell, aroundPostStop, aroundPreRestart, aroundReceive, super$aroundPostStop, super$aroundPreRestart, super$aroundReceive, timers
-
Constructor Details
-
ShardCoordinator
public ShardCoordinator(ClusterShardingSettings settings, ShardCoordinator.ShardAllocationStrategy allocationStrategy)
-
-
Method Details
-
leastShardAllocationStrategy
public static ShardCoordinator.ShardAllocationStrategy leastShardAllocationStrategy(int absoluteLimit, double relativeLimit) Java API:ShardAllocationStrategythat allocates new shards to theShardRegion(node) with least number of previously allocated shards.When a node is added to the cluster the shards on the existing nodes will be rebalanced to the new node. The
LeastShardAllocationStrategypicks shards for rebalancing from theShardRegions with most number of previously allocated shards. They will then be allocated to theShardRegionwith least number of previously allocated shards, i.e. new members in the cluster. The amount of shards to rebalance in each round can be limited to make it progress slower since rebalancing too many shards at the same time could result in additional load on the system. For example, causing many Event Sourced entities to be started at the same time.It will not rebalance when there is already an ongoing rebalance in progress.
- Parameters:
absoluteLimit- the maximum number of shards that will be rebalanced in one rebalance roundrelativeLimit- fraction (< 1.0) of total number of (known) shards that will be rebalanced in one rebalance round
-
context
Description copied from interface:ActorScala API: Stores the context for this actor, including self, and sender. It is implicit to support operations such asforward.WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!
pekko.actor.ActorContextis the Scala API.getContextreturns apekko.actor.AbstractActor.ActorContext, which is the Java API of the actor context. -
self
Description copied from interface:ActorThe 'self' field holds the ActorRef for this actor. Can be used to send messages to itself:self ! message
-
org$apache$pekko$actor$Actor$_setter_$context_$eq
Description copied from interface:ActorScala API: Stores the context for this actor, including self, and sender. It is implicit to support operations such asforward.WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!
pekko.actor.ActorContextis the Scala API.getContextreturns apekko.actor.AbstractActor.ActorContext, which is the Java API of the actor context.- Specified by:
org$apache$pekko$actor$Actor$_setter_$context_$eqin interfaceActor
-
org$apache$pekko$actor$Actor$_setter_$self_$eq
Description copied from interface:ActorThe 'self' field holds the ActorRef for this actor. Can be used to send messages to itself:self ! message
- Specified by:
org$apache$pekko$actor$Actor$_setter_$self_$eqin interfaceActor
-
log
-
cluster
-
removalMargin
public scala.concurrent.duration.FiniteDuration removalMargin() -
minMembers
public int minMembers() -
allRegionsRegistered
public boolean allRegionsRegistered() -
allRegionsRegistered_$eq
public void allRegionsRegistered_$eq(boolean x$1) -
state
public org.apache.pekko.cluster.sharding.ShardCoordinator.Internal.State state() -
state_$eq
public void state_$eq(org.apache.pekko.cluster.sharding.ShardCoordinator.Internal.State x$1) -
preparingForShutdown
public boolean preparingForShutdown() -
preparingForShutdown_$eq
public void preparingForShutdown_$eq(boolean x$1) -
rebalanceInProgress
-
rebalanceInProgress_$eq
-
rebalanceWorkers
-
rebalanceWorkers_$eq
-
unAckedHostShards
-
unAckedHostShards_$eq
-
gracefulShutdownInProgress
-
gracefulShutdownInProgress_$eq
-
waitingForLocalRegionToTerminate
public boolean waitingForLocalRegionToTerminate() -
waitingForLocalRegionToTerminate_$eq
public void waitingForLocalRegionToTerminate_$eq(boolean x$1) -
aliveRegions
-
aliveRegions_$eq
-
regionTerminationInProgress
-
regionTerminationInProgress_$eq
-
typeName
-
preStart
public void preStart()Description copied from interface:ActorUser overridable callback. Is called when an Actor is started. Actors are automatically started asynchronously when created. Empty default implementation. -
postStop
public void postStop()Description copied from interface:ActorUser overridable callback. Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation. -
isMember
-
active
-
handleGetShardHome
- Returns:
trueif the message could be handled without state update, i.e. the shard location was known or the request was deferred or ignored
-
receiveTerminated
-
update
public abstract <E extends org.apache.pekko.cluster.sharding.ShardCoordinator.Internal.DomainEvent> void update(E evt, scala.Function1<E, scala.runtime.BoxedUnit> f) -
watchStateActors
public void watchStateActors() -
stateInitialized
public void stateInitialized() -
hasAllRegionsRegistered
public boolean hasAllRegionsRegistered() -
regionTerminated
-
regionProxyTerminated
-
shuttingDown
-
sendHostShardMsg
-
allocateShardHomesForRememberEntities
public void allocateShardHomesForRememberEntities() -
continueGetShardHome
-
unstashOneGetShardHomeRequest
protected abstract void unstashOneGetShardHomeRequest() -
continueRebalance
-
shutdownShards
-