Search in sources :

Example 6 with GetSettingsResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse in project elasticsearch by elastic.

the class IndicesOptionsIntegrationIT method testUpdateSettings.

public void testUpdateSettings() throws Exception {
    verify(client().admin().indices().prepareUpdateSettings("foo").setSettings(Settings.builder().put("a", "b")), true);
    verify(client().admin().indices().prepareUpdateSettings("_all").setSettings(Settings.builder().put("a", "b")), true);
    createIndex("foo", "foobar", "bar", "barbaz");
    ensureGreen();
    assertAcked(client().admin().indices().prepareClose("_all").get());
    verify(client().admin().indices().prepareUpdateSettings("foo").setSettings(Settings.builder().put("a", "b")), false);
    verify(client().admin().indices().prepareUpdateSettings("bar*").setSettings(Settings.builder().put("a", "b")), false);
    verify(client().admin().indices().prepareUpdateSettings("_all").setSettings(Settings.builder().put("c", "d")), false);
    GetSettingsResponse settingsResponse = client().admin().indices().prepareGetSettings("foo").get();
    assertThat(settingsResponse.getSetting("foo", "index.a"), equalTo("b"));
    settingsResponse = client().admin().indices().prepareGetSettings("bar*").get();
    assertThat(settingsResponse.getSetting("bar", "index.a"), equalTo("b"));
    assertThat(settingsResponse.getSetting("barbaz", "index.a"), equalTo("b"));
    settingsResponse = client().admin().indices().prepareGetSettings("_all").get();
    assertThat(settingsResponse.getSetting("foo", "index.c"), equalTo("d"));
    assertThat(settingsResponse.getSetting("foobar", "index.c"), equalTo("d"));
    assertThat(settingsResponse.getSetting("bar", "index.c"), equalTo("d"));
    assertThat(settingsResponse.getSetting("barbaz", "index.c"), equalTo("d"));
    assertAcked(client().admin().indices().prepareOpen("_all").get());
    try {
        verify(client().admin().indices().prepareUpdateSettings("barbaz").setSettings(Settings.builder().put("e", "f")), false);
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), startsWith("Can't update non dynamic settings [[index.e]] for open indices [[barbaz"));
    }
    verify(client().admin().indices().prepareUpdateSettings("baz*").setSettings(Settings.builder().put("a", "b")), true);
}
Also used : GetSettingsResponse(org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse)

Example 7 with GetSettingsResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse in project elasticsearch by elastic.

the class DateMathIndexExpressionsIntegrationIT method testCreateIndexWithDateMathExpression.

public void testCreateIndexWithDateMathExpression() throws Exception {
    DateTime now = new DateTime(DateTimeZone.UTC);
    String index1 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now);
    String index2 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.minusDays(1));
    String index3 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.minusDays(2));
    String dateMathExp1 = "<.marvel-{now/d}>";
    String dateMathExp2 = "<.marvel-{now/d-1d}>";
    String dateMathExp3 = "<.marvel-{now/d-2d}>";
    createIndex(dateMathExp1, dateMathExp2, dateMathExp3);
    GetSettingsResponse getSettingsResponse = client().admin().indices().prepareGetSettings(index1, index2, index3).get();
    assertEquals(dateMathExp1, getSettingsResponse.getSetting(index1, IndexMetaData.SETTING_INDEX_PROVIDED_NAME));
    assertEquals(dateMathExp2, getSettingsResponse.getSetting(index2, IndexMetaData.SETTING_INDEX_PROVIDED_NAME));
    assertEquals(dateMathExp3, getSettingsResponse.getSetting(index3, IndexMetaData.SETTING_INDEX_PROVIDED_NAME));
    ClusterState clusterState = client().admin().cluster().prepareState().get().getState();
    assertThat(clusterState.metaData().index(index1), notNullValue());
    assertThat(clusterState.metaData().index(index2), notNullValue());
    assertThat(clusterState.metaData().index(index3), notNullValue());
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) GetSettingsResponse(org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse) DateTime(org.joda.time.DateTime)

Example 8 with GetSettingsResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse in project elasticsearch by elastic.

the class SimpleIndexTemplateIT method testPartitionedTemplate.

public void testPartitionedTemplate() throws Exception {
    // clean all templates setup by the framework.
    client().admin().indices().prepareDeleteTemplate("*").get();
    // check get all templates on an empty index.
    GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates().get();
    assertThat(response.getIndexTemplates(), empty());
    // provide more partitions than shards
    IllegalArgumentException eBadSettings = expectThrows(IllegalArgumentException.class, () -> client().admin().indices().preparePutTemplate("template_1").setPatterns(Collections.singletonList("te*")).setSettings(Settings.builder().put("index.number_of_shards", "5").put("index.routing_partition_size", "6")).get());
    assertThat(eBadSettings.getMessage(), containsString("partition size [6] should be a positive number " + "less than the number of shards [5]"));
    // provide an invalid mapping for a partitioned index
    IllegalArgumentException eBadMapping = expectThrows(IllegalArgumentException.class, () -> client().admin().indices().preparePutTemplate("template_2").setPatterns(Collections.singletonList("te*")).addMapping("type", "{\"type\":{\"_routing\":{\"required\":false}}}", XContentType.JSON).setSettings(Settings.builder().put("index.number_of_shards", "6").put("index.routing_partition_size", "3")).get());
    assertThat(eBadMapping.getMessage(), containsString("must have routing required for partitioned index"));
    // no templates yet
    response = client().admin().indices().prepareGetTemplates().get();
    assertEquals(0, response.getIndexTemplates().size());
    // a valid configuration that only provides the partition size
    assertAcked(client().admin().indices().preparePutTemplate("just_partitions").setPatterns(Collections.singletonList("te*")).setSettings(Settings.builder().put("index.routing_partition_size", "6")).get());
    // create an index with too few shards
    IllegalArgumentException eBadIndex = expectThrows(IllegalArgumentException.class, () -> prepareCreate("test_bad", Settings.builder().put("index.number_of_shards", 5)).get());
    assertThat(eBadIndex.getMessage(), containsString("partition size [6] should be a positive number " + "less than the number of shards [5]"));
    // finally, create a valid index
    prepareCreate("test_good", Settings.builder().put("index.number_of_shards", 7)).get();
    GetSettingsResponse getSettingsResponse = client().admin().indices().prepareGetSettings("test_good").get();
    assertEquals("6", getSettingsResponse.getIndexToSettings().get("test_good").getAsMap().get("index.routing_partition_size"));
}
Also used : GetSettingsResponse(org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse) GetIndexTemplatesResponse(org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse)

