allow to dynamically set cluster.routing.allocation.cluster_concurrent_rebalance using cluster update settings API

This commit is contained in:
Shay Banon 2011-09-25 21:09:15 +03:00
parent 4876e5a968
commit e8b88acbd3
1 changed files with 19 additions and 1 deletions

View File

@ -19,6 +19,7 @@
package org.elasticsearch.cluster.routing.allocation.decider; package org.elasticsearch.cluster.routing.allocation.decider;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.routing.MutableShardRouting; import org.elasticsearch.cluster.routing.MutableShardRouting;
import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRouting;
@ -26,10 +27,27 @@ import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.settings.NodeSettingsService;
public class ConcurrentRebalanceAllocationDecider extends AllocationDecider { public class ConcurrentRebalanceAllocationDecider extends AllocationDecider {
private final int clusterConcurrentRebalance; static {
MetaData.addDynamicSettings(
"cluster.routing.allocation.cluster_concurrent_rebalance"
);
}
class ApplySettings implements NodeSettingsService.Listener {
@Override public void onRefreshSettings(Settings settings) {
int clusterConcurrentRebalance = settings.getAsInt("cluster.routing.allocation.cluster_concurrent_rebalance", ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance);
if (clusterConcurrentRebalance != ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance) {
logger.info("updating [cluster.routing.allocation.cluster_concurrent_rebalance] from [{}], to [{}]", ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance, clusterConcurrentRebalance);
ConcurrentRebalanceAllocationDecider.this.clusterConcurrentRebalance = clusterConcurrentRebalance;
}
}
}
private volatile int clusterConcurrentRebalance;
@Inject public ConcurrentRebalanceAllocationDecider(Settings settings) { @Inject public ConcurrentRebalanceAllocationDecider(Settings settings) {
super(settings); super(settings);