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 Classes
    Modifier and Type
    Class
    Description
    static final class 
    Notification message that contains rebalance status.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ParallelLeastShardAllocationStrategy(int maxParallel, int rebalanceThreshold, Optional<org.apache.pekko.actor.ActorSelection> notify)
    Public constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    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)
     
    scala.concurrent.Future<Set<String>>
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 parallel
      rebalanceThreshold - difference in number of shards required to cause a rebalance
      notify - the ActorSelection 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 class org.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 class org.apache.pekko.cluster.sharding.ShardCoordinator.AbstractShardAllocationStrategy