Class PersistentActor<K>
- java.lang.Object
-
- org.elasticsoftware.elasticactors.state.PersistentActor<K>
-
- All Implemented Interfaces:
ActorContext,ProcessorContext
public final class PersistentActor<K> extends Object implements ActorContext, ProcessorContext
- Author:
- Joost van de Wijgerd
-
-
Constructor Summary
Constructors Constructor Description PersistentActor(K key, InternalActorSystem actorSystem, String currentActorStateVersion, String previousActorSystemVersion, ActorRef ref, Class<? extends ElasticActor> actorClass, byte[] serializedState, com.google.common.collect.HashMultimap<String,MessageSubscriber> messageSubscribers, List<InternalPersistentSubscription> persistentSubscriptions)This Constructor should be used when the PersistentActor is deserializedPersistentActor(K key, InternalActorSystem actorSystem, String currentActorStateVersion, String previousActorSystemVersion, ActorRef ref, Class<? extends ElasticActor> actorClass, byte[] serializedState, String affinityKey, com.google.common.collect.HashMultimap<String,MessageSubscriber> messageSubscribers, List<InternalPersistentSubscription> persistentSubscriptions)PersistentActor(K key, InternalActorSystem actorSystem, String previousActorStateVersion, ActorRef ref, Class<? extends ElasticActor> actorClass, ActorState actorState)This Constructor should be used when creating a new PersistentActor in memoryPersistentActor(K key, InternalActorSystem actorSystem, String previousActorStateVersion, ActorRef ref, String affinityKey, Class<? extends ElasticActor> actorClass, ActorState actorState)
-
Method Summary
-
-
-
Constructor Detail
-
PersistentActor
public PersistentActor(K key, InternalActorSystem actorSystem, String previousActorStateVersion, ActorRef ref, Class<? extends ElasticActor> actorClass, ActorState actorState)
This Constructor should be used when creating a new PersistentActor in memory- Parameters:
key-actorSystem-previousActorStateVersion-ref-actorClass-actorState-
-
PersistentActor
public PersistentActor(K key, InternalActorSystem actorSystem, String previousActorStateVersion, ActorRef ref, String affinityKey, Class<? extends ElasticActor> actorClass, ActorState actorState)
-
PersistentActor
public PersistentActor(K key, InternalActorSystem actorSystem, String currentActorStateVersion, String previousActorSystemVersion, ActorRef ref, Class<? extends ElasticActor> actorClass, byte[] serializedState, com.google.common.collect.HashMultimap<String,MessageSubscriber> messageSubscribers, List<InternalPersistentSubscription> persistentSubscriptions)
This Constructor should be used when the PersistentActor is deserialized- Parameters:
key-actorSystem-currentActorStateVersion-previousActorSystemVersion-ref-actorClass-serializedState-
-
PersistentActor
public PersistentActor(K key, InternalActorSystem actorSystem, String currentActorStateVersion, String previousActorSystemVersion, ActorRef ref, Class<? extends ElasticActor> actorClass, byte[] serializedState, String affinityKey, com.google.common.collect.HashMultimap<String,MessageSubscriber> messageSubscribers, List<InternalPersistentSubscription> persistentSubscriptions)
-
-
Method Detail
-
getKey
public K getKey()
-
getCurrentActorStateVersion
public String getCurrentActorStateVersion()
-
getPreviousActorStateVersion
public String getPreviousActorStateVersion()
-
getActorClass
public Class<? extends ElasticActor> getActorClass()
-
getSelf
public ActorRef getSelf()
- Specified by:
getSelfin interfaceActorContext
-
getSelfType
@Nullable public Class<?> getSelfType()
- Specified by:
getSelfTypein interfaceActorContext
-
getState
public <T extends ActorState> T getState(Class<T> stateClass)
- Specified by:
getStatein interfaceActorContext
-
getState
public ActorState getState()
-
getSerializedState
public byte[] getSerializedState()
-
setSerializedState
public void setSerializedState(byte[] serializedState)
-
setState
public void setState(ActorState state)
- Specified by:
setStatein interfaceActorContext
-
getActorSystem
public ActorSystem getActorSystem()
- Specified by:
getActorSystemin interfaceActorContext
-
getSubscriptions
public Collection<PersistentSubscription> getSubscriptions()
- Specified by:
getSubscriptionsin interfaceActorContext
-
getSubscribers
public Map<String,Set<ActorRef>> getSubscribers()
- Specified by:
getSubscribersin interfaceActorContext
-
addSubscription
public void addSubscription(InternalPersistentSubscription persistentSubscription)
- Specified by:
addSubscriptionin interfaceProcessorContext
-
getSubscription
public Optional<InternalPersistentSubscription> getSubscription(String messageName, ActorRef publisherRef)
-
cancelAllSubscriptions
public void cancelAllSubscriptions()
-
getPersistentSubscriptions
public List<InternalPersistentSubscription> getPersistentSubscriptions()
-
addSubscriber
public void addSubscriber(String messageName, MessageSubscriber messageSubscriber)
-
removeSubscriber
public boolean removeSubscriber(String messageName, MessageSubscriber messageSubscriber)
-
getMessageSubscribers
public com.google.common.collect.HashMultimap<String,MessageSubscriber> getMessageSubscribers()
-
serializeState
public void serializeState() throws IOException- Throws:
IOException
-
-