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