Search in sources :

Example 11 with IndexScopedSettings

use of org.elasticsearch.common.settings.IndexScopedSettings 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 12 with IndexScopedSettings

use of org.elasticsearch.common.settings.IndexScopedSettings 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)

Example 13 with IndexScopedSettings

use of org.elasticsearch.common.settings.IndexScopedSettings in project crate by crate.

the class AlterTableClusterStateExecutorTest method testPrivateSettingsAreRemovedOnUpdateTemplate.

@Test
public void testPrivateSettingsAreRemovedOnUpdateTemplate() throws IOException {
    IndexScopedSettings indexScopedSettings = new IndexScopedSettings(Settings.EMPTY, Collections.emptySet());
    RelationName relationName = new RelationName(Schemas.DOC_SCHEMA_NAME, "t1");
    String templateName = PartitionName.templateName(relationName.schema(), relationName.name());
    Settings settings = Settings.builder().put(SETTING_CREATION_DATE, // private, must be filtered out
    false).put(SETTING_NUMBER_OF_SHARDS, 4).build();
    IndexTemplateMetadata indexTemplateMetadata = IndexTemplateMetadata.builder(templateName).patterns(Collections.singletonList("*")).settings(settings).build();
    ClusterState initialState = ClusterState.builder(ClusterState.EMPTY_STATE).metadata(Metadata.builder().put(indexTemplateMetadata)).build();
    ClusterState result = AlterTableClusterStateExecutor.updateTemplate(initialState, relationName, settings, Collections.emptyMap(), (x, y) -> {
    }, indexScopedSettings);
    IndexTemplateMetadata template = result.getMetadata().getTemplates().get(templateName);
    assertThat(template.settings().keySet(), contains(SETTING_NUMBER_OF_SHARDS));
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) IndexScopedSettings(org.elasticsearch.common.settings.IndexScopedSettings) IndexTemplateMetadata(org.elasticsearch.cluster.metadata.IndexTemplateMetadata) RelationName(io.crate.metadata.RelationName) Matchers.containsString(org.hamcrest.Matchers.containsString) IndexScopedSettings(org.elasticsearch.common.settings.IndexScopedSettings) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test)

Example 14 with IndexScopedSettings

use of org.elasticsearch.common.settings.IndexScopedSettings in project crate by crate.

the class IndexSettingsModule method newIndexSettings.

public static IndexSettings newIndexSettings(Index index, Settings indexSetting, Settings nodeSettings, Setting<?>... setting) {
    Settings build = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1).put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(indexSetting).build();
    IndexMetadata metadata = IndexMetadata.builder(index.getName()).settings(build).build();
    Set<Setting<?>> settingSet = new HashSet<>(IndexScopedSettings.BUILT_IN_INDEX_SETTINGS);
    if (setting.length > 0) {
        settingSet.addAll(Arrays.asList(setting));
    }
    return new IndexSettings(metadata, nodeSettings, new IndexScopedSettings(Settings.EMPTY, settingSet));
}
Also used : IndexScopedSettings(org.elasticsearch.common.settings.IndexScopedSettings) Setting(org.elasticsearch.common.settings.Setting) IndexSettings(org.elasticsearch.index.IndexSettings) IndexMetadata(org.elasticsearch.cluster.metadata.IndexMetadata) Settings(org.elasticsearch.common.settings.Settings) IndexSettings(org.elasticsearch.index.IndexSettings) IndexScopedSettings(org.elasticsearch.common.settings.IndexScopedSettings) HashSet(java.util.HashSet)

Example 15 with IndexScopedSettings

use of org.elasticsearch.common.settings.IndexScopedSettings in project crate by crate.

the class IndexSettingsTests method testUpdateSoftDeletesFails.

@Test
public void testUpdateSoftDeletesFails() {
    IndexScopedSettings settings = new IndexScopedSettings(Settings.EMPTY, IndexScopedSettings.BUILT_IN_INDEX_SETTINGS);
    IllegalArgumentException error = expectThrows(IllegalArgumentException.class, () -> settings.updateSettings(Settings.builder().put("index.soft_deletes.enabled", randomBoolean()).build(), Settings.builder(), Settings.builder(), "index"));
    assertThat(error.getMessage(), equalTo("final index setting [index.soft_deletes.enabled], not updateable"));
}
Also used : IndexScopedSettings(org.elasticsearch.common.settings.IndexScopedSettings) Test(org.junit.Test)

Aggregations

IndexScopedSettings (org.elasticsearch.common.settings.IndexScopedSettings)15 Settings (org.elasticsearch.common.settings.Settings)12 ClusterSettings (org.elasticsearch.common.settings.ClusterSettings)4 IndexSettings (org.elasticsearch.index.IndexSettings)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 Supplier (java.util.function.Supplier)3 IndexNameExpressionResolver (org.elasticsearch.cluster.metadata.IndexNameExpressionResolver)3 SettingsFilter (org.elasticsearch.common.settings.SettingsFilter)3 ActionPlugin (org.elasticsearch.plugins.ActionPlugin)3 RestController (org.elasticsearch.rest.RestController)3 RestHandler (org.elasticsearch.rest.RestHandler)3 ThreadPool (org.elasticsearch.threadpool.ThreadPool)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 NodeClient (org.elasticsearch.client.node.NodeClient)2 AliasValidator (org.elasticsearch.cluster.metadata.AliasValidator)2 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)2 MetaDataCreateIndexService (org.elasticsearch.cluster.metadata.MetaDataCreateIndexService)2 MetaDataIndexTemplateService (org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService)2