public abstract class AbstractScopedSettings extends AbstractComponent
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractScopedSettings.SettingUpdater<T>
Transactional interface to update settings.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ARCHIVED_SETTINGS_PREFIX |
deprecationLogger, logger, settings
Modifier | Constructor and Description |
---|---|
protected |
AbstractScopedSettings(Settings settings,
java.util.Set<Setting<?>> settingsSet,
Setting.Property scope) |
protected |
AbstractScopedSettings(Settings nodeSettings,
Settings scopeSettings,
AbstractScopedSettings other) |
Modifier and Type | Method and Description |
---|---|
<A,B> void |
addSettingsUpdateConsumer(Setting<A> a,
Setting<B> b,
java.util.function.BiConsumer<A,B> consumer)
Adds a settings consumer that accepts the values for two settings.
|
<T> void |
addSettingsUpdateConsumer(Setting<T> setting,
java.util.function.Consumer<T> consumer)
Adds a settings consumer.
|
<T> void |
addSettingsUpdateConsumer(Setting<T> setting,
java.util.function.Consumer<T> consumer,
java.util.function.Consumer<T> validator)
Adds a settings consumer with a predicate that is only evaluated at update time.
|
Settings |
applySettings(Settings newSettings)
Applies the given settings to all the settings consumers or to none of them.
|
Settings |
archiveUnknownOrInvalidSettings(Settings settings,
java.util.function.Consumer<java.util.Map.Entry<java.lang.String,java.lang.String>> unknownConsumer,
java.util.function.BiConsumer<java.util.Map.Entry<java.lang.String,java.lang.String>,java.lang.IllegalArgumentException> invalidConsumer)
Archives invalid or unknown settings.
|
Settings |
diff(Settings source,
Settings defaultSettings)
Returns a settings object that contains all settings that are not
already set in the given source.
|
<T> T |
get(Setting<T> setting)
Returns the value for the given setting.
|
Setting<?> |
get(java.lang.String key)
Returns the
Setting for the given key or null if the setting can not be found. |
Setting.Property |
getScope() |
boolean |
hasDynamicSetting(java.lang.String key)
Returns
true if the setting for the given key is dynamically updateable. |
protected boolean |
isPrivateSetting(java.lang.String key)
Returns
true iff the setting is a private setting ie. |
static boolean |
isValidKey(java.lang.String key)
Returns
true iff the given key is a valid settings key otherwise false |
boolean |
updateDynamicSettings(Settings toApply,
Settings.Builder target,
Settings.Builder updates,
java.lang.String type)
Updates a target settings builder with new, updated or deleted settings from a given settings builder.
|
boolean |
updateSettings(Settings toApply,
Settings.Builder target,
Settings.Builder updates,
java.lang.String type)
Updates a target settings builder with new, updated or deleted settings from a given settings builder.
|
void |
validate(Settings.Builder settingsBuilder)
Validates that all settings in the builder are registered and valid
|
void |
validate(Settings settings)
* Validates that all given settings are registered and valid
|
void |
validate(java.lang.String key,
Settings settings)
Validates that the setting is valid
|
protected void |
validateSettingKey(Setting setting) |
Settings |
validateUpdate(Settings settings)
Validates the given settings by running it through all update listeners without applying it.
|
logDeprecatedSetting, logRemovedSetting, nodeName
public static final java.lang.String ARCHIVED_SETTINGS_PREFIX
protected AbstractScopedSettings(Settings settings, java.util.Set<Setting<?>> settingsSet, Setting.Property scope)
protected AbstractScopedSettings(Settings nodeSettings, Settings scopeSettings, AbstractScopedSettings other)
protected void validateSettingKey(Setting setting)
public static boolean isValidKey(java.lang.String key)
true
iff the given key is a valid settings key otherwise false
public Setting.Property getScope()
public Settings validateUpdate(Settings settings)
public Settings applySettings(Settings newSettings)
newSettings
- the settings to applypublic <T> void addSettingsUpdateConsumer(Setting<T> setting, java.util.function.Consumer<T> consumer, java.util.function.Consumer<T> validator)
Note: Only settings registered in SettingsModule
can be changed dynamically.
validator
- an additional validator that is only applied to updates of this setting.
This is useful to add additional validation to settings at runtime compared to at startup time.public <A,B> void addSettingsUpdateConsumer(Setting<A> a, Setting<B> b, java.util.function.BiConsumer<A,B> consumer)
Note: Only settings registered in SettingsModule
can be changed dynamically.
public <T> void addSettingsUpdateConsumer(Setting<T> setting, java.util.function.Consumer<T> consumer)
Note: Only settings registered in ClusterModule
can be changed dynamically.
public final void validate(Settings.Builder settingsBuilder)
public final void validate(Settings settings)
public final void validate(java.lang.String key, Settings settings)
public Setting<?> get(java.lang.String key)
Setting
for the given key or null
if the setting can not be found.public boolean hasDynamicSetting(java.lang.String key)
true
if the setting for the given key is dynamically updateable. Otherwise false
.public Settings diff(Settings source, Settings defaultSettings)
public <T> T get(Setting<T> setting)
public boolean updateDynamicSettings(Settings toApply, Settings.Builder target, Settings.Builder updates, java.lang.String type)
Note: This method will only allow updates to dynamic settings. if a non-dynamic setting is updated an
IllegalArgumentException
is thrown instead.
toApply
- the new settings to applytarget
- the target settings builder that the updates are applied to. All keys that have explicit null value in toApply will be
removed from this builderupdates
- a settings builder that holds all updates applied to targettype
- a free text string to allow better exceptions messagestrue
if the target has changed otherwise false
public boolean updateSettings(Settings toApply, Settings.Builder target, Settings.Builder updates, java.lang.String type)
toApply
- the new settings to applytarget
- the target settings builder that the updates are applied to. All keys that have explicit null value in toApply will be
removed from this builderupdates
- a settings builder that holds all updates applied to targettype
- a free text string to allow better exceptions messagestrue
if the target has changed otherwise false
public Settings archiveUnknownOrInvalidSettings(Settings settings, java.util.function.Consumer<java.util.Map.Entry<java.lang.String,java.lang.String>> unknownConsumer, java.util.function.BiConsumer<java.util.Map.Entry<java.lang.String,java.lang.String>,java.lang.IllegalArgumentException> invalidConsumer)
settings
- the Settings
instance to scan for unknown or invalid settingsunknownConsumer
- callback on unknown settings (consumer receives unknown key and its
associated value)invalidConsumer
- callback on invalid settings (consumer receives invalid key, its
associated value and an exception)Settings
instance with the unknown or invalid settings archivedprotected boolean isPrivateSetting(java.lang.String key)
true
iff the setting is a private setting ie. it should be treated as valid even though it has no internal
representation. Otherwise false