From e00c099f189cf4783834d38d3f7757a4e5bd2eed Mon Sep 17 00:00:00 2001 From: David Pilato Date: Wed, 29 Apr 2015 13:51:49 +0200 Subject: [PATCH] Fix non working update dynamic settings Described in https://github.com/elastic/elasticsearch/issues/10614, it's not possible with cloud discovery plugin to update dynamic settings anymore. ```sh curl -XPUT localhost:9200/_cluster/settings -d '{ "persistent" : { "discovery.zen.minimum_master_nodes" : 3 }, "transient" : { "discovery.zen.minimum_master_nodes" : 3 } }' ``` gives ```json {"acknowledged":true,"persistent":{},"transient":{}} ``` This patch makes that working again. (cherry picked from commit 37d6897) (cherry picked from commit 7a8c7b0ed5601dc71b8d3376cd197b8e0db2bbbd) Conflicts: src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java --- .../discovery/ec2/Ec2Discovery.java | 3 +- .../ec2/Ec2DiscoveryUpdateSettingsITest.java | 63 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsITest.java diff --git a/src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java b/src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java index 80e5c0226d0..4c6bc8c116c 100755 --- a/src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java +++ b/src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java @@ -21,6 +21,7 @@ package org.elasticsearch.discovery.ec2; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; +import org.elasticsearch.cluster.settings.ClusterDynamicSettings; import org.elasticsearch.cluster.settings.DynamicSettings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -41,7 +42,7 @@ public class Ec2Discovery extends ZenDiscovery { public Ec2Discovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, TransportService transportService, ClusterService clusterService, NodeSettingsService nodeSettingsService, ZenPingService pingService, DiscoverySettings discoverySettings, - ElectMasterService electMasterService, DynamicSettings dynamicSettings) { + ElectMasterService electMasterService, @ClusterDynamicSettings DynamicSettings dynamicSettings) { super(settings, clusterName, threadPool, transportService, clusterService, nodeSettingsService, pingService, electMasterService, discoverySettings, dynamicSettings); } diff --git a/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsITest.java b/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsITest.java new file mode 100644 index 00000000000..ca1b4d4ef19 --- /dev/null +++ b/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsITest.java @@ -0,0 +1,63 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.discovery.ec2; + + +import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; +import org.elasticsearch.cloud.aws.AbstractAwsTest; +import org.elasticsearch.cloud.aws.AbstractAwsTest.AwsTest; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.plugins.PluginsService; +import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope; +import org.elasticsearch.test.ElasticsearchIntegrationTest.Scope; +import org.junit.Test; + +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; +import static org.hamcrest.CoreMatchers.is; + +/** + * Just an empty Node Start test to check eveything if fine when + * starting. + * This test requires AWS to run. + */ +@AwsTest +@ClusterScope(scope = Scope.TEST, numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0.0) +public class Ec2DiscoveryUpdateSettingsITest extends AbstractAwsTest { + + @Test + public void testMinimumMasterNodesStart() { + Settings nodeSettings = settingsBuilder() + .put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true) + .put("cloud.enabled", true) + .put("discovery.type", "ec2") + .build(); + internalCluster().startNode(nodeSettings); + + // We try to update minimum_master_nodes now + ClusterUpdateSettingsResponse response = client().admin().cluster().prepareUpdateSettings() + .setPersistentSettings(settingsBuilder().put("discovery.zen.minimum_master_nodes", 1)) + .setTransientSettings(settingsBuilder().put("discovery.zen.minimum_master_nodes", 1)) + .get(); + + Integer min = response.getPersistentSettings().getAsInt("discovery.zen.minimum_master_nodes", null); + assertThat(min, is(1)); + } + +}