From bec264bdf73a2c84e5104104e7470be2c70a37cf Mon Sep 17 00:00:00 2001 From: Himadri Singh Date: Mon, 17 Feb 2014 14:25:40 +0530 Subject: [PATCH] Dynamic Config --- .../coordinator/CoordinatorDynamicConfig.java | 21 ++++++++++++++++++- .../server/coordinator/DruidCoordinator.java | 2 +- .../coordinator/DruidCoordinatorConfig.java | 4 ---- .../coordinator/DruidCoordinatorTest.java | 5 ----- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/server/src/main/java/io/druid/server/coordinator/CoordinatorDynamicConfig.java b/server/src/main/java/io/druid/server/coordinator/CoordinatorDynamicConfig.java index e4c553644fd..36605f0db28 100644 --- a/server/src/main/java/io/druid/server/coordinator/CoordinatorDynamicConfig.java +++ b/server/src/main/java/io/druid/server/coordinator/CoordinatorDynamicConfig.java @@ -31,6 +31,7 @@ public class CoordinatorDynamicConfig private final int maxSegmentsToMove; private final int replicantLifetime; private final int replicationThrottleLimit; + private final int costBalancerThreads; private final boolean emitBalancingStats; @JsonCreator @@ -41,6 +42,7 @@ public class CoordinatorDynamicConfig @JsonProperty("maxSegmentsToMove") int maxSegmentsToMove, @JsonProperty("replicantLifetime") int replicantLifetime, @JsonProperty("replicationThrottleLimit") int replicationThrottleLimit, + @JsonProperty("costBalancerThreads") int costBalancerThreads, @JsonProperty("emitBalancingStats") boolean emitBalancingStats ) { @@ -51,6 +53,7 @@ public class CoordinatorDynamicConfig this.replicantLifetime = replicantLifetime; this.replicationThrottleLimit = replicationThrottleLimit; this.emitBalancingStats = emitBalancingStats; + this.costBalancerThreads = costBalancerThreads; } @JsonProperty @@ -95,6 +98,12 @@ public class CoordinatorDynamicConfig return replicationThrottleLimit; } + @JsonProperty + public int getCostBalancerThreads() + { + return costBalancerThreads; + } + public static class Builder { private long millisToWaitBeforeDeleting; @@ -104,10 +113,11 @@ public class CoordinatorDynamicConfig private int replicantLifetime; private int replicationThrottleLimit; private boolean emitBalancingStats; + private int costBalancerThreads; 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( @@ -117,6 +127,7 @@ public class CoordinatorDynamicConfig int maxSegmentsToMove, int replicantLifetime, int replicationThrottleLimit, + int costBalancerThreads, boolean emitBalancingStats ) { @@ -127,6 +138,7 @@ public class CoordinatorDynamicConfig this.replicantLifetime = replicantLifetime; this.replicationThrottleLimit = replicationThrottleLimit; this.emitBalancingStats = emitBalancingStats; + this.costBalancerThreads = costBalancerThreads; } public Builder withMillisToWaitBeforeDeleting(long millisToWaitBeforeDeleting) @@ -165,6 +177,12 @@ public class CoordinatorDynamicConfig return this; } + public Builder withCostBalancerThreads(int costBalancerThreads) + { + this.costBalancerThreads = costBalancerThreads; + return this; + } + public CoordinatorDynamicConfig build() { return new CoordinatorDynamicConfig( @@ -174,6 +192,7 @@ public class CoordinatorDynamicConfig maxSegmentsToMove, replicantLifetime, replicationThrottleLimit, + costBalancerThreads, emitBalancingStats ); } diff --git a/server/src/main/java/io/druid/server/coordinator/DruidCoordinator.java b/server/src/main/java/io/druid/server/coordinator/DruidCoordinator.java index 770d867a8b9..19b4e2b0f68 100644 --- a/server/src/main/java/io/druid/server/coordinator/DruidCoordinator.java +++ b/server/src/main/java/io/druid/server/coordinator/DruidCoordinator.java @@ -745,7 +745,7 @@ public class DruidCoordinator else if (RANDOM.equals(config.getCoordinatorBalancerStrategy())) factory= new RandomBalancerStrategyFactory(); else if (COST_MULTI.equals(config.getCoordinatorBalancerStrategy())) - factory = new CostBalancerMultithreadStrategyFactory(config.getCostBalancerStrategyThreadCount()); + factory = new CostBalancerMultithreadStrategyFactory(getDynamicConfigs().getCostBalancerThreads()); // Do coordinator stuff. DruidCoordinatorRuntimeParams params = diff --git a/server/src/main/java/io/druid/server/coordinator/DruidCoordinatorConfig.java b/server/src/main/java/io/druid/server/coordinator/DruidCoordinatorConfig.java index 9905c013b1e..7b429cac705 100644 --- a/server/src/main/java/io/druid/server/coordinator/DruidCoordinatorConfig.java +++ b/server/src/main/java/io/druid/server/coordinator/DruidCoordinatorConfig.java @@ -46,10 +46,6 @@ public abstract class DruidCoordinatorConfig @Default("cost") public abstract String getCoordinatorBalancerStrategy(); - @Config("druid.coordinator.cost.balancer.threads") - @Default("4") - public abstract int getCostBalancerStrategyThreadCount(); - @Config("druid.coordinator.merge.on") public boolean isMergeSegments() { diff --git a/server/src/test/java/io/druid/server/coordinator/DruidCoordinatorTest.java b/server/src/test/java/io/druid/server/coordinator/DruidCoordinatorTest.java index f57e77afc3d..e1c19fe289d 100644 --- a/server/src/test/java/io/druid/server/coordinator/DruidCoordinatorTest.java +++ b/server/src/test/java/io/druid/server/coordinator/DruidCoordinatorTest.java @@ -102,11 +102,6 @@ public class DruidCoordinatorTest return null; } - @Override - public int getCostBalancerStrategyThreadCount() - { - return 1; - } }, new ZkPathsConfig(){