use of org.elasticsearch.common.settings.IndexScopedSettings in project elasticsearch by elastic.
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 MetadataCreateIndexService method onlyCreateIndex.
private void onlyCreateIndex(final NodeContext nodeContext, final CreateIndexClusterStateUpdateRequest request, final ActionListener<ClusterStateUpdateResponse> listener) {
Settings.Builder updatedSettingsBuilder = Settings.builder();
Settings build = updatedSettingsBuilder.put(request.settings()).normalizePrefix(IndexMetadata.INDEX_SETTING_PREFIX).build();
// we do validate here - index setting must be consistent
indexScopedSettings.validate(build, true);
request.settings(build);
clusterService.submitStateUpdateTask("create-index [" + request.index() + "], cause [" + request.cause() + "]", new IndexCreationTask(LOGGER, allocationService, request, listener, indicesService, aliasValidator, xContentRegistry, settings, this::validate, indexScopedSettings, nodeContext, indexNameExpressionResolver));
}
use of org.elasticsearch.common.settings.IndexScopedSettings in project crate by crate.
the class IndexSettingsModule method newIndexSettings.
public static IndexSettings newIndexSettings(Index index, Settings settings, IndexScopedSettings indexScopedSettings) {
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(settings).build();
IndexMetadata metadata = IndexMetadata.builder(index.getName()).settings(build).build();
return new IndexSettings(metadata, Settings.EMPTY, indexScopedSettings);
}
use of org.elasticsearch.common.settings.IndexScopedSettings in project crate by crate.
the class IndexSettingsTests method testArchivedSettingsValidation.
@Test
public void testArchivedSettingsValidation() {
final Settings settings = Settings.builder().put(AbstractScopedSettings.ARCHIVED_SETTINGS_PREFIX + "foo", System.currentTimeMillis()).build();
final IndexScopedSettings indexScopedSettings = new IndexScopedSettings(settings, IndexScopedSettings.BUILT_IN_INDEX_SETTINGS);
{
// validation should fail since we are not ignoring archived settings
final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> indexScopedSettings.validate(settings, randomBoolean()));
assertThat(e, hasToString(containsString("unknown setting [archived.foo]")));
}
{
// validation should fail since we are not ignoring archived settings
final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> indexScopedSettings.validate(settings, randomBoolean(), randomBoolean(), false));
assertThat(e, hasToString(containsString("unknown setting [archived.foo]")));
}
// nothing should happen since we are ignoring archived settings
indexScopedSettings.validate(settings, randomBoolean(), randomBoolean(), true);
}
use of org.elasticsearch.common.settings.IndexScopedSettings in project crate by crate.
the class IndexSettingsTests method testPrivateSettingsValidation.
@Test
public void testPrivateSettingsValidation() {
final Settings settings = Settings.builder().put(IndexMetadata.SETTING_CREATION_DATE, System.currentTimeMillis()).build();
final IndexScopedSettings indexScopedSettings = new IndexScopedSettings(settings, IndexScopedSettings.BUILT_IN_INDEX_SETTINGS);
{
// validation should fail since we are not ignoring private settings
final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> indexScopedSettings.validate(settings, randomBoolean()));
assertThat(e, hasToString(containsString("unknown setting [index.creation_date]")));
}
{
// validation should fail since we are not ignoring private settings
final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> indexScopedSettings.validate(settings, randomBoolean(), false, randomBoolean()));
assertThat(e, hasToString(containsString("unknown setting [index.creation_date]")));
}
// nothing should happen since we are ignoring private settings
indexScopedSettings.validate(settings, randomBoolean(), true, randomBoolean());
}
Aggregations