Interface BalancerStrategy
- All Known Implementing Classes:
CachingCostBalancerStrategy,CostBalancerStrategy,DiskNormalizedCostBalancerStrategy,RandomBalancerStrategy
public interface BalancerStrategy
Segment balancing strategy, used in every coordinator run by
StrategicSegmentAssigner
to choose optimal servers to load, move or drop a segment.-
Method Summary
Modifier and TypeMethodDescriptionfindDestinationServerToMoveSegment(DataSegment segmentToMove, ServerHolder sourceServer, List<ServerHolder> destinationServers) 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.
-
Method Details
-
findDestinationServerToMoveSegment
@Nullable ServerHolder findDestinationServerToMoveSegment(DataSegment segmentToMove, ServerHolder sourceServer, List<ServerHolder> destinationServers) Finds 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.- Returns:
- The server to move to, or null if the segment is already optimally placed.
-
findServersToLoadSegment
Iterator<ServerHolder> findServersToLoadSegment(DataSegment segmentToLoad, List<ServerHolder> serverHolders) Finds 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.- Returns:
- Iterator over the best servers (in order of preference) to load the segment.
-
findServersToDropSegment
Iterator<ServerHolder> findServersToDropSegment(DataSegment segmentToDrop, List<ServerHolder> serverHolders) Finds the best servers to drop the given segment.- Returns:
- Iterator over the servers (in order of preference) to drop the segment
-
getStats
CoordinatorRunStats getStats()Returns the stats collected by the strategy.
-