|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PersistentView
A view replicates the persistent message stream of a PersistentActor
. Implementation classes receive
the message stream directly from the Journal. These messages can be processed to update internal state
in order to maintain an (eventual consistent) view of the state of the corresponding persistent actor. A
persistent view can also run on a different node, provided that a replicated journal is used.
Implementation classes refer to a persistent actors' message stream by implementing persistenceId
with the corresponding (shared) identifier value.
Views can also store snapshots of internal state by calling autoUpdate
. The snapshots of a view
are independent of those of the referenced persistent actor. During recovery, a saved snapshot is offered
to the view with a SnapshotOffer
message, followed by replayed messages, if any, that are younger
than the snapshot. Default is to offer the latest saved snapshot.
By default, a view automatically updates itself with an interval returned by autoUpdateInterval
.
This method can be overridden by implementation classes to define a view instance-specific update
interval. The default update interval for all views of an actor system can be configured with the
akka.persistence.view.auto-update-interval
configuration key. Applications may trigger additional
view updates by sending the view Update
requests. See also methods
- autoUpdate
for turning automated updates on or off
- autoUpdateReplayMax
for limiting the number of replayed messages per view update cycle
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface akka.persistence.Recovery |
---|
Recovery.State |
Nested classes/interfaces inherited from interface akka.actor.Actor |
---|
Actor.emptyBehavior$ |
Method Summary | |
---|---|
boolean |
autoUpdate()
If true , this view automatically updates itself with an interval specified by autoUpdateInterval . |
scala.concurrent.duration.FiniteDuration |
autoUpdateInterval()
The interval for automated updates. |
long |
autoUpdateReplayMax()
The maximum number of messages to replay per update. |
Recovery.State |
idle()
When receiving an Update request, switches to replayStarted state and triggers
an incremental message replay. |
boolean |
isPersistent()
If true , the currently processed message was persisted (is sent from the Journal). |
void |
onReplayComplete(boolean await)
Switches to idle state and schedules the next update if autoUpdate returns true . |
void |
onReplayFailure(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive,
boolean await,
java.lang.Throwable cause)
INTERNAL API. |
void |
onReplaySuccess(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive,
boolean await)
INTERNAL API. |
void |
postStop()
User overridable callback. |
void |
preRestart(java.lang.Throwable reason,
scala.Option<java.lang.Object> message)
User overridable callback: '''By default it disposes of all children and then calls postStop() .''' |
void |
preStart()
Triggers an initial recovery, starting form a snapshot, if any, and replaying at most autoUpdateReplayMax
messages (following that snapshot). |
java.lang.Object |
replayStarted(boolean await)
INTERNAL API. |
void |
runReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive,
Persistent msg)
INTERNAL API WARNING: This implementation UNWRAPS PERSISTENT() before delivering to the receive block. |
scala.Option<Cancellable> |
schedule()
|
java.lang.String |
snapshotterId()
Returns viewId . |
java.lang.String |
viewId()
View id is used as identifier for snapshots performed by this PersistentView . |
akka.persistence.PersistenceSettings.view$ |
viewSettings()
|
Methods inherited from interface akka.persistence.Recovery |
---|
_currentPersistent, _currentState, _lastSequenceNr, _recoveryFailureCause, _recoveryFailureMessage, aroundReceive, currentPersistentMessage, extension, getCurrentPersistentMessage, journal, lastSequenceNr, persistenceId, prepareRestart, processorId, receiverStash, recoveryPending, recoveryStarted, replayFailed, snapshotSequenceNr, updateLastSequenceNr, updateLastSequenceNr, withCurrentPersistent |
Methods inherited from interface akka.persistence.Snapshotter |
---|
deleteSnapshot, deleteSnapshots, loadSnapshot, saveSnapshot, snapshotStore |
Methods inherited from interface akka.actor.Actor |
---|
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, context, postRestart, receive, self, sender, supervisorStrategy, unhandled |
Methods inherited from interface akka.actor.StashSupport |
---|
actorCell, capacity, clearStash, context, enqueueFirst, mailbox, prepend, self, stash, theStash, unstash, unstashAll, unstashAll |
Methods inherited from interface akka.actor.StashFactory |
---|
createStash |
Method Detail |
---|
java.lang.Object replayStarted(boolean await)
Extends the replayStarted
state of Recovery
with logic to handle Update
requests
sent by users.
replayStarted
in interface Recovery
await
- (undocumented)
Recovery.State idle()
Update
request, switches to replayStarted
state and triggers
an incremental message replay. Invokes the actor's current behavior for any other
received message.
void onReplaySuccess(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive, boolean await)
onReplaySuccess
in interface Recovery
receive
- (undocumented)await
- (undocumented)void onReplayFailure(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive, boolean await, java.lang.Throwable cause)
onReplayFailure
in interface Recovery
receive
- (undocumented)await
- (undocumented)cause
- (undocumented)void onReplayComplete(boolean await)
idle
state and schedules the next update if autoUpdate
returns true
.
await
- (undocumented)void runReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive, Persistent msg)
runReceive
in interface Recovery
receive
- (undocumented)msg
- (undocumented)akka.persistence.PersistenceSettings.view$ viewSettings()
scala.Option<Cancellable> schedule()
java.lang.String viewId()
PersistentView
.
This allows the View to keep separate snapshots of data than the PersistentActor
originating the message stream.
The usual case is to have a *different* id set as viewId
than persistenceId
,
although it is possible to share the same id with an PersistentActor
- for example to decide about snapshots
based on some average or sum, calculated by this view.
Example:
class SummingView extends PersistentView {
override def persistenceId = "count-123"
override def viewId = "count-123-sum" // this view is performing summing,
// so this view's snapshots reside under the "-sum" suffixed id
// ...
}
java.lang.String snapshotterId()
viewId
.
snapshotterId
in interface Snapshotter
boolean isPersistent()
true
, the currently processed message was persisted (is sent from the Journal).
If false
, the currently processed message comes from another actor (from "user-land").
boolean autoUpdate()
true
, this view automatically updates itself with an interval specified by autoUpdateInterval
.
If false
, applications must explicitly update this view by sending Update
requests. The default
value can be configured with the akka.persistence.view.auto-update
configuration key. This method
can be overridden by implementation classes to return non-default values.
scala.concurrent.duration.FiniteDuration autoUpdateInterval()
akka.persistence.view.auto-update-interval
configuration key. This method can be
overridden by implementation classes to return non-default values.
long autoUpdateReplayMax()
akka.persistence.view.auto-update-replay-max
configuration key. This method can be overridden by
implementation classes to return non-default values.
void preStart()
autoUpdateReplayMax
messages (following that snapshot).
preStart
in interface Actor
void preRestart(java.lang.Throwable reason, scala.Option<java.lang.Object> message)
Actor
postStop()
.'''
preRestart
in interface Actor
preRestart
in interface UnrestrictedStash
reason
- the Throwable that caused the restart to happenmessage
- optionally the current message the actor processed when failing, if applicable
Is called on a crashed Actor right BEFORE it is restarted to allow clean
up of resources before Actor is terminated.void postStop()
Actor
postStop
in interface Actor
postStop
in interface UnrestrictedStash
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |