Skip to content

Commit

Permalink
Internal: Flatten ClusterModule and add more tests
Browse files Browse the repository at this point in the history
The ClusterModule contained a couple submodules. This moves the
functionality from those modules into ClusterModule. Two of those
had to do with DynamicSettings. This change also cleans up
how DynamicSettings are built, and enforces they are added, with
validators, in ClusterModule.

See elastic#12783.
  • Loading branch information
rjernst committed Aug 16, 2015
1 parent 9b08f40 commit 008dc8e
Show file tree
Hide file tree
Showing 24 changed files with 668 additions and 710 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public ClusterState execute(final ClusterState currentState) {
transientSettings.put(currentState.metaData().transientSettings());
for (Map.Entry<String, String> entry : request.transientSettings().getAsMap().entrySet()) {
if (dynamicSettings.isDynamicOrLoggingSetting(entry.getKey())) {
String error = dynamicSettings.validateDynamicSetting(entry.getKey(), entry.getValue());
String error = dynamicSettings.validateDynamicSetting(entry.getKey(), entry.getValue(), clusterService.state());
if (error == null) {
transientSettings.put(entry.getKey(), entry.getValue());
transientUpdates.put(entry.getKey(), entry.getValue());
Expand All @@ -200,7 +200,7 @@ public ClusterState execute(final ClusterState currentState) {
persistentSettings.put(currentState.metaData().persistentSettings());
for (Map.Entry<String, String> entry : request.persistentSettings().getAsMap().entrySet()) {
if (dynamicSettings.isDynamicOrLoggingSetting(entry.getKey())) {
String error = dynamicSettings.validateDynamicSetting(entry.getKey(), entry.getValue());
String error = dynamicSettings.validateDynamicSetting(entry.getKey(), entry.getValue(), clusterService.state());
if (error == null) {
persistentSettings.put(entry.getKey(), entry.getValue());
persistentUpdates.put(entry.getKey(), entry.getValue());
Expand Down
296 changes: 265 additions & 31 deletions core/src/main/java/org/elasticsearch/cluster/ClusterModule.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void updateSettings(final UpdateSettingsClusterStateUpdateRequest request
if (!dynamicSettings.hasDynamicSetting(setting.getKey())) {
removedSettings.add(setting.getKey());
} else {
String error = dynamicSettings.validateDynamicSetting(setting.getKey(), setting.getValue());
String error = dynamicSettings.validateDynamicSetting(setting.getKey(), setting.getValue(), clusterService.state());
if (error != null) {
errors.add("[" + setting.getKey() + "] - " + error);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.elasticsearch.cluster.routing.allocation.decider;

import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
import org.elasticsearch.cluster.settings.Validator;
Expand Down Expand Up @@ -52,7 +53,7 @@ public class ClusterRebalanceAllocationDecider extends AllocationDecider {
public static final String CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE = "cluster.routing.allocation.allow_rebalance";
public static final Validator ALLOCATION_ALLOW_REBALANCE_VALIDATOR = new Validator() {
@Override
public String validate(String setting, String value) {
public String validate(String setting, String value, ClusterState clusterState) {
try {
ClusterRebalanceType.parseString(value);
return null;
Expand Down

This file was deleted.

Loading

0 comments on commit 008dc8e

Please sign in to comment.