akka.contrib.pattern
Class ShardRegion

java.lang.Object
  extended by akka.contrib.pattern.ShardRegion
All Implemented Interfaces:
Actor, ActorLogging

public class ShardRegion
extends java.lang.Object
implements Actor, ActorLogging

This actor creates children entry actors on demand for the shards that it is told to be responsible for. It delegates messages targeted to other shards to the responsible ShardRegion actor on other nodes.

See Also:
ClusterSharding extension

Nested Class Summary
static class ShardRegion.HandOffStopper
          INTERNAL API.
static interface ShardRegion.MessageExtractor
          Java API: Interface of functions to extract entry id, shard id, and the message to send to the entry from an incoming message.
static class ShardRegion.Passivate
          If the state of the entries are persistent you may stop entries that are not used to reduce memory consumption.
static class ShardRegion.Passivate$
           
static interface ShardRegion.ShardRegionCommand
           
 
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$
 
Constructor Summary
ShardRegion(scala.Option<Props> entryProps, scala.Option<java.lang.String> role, java.lang.String coordinatorPath, scala.concurrent.duration.FiniteDuration retryInterval, int bufferSize, scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> idExtractor, scala.Function1<java.lang.Object,java.lang.String> shardResolver)
           
 
Method Summary
 scala.math.Ordering<Member> ageOrdering()
           
 void changeMembers(scala.collection.immutable.SortedSet<Member> newMembers)
           
 Cluster cluster()
           
 scala.Option<ActorRef> coordinator()
           
 scala.Option<ActorSelection> coordinatorSelection()
           
 void deliverMessage(java.lang.Object msg, ActorRef snd)
           
 scala.collection.immutable.Map<ActorRef,java.lang.String> entries()
           
 scala.collection.immutable.Map<java.lang.String,scala.collection.immutable.Set<ActorRef>> entriesByShard()
           
 boolean matchingRole(Member member)
           
 scala.collection.immutable.SortedSet<Member> membersByAge()
           
 void passivate(ActorRef entry, java.lang.Object stopMessage)
           
 scala.collection.immutable.Map<ActorRef,scala.collection.immutable.Vector<scala.Tuple2<java.lang.Object,ActorRef>>> passivatingBuffers()
           
 void postStop()
          User overridable callback.
 void preStart()
          User overridable callback.
static Props props(scala.Option<Props> entryProps, scala.Option<java.lang.String> role, java.lang.String coordinatorPath, scala.concurrent.duration.FiniteDuration retryInterval, int bufferSize, scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> idExtractor, scala.Function1<java.lang.Object,java.lang.String> shardResolver)
          Scala API: Factory method for the Props of the ShardRegion actor.
static Props props(Props entryProps, scala.Option<java.lang.String> role, java.lang.String coordinatorPath, scala.concurrent.duration.FiniteDuration retryInterval, int bufferSize, scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> idExtractor, scala.Function1<java.lang.Object,java.lang.String> shardResolver)
          Scala API: Factory method for the Props of the ShardRegion actor.
static Props props(Props entryProps, java.lang.String role, java.lang.String coordinatorPath, scala.concurrent.duration.FiniteDuration retryInterval, int bufferSize, ShardRegion.MessageExtractor messageExtractor)
          Java API: Factory method for the Props of the ShardRegion actor.
static Props proxyProps(scala.Option<java.lang.String> role, java.lang.String coordinatorPath, scala.concurrent.duration.FiniteDuration retryInterval, int bufferSize, scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> idExtractor, scala.Function1<java.lang.Object,java.lang.String> shardResolver)
          Scala API: Factory method for the Props of the ShardRegion actor when using it in proxy only mode.
static Props proxyProps(java.lang.String role, java.lang.String coordinatorPath, scala.concurrent.duration.FiniteDuration retryInterval, int bufferSize, ShardRegion.MessageExtractor messageExtractor)
          Java API: : Factory method for the Props of the ShardRegion actor when using it in proxy only mode.
 scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
          This defines the initial actor behavior, it must return a partial function with the actor logic.
 void receiveClusterEvent(ClusterEvent.ClusterDomainEvent evt)
           
 void receiveClusterState(ClusterEvent.CurrentClusterState state)
           
 void receiveCommand(ShardRegion.ShardRegionCommand cmd)
           
 void receiveCoordinatorMessage(akka.contrib.pattern.ShardCoordinator.Internal.CoordinatorMessage msg)
           
 void receiveTerminated(ActorRef ref)
           
 scala.collection.immutable.Map<java.lang.String,ActorRef> regionByShard()
           
 scala.collection.immutable.Map<ActorRef,scala.collection.immutable.Set<java.lang.String>> regions()
           
 void register()
           
 java.lang.Object registrationMessage()
           
 void requestShardBufferHomes()
           
 Cancellable retryTask()
           
 scala.collection.immutable.Map<java.lang.String,scala.collection.immutable.Vector<scala.Tuple2<java.lang.Object,ActorRef>>> shardBuffers()
           
 int totalBufferSize()
           
 
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
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, context, postRestart, preRestart, self, sender, supervisorStrategy, unhandled
 
Methods inherited from interface akka.actor.ActorLogging
_log, log
 

Constructor Detail

ShardRegion

public ShardRegion(scala.Option<Props> entryProps,
                   scala.Option<java.lang.String> role,
                   java.lang.String coordinatorPath,
                   scala.concurrent.duration.FiniteDuration retryInterval,
                   int bufferSize,
                   scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> idExtractor,
                   scala.Function1<java.lang.Object,java.lang.String> shardResolver)
Method Detail

props

