Package akka.cluster.sharding
Class PersistentShard
- java.lang.Object
-
- akka.cluster.sharding.Shard
-
- akka.cluster.sharding.PersistentShard
-
- All Implemented Interfaces:
Actor
,ActorLogging
,Stash
,StashFactory
,StashSupport
,Timers
,UnrestrictedStash
,RememberingShard
,RequiresMessageQueue<DequeBasedMessageQueueSemantics>
,Eventsourced
,PersistenceIdentity
,PersistenceRecovery
,PersistenceStash
,PersistentActor
,Snapshotter
public class PersistentShard extends Shard implements RememberingShard, PersistentActor, ActorLogging
INTERNAL APIThis actor creates children entity actors on demand that it is told to be responsible for. It is used when
rememberEntities
is enabled andstate-store-mode=persistence
.- See Also:
ClusterSharding extension
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class akka.cluster.sharding.Shard
Shard.CurrentShardState, Shard.CurrentShardState$, Shard.EntityStarted, Shard.EntityStarted$, Shard.EntityStopped, Shard.EntityStopped$, Shard.GetCurrentShardState$, Shard.GetShardStats$, Shard.LeaseAcquireResult, Shard.LeaseAcquireResult$, Shard.LeaseLost, Shard.LeaseLost$, Shard.LeaseRetry$, Shard.PassivateIdleTick$, Shard.RestartEntities, Shard.RestartEntities$, Shard.RestartEntity, Shard.RestartEntity$, Shard.ShardCommand, Shard.ShardQuery, Shard.ShardStats, Shard.ShardStats$, Shard.State, Shard.State$, Shard.StateChange
-
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$, Actor.ignoringBehavior$
-
Nested classes/interfaces inherited from interface akka.persistence.Eventsourced
Eventsourced.AsyncHandlerInvocation, Eventsourced.AsyncHandlerInvocation$, Eventsourced.PendingHandlerInvocation, Eventsourced.RecoveryTick, Eventsourced.RecoveryTick$, Eventsourced.StashingHandlerInvocation, Eventsourced.StashingHandlerInvocation$, Eventsourced.State
-
-
Constructor Summary
Constructors Constructor Description PersistentShard(java.lang.String typeName, java.lang.String shardId, scala.Function1<java.lang.String,Props> entityProps, ClusterShardingSettings settings, scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> extractEntityId, scala.Function1<java.lang.Object,java.lang.String> extractShardId, java.lang.Object handOffStopMessage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
akka$actor$StashSupport$_setter_$mailbox_$eq(DequeBasedMessageQueueSemantics x$1)
protected void
akka$cluster$sharding$RememberingShard$_setter_$rememberedEntitiesRecoveryStrategy_$eq(EntityRecoveryStrategy x$1)
protected ActorRef
journal()
java.lang.String
journalPluginId()
Configuration id of the journal plugin servicing this persistent actor.DequeBasedMessageQueueSemantics
mailbox()
void
onLeaseAcquired()
java.lang.String
persistenceId()
Id of the persistent entity for which messages should be replayed.void
preStart()
User overridable callback.<E extends Shard.StateChange>
voidprocessChange(E event, scala.Function1<E,scala.runtime.BoxedUnit> handler)
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
receive()
Scala API: This defines the initial actor behavior, it must return a partial function with the actor logic.scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
receiveCommand()
Command handler.scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
receiveRecover()
Recovery handler that receives persisted events during recovery.protected EntityRecoveryStrategy
rememberedEntitiesRecoveryStrategy()
void
saveSnapshotWhenNeeded()
ClusterShardingSettings
settings()
java.lang.String
snapshotPluginId()
Configuration id of the snapshot plugin servicing this persistent actor.protected ActorRef
snapshotStore()
Snapshot store plugin actor.-
Methods inherited from class akka.cluster.sharding.Shard
acquireLeaseIfNeeded, akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, appendToMessageBuffer, context, deliverMessage, deliverTo, entityTerminated, getOrCreateEntity, getOrCreateEntity$default$2, idByRef, idByRef_$eq, lastMessageTimestamp, lastMessageTimestamp_$eq, messageBuffers, passivateCompleted, passivateIdleTask, passivating, passivating_$eq, postStop, props, receiveLeaseLost, receiveShardQuery, refById, refById_$eq, self, sendMsgBuffer, state, state_$eq, touchLastMessageTimestamp
-
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
akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, context, postRestart, self, sender, supervisorStrategy
-
Methods inherited from interface akka.actor.ActorLogging
_log_$eq, log
-
Methods inherited from interface akka.persistence.Eventsourced
_lastSequenceNr_$eq, aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, batchAtomicWrite, changeState, currentState_$eq, deleteMessages, eventBatch_$eq, flushBatch, flushJournalBatch, internalDefer, internalDeferAsync, internalDeleteMessagesBeforeSnapshot, internalPersist, internalPersistAll, internalPersistAllAsync, internalPersistAsync, journalBatch_$eq, lastSequenceNr, log, nextSequenceNr, onPersistFailure, onPersistRejected, onRecoveryFailure, onReplaySuccess, peekApplyHandler, pendingStashingPersistInvocations_$eq, recovering, recoveryFinished, recoveryRunning, recoveryStarted, requestRecoveryPermit, sendBatchedEventsToJournal, sequenceNr_$eq, setLastSequenceNr, snapshotSequenceNr, snapshotterId, startRecovery, stash, stashInternally, super$aroundPostRestart, super$aroundPostStop, super$aroundPreRestart, super$aroundPreStart, super$aroundReceive, super$stash, super$unhandled, unhandled, unstashAll, unstashInternally, updateLastSequenceNr, waitingRecoveryPermit, writeEventFailed, writeEventRejected, writeEventSucceeded, writeInProgress_$eq
-
Methods inherited from interface akka.persistence.PersistenceRecovery
recovery
-
Methods inherited from interface akka.persistence.PersistenceStash
internalStashOverflowStrategy
-
Methods inherited from interface akka.persistence.PersistentActor
defer, deferAsync, persist, persistAll, persistAllAsync, persistAsync
-
Methods inherited from interface akka.cluster.sharding.RememberingShard
deliverTo, entityTerminated, restartRememberedEntities
-
Methods inherited from interface akka.persistence.Snapshotter
deleteSnapshot, deleteSnapshots, loadSnapshot, saveSnapshot
-
Methods inherited from interface akka.actor.StashFactory
createStash
-
Methods inherited from interface akka.actor.StashSupport
actorCell, clearStash, context, enqueueFirst, prepend, self, theStash_$eq, unstash, unstashAll
-
Methods inherited from interface akka.actor.Timers
actorCell, aroundPostStop, aroundPreRestart, aroundReceive, super$aroundPostStop, super$aroundPreRestart, super$aroundReceive, timers
-
Methods inherited from interface akka.actor.UnrestrictedStash
postStop, preRestart, super$postStop, super$preRestart
-
-
-
-
Constructor Detail
-
PersistentShard
public PersistentShard(java.lang.String typeName, java.lang.String shardId, scala.Function1<java.lang.String,Props> entityProps, ClusterShardingSettings settings, scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> extractEntityId, scala.Function1<java.lang.Object,java.lang.String> extractShardId, java.lang.Object handOffStopMessage)
-
-
Method Detail
-
akka$actor$StashSupport$_setter_$mailbox_$eq
protected void akka$actor$StashSupport$_setter_$mailbox_$eq(DequeBasedMessageQueueSemantics x$1)
- Specified by:
akka$actor$StashSupport$_setter_$mailbox_$eq
in interfaceStashSupport
-
akka$cluster$sharding$RememberingShard$_setter_$rememberedEntitiesRecoveryStrategy_$eq
protected void akka$cluster$sharding$RememberingShard$_setter_$rememberedEntitiesRecoveryStrategy_$eq(EntityRecoveryStrategy x$1)
- Specified by:
akka$cluster$sharding$RememberingShard$_setter_$rememberedEntitiesRecoveryStrategy_$eq
in interfaceRememberingShard
-
journal
protected ActorRef journal()
- Specified by:
journal
in interfaceEventsourced
-
journalPluginId
public java.lang.String journalPluginId()
Description copied from interface:PersistenceIdentity
Configuration id of the journal plugin servicing this persistent actor. When empty, looks inakka.persistence.journal.plugin
to find configuration entry path. When configured, usesjournalPluginId
as absolute path to the journal configuration entry. Configuration entry must contain few required fields, such asclass
. Seesrc/main/resources/reference.conf
.- Specified by:
journalPluginId
in interfacePersistenceIdentity
- Returns:
- (undocumented)
-
mailbox
public DequeBasedMessageQueueSemantics mailbox()
- Specified by:
mailbox
in interfaceStashSupport
-
onLeaseAcquired
public void onLeaseAcquired()
- Overrides:
onLeaseAcquired
in classShard
-
persistenceId
public java.lang.String persistenceId()
Description copied from interface:PersistenceIdentity
Id of the persistent entity for which messages should be replayed.- Specified by:
persistenceId
in interfacePersistenceIdentity
- Returns:
- (undocumented)
-
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.
-
processChange
public <E extends Shard.StateChange> void processChange(E event, scala.Function1<E,scala.runtime.BoxedUnit> handler)
- Overrides:
processChange
in classShard
-
receive
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
Description copied from interface:Actor
Scala API: This defines the initial actor behavior, it must return a partial function with the actor logic.
-
receiveCommand
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveCommand()
Description copied from interface:Eventsourced
Command handler. Typically validates commands against current state (and/or by communication with other actors). On successful validation, one or more events are derived from a command and these events are then persisted by callingpersist
.- Specified by:
receiveCommand
in interfaceEventsourced
- Overrides:
receiveCommand
in classShard
- Returns:
- (undocumented)
-
receiveRecover
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveRecover()
Description copied from interface:Eventsourced
Recovery handler that receives persisted events during recovery. If a state snapshot has been captured and saved, this handler will receive aSnapshotOffer
message followed by events that are younger than the offered snapshot.This handler must not have side-effects other than changing persistent actor state i.e. it should not perform actions that may fail, such as interacting with external services, for example.
If there is a problem with recovering the state of the actor from the journal, the error will be logged and the actor will be stopped.
- Specified by:
receiveRecover
in interfaceEventsourced
- Returns:
- (undocumented)
- See Also:
Recovery
-
rememberedEntitiesRecoveryStrategy
protected EntityRecoveryStrategy rememberedEntitiesRecoveryStrategy()
- Specified by:
rememberedEntitiesRecoveryStrategy
in interfaceRememberingShard
-
saveSnapshotWhenNeeded
public void saveSnapshotWhenNeeded()
-
settings
public ClusterShardingSettings settings()
- Specified by:
settings
in interfaceRememberingShard
-
snapshotPluginId
public java.lang.String snapshotPluginId()
Description copied from interface:PersistenceIdentity
Configuration id of the snapshot plugin servicing this persistent actor. When empty, looks inakka.persistence.snapshot-store.plugin
to find configuration entry path. When configured, usessnapshotPluginId
as absolute path to the snapshot store configuration entry. Configuration entry must contain few required fields, such asclass
. Seesrc/main/resources/reference.conf
.- Specified by:
snapshotPluginId
in interfacePersistenceIdentity
- Returns:
- (undocumented)
-
snapshotStore
protected ActorRef snapshotStore()
Description copied from interface:Snapshotter
Snapshot store plugin actor.- Specified by:
snapshotStore
in interfaceEventsourced
- Specified by:
snapshotStore
in interfaceSnapshotter
-
-