use of org.elasticsearch.cluster.metadata.IndexTemplateMetadata in project crate by crate.
the class DefaultTemplateService method addDefaultTemplate.
@VisibleForTesting
static ClusterState addDefaultTemplate(ClusterState currentState) throws IOException {
MetaData currentMetaData = currentState.getMetaData();
ImmutableOpenMap<String, IndexTemplateMetaData> currentTemplates = currentMetaData.getTemplates();
ImmutableOpenMap<String, IndexTemplateMetaData> newTemplates = createCopyWithDefaultTemplateAdded(currentTemplates);
MetaData.Builder mdBuilder = MetaData.builder(currentMetaData).templates(newTemplates);
return ClusterState.builder(currentState).metaData(mdBuilder).build();
}
use of org.elasticsearch.cluster.metadata.IndexTemplateMetadata in project elasticsearch by elastic.
the class GetIndexTemplatesResponse method writeTo.
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeVInt(indexTemplates.size());
for (IndexTemplateMetaData indexTemplate : indexTemplates) {
indexTemplate.writeTo(out);
}
}
use of org.elasticsearch.cluster.metadata.IndexTemplateMetadata in project elasticsearch by elastic.
the class ElasticsearchAssertions method assertIndexTemplateMissing.
/**
* Assert that an index template is missing
*/
public static void assertIndexTemplateMissing(GetIndexTemplatesResponse templatesResponse, String name) {
List<String> templateNames = new ArrayList<>();
for (IndexTemplateMetaData indexTemplateMetaData : templatesResponse.getIndexTemplates()) {
templateNames.add(indexTemplateMetaData.name());
}
assertThat(templateNames, not(hasItem(name)));
}
use of org.elasticsearch.cluster.metadata.IndexTemplateMetadata in project elasticsearch by elastic.
the class ElasticsearchAssertions method assertIndexTemplateExists.
/**
* Assert that an index template exists
*/
public static void assertIndexTemplateExists(GetIndexTemplatesResponse templatesResponse, String name) {
List<String> templateNames = new ArrayList<>();
for (IndexTemplateMetaData indexTemplateMetaData : templatesResponse.getIndexTemplates()) {
templateNames.add(indexTemplateMetaData.name());
}
assertThat(templateNames, hasItem(name));
}
use of org.elasticsearch.cluster.metadata.IndexTemplateMetadata in project crate by crate.
the class TableAliasIntegrationTest method testPartitionedTableKeepsAliasAfterSchemaUpdate.
@Test
public void testPartitionedTableKeepsAliasAfterSchemaUpdate() throws Exception {
execute("create table t (name string, p string) partitioned by (p) " + "clustered into 2 shards with (number_of_replicas = 0)");
ensureYellow();
execute("insert into t (name, p) values ('Arthur', 'a')");
execute("insert into t (name, p) values ('Trillian', 'a')");
execute("alter table t add column age integer");
execute("insert into t (name, p) values ('Marvin', 'b')");
waitNoPendingTasksOnAll();
refresh();
execute("select count(*) from t");
assertThat(response.rowCount(), is(1L));
assertThat((Long) response.rows()[0][0], is(3L));
GetIndexTemplatesResponse indexTemplatesResponse = client().admin().indices().prepareGetTemplates(".partitioned.t.").execute().actionGet();
IndexTemplateMetaData indexTemplateMetaData = indexTemplatesResponse.getIndexTemplates().get(0);
AliasMetaData t = indexTemplateMetaData.aliases().get("t");
assertThat(t.alias(), is("t"));
execute("select partitioned_by from information_schema.tables where table_name = 't'");
assertThat((String) ((Object[]) response.rows()[0][0])[0], is("p"));
}
Aggregations