/** * Sets a property. This method supports testing and should not be called. * * @param key * key of property to set * @param value * property value */ public void set(String key, String value) { getXmlConfig().set(key, value); } }
protected Configuration getHadoopConfiguration() { String credProviderPathsKey = Property.GENERAL_SECURITY_CREDENTIAL_PROVIDER_PATHS.getKey(); String credProviderPathsValue = getXmlConfig().get(credProviderPathsKey); if (null != credProviderPathsValue) { // We have configuration for a CredentialProvider // Try to pull the sensitive password from there Configuration conf = new Configuration(CachedConfiguration.getInstance()); conf.set(CredentialProviderFactoryShim.CREDENTIAL_PROVIDER_PATH, credProviderPathsValue); return conf; } return null; }
private SiteConfiguration() { /* * Make a read-only copy of static configs so we can avoid lock contention on the Hadoop * Configuration object */ final Configuration conf = getXmlConfig(); Map<String,String> temp = new HashMap<>((int) (Math.ceil(conf.size() / 0.75f)), 0.75f); for (Entry<String,String> entry : conf) { temp.put(entry.getKey(), entry.getValue()); } /* * If any of the configs used in hot codepaths are unset here, set a null so that we'll default * to the parent config without contending for the Hadoop Configuration object */ for (Property hotConfig : Property.HOT_PATH_PROPERTIES) { if (!(temp.containsKey(hotConfig.getKey()))) { temp.put(hotConfig.getKey(), null); } } staticConfigs = Collections.unmodifiableMap(temp); }
@Override public void getProperties(Map<String,String> props, Predicate<String> filter) { parent.getProperties(props, filter); for (Entry<String,String> entry : getXmlConfig()) if (filter.apply(entry.getKey())) props.put(entry.getKey(), entry.getValue()); // CredentialProvider should take precedence over site Configuration hadoopConf = getHadoopConfiguration(); if (null != hadoopConf) { try { for (String key : CredentialProviderFactoryShim.getKeys(hadoopConf)) { if (!Property.isValidPropertyKey(key) || !Property.isSensitive(key)) { continue; } if (filter.apply(key)) { char[] value = CredentialProviderFactoryShim.getValueFromCredentialProvider(hadoopConf, key); if (null != value) { props.put(key, new String(value)); } } } } catch (IOException e) { log.warn("Failed to extract sensitive properties from Hadoop" + " CredentialProvider, falling back to accumulo-site.xml", e); } } }
: getXmlConfig().get(key);