Package com.arpnetworking.utility
Class ParallelLeastShardAllocationStrategy
java.lang.Object
org.apache.pekko.cluster.sharding.ShardCoordinator.AbstractShardAllocationStrategy
com.arpnetworking.utility.ParallelLeastShardAllocationStrategy
- All Implemented Interfaces:
org.apache.pekko.actor.NoSerializationVerificationNeeded
,org.apache.pekko.cluster.sharding.ShardCoordinator.ShardAllocationStrategy
public final class ParallelLeastShardAllocationStrategy
extends org.apache.pekko.cluster.sharding.ShardCoordinator.AbstractShardAllocationStrategy
Implementation of the least shard allocation strategy that seeks to parallelize shard rebalancing.
- Author:
- Brandon Arp (brandon dot arp at inscopemetrics dot com)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Notification message that contains rebalance status. -
Constructor Summary
ConstructorsConstructorDescriptionParallelLeastShardAllocationStrategy
(int maxParallel, int rebalanceThreshold, Optional<org.apache.pekko.actor.ActorSelection> notify) Public constructor. -
Method Summary
Modifier and TypeMethodDescriptionscala.concurrent.Future
<org.apache.pekko.actor.ActorRef> allocateShard
(org.apache.pekko.actor.ActorRef requester, String shardId, Map<org.apache.pekko.actor.ActorRef, scala.collection.immutable.IndexedSeq<String>> currentShardAllocations) rebalance
(Map<org.apache.pekko.actor.ActorRef, scala.collection.immutable.IndexedSeq<String>> currentShardAllocations, Set<String> rebalanceInProgress) Methods inherited from class org.apache.pekko.cluster.sharding.ShardCoordinator.AbstractShardAllocationStrategy
allocateShard, rebalance
-
Constructor Details
-
ParallelLeastShardAllocationStrategy
public ParallelLeastShardAllocationStrategy(int maxParallel, int rebalanceThreshold, Optional<org.apache.pekko.actor.ActorSelection> notify) Public constructor.- Parameters:
maxParallel
- number of allocations to start in parallelrebalanceThreshold
- difference in number of shards required to cause a rebalancenotify
- theActorSelection
selection to notify of changes
-
-
Method Details
-
allocateShard
public scala.concurrent.Future<org.apache.pekko.actor.ActorRef> allocateShard(org.apache.pekko.actor.ActorRef requester, String shardId, Map<org.apache.pekko.actor.ActorRef, scala.collection.immutable.IndexedSeq<String>> currentShardAllocations) - Specified by:
allocateShard
in classorg.apache.pekko.cluster.sharding.ShardCoordinator.AbstractShardAllocationStrategy
-
rebalance
public scala.concurrent.Future<Set<String>> rebalance(Map<org.apache.pekko.actor.ActorRef, scala.collection.immutable.IndexedSeq<String>> currentShardAllocations, Set<String> rebalanceInProgress) - Specified by:
rebalance
in classorg.apache.pekko.cluster.sharding.ShardCoordinator.AbstractShardAllocationStrategy
-