Package akka.cluster.sharding
Class ShardCoordinator
- java.lang.Object
-
- akka.cluster.sharding.ShardCoordinator
-
- All Implemented Interfaces:
Actor
- Direct Known Subclasses:
DDataShardCoordinator
,PersistentShardCoordinator
public abstract class ShardCoordinator extends java.lang.Object implements Actor
Singleton coordinator that decides where to allocate shards.- See Also:
ClusterSharding extension
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ShardCoordinator.AbstractShardAllocationStrategy
Java API: Java implementations of custom shard allocation and rebalancing logic used by theShardCoordinator
should extend this abstract class and implement the two methods.static class
ShardCoordinator.Internal$
INTERNAL APIstatic class
ShardCoordinator.LeastShardAllocationStrategy
The default implementation ofShardCoordinator.LeastShardAllocationStrategy
allocates new shards to theShardRegion
with least number of previously allocated shards.static class
ShardCoordinator.RebalanceWorker
INTERNAL API.static interface
ShardCoordinator.ShardAllocationStrategy
Interface of the pluggable shard allocation and rebalancing logic used by theShardCoordinator
.static interface
ShardCoordinator.StartableAllocationStrategy
Shard allocation strategy where start is called by the shard coordinator before any calls to rebalance or allocate shard.-
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$, Actor.ignoringBehavior$
-
-
Constructor Summary
Constructors Constructor Description ShardCoordinator(ClusterShardingSettings settings, ShardCoordinator.ShardAllocationStrategy allocationStrategy)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
active()
protected void
akka$actor$Actor$_setter_$context_$eq(ActorContext x$1)
Scala API: Stores the context for this actor, including self, and sender.protected void
akka$actor$Actor$_setter_$self_$eq(ActorRef x$1)
The 'self' field holds the ActorRef for this actor.scala.collection.immutable.Set<ActorRef>
aliveRegions()
void
aliveRegions_$eq(scala.collection.immutable.Set<ActorRef> x$1)
void
allocateShardHomesForRememberEntities()
boolean
allRegionsRegistered()
void
allRegionsRegistered_$eq(boolean x$1)
Cluster
cluster()
ActorContext
context()
Scala API: Stores the context for this actor, including self, and sender.void
continueGetShardHome(java.lang.String shard, ActorRef region, ActorRef getShardHomeSender)
void
continueRebalance(scala.collection.immutable.Set<java.lang.String> shards)
scala.collection.immutable.Set<ActorRef>
gracefulShutdownInProgress()
void
gracefulShutdownInProgress_$eq(scala.collection.immutable.Set<ActorRef> x$1)
boolean
handleGetShardHome(java.lang.String shard)
boolean
hasAllRegionsRegistered()
boolean
isMember(ActorRef region)
MarkerLoggingAdapter
log()
int
minMembers()
void
postStop()
User overridable callback.void
preStart()
User overridable callback.static Props
props(java.lang.String typeName, ClusterShardingSettings settings, ShardCoordinator.ShardAllocationStrategy allocationStrategy)
INTERNAL API Factory method for theProps
of theShardCoordinator
actor.static Props
props(java.lang.String typeName, ClusterShardingSettings settings, ShardCoordinator.ShardAllocationStrategy allocationStrategy, ActorRef replicator, int majorityMinCap)
INTERNAL API Factory method for theProps
of theShardCoordinator
actor with state based on ddata.scala.collection.immutable.Map<java.lang.String,scala.collection.immutable.Set<ActorRef>>
rebalanceInProgress()
void
rebalanceInProgress_$eq(scala.collection.immutable.Map<java.lang.String,scala.collection.immutable.Set<ActorRef>> x$1)
Cancellable
rebalanceTask()
static Props
rebalanceWorkerProps(java.lang.String shard, ActorRef from, scala.concurrent.duration.FiniteDuration handOffTimeout, scala.collection.immutable.Set<ActorRef> regions, scala.collection.immutable.Set<ActorRef> shuttingDownRegions)
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
receiveTerminated()
void
regionProxyTerminated(ActorRef ref)
void
regionTerminated(ActorRef ref)
scala.collection.immutable.Set<ActorRef>
regionTerminationInProgress()
void
regionTerminationInProgress_$eq(scala.collection.immutable.Set<ActorRef> x$1)
scala.concurrent.duration.FiniteDuration
removalMargin()
ActorRef
self()
The 'self' field holds the ActorRef for this actor.void
sendHostShardMsg(java.lang.String shard, ActorRef region)
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
shuttingDown()
akka.cluster.sharding.ShardCoordinator.Internal.State
state()
void
state_$eq(akka.cluster.sharding.ShardCoordinator.Internal.State x$1)
void
stateInitialized()
protected abstract java.lang.String
typeName()
scala.collection.immutable.Map<java.lang.String,Cancellable>
unAckedHostShards()
void
unAckedHostShards_$eq(scala.collection.immutable.Map<java.lang.String,Cancellable> x$1)
abstract <E extends akka.cluster.sharding.ShardCoordinator.Internal.DomainEvent>
voidupdate(E evt, scala.Function1<E,scala.runtime.BoxedUnit> f)
void
watchStateActors()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface akka.actor.Actor
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, postRestart, preRestart, receive, sender, supervisorStrategy, unhandled
-
-
-
-
Constructor Detail
-
ShardCoordinator
public ShardCoordinator(ClusterShardingSettings settings, ShardCoordinator.ShardAllocationStrategy allocationStrategy)
-
-
Method Detail
-
props
public static Props props(java.lang.String typeName, ClusterShardingSettings settings, ShardCoordinator.ShardAllocationStrategy allocationStrategy)
INTERNAL API Factory method for theProps
of theShardCoordinator
actor.
-
props
public static Props props(java.lang.String typeName, ClusterShardingSettings settings, ShardCoordinator.ShardAllocationStrategy allocationStrategy, ActorRef replicator, int majorityMinCap)
INTERNAL API Factory method for theProps
of theShardCoordinator
actor with state based on ddata.
-
rebalanceWorkerProps
public static Props rebalanceWorkerProps(java.lang.String shard, ActorRef from, scala.concurrent.duration.FiniteDuration handOffTimeout, scala.collection.immutable.Set<ActorRef> regions, scala.collection.immutable.Set<ActorRef> shuttingDownRegions)
-
context
public ActorContext context()
Description copied from interface:Actor
Scala 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!
ActorContext
is the Scala API.getContext
returns aAbstractActor.ActorContext
, which is the Java API of the actor context.
-
self
public final ActorRef self()
Description copied from interface:Actor
The 'self' field holds the ActorRef for this actor. Can be used to send messages to itself:self ! message
-
akka$actor$Actor$_setter_$context_$eq
protected void akka$actor$Actor$_setter_$context_$eq(ActorContext x$1)
Description copied from interface:Actor
Scala 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!
ActorContext
is the Scala API.getContext
returns aAbstractActor.ActorContext
, which is the Java API of the actor context.- Specified by:
akka$actor$Actor$_setter_$context_$eq
in interfaceActor
-
akka$actor$Actor$_setter_$self_$eq
protected final void akka$actor$Actor$_setter_$self_$eq(ActorRef x$1)
Description copied from interface:Actor
The 'self' field holds the ActorRef for this actor. Can be used to send messages to itself:self ! message
- Specified by:
akka$actor$Actor$_setter_$self_$eq
in interfaceActor
-
log
public MarkerLoggingAdapter log()
-
cluster
public Cluster 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 akka.cluster.sharding.ShardCoordinator.Internal.State state()
-
state_$eq
public void state_$eq(akka.cluster.sharding.ShardCoordinator.Internal.State x$1)
-
rebalanceInProgress
public scala.collection.immutable.Map<java.lang.String,scala.collection.immutable.Set<ActorRef>> rebalanceInProgress()
-
rebalanceInProgress_$eq
public void rebalanceInProgress_$eq(scala.collection.immutable.Map<java.lang.String,scala.collection.immutable.Set<ActorRef>> x$1)
-
unAckedHostShards
public scala.collection.immutable.Map<java.lang.String,Cancellable> unAckedHostShards()
-
unAckedHostShards_$eq
public void unAckedHostShards_$eq(scala.collection.immutable.Map<java.lang.String,Cancellable> x$1)
-
gracefulShutdownInProgress
public scala.collection.immutable.Set<ActorRef> gracefulShutdownInProgress()
-
gracefulShutdownInProgress_$eq
public void gracefulShutdownInProgress_$eq(scala.collection.immutable.Set<ActorRef> x$1)
-
aliveRegions
public scala.collection.immutable.Set<ActorRef> aliveRegions()
-
aliveRegions_$eq
public void aliveRegions_$eq(scala.collection.immutable.Set<ActorRef> x$1)
-
regionTerminationInProgress
public scala.collection.immutable.Set<ActorRef> regionTerminationInProgress()
-
regionTerminationInProgress_$eq
public void regionTerminationInProgress_$eq(scala.collection.immutable.Set<ActorRef> x$1)
-
rebalanceTask
public Cancellable rebalanceTask()
-
typeName
protected abstract java.lang.String typeName()
-
preStart
public void preStart()
Description copied from interface:Actor
User 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:Actor
User overridable callback. Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation.
-
isMember
public boolean isMember(ActorRef region)
-
active
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> active()
-
handleGetShardHome
public boolean handleGetShardHome(java.lang.String shard)
- Returns:
true
if the message could be handled without state update, i.e. the shard location was known or the request was deferred or ignored
-
receiveTerminated
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveTerminated()
-
update
public abstract <E extends akka.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
public void regionTerminated(ActorRef ref)
-
regionProxyTerminated
public void regionProxyTerminated(ActorRef ref)
-
shuttingDown
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> shuttingDown()
-
sendHostShardMsg
public void sendHostShardMsg(java.lang.String shard, ActorRef region)
-
allocateShardHomesForRememberEntities
public void allocateShardHomesForRememberEntities()
-
continueGetShardHome
public void continueGetShardHome(java.lang.String shard, ActorRef region, ActorRef getShardHomeSender)
-
continueRebalance
public void continueRebalance(scala.collection.immutable.Set<java.lang.String> shards)
-
-