Search in sources :

Example 11 with ClusterUpdateSettingsResponse

use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse in project elasticsearch by elastic.

the class AckClusterUpdateSettingsIT method testClusterUpdateSettingsNoAcknowledgement.

public void testClusterUpdateSettingsNoAcknowledgement() {
    client().admin().indices().prepareCreate("test").setSettings(Settings.builder().put("number_of_shards", between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS)).put("number_of_replicas", 0)).get();
    ensureGreen();
    // now that the cluster is stable, remove timeout
    removePublishTimeout();
    NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().get();
    String excludedNodeId = null;
    for (NodeInfo nodeInfo : nodesInfo.getNodes()) {
        if (nodeInfo.getNode().isDataNode()) {
            excludedNodeId = nodeInfo.getNode().getId();
            break;
        }
    }
    assertNotNull(excludedNodeId);
    ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings().setTimeout("0s").setTransientSettings(Settings.builder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get();
    assertThat(clusterUpdateSettingsResponse.isAcknowledged(), equalTo(false));
    assertThat(clusterUpdateSettingsResponse.getTransientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId));
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse)

Example 12 with ClusterUpdateSettingsResponse

use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse in project elasticsearch by elastic.

the class AckClusterUpdateSettingsIT method testClusterUpdateSettingsAcknowledgement.

public void testClusterUpdateSettingsAcknowledgement() {
    createIndex("test");
    ensureGreen();
    // now that the cluster is stable, remove timeout
    removePublishTimeout();
    NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().get();
    String excludedNodeId = null;
    for (NodeInfo nodeInfo : nodesInfo.getNodes()) {
        if (nodeInfo.getNode().isDataNode()) {
            excludedNodeId = nodeInfo.getNode().getId();
            break;
        }
    }
    assertNotNull(excludedNodeId);
    ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get();
    assertAcked(clusterUpdateSettingsResponse);
    assertThat(clusterUpdateSettingsResponse.getTransientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId));
    for (Client client : clients()) {
        ClusterState clusterState = getLocalClusterState(client);
        assertThat(clusterState.metaData().transientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId));
        for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) {
            for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) {
                for (ShardRouting shardRouting : indexShardRoutingTable) {
                    assert clusterState.nodes() != null;
                    if (shardRouting.unassigned() == false && clusterState.nodes().get(shardRouting.currentNodeId()).getId().equals(excludedNodeId)) {
                        //if the shard is still there it must be relocating and all nodes need to know, since the request was acknowledged
                        //reroute happens as part of the update settings and we made sure no throttling comes into the picture via settings
                        assertThat(shardRouting.relocating(), equalTo(true));
                    }
                }
            }
        }
    }
}
Also used : NodesInfoResponse(org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse) ClusterState(org.elasticsearch.cluster.ClusterState) IndexRoutingTable(org.elasticsearch.cluster.routing.IndexRoutingTable) IndexShardRoutingTable(org.elasticsearch.cluster.routing.IndexShardRoutingTable) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) Client(org.elasticsearch.client.Client) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting)

Example 13 with ClusterUpdateSettingsResponse

use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse 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 14 with ClusterUpdateSettingsResponse

use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse 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)

Example 15 with ClusterUpdateSettingsResponse

use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse in project elasticsearch by elastic.

the class ClusterSettingsIT method testClusterSettingsUpdateResponse.

public void testClusterSettingsUpdateResponse() {
    String key1 = RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey();
    int value1 = 10;
    String key2 = EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey();
    String value2 = EnableAllocationDecider.Allocation.NONE.name();
    Settings transientSettings1 = Settings.builder().put(key1, value1, ByteSizeUnit.BYTES).build();
    Settings persistentSettings1 = Settings.builder().put(key2, value2).build();
    ClusterUpdateSettingsResponse response1 = client().admin().cluster().prepareUpdateSettings().setTransientSettings(transientSettings1).setPersistentSettings(persistentSettings1).execute().actionGet();
    assertAcked(response1);
    assertThat(response1.getTransientSettings().get(key1), notNullValue());
    assertThat(response1.getTransientSettings().get(key2), nullValue());
    assertThat(response1.getPersistentSettings().get(key1), nullValue());
    assertThat(response1.getPersistentSettings().get(key2), notNullValue());
    Settings transientSettings2 = Settings.builder().put(key1, value1, ByteSizeUnit.BYTES).put(key2, value2).build();
    Settings persistentSettings2 = Settings.EMPTY;
    ClusterUpdateSettingsResponse response2 = client().admin().cluster().prepareUpdateSettings().setTransientSettings(transientSettings2).setPersistentSettings(persistentSettings2).execute().actionGet();
    assertAcked(response2);
    assertThat(response2.getTransientSettings().get(key1), notNullValue());
    assertThat(response2.getTransientSettings().get(key2), notNullValue());
    assertThat(response2.getPersistentSettings().get(key1), nullValue());
    assertThat(response2.getPersistentSettings().get(key2), nullValue());
    Settings transientSettings3 = Settings.EMPTY;
    Settings persistentSettings3 = Settings.builder().put(key1, value1, ByteSizeUnit.BYTES).put(key2, value2).build();
    ClusterUpdateSettingsResponse response3 = client().admin().cluster().prepareUpdateSettings().setTransientSettings(transientSettings3).setPersistentSettings(persistentSettings3).execute().actionGet();
    assertAcked(response3);
    assertThat(response3.getTransientSettings().get(key1), nullValue());
    assertThat(response3.getTransientSettings().get(key2), nullValue());
    assertThat(response3.getPersistentSettings().get(key1), notNullValue());
    assertThat(response3.getPersistentSettings().get(key2), notNullValue());
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) DiscoverySettings(org.elasticsearch.discovery.DiscoverySettings) RecoverySettings(org.elasticsearch.indices.recovery.RecoverySettings) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

ClusterUpdateSettingsResponse (org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse)16 Settings (org.elasticsearch.common.settings.Settings)8 ClusterUpdateSettingsRequest (org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)7 DiscoverySettings (org.elasticsearch.discovery.DiscoverySettings)5 CrateSettings (io.crate.metadata.settings.CrateSettings)3 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)2 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)2 Row (io.crate.data.Row)2 Row1 (io.crate.data.Row1)2 RowConsumer (io.crate.data.RowConsumer)2 OneRowActionListener (io.crate.execution.support.OneRowActionListener)2 OneRowActionListener (io.crate.executor.transport.OneRowActionListener)2 Symbol (io.crate.expression.symbol.Symbol)2 DependencyCarrier (io.crate.planner.DependencyCarrier)2 Plan (io.crate.planner.Plan)2 PlannerContext (io.crate.planner.PlannerContext)2 SubQueryResults (io.crate.planner.operators.SubQueryResults)2 Set (java.util.Set)2 Function (java.util.function.Function)2 NodeInfo (org.elasticsearch.action.admin.cluster.node.info.NodeInfo)2