use of 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);
}
use of 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());
}
use of 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"));
}
use of 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"));
}
use of 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();
}
Aggregations