private static Settings checkAndAddNodeName(final Settings settings) { if(!settings.hasValue("node.name")) { return Settings.builder().put(settings).put("node.name", "auto_node_name_"+System.currentTimeMillis()+"_"+ new Random().nextInt()).build(); } return settings; } }
/** * Returns the string value of the setting for the specified index. The order of search is first * in persistent settings the transient settings and finally the default settings. * @param setting the name of the setting to get * @return String */ public String getSetting(String setting) { if (persistentSettings.hasValue(setting)) { return persistentSettings.get(setting); } else if (transientSettings.hasValue(setting)) { return transientSettings.get(setting); } else if (defaultSettings.hasValue(setting)) { return defaultSettings.get(setting); } else { return null; } }
/** * Returns the string value for the specified index and setting. If the includeDefaults * flag was not set or set to false on the GetSettingsRequest, this method will only * return a value where the setting was explicitly set on the index. If the includeDefaults * flag was set to true on the GetSettingsRequest, this method will fall back to return the default * value if the setting was not explicitly set. */ public String getSetting(String index, String setting) { Settings settings = indexToSettings.get(index); if (setting != null) { if (settings != null && settings.hasValue(setting)) { return settings.get(setting); } else { Settings defaultSettings = indexToDefaultSettings.get(index); if (defaultSettings != null) { return defaultSettings.get(setting); } else { return null; } } } else { return null; } }
/** * Returns the string value for the specified index and setting. If the includeDefaults flag was not set or set to * false on the {@link GetIndexRequest}, this method will only return a value where the setting was explicitly set * on the index. If the includeDefaults flag was set to true on the {@link GetIndexRequest}, this method will fall * back to return the default value if the setting was not explicitly set. */ public String getSetting(String index, String setting) { Settings indexSettings = settings.get(index); if (setting != null) { if (indexSettings != null && indexSettings.hasValue(setting)) { return indexSettings.get(setting); } else { Settings defaultIndexSettings = defaultSettings.get(index); if (defaultIndexSettings != null) { return defaultIndexSettings.get(setting); } else { return null; } } } else { return null; } }
((onlyDynamic == false && get(key) != null) || isDynamicSetting(key))); for (String key : toApply.keySet()) { boolean isDelete = toApply.hasValue(key) == false; if (isDelete && (isValidDelete(key, onlyDynamic) || key.endsWith("*"))) {
boolean isWildcard = setting == null && Regex.isSimpleMatchPattern(key); assert setting != null // we already validated the normalized settings || (isWildcard && normalizedSettings.hasValue(key) == false) : "unknown setting: " + key + " isWildcard: " + isWildcard + " hasValue: " + normalizedSettings.hasValue(key); settingsForClosedIndices.copy(key, normalizedSettings); if (isWildcard || setting.isDynamic()) {
/** * Returns the string value of the setting for the specified index. The order of search is first * in persistent settings the transient settings and finally the default settings. * @param setting the name of the setting to get * @return String */ public String getSetting(String setting) { if (persistentSettings.hasValue(setting)) { return persistentSettings.get(setting); } else if (transientSettings.hasValue(setting)) { return transientSettings.get(setting); } else if (defaultSettings.hasValue(setting)) { return defaultSettings.get(setting); } else { return null; } }
/** * Returns the string value of the setting for the specified index. The order of search is first * in persistent settings the transient settings and finally the default settings. * @param setting the name of the setting to get * @return String */ public String getSetting(String setting) { if (persistentSettings.hasValue(setting)) { return persistentSettings.get(setting); } else if (transientSettings.hasValue(setting)) { return transientSettings.get(setting); } else if (defaultSettings.hasValue(setting)) { return defaultSettings.get(setting); } else { return null; } }
/** * Returns the string value for the specified index and setting. If the includeDefaults flag was not set or set to * false on the {@link GetIndexRequest}, this method will only return a value where the setting was explicitly set * on the index. If the includeDefaults flag was set to true on the {@link GetIndexRequest}, this method will fall * back to return the default value if the setting was not explicitly set. */ public String getSetting(String index, String setting) { Settings indexSettings = settings.get(index); if (setting != null) { if (indexSettings != null && indexSettings.hasValue(setting)) { return indexSettings.get(setting); } else { Settings defaultIndexSettings = defaultSettings.get(index); if (defaultIndexSettings != null) { return defaultIndexSettings.get(setting); } else { return null; } } } else { return null; } }
/** * Returns the string value for the specified index and setting. If the includeDefaults * flag was not set or set to false on the GetSettingsRequest, this method will only * return a value where the setting was explicitly set on the index. If the includeDefaults * flag was set to true on the GetSettingsRequest, this method will fall back to return the default * value if the setting was not explicitly set. */ public String getSetting(String index, String setting) { Settings settings = indexToSettings.get(index); if (setting != null) { if (settings != null && settings.hasValue(setting)) { return settings.get(setting); } else { Settings defaultSettings = indexToDefaultSettings.get(index); if (defaultSettings != null) { return defaultSettings.get(setting); } else { return null; } } } else { return null; } }
/** * Returns the string value for the specified index and setting. If the includeDefaults flag was not set or set to * false on the {@link GetIndexRequest}, this method will only return a value where the setting was explicitly set * on the index. If the includeDefaults flag was set to true on the {@link GetIndexRequest}, this method will fall * back to return the default value if the setting was not explicitly set. */ public String getSetting(String index, String setting) { Settings indexSettings = settings.get(index); if (setting != null) { if (indexSettings != null && indexSettings.hasValue(setting)) { return indexSettings.get(setting); } else { Settings defaultIndexSettings = defaultSettings.get(index); if (defaultIndexSettings != null) { return defaultIndexSettings.get(setting); } else { return null; } } } else { return null; } }
/** * Returns the string value for the specified index and setting. If the includeDefaults * flag was not set or set to false on the GetSettingsRequest, this method will only * return a value where the setting was explicitly set on the index. If the includeDefaults * flag was set to true on the GetSettingsRequest, this method will fall back to return the default * value if the setting was not explicitly set. */ public String getSetting(String index, String setting) { Settings settings = indexToSettings.get(index); if (setting != null) { if (settings != null && settings.hasValue(setting)) { return settings.get(setting); } else { Settings defaultSettings = indexToDefaultSettings.get(index); if (defaultSettings != null) { return defaultSettings.get(setting); } else { return null; } } } else { return null; } }
((onlyDynamic == false && get(key) != null) || isDynamicSetting(key))); for (String key : toApply.keySet()) { boolean isDelete = toApply.hasValue(key) == false; if (isDelete && (isValidDelete(key, onlyDynamic) || key.endsWith("*"))) {
/** * Transactional interface to update settings. * @see Setting * @param <T> the type of the value of the setting */ public interface SettingUpdater<T> { /** * Returns true if this updaters setting has changed with the current update * @param current the current settings * @param previous the previous setting * @return true if this updaters setting has changed with the current update */ boolean hasChanged(Settings current, Settings previous); /** * Returns the instance value for the current settings. This method is stateless and idempotent. * This method will throw an exception if the source of this value is invalid. */ T getValue(Settings current, Settings previous); /** * Applies the given value to the updater. This methods will actually run the update. */ void apply(T value, Settings current, Settings previous); /** * Updates this updaters value if it has changed. * @return <code>true</code> iff the value has been updated. */
boolean isWildcard = setting == null && Regex.isSimpleMatchPattern(key); assert setting != null // we already validated the normalized settings || (isWildcard && normalizedSettings.hasValue(key) == false) : "unknown setting: " + key + " isWildcard: " + isWildcard + " hasValue: " + normalizedSettings.hasValue(key); settingsForClosedIndices.copy(key, normalizedSettings); if (isWildcard || setting.isDynamic()) {
boolean isWildcard = setting == null && Regex.isSimpleMatchPattern(key); assert setting != null // we already validated the normalized settings || (isWildcard && normalizedSettings.hasValue(key) == false) : "unknown setting: " + key + " isWildcard: " + isWildcard + " hasValue: " + normalizedSettings.hasValue(key); settingsForClosedIndices.copy(key, normalizedSettings); if (isWildcard || setting.isDynamic()) {