akka.contrib.pattern
Class ShardCoordinator

java.lang.Object
  extended by akka.contrib.pattern.ShardCoordinator
All Implemented Interfaces:
Actor, ActorLogging, Stash, StashFactory, StashSupport, UnrestrictedStash, RequiresMessageQueue<DequeBasedMessageQueueSemantics>, Eventsourced, PersistentActor, ProcessorImpl, Recovery, Snapshotter

public class ShardCoordinator
extends java.lang.Object
implements PersistentActor, ActorLogging

Singleton coordinator that decides where to allocate shards.

See Also:
ClusterSharding extension

Nested Class Summary
static class ShardCoordinator.AbstractShardAllocationStrategy
          Java API: Java implementations of custom shard allocation and rebalancing logic used by the ShardCoordinator should extend this abstract class and implement the two methods.
static class ShardCoordinator.Internal$
          INTERNAL API
static class ShardCoordinator.LeastShardAllocationStrategy
          The default implementation of ShardCoordinator.LeastShardAllocationStrategy allocates new shards to the ShardRegion 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 the ShardCoordinator.
 
Nested classes/interfaces inherited from interface akka.persistence.Eventsourced
Eventsourced.PendingHandlerInvocation
 
Nested classes/interfaces inherited from interface akka.persistence.Recovery
Recovery.State
 
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$
 
Constructor Summary
ShardCoordinator(scala.concurrent.duration.FiniteDuration handOffTimeout, scala.concurrent.duration.FiniteDuration rebalanceInterval, scala.concurrent.duration.FiniteDuration snapshotInterval, ShardCoordinator.ShardAllocationStrategy allocationStrategy)
           
 
Method Summary
 java.lang.String persistenceId()
          Id of the persistent entity for which messages should be replayed.
 akka.contrib.pattern.ShardCoordinator.Internal.State persistentState()
           
 void postStop()
          User overridable callback.
static Props props(scala.concurrent.duration.FiniteDuration handOffTimeout, scala.concurrent.duration.FiniteDuration rebalanceInterval, scala.concurrent.duration.FiniteDuration snapshotInterval, ShardCoordinator.ShardAllocationStrategy allocationStrategy)
          Factory method for the Props of the ShardCoordinator actor.
 scala.collection.immutable.Set<java.lang.String> rebalanceInProgress()
           
 Cancellable rebalanceTask()
           
 scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveCommand()
           
 scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveRecover()
           
 scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> shuttingDown()
           
 Cancellable snapshotTask()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface akka.persistence.PersistentActor
receive
 
Methods inherited from interface akka.persistence.Eventsourced
aroundPreRestart, aroundReceive, currentState, defer, defer, flushBatch, initialBehavior, pendingInvocations, pendingStashingPersistInvocations, persist, persist, persistAsync, persistAsync, persistingEvents, preRestart, processingCommands, processorStash, recovering, recoveryBehavior, resequenceableEventBatch, unstashAll, useProcessorBatching
 
Methods inherited from interface akka.persistence.ProcessorImpl
_persistenceId, aroundPostStop, aroundPreStart, deleteMessage, deleteMessage, deleteMessages, deleteMessages, flushJournalBatch, initializing, instanceId, nextSequenceNr, onRecoveryCompleted, onRecoveryFailure, onReplayFailure, onReplaySuccess, preRestartDefault, preStart, processing, processorBatch, processorId, recoveryFinished, recoveryRunning, sequenceNr, snapshotterId, unhandled, unstashFilterPredicate
 
Methods inherited from interface akka.persistence.Recovery
_currentPersistent, _currentState, _lastSequenceNr, _recoveryFailureCause, _recoveryFailureMessage, currentPersistentMessage, extension, getCurrentPersistentMessage, journal, lastSequenceNr, prepareRestart, receiverStash, recoveryPending, recoveryStarted, replayFailed, replayStarted, runReceive, snapshotSequenceNr, updateLastSequenceNr, updateLastSequenceNr, withCurrentPersistent
 
Methods inherited from interface akka.persistence.Snapshotter
deleteSnapshot, deleteSnapshots, loadSnapshot, saveSnapshot, snapshotStore
 
Methods inherited from interface akka.actor.Actor
aroundPostRestart, context, postRestart, self, sender, supervisorStrategy
 
Methods inherited from interface akka.actor.StashSupport
actorCell, capacity, clearStash, context, enqueueFirst, mailbox, prepend, self, stash, theStash, unstash, unstashAll
 
Methods inherited from interface akka.actor.StashFactory
createStash
 
Methods inherited from interface akka.actor.ActorLogging
_log, log
 

Constructor Detail

ShardCoordinator

public ShardCoordinator(scala.concurrent.duration.FiniteDuration handOffTimeout,
                        scala.concurrent.duration.FiniteDuration rebalanceInterval,
                        scala.concurrent.duration.FiniteDuration snapshotInterval,
                        ShardCoordinator.ShardAllocationStrategy allocationStrategy)
Method Detail

props

public static Props props(scala.concurrent.duration.FiniteDuration handOffTimeout,
                          scala.concurrent.duration.FiniteDuration rebalanceInterval,
                          scala.concurrent.duration.FiniteDuration snapshotInterval,
                          ShardCoordinator.ShardAllocationStrategy allocationStrategy)
Factory method for the Props of the ShardCoordinator actor.

Parameters:
handOffTimeout - (undocumented)
rebalanceInterval - (undocumented)
snapshotInterval - (undocumented)
allocationStrategy - (undocumented)
Returns:
(undocumented)

persistenceId

public java.lang.String persistenceId()
Description copied from interface: Recovery
Id of the persistent entity for which messages should be replayed.

Specified by:
persistenceId in interface Recovery
Returns:
(undocumented)

persistentState

public akka.contrib.pattern.ShardCoordinator.Internal.State persistentState()

rebalanceInProgress

public scala.collection.immutable.Set<java.lang.String> rebalanceInProgress()

rebalanceTask

public Cancellable rebalanceTask()

snapshotTask

public Cancellable snapshotTask()

postStop

public void postStop()
Description copied from interface: Actor
User overridable callback.

Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation.

Specified by:
postStop in interface Actor
Specified by:
postStop in interface UnrestrictedStash
Specified by:
postStop in interface Eventsourced

receiveRecover

public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveRecover()
Specified by:
receiveRecover in interface Eventsourced

receiveCommand

public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveCommand()
Specified by:
receiveCommand in interface Eventsourced

shuttingDown

public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> shuttingDown()