public boolean isNamespace() { return !isOption(); }
public void setAll(Map<ConfigElement.PathIdentifier,Object> options) { for (Map.Entry<ConfigElement.PathIdentifier,Object> entry : options.entrySet()) { Preconditions.checkArgument(entry.getKey().element.isOption()); set((ConfigOption) entry.getKey().element, entry.getValue(), entry.getKey().umbrellaElements); } }
private static Map<ConfigElement.PathIdentifier, Object> getManagedSubset(Map<ConfigElement.PathIdentifier, Object> m) { return Maps.filterEntries(m, entry -> { assert entry.getKey().element.isOption(); return ((ConfigOption)entry.getKey().element).isManaged(); }); }
private static Map<ConfigElement.PathIdentifier, Object> getGlobalSubset(Map<ConfigElement.PathIdentifier, Object> m) { return Maps.filterEntries(m, entry -> { assert entry.getKey().element.isOption(); return ((ConfigOption)entry.getKey().element).isGlobal(); }); }
private static Map<ConfigElement.PathIdentifier, Object> getLocalSubset(Map<ConfigElement.PathIdentifier, Object> m) { return Maps.filterEntries(m, entry -> { assert entry.getKey().element.isOption(); return ((ConfigOption)entry.getKey().element).isLocal(); }); }
public Map<ConfigElement.PathIdentifier,Object> getAll() { Map<ConfigElement.PathIdentifier,Object> result = Maps.newHashMap(); for (String key : config.getKeys("")) { Preconditions.checkArgument(StringUtils.isNotBlank(key)); try { final ConfigElement.PathIdentifier pid = ConfigElement.parse(getRootNamespace(),key); Preconditions.checkArgument(pid.element.isOption() && !pid.lastIsUmbrella); result.put(pid, get((ConfigOption) pid.element, pid.umbrellaElements)); } catch (IllegalArgumentException e) { log.debug("Ignored configuration entry for {} since it does not map to an option",key,e); } } return result; }
private List<ConfigOption<?>> getSortedChildOptions(ConfigNamespace n) { return getSortedChildren(n, arg0 -> arg0.isOption() && !((ConfigOption)arg0).isHidden()); }
@Override public UserModifiableConfiguration set(String path, Object value) { ConfigElement.PathIdentifier pp = ConfigElement.parse(config.getRootNamespace(),path); Preconditions.checkArgument(pp.element.isOption(),"Need to provide configuration option - not namespace: %s",path); ConfigOption option = (ConfigOption)pp.element; verifier.verifyModification(option); if (option.getDatatype().isArray()) { Class arrayType = option.getDatatype().getComponentType(); Object arr; if (value.getClass().isArray()) { int size = Array.getLength(value); arr = Array.newInstance(arrayType,size); for (int i=0;i<size;i++) { Array.set(arr,i,convertBasic(Array.get(value,i),arrayType)); } } else { arr = Array.newInstance(arrayType,1); Array.set(arr,0,convertBasic(value,arrayType)); } value = arr; } else { value = convertBasic(value,option.getDatatype()); } config.set(option,value,pp.umbrellaElements); return this; }
if (!pid.element.isOption()) { log.warn("Config key {} is a namespace (only options can be keys)", key); continue;
for (Map.Entry<ConfigElement.PathIdentifier, Object> ent : getManagedSubset(localBasicConfiguration.getAll()).entrySet()) { ConfigElement.PathIdentifier pid = ent.getKey(); assert pid.element.isOption(); ConfigOption<?> opt = (ConfigOption<?>)pid.element; Object localValue = ent.getValue();
private static void copyInputKeys(org.apache.hadoop.conf.Configuration hadoopConf, org.apache.commons.configuration.Configuration source) { // Copy IndexUpdateJob settings into the hadoop-backed cfg Iterator<String> iterator = source.getKeys(); while (iterator.hasNext()) { String key = iterator.next(); ConfigElement.PathIdentifier pid; try { pid = ConfigElement.parse(ROOT_NS, key); } catch (RuntimeException e) { log.debug("[inputkeys] Skipping {}", key, e); continue; } if (!pid.element.isOption()) continue; String k = ConfigElement.getPath(JanusGraphHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + "." + key; String v = source.getProperty(key).toString(); hadoopConf.set(k, v); log.debug("[inputkeys] Set {}={}", k, v); } }
private static void copyInputKeys(org.apache.hadoop.conf.Configuration hadoopConf, org.apache.commons.configuration.Configuration source) { // Copy IndexUpdateJob settings into the hadoop-backed cfg Iterator<String> iterator = source.getKeys(); while (iterator.hasNext()) { String key = iterator.next(); ConfigElement.PathIdentifier pid; try { pid = ConfigElement.parse(ROOT_NS, key); } catch (RuntimeException e) { log.debug("[inputkeys] Skipping {}", key, e); continue; } if (!pid.element.isOption()) continue; String k = ConfigElement.getPath(JanusGraphHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + "." + key; String v = source.getProperty(key).toString(); hadoopConf.set(k, v); log.debug("[inputkeys] Set {}={}", k, v); } }