Class ClusterSharding
- All Implemented Interfaces:
Extension
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Tapply(ActorSystem system) static Tapply(ClassicActorSystemProvider system) static ClusterShardingcreateExtension(ExtendedActorSystem system) The defaultShardAllocationStrategyis configured byleast-shard-allocation-strategyproperties.static final booleanstatic ClusterShardingget(ActorSystem system) static ClusterShardingget(ClassicActorSystemProvider system) Java API: get all currently defined sharding type names.static final inthashCode()static ClusterSharding$lookup()shardRegion(String typeName) Retrieve the actor reference of theShardRegionactor responsible for the named entity type.shardRegionProxy(String typeName, String dataCenter) Retrieve the actor reference of theShardRegionactor that will act as a proxy to the named entity type running in another data center.scala.collection.immutable.Set<String>Scala API: get all currently defined sharding type names.start(String typeName, Props entityProps, ClusterShardingSettings settings, org.apache.pekko.cluster.sharding.ShardRegion.MessageExtractor messageExtractor) Java/Scala API: Register a named entity type by defining thepekko.actor.Propsof the entity actor and functions to extract entity and shard identifier from messages.start(String typeName, Props entityProps, ClusterShardingSettings settings, org.apache.pekko.cluster.sharding.ShardRegion.MessageExtractor messageExtractor, ShardCoordinator.ShardAllocationStrategy allocationStrategy, Object handOffStopMessage) Java/Scala API: Register a named entity type by defining thepekko.actor.Propsof the entity actor and functions to extract entity and shard identifier from messages.start(String typeName, Props entityProps, ClusterShardingSettings settings, scala.PartialFunction<Object, scala.Tuple2<String, Object>> extractEntityId, scala.Function1<Object, String> extractShardId) Register a named entity type by defining thepekko.actor.Propsof the entity actor and functions to extract entity and shard identifier from messages.start(String typeName, Props entityProps, ClusterShardingSettings settings, scala.PartialFunction<Object, scala.Tuple2<String, Object>> extractEntityId, scala.Function1<Object, String> extractShardId, ShardCoordinator.ShardAllocationStrategy allocationStrategy, Object handOffStopMessage) Scala API: Register a named entity type by defining thepekko.actor.Propsof the entity actor and functions to extract entity and shard identifier from messages.start(String typeName, Props entityProps, org.apache.pekko.cluster.sharding.ShardRegion.MessageExtractor messageExtractor) Java/Scala API: Register a named entity type by defining thepekko.actor.Propsof the entity actor and functions to extract entity and shard identifier from messages.start(String typeName, Props entityProps, scala.PartialFunction<Object, scala.Tuple2<String, Object>> extractEntityId, scala.Function1<Object, String> extractShardId) Register a named entity type by defining thepekko.actor.Propsof the entity actor and functions to extract entity and shard identifier from messages.start(String typeName, Props entityProps, scala.PartialFunction<Object, scala.Tuple2<String, Object>> extractEntityId, scala.Function1<Object, String> extractShardId, ShardCoordinator.ShardAllocationStrategy allocationStrategy, Object handOffStopMessage) Scala API: Register a named entity type by defining thepekko.actor.Propsof the entity actor and functions to extract entity and shard identifier from messages.startProxy(String typeName, Optional<String> role, Optional<String> dataCenter, org.apache.pekko.cluster.sharding.ShardRegion.MessageExtractor messageExtractor) Java/Scala API: Register a named entity typeShardRegionon this node that will run in proxy only mode, i.e.startProxy(String typeName, Optional<String> role, org.apache.pekko.cluster.sharding.ShardRegion.MessageExtractor messageExtractor) Java/Scala API: Register a named entity typeShardRegionon this node that will run in proxy only mode, i.e.startProxy(String typeName, scala.Option<String> role, scala.Option<String> dataCenter, scala.PartialFunction<Object, scala.Tuple2<String, Object>> extractEntityId, scala.Function1<Object, String> extractShardId) Scala API: Register a named entity typeShardRegionon this node that will run in proxy only mode, i.e.startProxy(String typeName, scala.Option<String> role, scala.PartialFunction<Object, scala.Tuple2<String, Object>> extractEntityId, scala.Function1<Object, String> extractShardId) Scala API: Register a named entity typeShardRegionon this node that will run in proxy only mode, i.e.
-
Constructor Details
-
ClusterSharding
-
-
Method Details
-
get
-
get
-
lookup
-
createExtension
-
apply
-
apply
-
hashCode
public static final int hashCode() -
equals
-
start
public ActorRef start(String typeName, Props entityProps, ClusterShardingSettings settings, scala.PartialFunction<Object, scala.Tuple2<String, Object>> extractEntityId, scala.Function1<Object, String> extractShardId, ShardCoordinator.ShardAllocationStrategy allocationStrategy, Object handOffStopMessage) Scala API: Register a named entity type by defining thepekko.actor.Propsof 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
pekko.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(String typeName, Props entityProps, scala.PartialFunction<Object, scala.Tuple2<String, Object>> extractEntityId, scala.Function1<Object, String> extractShardId, ShardCoordinator.ShardAllocationStrategy allocationStrategy, Object handOffStopMessage) Scala API: Register a named entity type by defining thepekko.actor.Propsof 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
pekko.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(String typeName, Props entityProps, ClusterShardingSettings settings, scala.PartialFunction<Object, scala.Tuple2<String, Object>> extractEntityId, scala.Function1<Object, String> extractShardId) Register a named entity type by defining thepekko.actor.Propsof 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.pekko.actor.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
pekko.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(String typeName, Props entityProps, scala.PartialFunction<Object, scala.Tuple2<String, Object>> extractEntityId, scala.Function1<Object, String> extractShardId) Register a named entity type by defining thepekko.actor.Propsof 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.pekko.actor.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
pekko.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(String typeName, Props entityProps, ClusterShardingSettings settings, org.apache.pekko.cluster.sharding.ShardRegion.MessageExtractor messageExtractor, ShardCoordinator.ShardAllocationStrategy allocationStrategy, Object handOffStopMessage) Java/Scala API: Register a named entity type by defining thepekko.actor.Propsof 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
pekko.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(String typeName, Props entityProps, ClusterShardingSettings settings, org.apache.pekko.cluster.sharding.ShardRegion.MessageExtractor messageExtractor) Java/Scala API: Register a named entity type by defining thepekko.actor.Propsof 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.pekko.actor.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
pekko.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(String typeName, Props entityProps, org.apache.pekko.cluster.sharding.ShardRegion.MessageExtractor messageExtractor) Java/Scala API: Register a named entity type by defining thepekko.actor.Propsof 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.pekko.actor.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
pekko.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(String typeName, scala.Option<String> role, scala.PartialFunction<Object, scala.Tuple2<String, Object>> extractEntityId, scala.Function1<Object, 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
pekko.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(String typeName, scala.Option<String> role, scala.Option<String> dataCenter, scala.PartialFunction<Object, scala.Tuple2<String, Object>> extractEntityId, scala.Function1<Object, 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
pekko.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(String typeName, Optional<String> role, org.apache.pekko.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
pekko.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(String typeName, Optional<String> role, Optional<String> dataCenter, org.apache.pekko.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
pekko.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
Scala API: get all currently defined sharding type names. -
getShardTypeNames
Java API: get all currently defined sharding type names. -
shardRegion
Retrieve the actor reference of theShardRegionactor responsible for the named entity type. The entity type must be registered with thestart(java.lang.String, org.apache.pekko.actor.Props, org.apache.pekko.cluster.sharding.ClusterShardingSettings, scala.PartialFunction<java.lang.Object, scala.Tuple2<java.lang.String, java.lang.Object>>, scala.Function1<java.lang.Object, java.lang.String>, org.apache.pekko.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
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.
-