Class ClusterSharding
- java.lang.Object
-
- akka.cluster.sharding.ClusterSharding
-
- All Implemented Interfaces:
Extension
public class ClusterSharding extends java.lang.Object implements Extension
- See Also:
ClusterSharding companion object
-
-
Constructor Summary
Constructors Constructor Description ClusterSharding(ExtendedActorSystem system)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Tapply(ActorSystem system)static Tapply(ClassicActorSystemProvider system)static ClusterShardingcreateExtension(ExtendedActorSystem system)ShardCoordinator.ShardAllocationStrategydefaultShardAllocationStrategy(ClusterShardingSettings settings)The defaultShardAllocationStrategyis configured byleast-shard-allocation-strategyproperties.static booleanequals(java.lang.Object other)static ClusterShardingget(ActorSystem system)static ClusterShardingget(ClassicActorSystemProvider system)java.util.Set<java.lang.String>getShardTypeNames()Java API: get all currently defined sharding type names.static inthashCode()static ClusterSharding$lookup()ActorRefshardRegion(java.lang.String typeName)Retrieve the actor reference of theShardRegionactor responsible for the named entity type.ActorRefshardRegionProxy(java.lang.String typeName, java.lang.String dataCenter)Deprecated.Use Akka Distributed Cluster instead.scala.collection.immutable.Set<java.lang.String>shardTypeNames()Scala API: get all currently defined sharding type names.ActorRefstart(java.lang.String typeName, Props entityProps, ClusterShardingSettings settings, akka.cluster.sharding.ShardRegion.MessageExtractor messageExtractor)Java/Scala API: Register a named entity type by defining thePropsof the entity actor and functions to extract entity and shard identifier from messages.ActorRefstart(java.lang.String typeName, Props entityProps, ClusterShardingSettings settings, akka.cluster.sharding.ShardRegion.MessageExtractor messageExtractor, ShardCoordinator.ShardAllocationStrategy allocationStrategy, java.lang.Object handOffStopMessage)Java/Scala API: Register a named entity type by defining thePropsof the entity actor and functions to extract entity and shard identifier from messages.ActorRefstart(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 thePropsof the entity actor and functions to extract entity and shard identifier from messages.ActorRefstart(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 thePropsof the entity actor and functions to extract entity and shard identifier from messages.ActorRefstart(java.lang.String typeName, Props entityProps, akka.cluster.sharding.ShardRegion.MessageExtractor messageExtractor)Java/Scala API: Register a named entity type by defining thePropsof the entity actor and functions to extract entity and shard identifier from messages.ActorRefstart(java.lang.String typeName, Props entityProps, 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 thePropsof the entity actor and functions to extract entity and shard identifier from messages.ActorRefstart(java.lang.String typeName, Props entityProps, 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 thePropsof the entity actor and functions to extract entity and shard identifier from messages.ActorRefstartProxy(java.lang.String typeName, java.util.Optional<java.lang.String> role, akka.cluster.sharding.ShardRegion.MessageExtractor messageExtractor)Java/Scala API: Register a named entity typeShardRegionon this node that will run in proxy only mode, i.e.ActorRefstartProxy(java.lang.String typeName, java.util.Optional<java.lang.String> role, java.util.Optional<java.lang.String> dataCenter, akka.cluster.sharding.ShardRegion.MessageExtractor messageExtractor)Deprecated.Use Akka Distributed Cluster instead.ActorRefstartProxy(java.lang.String typeName, scala.Option<java.lang.String> role, scala.Option<java.lang.String> dataCenter, scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> extractEntityId, scala.Function1<java.lang.Object,java.lang.String> extractShardId)Deprecated.Use Akka Distributed Cluster instead.ActorRefstartProxy(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 typeShardRegionon this node that will run in proxy only mode, i.e.
-
-
-
Constructor Detail
-
ClusterSharding
public ClusterSharding(ExtendedActorSystem system)
-
-
Method Detail
-
get
public static ClusterSharding get(ActorSystem system)
-
get
public static ClusterSharding get(ClassicActorSystemProvider system)
-
lookup
public static ClusterSharding$ lookup()
-
createExtension
public static ClusterSharding createExtension(ExtendedActorSystem system)
-
apply
public static T apply(ActorSystem system)
-
apply
public static T apply(ClassicActorSystemProvider system)
-
hashCode
public static final int hashCode()
-
equals
public static final boolean equals(java.lang.Object other)
-
start
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)
Scala API: Register a named entity type by defining thePropsof the entity actor and functions to extract entity and shard identifier from messages. TheShardRegionactor for this type can later be retrieved with theshardRegion(java.lang.String)method.This method will start a
ShardRegionin proxy mode when there is no match between the roles of the current cluster node and the role specified inClusterShardingSettingspassed to this method.Some settings can be configured as described in the
akka.cluster.shardingsection of thereference.conf.- Parameters:
typeName- the name of the entity typeentityProps- thePropsof the entity actors that will be created by theShardRegionsettings- configuration settings, seeClusterShardingSettingsextractEntityId- 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 beunhandled, i.e. posted asUnhandledmessages on the event streamextractShardId- function to determine the shard id for an incoming message, only messages that passed theextractEntityIdwill 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 aShardRegion, e.g.PoisonPill.- Returns:
- the actor ref of the
ShardRegionthat is to be responsible for the shard
-
start
public ActorRef start(java.lang.String typeName, Props entityProps, 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 thePropsof the entity actor and functions to extract entity and shard identifier from messages. TheShardRegionactor for this type can later be retrieved with theshardRegion(java.lang.String)method.This method will start a
ShardRegionin proxy mode when there is no match between the roles of the current cluster node and the role specified inClusterShardingSettingspassed to this method.Some settings can be configured as described in the
akka.cluster.shardingsection of thereference.conf.- Parameters:
typeName- the name of the entity typeentityProps- thePropsof the entity actors that will be created by theShardRegionextractEntityId- 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 beunhandled, i.e. posted asUnhandledmessages on the event streamextractShardId- function to determine the shard id for an incoming message, only messages that passed theextractEntityIdwill 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 aShardRegion, e.g.PoisonPill.- Returns:
- the actor ref of the
ShardRegionthat is to be responsible for the shard
-
start
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)
Register a named entity type by defining thePropsof the entity actor and functions to extract entity and shard identifier from messages. TheShardRegionactor for this type can later be retrieved with theshardRegion(java.lang.String)method.The default shard allocation strategy
ShardCoordinator.LeastShardAllocationStrategyis used.PoisonPillis used ashandOffStopMessage.This method will start a
ShardRegionin proxy mode when there is no match between the node roles and the role specified in theClusterShardingSettingspassed to this method.Some settings can be configured as described in the
akka.cluster.shardingsection of thereference.conf.- Parameters:
typeName- the name of the entity typeentityProps- thePropsof the entity actors that will be created by theShardRegionsettings- configuration settings, seeClusterShardingSettingsextractEntityId- 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 beunhandled, i.e. posted asUnhandledmessages on the event streamextractShardId- function to determine the shard id for an incoming message, only messages that passed theextractEntityIdwill be used- Returns:
- the actor ref of the
ShardRegionthat is to be responsible for the shard
-
start
public ActorRef start(java.lang.String typeName, Props entityProps, 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 thePropsof the entity actor and functions to extract entity and shard identifier from messages. TheShardRegionactor for this type can later be retrieved with theshardRegion(java.lang.String)method.The default shard allocation strategy
ShardCoordinator.LeastShardAllocationStrategyis used.PoisonPillis used ashandOffStopMessage.This method will start a
ShardRegionin proxy mode when there is no match between the node roles and the role specified in theClusterShardingSettingspassed to this method.Some settings can be configured as described in the
akka.cluster.shardingsection of thereference.conf.- Parameters:
typeName- the name of the entity typeentityProps- thePropsof the entity actors that will be created by theShardRegionextractEntityId- 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 beunhandled, i.e. posted asUnhandledmessages on the event streamextractShardId- function to determine the shard id for an incoming message, only messages that passed theextractEntityIdwill be used- Returns:
- the actor ref of the
ShardRegionthat is to be responsible for the shard
-
start
public ActorRef start(java.lang.String typeName, Props entityProps, ClusterShardingSettings settings, akka.cluster.sharding.ShardRegion.MessageExtractor messageExtractor, ShardCoordinator.ShardAllocationStrategy allocationStrategy, java.lang.Object handOffStopMessage)
Java/Scala API: Register a named entity type by defining thePropsof the entity actor and functions to extract entity and shard identifier from messages. TheShardRegionactor for this type can later be retrieved with theshardRegion(java.lang.String)method.This method will start a
ShardRegionin proxy mode when there is no match between the node roles and the role specified in theClusterShardingSettingspassed to this method.Some settings can be configured as described in the
akka.cluster.shardingsection of thereference.conf.- Parameters:
typeName- the name of the entity typeentityProps- thePropsof the entity actors that will be created by theShardRegionsettings- configuration settings, seeClusterShardingSettingsmessageExtractor- functions to extract the entity id, shard id, and the message to send to the entity from the incoming message, seeShardRegion.MessageExtractorallocationStrategy- 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 aShardRegion, e.g.PoisonPill.- Returns:
- the actor ref of the
ShardRegionthat is to be responsible for the shard
-
start
public ActorRef start(java.lang.String typeName, Props entityProps, ClusterShardingSettings settings, akka.cluster.sharding.ShardRegion.MessageExtractor messageExtractor)
Java/Scala API: Register a named entity type by defining thePropsof the entity actor and functions to extract entity and shard identifier from messages. TheShardRegionactor for this type can later be retrieved with theshardRegion(java.lang.String)method.The default shard allocation strategy
ShardCoordinator.LeastShardAllocationStrategyis used.PoisonPillis used ashandOffStopMessage.This method will start a
ShardRegionin proxy mode when there is no match between the node roles and the role specified in theClusterShardingSettingspassed to this method.Some settings can be configured as described in the
akka.cluster.shardingsection of thereference.conf.- Parameters:
typeName- the name of the entity typeentityProps- thePropsof the entity actors that will be created by theShardRegionsettings- configuration settings, seeClusterShardingSettingsmessageExtractor- functions to extract the entity id, shard id, and the message to send to the entity from the incoming message- Returns:
- the actor ref of the
ShardRegionthat is to be responsible for the shard
-
start
public ActorRef start(java.lang.String typeName, Props entityProps, akka.cluster.sharding.ShardRegion.MessageExtractor messageExtractor)
Java/Scala API: Register a named entity type by defining thePropsof the entity actor and functions to extract entity and shard identifier from messages. TheShardRegionactor for this type can later be retrieved with theshardRegion(java.lang.String)method.The default shard allocation strategy
ShardCoordinator.LeastShardAllocationStrategyis used.PoisonPillis used ashandOffStopMessage.This method will start a
ShardRegionin proxy mode when there is no match between the node roles and the role specified in theClusterShardingSettingspassed to this method.Some settings can be configured as described in the
akka.cluster.shardingsection of thereference.conf.- Parameters:
typeName- the name of the entity typeentityProps- thePropsof the entity actors that will be created by theShardRegionmessageExtractor- functions to extract the entity id, shard id, and the message to send to the entity from the incoming message- Returns:
- the actor ref of the
ShardRegionthat is to be responsible for the shard
-
startProxy
public 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 typeShardRegionon this node that will run in proxy only mode, i.e. it will delegate messages to otherShardRegionactors on other nodes, but not host any entity actors itself. TheShardRegionactor for this type can later be retrieved with theshardRegion(java.lang.String)method.Some settings can be configured as described in the
akka.cluster.shardingsection of thereference.conf.- Parameters:
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 beunhandled, i.e. posted asUnhandledmessages on the event streamextractShardId- function to determine the shard id for an incoming message, only messages that passed theextractEntityIdwill be used- Returns:
- the actor ref of the
ShardRegionthat is to be responsible for the shard
-
startProxy
public ActorRef startProxy(java.lang.String typeName, scala.Option<java.lang.String> role, scala.Option<java.lang.String> dataCenter, scala.PartialFunction<java.lang.Object,scala.Tuple2<java.lang.String,java.lang.Object>> extractEntityId, scala.Function1<java.lang.Object,java.lang.String> extractShardId)
Deprecated.Use Akka Distributed Cluster instead. Since 2.10.0.Scala API: Register a named entity typeShardRegionon this node that will run in proxy only mode, i.e. it will delegate messages to otherShardRegionactors on other nodes, but not host any entity actors itself. TheShardRegionactor for this type can later be retrieved with theshardRegion(java.lang.String)method.Some settings can be configured as described in the
akka.cluster.shardingsection of thereference.conf.- Parameters:
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.dataCenter- The data center of the cluster nodes where the cluster sharding is running. If None then the same data center as current node.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 beunhandled, i.e. posted asUnhandledmessages on the event streamextractShardId- function to determine the shard id for an incoming message, only messages that passed theextractEntityIdwill be used- Returns:
- the actor ref of the
ShardRegionthat is to be responsible for the shard
-
startProxy
public ActorRef startProxy(java.lang.String typeName, java.util.Optional<java.lang.String> role, akka.cluster.sharding.ShardRegion.MessageExtractor messageExtractor)
Java/Scala API: Register a named entity typeShardRegionon this node that will run in proxy only mode, i.e. it will delegate messages to otherShardRegionactors on other nodes, but not host any entity actors itself. TheShardRegionactor for this type can later be retrieved with theshardRegion(java.lang.String)method.Some settings can be configured as described in the
akka.cluster.shardingsection of thereference.conf.- Parameters:
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 message- Returns:
- the actor ref of the
ShardRegionthat is to be responsible for the shard
-
startProxy
public ActorRef startProxy(java.lang.String typeName, java.util.Optional<java.lang.String> role, java.util.Optional<java.lang.String> dataCenter, akka.cluster.sharding.ShardRegion.MessageExtractor messageExtractor)
Deprecated.Use Akka Distributed Cluster instead. Since 2.10.0.Java/Scala API: Register a named entity typeShardRegionon this node that will run in proxy only mode, i.e. it will delegate messages to otherShardRegionactors on other nodes, but not host any entity actors itself. TheShardRegionactor for this type can later be retrieved with theshardRegion(java.lang.String)method.Some settings can be configured as described in the
akka.cluster.shardingsection of thereference.conf.- Parameters:
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.dataCenter- The data center of the cluster nodes where the cluster sharding is running. If None then the same data center as current node.messageExtractor- functions to extract the entity id, shard id, and the message to send to the entity from the incoming message- Returns:
- the actor ref of the
ShardRegionthat is to be responsible for the shard
-
shardTypeNames
public scala.collection.immutable.Set<java.lang.String> shardTypeNames()
Scala API: get all currently defined sharding type names.
-
getShardTypeNames
public java.util.Set<java.lang.String> getShardTypeNames()
Java API: get all currently defined sharding type names.
-
shardRegion
public ActorRef shardRegion(java.lang.String typeName)
Retrieve the actor reference of theShardRegionactor responsible for the named entity type. The entity type must be registered with thestart(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)orstartProxy(java.lang.String, scala.Option<java.lang.String>, scala.PartialFunction<java.lang.Object, scala.Tuple2<java.lang.String, java.lang.Object>>, scala.Function1<java.lang.Object, java.lang.String>)method before it can be used here. Messages to the entity is always sent via theShardRegion.
-
shardRegionProxy
public ActorRef shardRegionProxy(java.lang.String typeName, java.lang.String dataCenter)
Deprecated.Use Akka Distributed Cluster instead. Since 2.10.0.Retrieve the actor reference of theShardRegionactor that will act as a proxy to the named entity type running in another data center. A proxy within the same data center can be accessed withshardRegion(java.lang.String)instead of this method. The entity type must be registered with thestartProxy(java.lang.String, scala.Option<java.lang.String>, scala.PartialFunction<java.lang.Object, scala.Tuple2<java.lang.String, java.lang.Object>>, scala.Function1<java.lang.Object, java.lang.String>)method before it can be used here. Messages to the entity is always sent via theShardRegion.
-
defaultShardAllocationStrategy
public ShardCoordinator.ShardAllocationStrategy defaultShardAllocationStrategy(ClusterShardingSettings settings)
The defaultShardAllocationStrategyis configured byleast-shard-allocation-strategyproperties.
-
-