Search in sources :

Example 1 with ClusterUpdateSettingsResponse

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

the class DecommissioningService method decommission.

private void decommission() {
    // fail on new requests so that clients don't use this node anymore
    sqlOperations.disable();
    /*
         * setting this setting will cause the {@link DecommissionAllocationDecider} to prevent allocations onto this node
         *
         * nodeIds are part of the key to prevent conflicts if other nodes are being decommissioned in parallel
         */
    Settings settings = Settings.builder().put(DECOMMISSION_PREFIX + clusterService.localNode().getId(), true).build();
    updateSettingsAction.execute(new ClusterUpdateSettingsRequest().transientSettings(settings), new ActionListener<ClusterUpdateSettingsResponse>() {

        @Override
        public void onResponse(ClusterUpdateSettingsResponse clusterUpdateSettingsResponse) {
            // changing settings triggers AllocationService.reroute -> shards will be relocated
            // NOTE: it waits for ALL relocating shards, not just those that involve THIS node.
            ClusterHealthRequest request = new ClusterHealthRequest().waitForRelocatingShards(0).waitForEvents(Priority.LANGUID).timeout(gracefulStopTimeout);
            if (dataAvailability == DataAvailability.FULL) {
                request = request.waitForGreenStatus();
            } else {
                request = request.waitForYellowStatus();
            }
            final long startTime = System.nanoTime();
            healthAction.execute(request, new ActionListener<ClusterHealthResponse>() {

                @Override
                public void onResponse(ClusterHealthResponse clusterHealthResponse) {
                    exitIfNoActiveRequests(startTime);
                }

                @Override
                public void onFailure(Throwable e) {
                    forceStopOrAbort(e);
                }
            });
        }

        @Override
        public void onFailure(Throwable e) {
            logger.error("Couldn't set settings. Graceful shutdown failed", e);
        }
    });
}
Also used : ActionListener(org.elasticsearch.action.ActionListener) ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) ClusterHealthRequest(org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) CrateSettings(io.crate.metadata.settings.CrateSettings) Settings(org.elasticsearch.common.settings.Settings) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)

Example 2 with ClusterUpdateSettingsResponse

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

the class Ec2DiscoveryUpdateSettingsTests method testMinimumMasterNodesStart.

public void testMinimumMasterNodesStart() {
    Settings nodeSettings = Settings.builder().put("discovery.type", "ec2").build();
    internalCluster().startNode(nodeSettings);
    // We try to update minimum_master_nodes now
    ClusterUpdateSettingsResponse response = client().admin().cluster().prepareUpdateSettings().setPersistentSettings(Settings.builder().put("discovery.zen.minimum_master_nodes", 1)).setTransientSettings(Settings.builder().put("discovery.zen.minimum_master_nodes", 1)).get();
    Integer min = response.getPersistentSettings().getAsInt("discovery.zen.minimum_master_nodes", null);
    assertThat(min, is(1));
}
Also used : ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) Settings(org.elasticsearch.common.settings.Settings)

Example 3 with ClusterUpdateSettingsResponse

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

the class ClusterSettingsIT method testCanUpdateTracerSettings.

public void testCanUpdateTracerSettings() {
    ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().putArray("transport.tracer.include", "internal:index/shard/recovery/*", "internal:gateway/local*")).get();
    assertArrayEquals(clusterUpdateSettingsResponse.getTransientSettings().getAsArray("transport.tracer.include"), new String[] { "internal:index/shard/recovery/*", "internal:gateway/local*" });
}
Also used : ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse)

Example 4 with ClusterUpdateSettingsResponse

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

the class ClusterSettingsIT method testDeleteIsAppliedFirst.

public void testDeleteIsAppliedFirst() {
    DiscoverySettings discoverySettings = getDiscoverySettings();
    assertEquals(discoverySettings.getPublishTimeout(), DiscoverySettings.PUBLISH_TIMEOUT_SETTING.get(Settings.EMPTY));
    assertTrue(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY));
    ClusterUpdateSettingsResponse response = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), false).put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s").build()).get();
    assertAcked(response);
    assertEquals(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), "1s");
    assertTrue(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY));
    assertFalse(response.getTransientSettings().getAsBoolean(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), null));
    response = client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().putNull((randomBoolean() ? "discovery.zen.*" : "*")).put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "2s")).get();
    assertEquals(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), "2s");
    assertNull(response.getTransientSettings().getAsBoolean(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.getKey(), null));
}
Also used : DiscoverySettings(org.elasticsearch.discovery.DiscoverySettings) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse)

Example 5 with ClusterUpdateSettingsResponse

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

the class ClusterSettingsIT method testClusterUpdateSettingsWithBlocks.

public void testClusterUpdateSettingsWithBlocks() {
    String key1 = "cluster.routing.allocation.enable";
    Settings transientSettings = Settings.builder().put(key1, EnableAllocationDecider.Allocation.NONE.name()).build();
    String key2 = "cluster.routing.allocation.node_concurrent_recoveries";
    Settings persistentSettings = Settings.builder().put(key2, "5").build();
    ClusterUpdateSettingsRequestBuilder request = client().admin().cluster().prepareUpdateSettings().setTransientSettings(transientSettings).setPersistentSettings(persistentSettings);
    // Cluster settings updates are blocked when the cluster is read only
    try {
        setClusterReadOnly(true);
        assertBlocked(request, MetaData.CLUSTER_READ_ONLY_BLOCK);
        // But it's possible to update the settings to update the "cluster.blocks.read_only" setting
        Settings settings = Settings.builder().put(MetaData.SETTING_READ_ONLY_SETTING.getKey(), false).build();
        assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings).get());
    } finally {
        setClusterReadOnly(false);
    }
    // It should work now
    ClusterUpdateSettingsResponse response = request.execute().actionGet();
    assertAcked(response);
    assertThat(response.getTransientSettings().get(key1), notNullValue());
    assertThat(response.getTransientSettings().get(key2), nullValue());
    assertThat(response.getPersistentSettings().get(key1), nullValue());
    assertThat(response.getPersistentSettings().get(key2), notNullValue());
}
Also used : ClusterUpdateSettingsRequestBuilder(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequestBuilder) 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)17 Settings (org.elasticsearch.common.settings.Settings)9 ClusterUpdateSettingsRequest (org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)8 DiscoverySettings (org.elasticsearch.discovery.DiscoverySettings)5 CrateSettings (io.crate.metadata.settings.CrateSettings)3 RecoverySettings (org.elasticsearch.indices.recovery.RecoverySettings)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