mirror of https://github.com/apache/druid.git
Check lower bound of replicant values for rules
This commit is contained in:
parent
600b30566c
commit
1030899cdf
|
@ -36,6 +36,7 @@ public class ForeverLoadRule extends LoadRule
|
||||||
@JsonProperty("tieredReplicants") Map<String, Integer> tieredReplicants
|
@JsonProperty("tieredReplicants") Map<String, Integer> tieredReplicants
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
validateTieredReplicants(tieredReplicants);
|
||||||
this.tieredReplicants = tieredReplicants;
|
this.tieredReplicants = tieredReplicants;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class IntervalLoadRule extends LoadRule
|
||||||
@JsonProperty("tieredReplicants") Map<String, Integer> tieredReplicants
|
@JsonProperty("tieredReplicants") Map<String, Integer> tieredReplicants
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
validateTieredReplicants(tieredReplicants);
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
this.tieredReplicants = tieredReplicants;
|
this.tieredReplicants = tieredReplicants;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package io.druid.server.coordinator.rules;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.MinMaxPriorityQueue;
|
import com.google.common.collect.MinMaxPriorityQueue;
|
||||||
|
import com.metamx.common.IAE;
|
||||||
import com.metamx.emitter.EmittingLogger;
|
import com.metamx.emitter.EmittingLogger;
|
||||||
import io.druid.server.coordinator.BalancerStrategy;
|
import io.druid.server.coordinator.BalancerStrategy;
|
||||||
import io.druid.server.coordinator.CoordinatorStats;
|
import io.druid.server.coordinator.CoordinatorStats;
|
||||||
|
@ -240,6 +241,13 @@ public abstract class LoadRule implements Rule
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void validateTieredReplicants(Map<String, Integer> tieredReplicants){
|
||||||
|
for (Map.Entry<String, Integer> entry: tieredReplicants.entrySet()) {
|
||||||
|
if (entry.getValue() < 0)
|
||||||
|
throw new IAE("Replicant value [%d] is less than 0, which is not allowed", entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public abstract Map<String, Integer> getTieredReplicants();
|
public abstract Map<String, Integer> getTieredReplicants();
|
||||||
|
|
||||||
public abstract int getNumReplicants(String tier);
|
public abstract int getNumReplicants(String tier);
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class PeriodLoadRule extends LoadRule
|
||||||
@JsonProperty("tieredReplicants") Map<String, Integer> tieredReplicants
|
@JsonProperty("tieredReplicants") Map<String, Integer> tieredReplicants
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
validateTieredReplicants(tieredReplicants);
|
||||||
this.period = period;
|
this.period = period;
|
||||||
this.tieredReplicants = tieredReplicants;
|
this.tieredReplicants = tieredReplicants;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue