Class RandomBalancerStrategy
java.lang.Object
org.apache.druid.server.coordinator.balancer.RandomBalancerStrategy
- All Implemented Interfaces:
BalancerStrategy
A simple
BalancerStrategy that
- assigns segments randomly amongst eligible servers
- performs no balancing
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindDestinationServerToMoveSegment(DataSegment segmentToMove, ServerHolder sourceServer, List<ServerHolder> serverHolders) Finds the best server from the list ofdestinationServersto load thesegmentToMove, if it is moved from thesourceServer.findServersToDropSegment(DataSegment segmentToDrop, List<ServerHolder> serverHolders) Finds the best servers to drop the given segment.findServersToLoadSegment(DataSegment segmentToLoad, List<ServerHolder> serverHolders) Finds the best servers to load the given segment.getStats()Returns the stats collected by the strategy.
-
Constructor Details
-
RandomBalancerStrategy
public RandomBalancerStrategy()
-
-
Method Details
-
findServersToLoadSegment
public Iterator<ServerHolder> findServersToLoadSegment(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(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(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
Description copied from interface:BalancerStrategyReturns the stats collected by the strategy.- Specified by:
getStatsin interfaceBalancerStrategy
-