Java Code Examples for org.elasticsearch.common.settings.Settings#keySet()
The following examples show how to use
org.elasticsearch.common.settings.Settings#keySet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdateSettingsPlan.java From crate with Apache License 2.0 | 6 votes |
@VisibleForTesting static Settings buildSettingsFrom(Collection<Assignment<Symbol>> assignments, Function<? super Symbol, Object> eval) { Settings.Builder settingsBuilder = Settings.builder(); for (Assignment<Symbol> entry : assignments) { String settingsName = eval.apply(entry.columnName()).toString(); if (CrateSettings.isValidSetting(settingsName) == false) { throw new IllegalArgumentException("Setting '" + settingsName + "' is not supported"); } Symbol expression = Lists2.getOnlyElement(entry.expressions()); Object value = eval.apply(expression); CrateSettings.flattenSettings(settingsBuilder, settingsName, value); } Settings settings = settingsBuilder.build(); for (String checkForRuntime : settings.keySet()) { CrateSettings.checkIfRuntimeSetting(checkForRuntime); } return settings; }
Example 2
Source File: DynamicRanker.java From elasticsearch-dynarank with Apache License 2.0 | 5 votes |
ScriptInfo(final String script, final String lang, final String scriptType, final Settings settings, final int reorderSize) { this.script = script; this.lang = lang; this.reorderSize = reorderSize; this.settings = new HashMap<>(); for (final String name : settings.keySet()) { final List<String> list = settings.getAsList(name); this.settings.put(name, list.toArray(new String[list.size()])); } if ("STORED".equalsIgnoreCase(scriptType)) { this.scriptType = ScriptType.STORED; } else { this.scriptType = ScriptType.INLINE; } }
Example 3
Source File: PairTokenFilterFactory.java From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 | 5 votes |
public PairTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); this.pairs = new LinkedHashMap<>(); Settings pairsSettings = settings.getAsSettings("pairs"); for (String key: pairsSettings.keySet()) { pairs.put(key, pairsSettings.get(key)); } }
Example 4
Source File: RepositoryParamValidator.java From crate with Apache License 2.0 | 5 votes |
public void validate(String type, GenericProperties<?> genericProperties, Settings settings) { TypeSettings typeSettings = settingsForType(type); Map<String, Setting<?>> allSettings = typeSettings.all(); // create string settings for all dynamic settings GenericProperties<?> dynamicProperties = typeSettings.dynamicProperties(genericProperties); if (!dynamicProperties.isEmpty()) { // allSettings are immutable by default, copy map allSettings = new HashMap<>(allSettings); for (String key : dynamicProperties.properties().keySet()) { allSettings.put(key, Setting.simpleString(key)); } } // validate all settings Set<String> names = settings.keySet(); Sets.SetView<String> missingRequiredSettings = Sets.difference(typeSettings.required().keySet(), names); if (!missingRequiredSettings.isEmpty()) { throw new IllegalArgumentException( String.format( Locale.ENGLISH, "The following required parameters are missing to create a repository of type \"%s\": [%s]", type, String.join(", ", missingRequiredSettings)) ); } }
Example 5
Source File: FulltextAnalyzerResolver.java From crate with Apache License 2.0 | 5 votes |
public Map<String, Settings> getCustomAnalyzers() throws IOException { Map<String, Settings> result = new HashMap<>(); Settings analyzer = getCustomThingies(ANALYZER); for (String settingName : analyzer.keySet()) { if (!settingName.endsWith("." + SQL_STATEMENT_KEY)) { result.put(settingName, decodeSettings(analyzer.get(settingName))); } } return result; }
Example 6
Source File: FulltextAnalyzerResolver.java From crate with Apache License 2.0 | 5 votes |
private static Map<String, Settings> getDecodedSettings(Settings settings) throws IOException { Map<String, Settings> result = new HashMap<>(); for (String name : settings.keySet()) { result.put(name, decodeSettings(settings.get(name))); } return result; }
Example 7
Source File: HostBasedAuthentication.java From crate with Apache License 2.0 | 5 votes |
@VisibleForTesting SortedMap<String, Map<String, String>> convertHbaSettingsToHbaConf(Settings settings) { Settings hbaSettings = AuthSettings.AUTH_HOST_BASED_CONFIG_SETTING.setting().get(settings); ImmutableSortedMap.Builder<String, Map<String, String>> hostBasedConf = ImmutableSortedMap.naturalOrder(); for (Map.Entry<String, Settings> entry : hbaSettings.getAsGroups().entrySet()) { Settings hbaEntry = entry.getValue(); HashMap<String, String> map = new HashMap<>(hbaEntry.size()); for (String name : hbaEntry.keySet()) { map.put(name, hbaEntry.get(name)); } hostBasedConf.put(entry.getKey(), map); } return hostBasedConf.build(); }
Example 8
Source File: AbstractAuditLog.java From deprecated-security-advanced-modules with Apache License 2.0 | 4 votes |
@Override public void logExternalConfig(Settings settings, Environment environment) { if(!checkComplianceFilter(Category.COMPLIANCE_EXTERNAL_CONFIG, null, getOrigin())) { return; } final Map<String, Object> configAsMap = Utils.convertJsonToxToStructuredMap(settings); final SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new SpecialPermission()); } final Map<String, String> envAsMap = AccessController.doPrivileged(new PrivilegedAction<Map<String, String>>() { @Override public Map<String, String> run() { return System.getenv(); } }); final Map propsAsMap = AccessController.doPrivileged(new PrivilegedAction<Map>() { @Override public Map run() { return System.getProperties(); } }); final String sha256 = DigestUtils.sha256Hex(configAsMap.toString()+envAsMap.toString()+propsAsMap.toString()); AuditMessage msg = new AuditMessage(Category.COMPLIANCE_EXTERNAL_CONFIG, clusterService, null, null); try (XContentBuilder builder = XContentBuilder.builder(XContentType.JSON.xContent())) { builder.startObject(); builder.startObject("external_configuration"); builder.field("elasticsearch_yml", configAsMap); builder.field("os_environment", envAsMap); builder.field("java_properties", propsAsMap); builder.field("sha256_checksum", sha256); builder.endObject(); builder.endObject(); builder.close(); msg.addUnescapedJsonToRequestBody(Strings.toString(builder)); } catch (Exception e) { log.error("Unable to build message",e); } Map<String, Path> paths = new HashMap<String, Path>(); for(String key: settings.keySet()) { if(key.startsWith("opendistro_security") && (key.contains("filepath") || key.contains("file_path"))) { String value = settings.get(key); if(value != null && !value.isEmpty()) { Path path = value.startsWith("/")?Paths.get(value):environment.configFile().resolve(value); paths.put(key, path); } } } msg.addFileInfos(paths); save(msg); }
Example 9
Source File: DecommissionAllocationDecider.java From crate with Apache License 2.0 | 4 votes |
private void updateDecommissioningNodes(Settings decommissionNodesSettings) { decommissioningNodes = decommissionNodesSettings.keySet(); }