Search in sources :

Example 86 with Settings

use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class ActiveShardsObserverIT method testCreateIndexNoActiveShardsTimesOut.

public void testCreateIndexNoActiveShardsTimesOut() throws Exception {
    Settings.Builder settingsBuilder = Settings.builder().put(indexSettings()).put(INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), randomIntBetween(1, 5)).put(INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0);
    if (internalCluster().getNodeNames().length > 0) {
        String exclude = String.join(",", internalCluster().getNodeNames());
        settingsBuilder.put("index.routing.allocation.exclude._name", exclude);
    }
    Settings settings = settingsBuilder.build();
    final String indexName = "test-idx";
    assertFalse(prepareCreate(indexName).setSettings(settings).setWaitForActiveShards(randomBoolean() ? ActiveShardCount.from(1) : ActiveShardCount.ALL).setTimeout("100ms").get().isShardsAcked());
    waitForIndexCreationToComplete(indexName);
}
Also used : Settings(org.elasticsearch.common.settings.Settings)

Example 87 with Settings

use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class ActiveShardsObserverIT method testCreateIndexWaitsForAllActiveShards.

public void testCreateIndexWaitsForAllActiveShards() throws Exception {
    // not enough data nodes, index creation times out
    final int numReplicas = internalCluster().numDataNodes() + randomInt(4);
    Settings settings = Settings.builder().put(indexSettings()).put(INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), randomIntBetween(1, 5)).put(INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), numReplicas).build();
    final String indexName = "test-idx";
    assertFalse(prepareCreate(indexName).setSettings(settings).setWaitForActiveShards(ActiveShardCount.ALL).setTimeout("100ms").get().isShardsAcked());
    waitForIndexCreationToComplete(indexName);
    if (client().admin().indices().prepareExists(indexName).get().isExists()) {
        client().admin().indices().prepareDelete(indexName).get();
    }
    // enough data nodes, all shards are active
    settings = Settings.builder().put(indexSettings()).put(INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), randomIntBetween(1, 7)).put(INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), internalCluster().numDataNodes() - 1).build();
    assertAcked(prepareCreate(indexName).setSettings(settings).setWaitForActiveShards(ActiveShardCount.ALL).get());
}
Also used : Settings(org.elasticsearch.common.settings.Settings)

Example 88 with Settings

use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class AutoCreateIndexTests method testAutoCreationPatternDisabled.

public void testAutoCreationPatternDisabled() {
    Settings settings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), "-index*").build();
    AutoCreateIndex autoCreateIndex = newAutoCreateIndex(settings);
    ClusterState clusterState = ClusterState.builder(new ClusterName("test")).metaData(MetaData.builder()).build();
    expectForbidden(clusterState, autoCreateIndex, "index" + randomAsciiOfLengthBetween(1, 5), "-index*");
    /* When patterns are specified, even if the are all negative, the default is can't create. So a pure negative pattern is the same
         * as false, really. */
    expectNotMatch(clusterState, autoCreateIndex, "does_not_match" + randomAsciiOfLengthBetween(1, 5));
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) ClusterName(org.elasticsearch.cluster.ClusterName) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) Settings(org.elasticsearch.common.settings.Settings)

Example 89 with Settings

use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class AutoCreateIndexTests method testDynamicMappingDisabled.

public void testDynamicMappingDisabled() {
    Settings settings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), randomFrom(true, randomAsciiOfLengthBetween(1, 10))).put(MapperService.INDEX_MAPPER_DYNAMIC_SETTING.getKey(), false).build();
    AutoCreateIndex autoCreateIndex = newAutoCreateIndex(settings);
    IndexNotFoundException e = expectThrows(IndexNotFoundException.class, () -> autoCreateIndex.shouldAutoCreate(randomAsciiOfLengthBetween(1, 10), buildClusterState()));
    assertEquals("no such index and [index.mapper.dynamic] is [false]", e.getMessage());
}
Also used : IndexNotFoundException(org.elasticsearch.index.IndexNotFoundException) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) Settings(org.elasticsearch.common.settings.Settings)

Example 90 with Settings

use of org.elasticsearch.common.settings.Settings in project elasticsearch by elastic.

the class AutoCreateIndexTests method testParseFailedMissingIndex.

public void testParseFailedMissingIndex() {
    String prefix = randomFrom("+", "-");
    Settings settings = Settings.builder().put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), prefix).build();
    try {
        newAutoCreateIndex(settings);
        fail("initialization should have failed");
    } catch (IllegalArgumentException ex) {
        assertEquals("Can't parse [" + prefix + "] for setting [action.auto_create_index] must contain an index name after [" + prefix + "]", ex.getMessage());
    }
}
Also used : ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

Settings (org.elasticsearch.common.settings.Settings)874 IndexSettings (org.elasticsearch.index.IndexSettings)112 Path (java.nio.file.Path)91 IOException (java.io.IOException)83 ClusterState (org.elasticsearch.cluster.ClusterState)76 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)72 ClusterSettings (org.elasticsearch.common.settings.ClusterSettings)68 HashMap (java.util.HashMap)66 ArrayList (java.util.ArrayList)65 Version (org.elasticsearch.Version)63 Environment (org.elasticsearch.env.Environment)63 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)61 Test (org.junit.Test)60 Map (java.util.Map)55 Index (org.elasticsearch.index.Index)55 Matchers.containsString (org.hamcrest.Matchers.containsString)54 List (java.util.List)45 ThreadPool (org.elasticsearch.threadpool.ThreadPool)41 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)37 MetaData (org.elasticsearch.cluster.metadata.MetaData)36