public class ClusterSharding extends java.lang.Object implements Extension
ClusterSharding companion object
Constructor and Description |
---|
ClusterSharding(ExtendedActorSystem system) |
Modifier and Type | Method and Description |
---|---|
static ClusterSharding |
createExtension(ExtendedActorSystem system) |
static ClusterSharding |
get(ActorSystem system) |
static ClusterSharding$ |
lookup() |
void |
requireClusterRole(scala.Option<java.lang.String> role) |
ActorRef |
shardRegion(java.lang.String typeName)
Retrieve the actor reference of the
ShardRegion actor responsible for the named entity type. |
ActorRef |
start(java.lang.String typeName,
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)
Register a named entity type by defining the
Props of the entity actor and
functions to extract entity and shard identifier from messages. |
ActorRef |
start(java.lang.String typeName,
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,
ShardCoordinator.ShardAllocationStrategy allocationStrategy,
java.lang.Object handOffStopMessage)
Scala API: Register a named entity type by defining the
Props of the entity actor
and functions to extract entity and shard identifier from messages. |
ActorRef |
start(java.lang.String typeName,
Props entityProps,
ClusterShardingSettings settings,
ShardRegion.MessageExtractor messageExtractor)
Java/Scala API: Register a named entity type by defining the
Props of the entity actor
and functions to extract entity and shard identifier from messages. |
ActorRef |
start(java.lang.String typeName,
Props entityProps,
ClusterShardingSettings settings,
ShardRegion.MessageExtractor messageExtractor,
ShardCoordinator.ShardAllocationStrategy allocationStrategy,
java.lang.Object handOffStopMessage)
Java/Scala API: Register a named entity type by defining the
Props of the entity actor
and functions to extract entity and shard identifier from messages. |
ActorRef |
startProxy(java.lang.String typeName,
scala.Option<java.lang.String> role,
scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> extractEntityId,
scala.Function1<java.lang.Object,java.lang.String> extractShardId)
Scala API: Register a named entity type
ShardRegion on this node that will run in proxy only mode,
i.e. |
ActorRef |
startProxy(java.lang.String typeName,
java.util.Optional<java.lang.String> role,
ShardRegion.MessageExtractor messageExtractor)
Java/Scala API: Register a named entity type
ShardRegion on this node that will run in proxy only mode,
i.e. |
public ClusterSharding(ExtendedActorSystem system)
public static ClusterSharding get(ActorSystem system)
public static ClusterSharding$ lookup()
public static ClusterSharding createExtension(ExtendedActorSystem system)
public void requireClusterRole(scala.Option<java.lang.String> role)
public ActorRef start(java.lang.String typeName, 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, ShardCoordinator.ShardAllocationStrategy allocationStrategy, java.lang.Object handOffStopMessage)
Props
of the entity actor
and functions to extract entity and shard identifier from messages. The ShardRegion
actor
for this type can later be retrieved with the shardRegion(java.lang.String)
method.
Some settings can be configured as described in the akka.cluster.sharding
section
of the reference.conf
.
typeName
- the name of the entity typeentityProps
- the Props
of the entity actors that will be created by the ShardRegion
settings
- configuration settings, see ClusterShardingSettings
extractEntityId
- partial function to extract the entity id and the message to send to the
entity from the incoming message, if the partial function does not match the message will
be unhandled
, i.e. posted as Unhandled
messages on the event streamextractShardId
- function to determine the shard id for an incoming message, only messages
that passed the extractEntityId
will be usedallocationStrategy
- possibility to use a custom shard allocation and
rebalancing logichandOffStopMessage
- the message that will be sent to entities when they are to be stopped
for a rebalance or graceful shutdown of a ShardRegion
, e.g. PoisonPill
.ShardRegion
that is to be responsible for the shardpublic ActorRef start(java.lang.String typeName, 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)
Props
of the entity actor and
functions to extract entity and shard identifier from messages. The ShardRegion
actor
for this type can later be retrieved with the shardRegion(java.lang.String)
method.
The default shard allocation strategy ShardCoordinator.LeastShardAllocationStrategy
is used. PoisonPill
is used as handOffStopMessage
.
Some settings can be configured as described in the akka.cluster.sharding
section
of the reference.conf
.
typeName
- the name of the entity typeentityProps
- the Props
of the entity actors that will be created by the ShardRegion
settings
- configuration settings, see ClusterShardingSettings
extractEntityId
- partial function to extract the entity id and the message to send to the
entity from the incoming message, if the partial function does not match the message will
be unhandled
, i.e. posted as Unhandled
messages on the event streamextractShardId
- function to determine the shard id for an incoming message, only messages
that passed the extractEntityId
will be usedShardRegion
that is to be responsible for the shardpublic ActorRef start(java.lang.String typeName, Props entityProps, ClusterShardingSettings settings, ShardRegion.MessageExtractor messageExtractor, ShardCoordinator.ShardAllocationStrategy allocationStrategy, java.lang.Object handOffStopMessage)
Props
of the entity actor
and functions to extract entity and shard identifier from messages. The ShardRegion
actor
for this type can later be retrieved with the shardRegion(java.lang.String)
method.
Some settings can be configured as described in the akka.cluster.sharding
section
of the reference.conf
.
typeName
- the name of the entity typeentityProps
- the Props
of the entity actors that will be created by the ShardRegion
settings
- configuration settings, see ClusterShardingSettings
messageExtractor
- functions to extract the entity id, shard id, and the message to send to the
entity from the incoming message, see ShardRegion.MessageExtractor
allocationStrategy
- possibility to use a custom shard allocation and
rebalancing logichandOffStopMessage
- the message that will be sent to entities when they are to be stopped
for a rebalance or graceful shutdown of a ShardRegion
, e.g. PoisonPill
.ShardRegion
that is to be responsible for the shardpublic ActorRef start(java.lang.String typeName, Props entityProps, ClusterShardingSettings settings, ShardRegion.MessageExtractor messageExtractor)
Props
of the entity actor
and functions to extract entity and shard identifier from messages. The ShardRegion
actor
for this type can later be retrieved with the shardRegion(java.lang.String)
method.
The default shard allocation strategy ShardCoordinator.LeastShardAllocationStrategy
is used. PoisonPill
is used as handOffStopMessage
.
Some settings can be configured as described in the akka.cluster.sharding
section
of the reference.conf
.
typeName
- the name of the entity typeentityProps
- the Props
of the entity actors that will be created by the ShardRegion
settings
- configuration settings, see ClusterShardingSettings
messageExtractor
- functions to extract the entity id, shard id, and the message to send to the
entity from the incoming messageShardRegion
that is to be responsible for the shardpublic ActorRef startProxy(java.lang.String typeName, scala.Option<java.lang.String> role, scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> extractEntityId, scala.Function1<java.lang.Object,java.lang.String> extractShardId)
ShardRegion
on this node that will run in proxy only mode,
i.e. it will delegate messages to other ShardRegion
actors on other nodes, but not host any
entity actors itself. The ShardRegion
actor for this type can later be retrieved with the
shardRegion(java.lang.String)
method.
Some settings can be configured as described in the akka.cluster.sharding
section
of the reference.conf
.
typeName
- the name of the entity typerole
- specifies that this entity type is located on cluster nodes with a specific role.
If the role is not specified all nodes in the cluster are used.extractEntityId
- partial function to extract the entity id and the message to send to the
entity from the incoming message, if the partial function does not match the message will
be unhandled
, i.e. posted as Unhandled
messages on the event streamextractShardId
- function to determine the shard id for an incoming message, only messages
that passed the extractEntityId
will be usedShardRegion
that is to be responsible for the shardpublic ActorRef startProxy(java.lang.String typeName, java.util.Optional<java.lang.String> role, ShardRegion.MessageExtractor messageExtractor)
ShardRegion
on this node that will run in proxy only mode,
i.e. it will delegate messages to other ShardRegion
actors on other nodes, but not host any
entity actors itself. The ShardRegion
actor for this type can later be retrieved with the
shardRegion(java.lang.String)
method.
Some settings can be configured as described in the akka.cluster.sharding
section
of the reference.conf
.
typeName
- the name of the entity typerole
- specifies that this entity type is located on cluster nodes with a specific role.
If the role is not specified all nodes in the cluster are used.messageExtractor
- functions to extract the entity id, shard id, and the message to send to the
entity from the incoming messageShardRegion
that is to be responsible for the shardpublic ActorRef shardRegion(java.lang.String typeName)
ShardRegion
actor responsible for the named entity type.
The entity type must be registered with the start(java.lang.String, akka.actor.Props, akka.cluster.sharding.ClusterShardingSettings, scala.PartialFunction<java.lang.Object, scala.Tuple2<java.lang.String, java.lang.Object>>, scala.Function1<java.lang.Object, java.lang.String>, akka.cluster.sharding.ShardCoordinator.ShardAllocationStrategy, java.lang.Object)
method before it can be used here.
Messages to the entity is always sent via the ShardRegion
.typeName
- (undocumented)