/** * Return the number of keys in the configuration. * * @return number of keys in the configuration. */ public int size() { return getProps().size(); }
/** * Return the number of keys in the configuration. * * @return number of keys in the configuration. */ public int size() { return getProps().size(); }
private void handleDeprecation() { LOG.debug("Handling deprecation for all properties in config..."); DeprecationContext deprecations = deprecationContext.get(); Set<Object> keys = new HashSet<Object>(); keys.addAll(getProps().keySet()); for (Object item: keys) { LOG.debug("Handling deprecation for " + (String)item); handleDeprecation(deprecations, (String)item); } }
private void handleDeprecation() { LOG.debug("Handling deprecation for all properties in config..."); DeprecationContext deprecations = deprecationContext.get(); Set<Object> keys = new HashSet<Object>(); keys.addAll(getProps().keySet()); for (Object item: keys) { LOG.debug("Handling deprecation for " + (String)item); handleDeprecation(deprecations, (String)item); } }
/** * Clears all keys from the configuration. */ public void clear() { getProps().clear(); getOverlay().clear(); }
/** * Clears all keys from the configuration. */ public void clear() { getProps().clear(); getOverlay().clear(); }
/** * get keys matching the the regex * @param regex * @return Map<String,String> with matching keys */ public Map<String,String> getValByRegex(String regex) { Pattern p = Pattern.compile(regex); Map<String,String> result = new HashMap<String,String>(); Matcher m; for(Entry<Object,Object> item: getProps().entrySet()) { if (item.getKey() instanceof String && item.getValue() instanceof String) { m = p.matcher((String)item.getKey()); if(m.find()) { // match result.put((String) item.getKey(), substituteVars(getProps().getProperty((String) item.getKey()))); } } } return result; }
/** * get keys matching the the regex * @param regex * @return Map<String,String> with matching keys */ public Map<String,String> getValByRegex(String regex) { Pattern p = Pattern.compile(regex); Map<String,String> result = new HashMap<String,String>(); Matcher m; for(Map.Entry<Object,Object> item: getProps().entrySet()) { if (item.getKey() instanceof String && item.getValue() instanceof String) { m = p.matcher((String)item.getKey()); if(m.find()) { // match result.put((String) item.getKey(), substituteVars(getProps().getProperty((String) item.getKey()))); } } } return result; }
/** * Get the value of the <code>name</code> property, without doing * <a href="#VariableExpansion">variable expansion</a>.If the key is * deprecated, it returns the value of the first key which replaces * the deprecated key and is not null. * * @param name the property name. * @return the value of the <code>name</code> property or * its replacing property and null if no such property exists. */ public String getRaw(String name) { String[] names = handleDeprecation(deprecationContext.get(), name); String result = null; for(String n : names) { result = getProps().getProperty(n); } return result; }
/** * Get the value of the <code>name</code> property, without doing * <a href="#VariableExpansion">variable expansion</a>.If the key is * deprecated, it returns the value of the first key which replaces * the deprecated key and is not null. * * @param name the property name. * @return the value of the <code>name</code> property or * its replacing property and null if no such property exists. */ public String getRaw(String name) { String[] names = handleDeprecation(deprecationContext.get(), name); String result = null; for(String n : names) { result = getProps().getProperty(n); } return result; }
/** * Return existence of the <code>name</code> property, but only for * names which have no valid value, usually non-existent or commented * out in XML. * * @param name the property name * @return true if the property <code>name</code> exists without value */ @VisibleForTesting public boolean onlyKeyExists(String name) { String[] names = handleDeprecation(deprecationContext.get(), name); for(String n : names) { if ( getProps().getProperty(n,DEFAULT_STRING_CHECK) .equals(DEFAULT_STRING_CHECK) ) { return true; } } return false; }
/** * Return existence of the <code>name</code> property, but only for * names which have no valid value, usually non-existent or commented * out in XML. * * @param name the property name * @return true if the property <code>name</code> exists without value */ @VisibleForTesting public boolean onlyKeyExists(String name) { String[] names = handleDeprecation(deprecationContext.get(), name); for(String n : names) { if ( getProps().getProperty(n,DEFAULT_STRING_CHECK) .equals(DEFAULT_STRING_CHECK) ) { return true; } } return false; }
@Override public void write(DataOutput out) throws IOException { Properties props = getProps(); WritableUtils.writeVInt(out, props.size()); for(Map.Entry<Object, Object> item: props.entrySet()) { org.apache.hadoop.io.Text.writeString(out, (String) item.getKey()); org.apache.hadoop.io.Text.writeString(out, (String) item.getValue()); WritableUtils.writeCompressedStringArray(out, updatingResource != null ? updatingResource.get(item.getKey()) : null); } }
@Override public void write(DataOutput out) throws IOException { Properties props = getProps(); WritableUtils.writeVInt(out, props.size()); for(Entry<Object, Object> item: props.entrySet()) { org.apache.hadoop.io.Text.writeString(out, (String) item.getKey()); org.apache.hadoop.io.Text.writeString(out, (String) item.getValue()); WritableUtils.writeCompressedStringArray(out, updatingResource.get(item.getKey())); } }
/** * Add a configuration resource. * * The properties of this resource will override properties of previously * added resources, unless they were marked <a href="#Final">final</a>. * * @param conf Configuration object from which to load properties */ public void addResource(Configuration conf) { addResourceObject(new Resource(conf.getProps())); }
/** * Get the value of the <code>name</code> property, <code>null</code> if * no such property exists. If the key is deprecated, it returns the value of * the first key which replaces the deprecated key and is not null. * * Values are processed for <a href="#VariableExpansion">variable expansion</a> * before being returned. * * @param name the property name, will be trimmed before get value. * @return the value of the <code>name</code> or its replacing property, * or null if no such property exists. */ public String get(String name) { String[] names = handleDeprecation(deprecationContext.get(), name); String result = null; for(String n : names) { result = substituteVars(getProps().getProperty(n)); } return result; }
/** * Add a configuration resource. * * The properties of this resource will override properties of previously * added resources, unless they were marked <a href="#Final">final</a>. * * @param conf Configuration object from which to load properties */ public void addResource(Configuration conf) { addResourceObject(new Resource(conf.getProps(), conf.restrictSystemProps)); }
/** * Get the value of the <code>name</code>. If the key is deprecated, * it returns the value of the first key which replaces the deprecated key * and is not null. * If no such property exists, * then <code>defaultValue</code> is returned. * * @param name property name, will be trimmed before get value. * @param defaultValue default value. * @return property value, or <code>defaultValue</code> if the property * doesn't exist. */ public String get(String name, String defaultValue) { String[] names = handleDeprecation(deprecationContext.get(), name); String result = null; for(String n : names) { result = substituteVars(getProps().getProperty(n, defaultValue)); } return result; }
/** * Unset a previously set property. */ public synchronized void unset(String name) { String[] names = null; if (!isDeprecated(name)) { names = getAlternativeNames(name); if(names == null) { names = new String[]{name}; } } else { names = handleDeprecation(deprecationContext.get(), name); } for(String n: names) { getOverlay().remove(n); getProps().remove(n); } }
/** * Unset a previously set property. */ public synchronized void unset(String name) { String[] names = null; if (!isDeprecated(name)) { names = getAlternativeNames(name); if(names == null) { names = new String[]{name}; } } else { names = handleDeprecation(deprecationContext.get(), name); } for(String n: names) { getOverlay().remove(n); getProps().remove(n); } }