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
rememberEntitiesis 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 voidakka$actor$StashSupport$_setter_$mailbox_$eq(DequeBasedMessageQueueSemantics x$1)protected voidakka$cluster$sharding$RememberingShard$_setter_$rememberedEntitiesRecoveryStrategy_$eq(EntityRecoveryStrategy x$1)protected ActorRefjournal()java.lang.StringjournalPluginId()Configuration id of the journal plugin servicing this persistent actor.DequeBasedMessageQueueSemanticsmailbox()voidonLeaseAcquired()java.lang.StringpersistenceId()Id of the persistent entity for which messages should be replayed.voidpreStart()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 EntityRecoveryStrategyrememberedEntitiesRecoveryStrategy()voidsaveSnapshotWhenNeeded()ClusterShardingSettingssettings()java.lang.StringsnapshotPluginId()Configuration id of the snapshot plugin servicing this persistent actor.protected ActorRefsnapshotStore()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_$eqin 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_$eqin interfaceRememberingShard
-
journal
protected ActorRef journal()
- Specified by:
journalin interfaceEventsourced
-
journalPluginId
public java.lang.String journalPluginId()
Description copied from interface:PersistenceIdentityConfiguration id of the journal plugin servicing this persistent actor. When empty, looks inakka.persistence.journal.pluginto find configuration entry path. When configured, usesjournalPluginIdas absolute path to the journal configuration entry. Configuration entry must contain few required fields, such asclass. Seesrc/main/resources/reference.conf.- Specified by:
journalPluginIdin interfacePersistenceIdentity- Returns:
- (undocumented)
-
mailbox
public DequeBasedMessageQueueSemantics mailbox()
- Specified by:
mailboxin interfaceStashSupport
-
onLeaseAcquired
public void onLeaseAcquired()
- Overrides:
onLeaseAcquiredin classShard
-
persistenceId
public java.lang.String persistenceId()
Description copied from interface:PersistenceIdentityId of the persistent entity for which messages should be replayed.- Specified by:
persistenceIdin interfacePersistenceIdentity- Returns:
- (undocumented)
-
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.
-
processChange
public <E extends Shard.StateChange> void processChange(E event, scala.Function1<E,scala.runtime.BoxedUnit> handler)
- Overrides:
processChangein classShard
-
receive
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
Description copied from interface:ActorScala 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:EventsourcedCommand 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:
receiveCommandin interfaceEventsourced- Overrides:
receiveCommandin classShard- Returns:
- (undocumented)
-
receiveRecover
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receiveRecover()
Description copied from interface:EventsourcedRecovery handler that receives persisted events during recovery. If a state snapshot has been captured and saved, this handler will receive aSnapshotOffermessage 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:
receiveRecoverin interfaceEventsourced- Returns:
- (undocumented)
- See Also:
Recovery
-
rememberedEntitiesRecoveryStrategy
protected EntityRecoveryStrategy rememberedEntitiesRecoveryStrategy()
- Specified by:
rememberedEntitiesRecoveryStrategyin interfaceRememberingShard
-
saveSnapshotWhenNeeded
public void saveSnapshotWhenNeeded()
-
settings
public ClusterShardingSettings settings()
- Specified by:
settingsin interfaceRememberingShard
-
snapshotPluginId
public java.lang.String snapshotPluginId()
Description copied from interface:PersistenceIdentityConfiguration id of the snapshot plugin servicing this persistent actor. When empty, looks inakka.persistence.snapshot-store.pluginto find configuration entry path. When configured, usessnapshotPluginIdas absolute path to the snapshot store configuration entry. Configuration entry must contain few required fields, such asclass. Seesrc/main/resources/reference.conf.- Specified by:
snapshotPluginIdin interfacePersistenceIdentity- Returns:
- (undocumented)
-
snapshotStore
protected ActorRef snapshotStore()
Description copied from interface:SnapshotterSnapshot store plugin actor.- Specified by:
snapshotStorein interfaceEventsourced- Specified by:
snapshotStorein interfaceSnapshotter
-
-