public abstract class InternalReplicatedEntity<Command,Event,State>
extends java.lang.Object
| Constructor and Description |
|---|
InternalReplicatedEntity() |
| Modifier and Type | Method and Description |
|---|---|
protected scala.collection.immutable.Set<java.lang.String> |
allDcs()
All data centers
|
long |
currentTimeMillis()
Called to create the timestamp when an event is persisted.
|
protected java.lang.String |
entityId()
The id of the current entity
|
protected java.lang.String |
getEntityId()
The id of the current entity
|
akka.actor.ActorRef |
getSelf()
The 'self' field holds the ActorRef for this actor.
|
protected java.lang.String |
getSelfDc()
Java API: Name of the data-center in which this entity is running
|
abstract State |
initialState()
Abstract method that must be implemented by concrete subclass to define
the initial state of the entity.
|
abstract State |
internalApplyEvent(State state,
Event event)
INTERNAL API: Apply the
event to the state. |
abstract CommandHandlerImpl<Command,Event,State> |
internalCommandHandler()
INTERNAL API: Abstract method that must be implemented by concrete subclass to define
the command handlers of the entity.
|
abstract EffectImpl<Event,State> |
internalEventTrigger(EventTriggerContextImpl ctx,
State state,
Event event) |
abstract EffectImpl<Event,State> |
internalRecoveryCompleted(ReplicatedActorContextImpl ctx,
State state)
INTERNAL API: This method is called to notify the entity that the recovery process is finished.
|
void |
internalSetEntityId(java.lang.String id)
INTERNAL API
|
void |
internalSetLogger(ReplicatedEntityLoggingAdapter l)
INTERNAL API
|
void |
internalSetSelf(akka.actor.ActorRef s)
INTERNAL API
|
void |
internalSetSelfDc(java.lang.String id,
scala.collection.immutable.Set<java.lang.String> all)
INTERNAL API
|
abstract scala.collection.immutable.Set<java.lang.String> |
internalTagsFor(EventTaggingContextImpl ctx,
Event event)
INTERNAL API: Allows "tagging" certain events with any number of tags.
|
ReplicatedEntityLoggingAdapter |
log()
Special
LoggingAdapter which adds the enclosing replicated entity persistenceId to each log statement. |
protected scala.collection.immutable.Set<java.lang.String> |
otherDcs()
Other data centers,
allDcs without selfDc |
java.lang.String |
persistenceId(java.lang.String persistenceIdPrefix,
java.lang.String entityId,
java.lang.String dc)
When migrating from PersistenceActor you need to define the exact format of
the persistenceId to match the old identifiers in one of the data centers,
which hosts the old data which are stored with persistence ids that don't
include the data center suffix.
|
void |
postStop()
User overridable callback.
|
State |
replicatedEventHandler(ReplicatedEventContext ctx,
State state,
Event event)
Apply the
event that was persisted by another data center to the given state. |
akka.actor.ActorRef |
self()
The 'self' field holds the ActorRef for this actor.
|
protected java.lang.String |
selfDc()
Name of the data-center in which this entity is running
|
State |
selfEventHandler(SelfEventContext ctx,
State state,
Event event)
Apply the
event that was persisted by this data center to the given state. |
State |
snapshotMigration(java.lang.Object oldSnapshot)
When migrating from PersistentActor to Replicated entity this method is
called to be able to convert old snapshots to the new
State if needed. |
akka.actor.SupervisorStrategy |
supervisorStrategy()
User overridable definition the strategy to use for supervising
child actors.
|
protected final scala.collection.immutable.Set<java.lang.String> allDcs()
public long currentTimeMillis()
protected final java.lang.String entityId()
protected final java.lang.String getEntityId()
public akka.actor.ActorRef getSelf()
self ! message
Used as the implicit sender for !
protected final java.lang.String getSelfDc()
public abstract State initialState()
public abstract State internalApplyEvent(State state, Event event)
event to the state. Return the new State.state - (undocumented)event - (undocumented)public abstract CommandHandlerImpl<Command,Event,State> internalCommandHandler()
CommandHandler defines command handlers and optional
functions for other signals, e.g. Termination messages if watch is used.
Note that you can have different handlers based on current state by using
CommandHandlerImpl#byState.
public abstract EffectImpl<Event,State> internalEventTrigger(EventTriggerContextImpl ctx, State state, Event event)
public abstract EffectImpl<Event,State> internalRecoveryCompleted(ReplicatedActorContextImpl ctx, State state)
ctx - (undocumented)state - (undocumented)public void internalSetEntityId(java.lang.String id)
public void internalSetLogger(ReplicatedEntityLoggingAdapter l)
public void internalSetSelf(akka.actor.ActorRef s)
s - (undocumented)public void internalSetSelfDc(java.lang.String id,
scala.collection.immutable.Set<java.lang.String> all)
public abstract scala.collection.immutable.Set<java.lang.String> internalTagsFor(EventTaggingContextImpl ctx, Event event)
ctx - (undocumented)event - (undocumented)public ReplicatedEntityLoggingAdapter log()
LoggingAdapter which adds the enclosing replicated entity persistenceId to each log statement.
Configure how it should add such metadata under the akka.persistence.multi-datacenter.logging
config section.
WARNING: The logger may only be used after construction of the ReplicatedEntity has completed, i.e. not in its constructor.
WARNING: When using the MDC features of this logger, and NOT using Lightbend Monitoring's automatic MDC propagation, be awere that the MDC context would be lost if the logger were to be invoked from a Future.
protected final scala.collection.immutable.Set<java.lang.String> otherDcs()
allDcs without selfDcpublic java.lang.String persistenceId(java.lang.String persistenceIdPrefix,
java.lang.String entityId,
java.lang.String dc)
The persistenceId is by default the concatenation of persistenceIdPrefix, entityId
and the data center identifier, separated with |.
persistenceIdPrefix - (undocumented)entityId - (undocumented)dc - (undocumented)public void postStop()
throws java.lang.Exception
java.lang.Exceptionpublic State replicatedEventHandler(ReplicatedEventContext ctx, State state, Event event)
event that was persisted by another data center to the given state.
Return the new State. By default this invokes eventHandler but in case more
context of the event is needed this can be overridden instead. See also
selfEventHandler(akka.persistence.multidc.SelfEventContext, State, Event).ctx - (undocumented)state - (undocumented)event - (undocumented)public akka.actor.ActorRef self()
self ! message
Used as the implicit sender for !
protected final java.lang.String selfDc()
public State selfEventHandler(SelfEventContext ctx, State state, Event event)
event that was persisted by this data center to the given state.
Return the new State. By default this invokes eventHandler but in case more
context of the event is needed this can be overridden instead. See also
replicatedEventHandler(akka.persistence.multidc.ReplicatedEventContext, State, Event).ctx - (undocumented)state - (undocumented)event - (undocumented)public State snapshotMigration(java.lang.Object oldSnapshot)
State if needed.
By default it tries to cast the oldSnapshot to State.oldSnapshot - (undocumented)public akka.actor.SupervisorStrategy supervisorStrategy()