Dynamic Config

This commit is contained in:
Himadri Singh 2014-02-17 14:25:40 +05:30
parent 5af414c93c
commit bec264bdf7
4 changed files with 21 additions and 11 deletions

View File

@ -31,6 +31,7 @@ public class CoordinatorDynamicConfig
private final int maxSegmentsToMove; private final int maxSegmentsToMove;
private final int replicantLifetime; private final int replicantLifetime;
private final int replicationThrottleLimit; private final int replicationThrottleLimit;
private final int costBalancerThreads;
private final boolean emitBalancingStats; private final boolean emitBalancingStats;
@JsonCreator @JsonCreator
@ -41,6 +42,7 @@ public class CoordinatorDynamicConfig
@JsonProperty("maxSegmentsToMove") int maxSegmentsToMove, @JsonProperty("maxSegmentsToMove") int maxSegmentsToMove,
@JsonProperty("replicantLifetime") int replicantLifetime, @JsonProperty("replicantLifetime") int replicantLifetime,
@JsonProperty("replicationThrottleLimit") int replicationThrottleLimit, @JsonProperty("replicationThrottleLimit") int replicationThrottleLimit,
@JsonProperty("costBalancerThreads") int costBalancerThreads,
@JsonProperty("emitBalancingStats") boolean emitBalancingStats @JsonProperty("emitBalancingStats") boolean emitBalancingStats
) )
{ {
@ -51,6 +53,7 @@ public class CoordinatorDynamicConfig
this.replicantLifetime = replicantLifetime; this.replicantLifetime = replicantLifetime;
this.replicationThrottleLimit = replicationThrottleLimit; this.replicationThrottleLimit = replicationThrottleLimit;
this.emitBalancingStats = emitBalancingStats; this.emitBalancingStats = emitBalancingStats;
this.costBalancerThreads = costBalancerThreads;
} }
@JsonProperty @JsonProperty
@ -95,6 +98,12 @@ public class CoordinatorDynamicConfig
return replicationThrottleLimit; return replicationThrottleLimit;
} }
@JsonProperty
public int getCostBalancerThreads()
{
return costBalancerThreads;
}
public static class Builder public static class Builder
{ {
private long millisToWaitBeforeDeleting; private long millisToWaitBeforeDeleting;
@ -104,10 +113,11 @@ public class CoordinatorDynamicConfig
private int replicantLifetime; private int replicantLifetime;
private int replicationThrottleLimit; private int replicationThrottleLimit;
private boolean emitBalancingStats; private boolean emitBalancingStats;
private int costBalancerThreads;
public Builder() public Builder()
{ {
this(15 * 60 * 1000L, 100000000L, Integer.MAX_VALUE, 5, 15, 10, false); this(15 * 60 * 1000L, 100000000L, Integer.MAX_VALUE, 5, 15, 10, 1, false);
} }
private Builder( private Builder(
@ -117,6 +127,7 @@ public class CoordinatorDynamicConfig
int maxSegmentsToMove, int maxSegmentsToMove,
int replicantLifetime, int replicantLifetime,
int replicationThrottleLimit, int replicationThrottleLimit,
int costBalancerThreads,
boolean emitBalancingStats boolean emitBalancingStats
) )
{ {
@ -127,6 +138,7 @@ public class CoordinatorDynamicConfig
this.replicantLifetime = replicantLifetime; this.replicantLifetime = replicantLifetime;
this.replicationThrottleLimit = replicationThrottleLimit; this.replicationThrottleLimit = replicationThrottleLimit;
this.emitBalancingStats = emitBalancingStats; this.emitBalancingStats = emitBalancingStats;
this.costBalancerThreads = costBalancerThreads;
} }
public Builder withMillisToWaitBeforeDeleting(long millisToWaitBeforeDeleting) public Builder withMillisToWaitBeforeDeleting(long millisToWaitBeforeDeleting)
@ -165,6 +177,12 @@ public class CoordinatorDynamicConfig
return this; return this;
} }
public Builder withCostBalancerThreads(int costBalancerThreads)
{
this.costBalancerThreads = costBalancerThreads;
return this;
}
public CoordinatorDynamicConfig build() public CoordinatorDynamicConfig build()
{ {
return new CoordinatorDynamicConfig( return new CoordinatorDynamicConfig(
@ -174,6 +192,7 @@ public class CoordinatorDynamicConfig
maxSegmentsToMove, maxSegmentsToMove,
replicantLifetime, replicantLifetime,
replicationThrottleLimit, replicationThrottleLimit,
costBalancerThreads,
emitBalancingStats emitBalancingStats
); );
} }

View File

@ -745,7 +745,7 @@ public class DruidCoordinator
else if (RANDOM.equals(config.getCoordinatorBalancerStrategy())) else if (RANDOM.equals(config.getCoordinatorBalancerStrategy()))
factory= new RandomBalancerStrategyFactory(); factory= new RandomBalancerStrategyFactory();
else if (COST_MULTI.equals(config.getCoordinatorBalancerStrategy())) else if (COST_MULTI.equals(config.getCoordinatorBalancerStrategy()))
factory = new CostBalancerMultithreadStrategyFactory(config.getCostBalancerStrategyThreadCount()); factory = new CostBalancerMultithreadStrategyFactory(getDynamicConfigs().getCostBalancerThreads());
// Do coordinator stuff. // Do coordinator stuff.
DruidCoordinatorRuntimeParams params = DruidCoordinatorRuntimeParams params =

View File

@ -46,10 +46,6 @@ public abstract class DruidCoordinatorConfig
@Default("cost") @Default("cost")
public abstract String getCoordinatorBalancerStrategy(); public abstract String getCoordinatorBalancerStrategy();
@Config("druid.coordinator.cost.balancer.threads")
@Default("4")
public abstract int getCostBalancerStrategyThreadCount();
@Config("druid.coordinator.merge.on") @Config("druid.coordinator.merge.on")
public boolean isMergeSegments() public boolean isMergeSegments()
{ {

View File

@ -102,11 +102,6 @@ public class DruidCoordinatorTest
return null; return null;
} }
@Override
public int getCostBalancerStrategyThreadCount()
{
return 1;
}
}, },
new ZkPathsConfig(){ new ZkPathsConfig(){