diff options
author | Simon Willnauer <simon.willnauer@elasticsearch.com> | 2017-01-10 15:14:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-10 15:14:55 +0100 |
commit | 081c1ad416e45592bee281df5bb5778787be2f8c (patch) | |
tree | 17c6540ace69eb56b13e3b89b303845950829175 /plugins/repository-azure | |
parent | 5ef78fd0159384f08a4d6f87a01f9fe6be21afc9 (diff) |
Allow affix settings to delegate to actual settings (#22523)
Affix settings are useful to namespace a certain setting. Yet, affix settings
must be specialized for their concrete type which causes lot of code duplication.
This commit allows to reuse an existing setting with and affix setting as soon as
a concrete key is available.
Diffstat (limited to 'plugins/repository-azure')
-rw-r--r-- | plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java index 9d67eea628..5e0de46f65 100644 --- a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java +++ b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java @@ -25,6 +25,7 @@ import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsException; import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.node.Node; import java.util.ArrayList; import java.util.Collections; @@ -34,19 +35,14 @@ import java.util.Map; import java.util.function.Function; public final class AzureStorageSettings { - private static final Setting.AffixKey TIMEOUT_KEY = Setting.AffixKey.withAffix(Storage.PREFIX, "timeout"); - - private static final Setting<TimeValue> TIMEOUT_SETTING = Setting.affixKeySetting( - TIMEOUT_KEY, - (s) -> Storage.TIMEOUT_SETTING.get(s).toString(), - (s) -> Setting.parseTimeValue(s, TimeValue.timeValueSeconds(-1), TIMEOUT_KEY.toString()), - Setting.Property.NodeScope); + private static final Setting<TimeValue> TIMEOUT_SETTING = Setting.affixKeySetting(Storage.PREFIX, "timeout", + (key) -> Setting.timeSetting(key, Storage.TIMEOUT_SETTING, Setting.Property.NodeScope)); private static final Setting<String> ACCOUNT_SETTING = - Setting.affixKeySetting(Storage.PREFIX, "account", "", Function.identity(), Setting.Property.NodeScope); + Setting.affixKeySetting(Storage.PREFIX, "account", (key) -> Setting.simpleString(key, Setting.Property.NodeScope)); private static final Setting<String> KEY_SETTING = - Setting.affixKeySetting(Storage.PREFIX, "key", "", Function.identity(), Setting.Property.NodeScope); + Setting.affixKeySetting(Storage.PREFIX, "key", (key) -> Setting.simpleString(key, Setting.Property.NodeScope)); private static final Setting<Boolean> DEFAULT_SETTING = - Setting.affixKeySetting(Storage.PREFIX, "default", "false", Boolean::valueOf, Setting.Property.NodeScope); + Setting.affixKeySetting(Storage.PREFIX, "default", (key) -> Setting.boolSetting(key, false, Setting.Property.NodeScope)); private final String name; |