"partitioned by(date) clustered into 3 shards with (number_of_replicas='0-all')");
ensureGreen();
assertThat(response.rowCount(), is(1L));
String templateName = PartitionName.templateName("quotes");
GetIndexTemplatesResponse templatesResponse = client().admin().indices()
.prepareGetTemplates(templateName).execute().actionGet();
Settings templateSettings = templatesResponse.getIndexTemplates().get(0).getSettings();
assertThat(templateSettings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0), is(1));
assertThat(templateSettings.get(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS), is("0-all"));
assertThat(templateSettings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 0), is(3));
execute("alter table quotes set (number_of_replicas=0)");
ensureGreen();
templatesResponse = client().admin().indices()
.prepareGetTemplates(templateName).execute().actionGet();
templateSettings = templatesResponse.getIndexTemplates().get(0).getSettings();
assertThat(templateSettings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0), is(0));
assertThat(templateSettings.getAsBoolean(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, true), is(false));
assertThat(templateSettings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 0), is(3));
execute("insert into quotes (id, quote, date) values (?, ?, ?), (?, ?, ?)",
new Object[]{1, "Don't panic", 1395874800000L,
2, "Now panic", 1395961200000L}
);
assertThat(response.rowCount(), is(2L));
ensureGreen();
refresh();
assertTrue(clusterService().state().metaData().aliases().containsKey("quotes"));
execute("select number_of_replicas, number_of_shards from information_schema.tables where table_name = 'quotes'");
assertEquals("0", response.rows()[0][0]);
assertEquals(3, response.rows()[0][1]);
execute("alter table quotes set (number_of_replicas='1-all')");
ensureGreen();
execute("select number_of_replicas from information_schema.tables where table_name = 'quotes'");
assertEquals("1-all", response.rows()[0][0]);
templatesResponse = client().admin().indices()
.prepareGetTemplates(templateName).execute().actionGet();
templateSettings = templatesResponse.getIndexTemplates().get(0).getSettings();
assertThat(templateSettings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1), is(0));
assertThat(templateSettings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 0), is(3));
assertThat(templateSettings.get(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS), is("1-all"));
List<String> partitions = ImmutableList.of(