mirror of https://github.com/apache/druid.git
put MAX_SEGMENTS_TO_MOVE in the config
This commit is contained in:
parent
d2ff88e923
commit
ba82fe746a
|
@ -44,7 +44,7 @@ import java.util.Set;
|
|||
public class BalancerCostAnalyzer
|
||||
{
|
||||
private static final Logger log = new Logger(BalancerCostAnalyzer.class);
|
||||
private static final int MAX_SEGMENTS_TO_MOVE = 5;
|
||||
private final int MAX_SEGMENTS_TO_MOVE;
|
||||
private static final int DAY_IN_MILLIS = 1000 * 60 * 60 * 24;
|
||||
private static final int SEVEN_DAYS_IN_MILLIS = 7 * DAY_IN_MILLIS;
|
||||
private static final int THIRTY_DAYS_IN_MILLIS = 30 * DAY_IN_MILLIS;
|
||||
|
@ -58,9 +58,10 @@ public class BalancerCostAnalyzer
|
|||
private double totalCostChange;
|
||||
private int totalSegments;
|
||||
|
||||
public BalancerCostAnalyzer(DateTime referenceTimestamp)
|
||||
public BalancerCostAnalyzer(DateTime referenceTimestamp, int MAX_SEGMENTS_TO_MOVE)
|
||||
{
|
||||
this.referenceTimestamp = referenceTimestamp;
|
||||
this.MAX_SEGMENTS_TO_MOVE = MAX_SEGMENTS_TO_MOVE;
|
||||
rand = new Random(0);
|
||||
totalCostChange = 0;
|
||||
}
|
||||
|
|
|
@ -132,6 +132,11 @@ public class DruidMaster
|
|||
return master;
|
||||
}
|
||||
|
||||
public DruidMasterConfig getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
public Map<String, Double> getLoadStatus()
|
||||
{
|
||||
Map<String, Integer> availableSegmentMap = Maps.newHashMap();
|
||||
|
@ -675,7 +680,7 @@ public class DruidMaster
|
|||
},
|
||||
new DruidMasterRuleRunner(DruidMaster.this),
|
||||
new DruidMasterCleanup(DruidMaster.this),
|
||||
new DruidMasterBalancer(DruidMaster.this, new BalancerCostAnalyzer(DateTime.now())),
|
||||
new DruidMasterBalancer(DruidMaster.this, new BalancerCostAnalyzer(DateTime.now(), config.getMaxSegmentsToMove())),
|
||||
new DruidMasterLogger()
|
||||
)
|
||||
);
|
||||
|
|
|
@ -80,4 +80,8 @@ public abstract class DruidMasterConfig
|
|||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Config("druid.master.balancer.maxSegmentsToMove")
|
||||
@Default("5")
|
||||
public abstract int getMaxSegmentsToMove();
|
||||
}
|
||||
|
|
|
@ -59,7 +59,15 @@ public abstract class LoadRule implements Rule
|
|||
return stats;
|
||||
}
|
||||
|
||||
stats.accumulate(assign(expectedReplicants, totalReplicants, serverQueue, segment));
|
||||
stats.accumulate(
|
||||
assign(
|
||||
expectedReplicants,
|
||||
totalReplicants,
|
||||
serverQueue,
|
||||
segment,
|
||||
master.getConfig().getMaxSegmentsToMove()
|
||||
)
|
||||
);
|
||||
stats.accumulate(drop(expectedReplicants, clusterReplicants, segment, params));
|
||||
|
||||
return stats;
|
||||
|
@ -69,7 +77,8 @@ public abstract class LoadRule implements Rule
|
|||
int expectedReplicants,
|
||||
int totalReplicants,
|
||||
MinMaxPriorityQueue<ServerHolder> serverQueue,
|
||||
DataSegment segment
|
||||
DataSegment segment,
|
||||
int MAX_SEGMENTS_TO_MOVE
|
||||
)
|
||||
{
|
||||
MasterStats stats = new MasterStats();
|
||||
|
@ -78,7 +87,7 @@ public abstract class LoadRule implements Rule
|
|||
|
||||
List<ServerHolder> assignedServers = Lists.newArrayList();
|
||||
while (totalReplicants < expectedReplicants) {
|
||||
BalancerCostAnalyzer analyzer = new BalancerCostAnalyzer(DateTime.now());
|
||||
BalancerCostAnalyzer analyzer = new BalancerCostAnalyzer(DateTime.now(), MAX_SEGMENTS_TO_MOVE);
|
||||
BalancerCostAnalyzer.BalancerCostAnalyzerHelper helper = analyzer.new BalancerCostAnalyzerHelper(serverHolderList, segment);
|
||||
helper.computeAllCosts();
|
||||
Pair<Double, ServerHolder> minPair = helper.getCostsServerHolderPairs().pollFirst();
|
||||
|
|
Loading…
Reference in New Issue