Search in sources :

Example 6 with DiscoverySettings

use of org.elasticsearch.discovery.DiscoverySettings in project elasticsearch by elastic.

the class ClusterSettingsIT method testUpdateDiscoveryPublishTimeout.

public void testUpdateDiscoveryPublishTimeout() {
    DiscoverySettings discoverySettings = getDiscoverySettings();
    assertThat(discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
    ClusterUpdateSettingsResponse response = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s").build()).get();
    assertAcked(response);
    assertThat(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s"));
    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
    try {
        client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "whatever").build()).get();
        fail("bogus value");
    } catch (IllegalArgumentException ex) {
        assertEquals(ex.getMessage(), "failed to parse setting [discovery.zen.publish_timeout] with value [whatever] as a time value: unit is missing or unrecognized");
    }
    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
    try {
        client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), -1).build()).get();
        fail("bogus value");
    } catch (IllegalArgumentException ex) {
        assertEquals(ex.getMessage(), "Failed to parse value [-1] for setting [discovery.zen.publish_timeout] must be >= 0s");
    }
    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
}
Also used : DiscoverySettings(org.elasticsearch.discovery.DiscoverySettings) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse)

Example 7 with DiscoverySettings

use of org.elasticsearch.discovery.DiscoverySettings in project elasticsearch by elastic.

the class ClusterSettingsIT method testResetClusterSetting.

public void testResetClusterSetting() {
    DiscoverySettings discoverySettings = getDiscoverySettings();
    assertThat(discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
    assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
    ClusterUpdateSettingsResponse response = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s").build()).get();
    assertAcked(response);
    assertThat(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s"));
    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
    assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
    response = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().putNull(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey())).get();
    assertAcked(response);
    assertNull(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()));
    assertThat(discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
    assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
    response = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s").put(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), false).build()).get();
    assertAcked(response);
    assertThat(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s"));
    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
    assertFalse(discoverySettings.getPublishDiff());
    response = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().putNull((randomBoolean() ? "discovery.zen.*" : "*"))).get();
    assertNull(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()));
    assertNull(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey()));
    assertThat(discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
    assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
    // now persistent
    response = client().admin().cluster().prepareUpdateSettings().setPersistentSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s").build()).get();
    assertAcked(response);
    assertThat(response.getPersistentSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s"));
    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
    assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
    response = client().admin().cluster().prepareUpdateSettings().setPersistentSettings(Settings.builder().putNull((DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()))).get();
    assertAcked(response);
    assertNull(response.getPersistentSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()));
    assertThat(discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
    assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
    response = client().admin().cluster().prepareUpdateSettings().setPersistentSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s").put(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), false).build()).get();
    assertAcked(response);
    assertThat(response.getPersistentSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s"));
    assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L));
    assertFalse(discoverySettings.getPublishDiff());
    response = client().admin().cluster().prepareUpdateSettings().setPersistentSettings(Settings.builder().putNull((randomBoolean() ? "discovery.zen.*" : "*"))).get();
    assertNull(response.getPersistentSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()));
    assertNull(response.getPersistentSettings().getAsMap().get(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey()));
    assertThat(discoverySettings.getPublishTimeout(), equalTo(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY)));
    assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY)));
}
Also used : DiscoverySettings(org.elasticsearch.discovery.DiscoverySettings) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse)

Aggregations

DiscoverySettings (org.elasticsearch.discovery.DiscoverySettings)7 ClusterSettings (org.elasticsearch.common.settings.ClusterSettings)4 ClusterUpdateSettingsResponse (org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse)3 NodeConnectionsService (org.elasticsearch.cluster.NodeConnectionsService)3 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)3 ClusterState (org.elasticsearch.cluster.ClusterState)2 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Collections.emptyMap (java.util.Collections.emptyMap)1 Collections.emptySet (java.util.Collections.emptySet)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1