public static Props props(scala.Option<Props> entryProps,
                          scala.Option<java.lang.String> role,
                          java.lang.String coordinatorPath,
                          scala.concurrent.duration.FiniteDuration retryInterval,
                          int bufferSize,
                          scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> idExtractor,
                          scala.Function1<java.lang.Object,java.lang.String> shardResolver)
Scala API: Factory method for the Props of the ShardRegion actor.

Parameters:
entryProps - (undocumented)
role - (undocumented)
coordinatorPath - (undocumented)
retryInterval - (undocumented)
bufferSize - (undocumented)
idExtractor - (undocumented)
shardResolver - (undocumented)
Returns:
(undocumented)

props

public static Props props(Props entryProps,
                          scala.Option<java.lang.String> role,
                          java.lang.String coordinatorPath,
                          scala.concurrent.duration.FiniteDuration retryInterval,
                          int bufferSize,
                          scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> idExtractor,
                          scala.Function1<java.lang.Object,java.lang.String> shardResolver)
Scala API: Factory method for the Props of the ShardRegion actor.

Parameters:
entryProps - (undocumented)
role - (undocumented)
coordinatorPath - (undocumented)
retryInterval - (undocumented)
bufferSize - (undocumented)
idExtractor - (undocumented)
shardResolver - (undocumented)
Returns:
(undocumented)

props

public static Props props(Props entryProps,
                          java.lang.String role,
                          java.lang.String coordinatorPath,
                          scala.concurrent.duration.FiniteDuration retryInterval,
                          int bufferSize,
                          ShardRegion.MessageExtractor messageExtractor)
Java API: Factory method for the Props of the ShardRegion actor.

Parameters:
entryProps - (undocumented)
role - (undocumented)
coordinatorPath - (undocumented)
retryInterval - (undocumented)
bufferSize - (undocumented)
messageExtractor - (undocumented)
Returns:
(undocumented)

proxyProps

public static Props proxyProps(scala.Option<java.lang.String> role,
                               java.lang.String coordinatorPath,
                               scala.concurrent.duration.FiniteDuration retryInterval,
                               int bufferSize,
                               scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> idExtractor,
                               scala.Function1<java.lang.Object,java.lang.String> shardResolver)
Scala API: Factory method for the Props of the ShardRegion actor when using it in proxy only mode.

Parameters:
role - (undocumented)
coordinatorPath - (undocumented)
retryInterval - (undocumented)
bufferSize - (undocumented)
idExtractor - (undocumented)
shardResolver - (undocumented)
Returns:
(undocumented)

proxyProps

public static Props proxyProps(java.lang.String role,
                               java.lang.String coordinatorPath,
                               scala.concurrent.duration.FiniteDuration retryInterval,
                               int bufferSize,
                               ShardRegion.MessageExtractor messageExtractor)
Java API: : Factory method for the Props of the ShardRegion actor when using it in proxy only mode.

Parameters:
role - (undocumented)
coordinatorPath - (undocumented)
retryInterval - (undocumented)
bufferSize - (undocumented)
messageExtractor - (undocumented)
Returns:
(undocumented)

cluster

public Cluster cluster()

ageOrdering

public scala.math.Ordering<Member> ageOrdering()

membersByAge

public scala.collection.immutable.SortedSet<Member> membersByAge()

regions

public scala.collection.immutable.Map<ActorRef,scala.collection.immutable.Set<java.lang.String>> regions()

regionByShard

public scala.collection.immutable.Map<java.lang.String,ActorRef> regionByShard()

entries

public scala.collection.immutable.Map<ActorRef,java.lang.String> entries()

entriesByShard

public scala.collection.immutable.Map<java.lang.String,scala.collection.immutable.Set<ActorRef>> entriesByShard()

shardBuffers

public scala.collection.immutable.Map<java.lang.String,scala.collection.immutable.Vector<scala.Tuple2<java.lang.Object,ActorRef>>> shardBuffers()

passivatingBuffers

public scala.collection.immutable.Map<ActorRef,scala.collection.immutable.Vector<scala.Tuple2<java.lang.Object,ActorRef>>> passivatingBuffers()

totalBufferSize

public int totalBufferSize()

retryTask

public Cancellable retryTask()

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.

Specified by:
preStart in interface Actor

postStop

public void postStop()
Description copied from interface: Actor
User overridable callback.

Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation.

Specified by:
postStop in interface Actor

matchingRole

public boolean matchingRole(Member member)

coordinatorSelection

public scala.Option<ActorSelection> coordinatorSelection()

coordinator

public scala.Option<ActorRef> coordinator()

changeMembers

public void changeMembers(scala.collection.immutable.SortedSet<Member> newMembers)

receive

public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
Description copied from interface: Actor
This defines the initial actor behavior, it must return a partial function with the actor logic.

Specified by:
receive in interface Actor
Returns:
(undocumented)

receiveClusterState

public void receiveClusterState(ClusterEvent.CurrentClusterState state)

receiveClusterEvent

public void receiveClusterEvent(ClusterEvent.ClusterDomainEvent evt)

receiveCoordinatorMessage

public void receiveCoordinatorMessage(akka.contrib.pattern.ShardCoordinator.Internal.CoordinatorMessage msg)

receiveCommand

public void receiveCommand(ShardRegion.ShardRegionCommand cmd)

receiveTerminated

public void receiveTerminated(ActorRef ref)

register

public void register()

registrationMessage

public java.lang.Object registrationMessage()

requestShardBufferHomes

public void requestShardBufferHomes()

deliverMessage

public void deliverMessage(java.lang.Object msg,
                           ActorRef snd)

passivate

public void passivate(ActorRef entry,
                      java.lang.Object stopMessage)