Search in sources :

Example 1 with MetadataIndexTemplateService

use of org.elasticsearch.cluster.metadata.MetadataIndexTemplateService in project elasticsearch by elastic.

the class MetaDataIndexTemplateServiceTests method putTemplate.

private static List<Throwable> putTemplate(NamedXContentRegistry xContentRegistry, PutRequest request) {
    MetaDataCreateIndexService createIndexService = new MetaDataCreateIndexService(Settings.EMPTY, null, null, null, null, null, null, null, xContentRegistry);
    MetaDataIndexTemplateService service = new MetaDataIndexTemplateService(Settings.EMPTY, null, createIndexService, new AliasValidator(Settings.EMPTY), null, new IndexScopedSettings(Settings.EMPTY, IndexScopedSettings.BUILT_IN_INDEX_SETTINGS), xContentRegistry);
    final List<Throwable> throwables = new ArrayList<>();
    service.putTemplate(request, new MetaDataIndexTemplateService.PutListener() {

        @Override
        public void onResponse(MetaDataIndexTemplateService.PutResponse response) {
        }

        @Override
        public void onFailure(Exception e) {
            throwables.add(e);
        }
    });
    return throwables;
}
Also used : IndexScopedSettings(org.elasticsearch.common.settings.IndexScopedSettings) AliasValidator(org.elasticsearch.cluster.metadata.AliasValidator) ArrayList(java.util.ArrayList) MetaDataCreateIndexService(org.elasticsearch.cluster.metadata.MetaDataCreateIndexService) MapperParsingException(org.elasticsearch.index.mapper.MapperParsingException) InvalidIndexTemplateException(org.elasticsearch.indices.InvalidIndexTemplateException) MetaDataIndexTemplateService(org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService)

Example 2 with MetadataIndexTemplateService

use of org.elasticsearch.cluster.metadata.MetadataIndexTemplateService in project elasticsearch by elastic.

the class MetaDataIndexTemplateServiceTests method putTemplateDetail.

private List<Throwable> putTemplateDetail(PutRequest request) throws Exception {
    IndicesService indicesService = getInstanceFromNode(IndicesService.class);
    ClusterService clusterService = getInstanceFromNode(ClusterService.class);
    MetaDataCreateIndexService createIndexService = new MetaDataCreateIndexService(Settings.EMPTY, clusterService, indicesService, null, null, null, null, null, xContentRegistry());
    MetaDataIndexTemplateService service = new MetaDataIndexTemplateService(Settings.EMPTY, clusterService, createIndexService, new AliasValidator(Settings.EMPTY), indicesService, new IndexScopedSettings(Settings.EMPTY, IndexScopedSettings.BUILT_IN_INDEX_SETTINGS), xContentRegistry());
    final List<Throwable> throwables = new ArrayList<>();
    final CountDownLatch latch = new CountDownLatch(1);
    service.putTemplate(request, new MetaDataIndexTemplateService.PutListener() {

        @Override
        public void onResponse(MetaDataIndexTemplateService.PutResponse response) {
            latch.countDown();
        }

        @Override
        public void onFailure(Exception e) {
            throwables.add(e);
            latch.countDown();
        }
    });
    latch.await();
    return throwables;
}
Also used : IndexScopedSettings(org.elasticsearch.common.settings.IndexScopedSettings) AliasValidator(org.elasticsearch.cluster.metadata.AliasValidator) ArrayList(java.util.ArrayList) IndicesService(org.elasticsearch.indices.IndicesService) MetaDataCreateIndexService(org.elasticsearch.cluster.metadata.MetaDataCreateIndexService) CountDownLatch(java.util.concurrent.CountDownLatch) MapperParsingException(org.elasticsearch.index.mapper.MapperParsingException) InvalidIndexTemplateException(org.elasticsearch.indices.InvalidIndexTemplateException) ClusterService(org.elasticsearch.cluster.service.ClusterService) MetaDataIndexTemplateService(org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService)

Aggregations

ArrayList (java.util.ArrayList)2 AliasValidator (org.elasticsearch.cluster.metadata.AliasValidator)2 MetaDataCreateIndexService (org.elasticsearch.cluster.metadata.MetaDataCreateIndexService)2 MetaDataIndexTemplateService (org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService)2 IndexScopedSettings (org.elasticsearch.common.settings.IndexScopedSettings)2 MapperParsingException (org.elasticsearch.index.mapper.MapperParsingException)2 InvalidIndexTemplateException (org.elasticsearch.indices.InvalidIndexTemplateException)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 ClusterService (org.elasticsearch.cluster.service.ClusterService)1 IndicesService (org.elasticsearch.indices.IndicesService)1