Class RandomBalancerStrategy
- java.lang.Object
-
- org.apache.druid.server.coordinator.balancer.RandomBalancerStrategy
-
- All Implemented Interfaces:
BalancerStrategy
public class RandomBalancerStrategy extends Object implements BalancerStrategy
A simpleBalancerStrategythat- assigns segments randomly amongst eligible servers
- performs no balancing
-
-
Constructor Summary
Constructors Constructor Description RandomBalancerStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ServerHolderfindDestinationServerToMoveSegment(org.apache.druid.timeline.DataSegment segmentToMove, ServerHolder sourceServer, List<ServerHolder> serverHolders)Finds the best server from the list ofdestinationServersto load thesegmentToMove, if it is moved from thesourceServer.Iterator<ServerHolder>findServersToDropSegment(org.apache.druid.timeline.DataSegment segmentToDrop, List<ServerHolder> serverHolders)Finds the best servers to drop the given segment.Iterator<ServerHolder>findServersToLoadSegment(org.apache.druid.timeline.DataSegment segmentToLoad, List<ServerHolder> serverHolders)Finds the best servers to load the given segment.CoordinatorRunStatsgetStats()Returns the stats collected by the strategy.
-
-
-
Method Detail
-
findServersToLoadSegment
public Iterator<ServerHolder> findServersToLoadSegment(org.apache.druid.timeline.DataSegment segmentToLoad, List<ServerHolder> serverHolders)
Description copied from interface:BalancerStrategyFinds the best servers to load the given segment. This method can be used both for placing the first copy of a segment in a tier or a replica of an already available segment.- Specified by:
findServersToLoadSegmentin interfaceBalancerStrategy- Returns:
- Iterator over the best servers (in order of preference) to load the segment.
-
findDestinationServerToMoveSegment
public ServerHolder findDestinationServerToMoveSegment(org.apache.druid.timeline.DataSegment segmentToMove, ServerHolder sourceServer, List<ServerHolder> serverHolders)
Description copied from interface:BalancerStrategyFinds the best server from the list ofdestinationServersto load thesegmentToMove, if it is moved from thesourceServer.In order to avoid unnecessary moves when the segment is already optimally placed, include the
sourceServerin the list ofdestinationServers.- Specified by:
findDestinationServerToMoveSegmentin interfaceBalancerStrategy- Returns:
- The server to move to, or null if the segment is already optimally placed.
-
findServersToDropSegment
public Iterator<ServerHolder> findServersToDropSegment(org.apache.druid.timeline.DataSegment segmentToDrop, List<ServerHolder> serverHolders)
Description copied from interface:BalancerStrategyFinds the best servers to drop the given segment.- Specified by:
findServersToDropSegmentin interfaceBalancerStrategy- Returns:
- Iterator over the servers (in order of preference) to drop the segment
-
getStats
public CoordinatorRunStats getStats()
Description copied from interface:BalancerStrategyReturns the stats collected by the strategy.- Specified by:
getStatsin interfaceBalancerStrategy
-
-