public class CostBalancerStrategy extends Object implements BalancerStrategy
| Constructor and Description |
|---|
CostBalancerStrategy(com.google.common.util.concurrent.ListeningExecutorService exec) |
| Modifier and Type | Method and Description |
|---|---|
double |
calculateInitialTotalCost(List<ServerHolder> serverHolders)
Calculates the initial cost of the Druid segment configuration.
|
double |
calculateNormalization(List<ServerHolder> serverHolders)
Calculates the cost normalization.
|
protected Pair<Double,ServerHolder> |
chooseBestServer(DataSegment proposalSegment,
Iterable<ServerHolder> serverHolders,
boolean includeCurrentServer)
For assignment, we want to move to the lowest cost server that isn't already serving the segment.
|
protected double |
computeCost(DataSegment proposalSegment,
ServerHolder server,
boolean includeCurrentServer) |
static double |
computeJointSegmentsCost(DataSegment segmentA,
DataSegment segmentB)
This defines the unnormalized cost function between two segments.
|
void |
emitStats(String tier,
CoordinatorStats stats,
List<ServerHolder> serverHolderList)
Add balancing strategy stats during the 'balanceTier' operation of
BalanceSegments to be included |
ServerHolder |
findNewSegmentHomeBalancer(DataSegment proposalSegment,
List<ServerHolder> serverHolders)
Find the best server to move a
DataSegment to according the balancing strategy. |
ServerHolder |
findNewSegmentHomeReplicator(DataSegment proposalSegment,
List<ServerHolder> serverHolders)
Find the best server on which to place a
DataSegment replica according to the balancing strategy |
static double |
intervalCost(double x1,
double y0,
double y1)
Computes the joint cost of two intervals X = [x_0 = 0, x_1) and Y = [y_0, y_1)
cost(X, Y) = \int_{x_0}^{x_1} \int_{y_0}^{y_1} e^{-\lambda |x-y|}dxdy $$
lambda = 1 in this particular implementation
Other values of lambda can be calculated by multiplying inputs by lambda
and multiplying the result by 1 / lambda ^ 2
Interval start and end are all relative to x_0.
|
Iterator<ServerHolder> |
pickServersToDrop(DataSegment toDrop,
NavigableSet<ServerHolder> serverHolders)
Returns an iterator for a set of servers to drop from, ordered by preference of which server to drop from first
for a given drop strategy.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpickSegmentsToMovepublic CostBalancerStrategy(com.google.common.util.concurrent.ListeningExecutorService exec)
public static double computeJointSegmentsCost(DataSegment segmentA, DataSegment segmentB)
segmentA - The first DataSegment.segmentB - The second DataSegment.public static double intervalCost(double x1,
double y0,
double y1)
x1 - end of interval Xy0 - start of interval Yy1 - end o interval Ypublic ServerHolder findNewSegmentHomeReplicator(DataSegment proposalSegment, List<ServerHolder> serverHolders)
BalancerStrategyDataSegment replica according to the balancing strategyfindNewSegmentHomeReplicator in interface BalancerStrategyproposalSegment - segment to replicateserverHolders - servers to consider as replica holderspublic ServerHolder findNewSegmentHomeBalancer(DataSegment proposalSegment, List<ServerHolder> serverHolders)
BalancerStrategyDataSegment to according the balancing strategy.findNewSegmentHomeBalancer in interface BalancerStrategyproposalSegment - segment to moveserverHolders - servers to consider as move destinationspublic Iterator<ServerHolder> pickServersToDrop(DataSegment toDrop, NavigableSet<ServerHolder> serverHolders)
BalancerStrategypickServersToDrop in interface BalancerStrategytoDrop - segment to drop from one or more serversserverHolders - set of historicals to consider dropping frompublic double calculateInitialTotalCost(List<ServerHolder> serverHolders)
serverHolders - A list of ServerHolders for a particular tier.public double calculateNormalization(List<ServerHolder> serverHolders)
serverHolders - A list of ServerHolders for a particular tier.public void emitStats(String tier, CoordinatorStats stats, List<ServerHolder> serverHolderList)
BalancerStrategyBalanceSegments to be includedemitStats in interface BalancerStrategytier - historical tier being balancedstats - stats object to add balancing strategy stats toserverHolderList - servers in tier being balancedprotected double computeCost(DataSegment proposalSegment, ServerHolder server, boolean includeCurrentServer)
protected Pair<Double,ServerHolder> chooseBestServer(DataSegment proposalSegment, Iterable<ServerHolder> serverHolders, boolean includeCurrentServer)
proposalSegment - A DataSegment that we are proposing to move.serverHolders - An iterable of ServerHolders for a particular tier.Copyright © 2011–2021 The Apache Software Foundation. All rights reserved.