Example 9 with GetSettingsResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse in project elasticsearch by elastic.

the class SettingsFilteringIT method testSettingsFiltering.

public void testSettingsFiltering() {
    assertAcked(client().admin().indices().prepareCreate("test-idx").setSettings(Settings.builder().put("filter_test.foo", "test").put("filter_test.bar1", "test").put("filter_test.bar2", "test").put("filter_test.notbar", "test").put("filter_test.notfoo", "test").build()).get());
    GetSettingsResponse response = client().admin().indices().prepareGetSettings("test-idx").get();
    Settings settings = response.getIndexToSettings().get("test-idx");
    assertThat(settings.get("index.filter_test.foo"), nullValue());
    assertThat(settings.get("index.filter_test.bar1"), nullValue());
    assertThat(settings.get("index.filter_test.bar2"), nullValue());
    assertThat(settings.get("index.filter_test.notbar"), equalTo("test"));
    assertThat(settings.get("index.filter_test.notfoo"), equalTo("test"));
}
Also used : GetSettingsResponse(org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse) Settings(org.elasticsearch.common.settings.Settings)

Example 10 with GetSettingsResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse in project titan by thinkaurelius.

the class ElasticSearchConfigTest method testIndexCreationOptions.

@Test
public void testIndexCreationOptions() throws InterruptedException, BackendException {
    final int shards = 77;
    ElasticsearchRunner esr = new ElasticsearchRunner(".", "indexCreationOptions.yml");
    esr.start();
    CommonsConfiguration cc = new CommonsConfiguration(new BaseConfiguration());
    cc.set("index." + INDEX_NAME + ".elasticsearch.create.ext.number_of_shards", String.valueOf(shards));
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.cluster.name", "indexCreationOptions");
    ModifiableConfiguration config = new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS, cc, BasicConfiguration.Restriction.NONE);
    config.set(INTERFACE, ElasticSearchSetup.NODE.toString(), INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = new ElasticSearchIndex(indexConfig);
    simpleWriteAndQuery(idx);
    ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder();
    settingsBuilder.put("discovery.zen.ping.multicast.enabled", "false");
    settingsBuilder.put("discovery.zen.ping.unicast.hosts", "localhost,127.0.0.1:9300");
    settingsBuilder.put("cluster.name", "indexCreationOptions");
    NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder().settings(settingsBuilder.build());
    nodeBuilder.client(true).data(false).local(false);
    Node n = nodeBuilder.build().start();
    GetSettingsResponse response = n.client().admin().indices().getSettings(new GetSettingsRequest().indices("titan")).actionGet();
    assertEquals(String.valueOf(shards), response.getSetting("titan", "index.number_of_shards"));
    idx.close();
    n.stop();
    esr.stop();
}
Also used : Configuration(com.thinkaurelius.titan.diskstorage.configuration.Configuration) CommonsConfiguration(com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration) BasicConfiguration(com.thinkaurelius.titan.diskstorage.configuration.BasicConfiguration) GraphDatabaseConfiguration(com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration) BaseConfiguration(org.apache.commons.configuration.BaseConfiguration) ModifiableConfiguration(com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration) GetSettingsResponse(org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse) Node(org.elasticsearch.node.Node) CommonsConfiguration(com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration) ModifiableConfiguration(com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration) NodeBuilder(org.elasticsearch.node.NodeBuilder) ImmutableSettings(org.elasticsearch.common.settings.ImmutableSettings) BaseConfiguration(org.apache.commons.configuration.BaseConfiguration) GetSettingsRequest(org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest) ElasticSearchIndex(com.thinkaurelius.titan.diskstorage.es.ElasticSearchIndex) Test(org.junit.Test)

Aggregations

GetSettingsResponse (org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse)17 Settings (org.elasticsearch.common.settings.Settings)4 DateTime (org.joda.time.DateTime)4 GetIndexTemplatesResponse (org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse)3 Version (org.elasticsearch.Version)2 CreateSnapshotResponse (org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse)2 RestoreSnapshotResponse (org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse)2 GetSettingsRequest (org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest)2 SearchResponse (org.elasticsearch.action.search.SearchResponse)2 Client (org.elasticsearch.client.Client)2 ObjectObjectCursor (com.carrotsearch.hppc.cursors.ObjectObjectCursor)1 BasicConfiguration (com.thinkaurelius.titan.diskstorage.configuration.BasicConfiguration)1 Configuration (com.thinkaurelius.titan.diskstorage.configuration.Configuration)1 ModifiableConfiguration (com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration)1 CommonsConfiguration (com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration)1 ElasticSearchIndex (com.thinkaurelius.titan.diskstorage.es.ElasticSearchIndex)1 GraphDatabaseConfiguration (com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration)1 PartitionName (io.crate.metadata.PartitionName)1 IOException (java.io.IOException)1 BaseConfiguration (org.apache.commons.configuration.BaseConfiguration)1