@Override public void put(String componentName, String key, Object value) { Map<String, Object> componentData = data.get(componentName); if (null == componentData) { data.putIfAbsent(componentName, new ConcurrentHashMap<String, Object>()); componentData = data.get(componentName); } componentData.put(key, value); }
/** * Get the snapshot map for the given log channel ID. If no map is available, one is created (and stored). * * @param logChannelId * The log channel to use. * @return an existing or a new metrics snapshot map. */ public Map<String, MetricsSnapshotInterface> getSnapshotMap( String logChannelId ) { Map<String, MetricsSnapshotInterface> map = snapshotMaps.get( logChannelId ); if ( map == null ) { map = new ConcurrentHashMap<String, MetricsSnapshotInterface>(); snapshotMaps.put( logChannelId, map ); } return map; }
@Override public <T> T hget(String key, String field, Class<T> tClass) { Object obj = ((Map) cache.computeIfAbsent(key, k -> new ConcurrentHashMap<>())).get(field); if (obj == null) return null; return Jsons.fromJson(obj.toString(), tClass); }
throws MissingResourceException { Map<String, Map<Locale, MessageFormat>> codeMap = this.cachedBundleMessageFormats.get(bundle); Map<Locale, MessageFormat> localeMap = null; if (codeMap != null) { localeMap = codeMap.get(code); if (localeMap != null) { MessageFormat result = localeMap.get(locale); if (result != null) { return result; if (msg != null) { if (codeMap == null) { codeMap = new ConcurrentHashMap<>(); Map<String, Map<Locale, MessageFormat>> existing = this.cachedBundleMessageFormats.putIfAbsent(bundle, codeMap); localeMap = new ConcurrentHashMap<>(); Map<Locale, MessageFormat> existing = codeMap.putIfAbsent(code, localeMap); if (existing != null) { localeMap.put(locale, result); return result;
@Override public void put(String componentName, String key, Object value) { Map<String, Object> componentData = data.get(componentName); if (null == componentData) { data.putIfAbsent(componentName, new ConcurrentHashMap<String, Object>()); componentData = data.get(componentName); } componentData.put(key, value); }
@Override public long hincrBy(String key, String field, long value) { Map fields = ((Map) cache.computeIfAbsent(key, k -> new ConcurrentHashMap<>())); Number num = (Number) fields.get(field); long result = num.longValue() + 1; fields.put(field, result); executor.execute(this::writeToFile); return result; }
Map<Locale, ResourceBundle> localeMap = this.cachedResourceBundles.get(basename); if (localeMap != null) { ResourceBundle bundle = localeMap.get(locale); if (bundle != null) { return bundle; ResourceBundle bundle = doGetBundle(basename, locale); if (localeMap == null) { localeMap = new ConcurrentHashMap<>(); Map<Locale, ResourceBundle> existing = this.cachedResourceBundles.putIfAbsent(basename, localeMap); if (existing != null) { localeMap.put(locale, bundle); return bundle;
ServerExtender( PluginPointFactory pluginPointFactory ) { this.pluginPointFactory = pluginPointFactory; targetToPluginMap.put( Node.class, new ConcurrentHashMap<>() ); targetToPluginMap.put( Relationship.class, new ConcurrentHashMap<>() ); targetToPluginMap.put( GraphDatabaseService.class, new ConcurrentHashMap<>() ); }
private static Map<String, Object> mergeAttributes(ServerRequest request, Map<String, String> pathVariables, PathPattern pattern) { Map<String, Object> result = new ConcurrentHashMap<>(request.attributes()); result.put(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE, mergePathVariables(request.pathVariables(), pathVariables)); pattern = mergePatterns( (PathPattern) request.attributes().get(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE), pattern); result.put(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE, pattern); return result; }
private void putIntoUpdatingResource(String key, String[] value) { Map<String, String[]> localUR = updatingResource; if (localUR == null) { synchronized (this) { localUR = updatingResource; if (localUR == null) { updatingResource = localUR = new ConcurrentHashMap<>(8); } } } localUR.put(key, value); } }
@Nullable public MessageFormat getMessageFormat(String code, Locale locale) { if (this.properties == null) { return null; } Map<Locale, MessageFormat> localeMap = this.cachedMessageFormats.get(code); if (localeMap != null) { MessageFormat result = localeMap.get(locale); if (result != null) { return result; } } String msg = this.properties.getProperty(code); if (msg != null) { if (localeMap == null) { localeMap = new ConcurrentHashMap<>(); Map<Locale, MessageFormat> existing = this.cachedMessageFormats.putIfAbsent(code, localeMap); if (existing != null) { localeMap = existing; } } MessageFormat result = createMessageFormat(msg, locale); localeMap.put(locale, result); return result; } return null; } }
public static Map<String, Object> makeResponseContextForQuery() { final Map<String, Object> responseContext = new ConcurrentHashMap<>(); responseContext.put( DirectDruidClient.QUERY_TOTAL_BYTES_GATHERED, new AtomicLong() ); return responseContext; }
@Nullable private String getBeanNameByType(WebApplicationContext wac, Class<?> endpointClass) { String wacId = wac.getId(); Map<Class<?>, String> beanNamesByType = cache.get(wacId); if (beanNamesByType == null) { beanNamesByType = new ConcurrentHashMap<>(); cache.put(wacId, beanNamesByType); } if (!beanNamesByType.containsKey(endpointClass)) { String[] names = wac.getBeanNamesForType(endpointClass); if (names.length == 1) { beanNamesByType.put(endpointClass, names[0]); } else { beanNamesByType.put(endpointClass, NO_VALUE); if (names.length > 1) { throw new IllegalStateException("Found multiple @ServerEndpoint's of type [" + endpointClass.getName() + "]: bean names " + Arrays.asList(names)); } } } String beanName = beanNamesByType.get(endpointClass); return (NO_VALUE.equals(beanName) ? null : beanName); }
private static Map<EntityMode,Class<? extends ComponentTuplizer>> buildBaseMapping() { Map<EntityMode,Class<? extends ComponentTuplizer>> map = new ConcurrentHashMap<EntityMode,Class<? extends ComponentTuplizer>>(); map.put( EntityMode.POJO, PojoComponentTuplizer.class ); map.put( EntityMode.MAP, DynamicMapComponentTuplizer.class ); return map; } }
public Map<XLearningContainerId, ConcurrentHashMap<String, List<Double>>> getContainersCpuStatistics(){ Map<XLearningContainerId, ConcurrentHashMap<String, List<Double>>> cpuStatistics = new ConcurrentHashMap<>(); for(XLearningContainerId id: this.containersCpuStatistics.keySet()){ Map<String, ContainerMetricsStatisticsTuple> statisticsTuple = this.containersCpuStatistics.get(id); ConcurrentHashMap<String, List<Double>> statisticsValue = new ConcurrentHashMap<>(); for (String str: statisticsTuple.keySet()){ statisticsValue.put(str, statisticsTuple.get(str).getStatisticsInfo()); } cpuStatistics.put(id, statisticsValue); } return cpuStatistics; }
private static Map<EntityMode,Class<? extends EntityTuplizer>> buildBaseMapping() { Map<EntityMode,Class<? extends EntityTuplizer>> map = new ConcurrentHashMap<EntityMode,Class<? extends EntityTuplizer>>(); map.put( EntityMode.POJO, PojoEntityTuplizer.class ); map.put( EntityMode.MAP, DynamicMapEntityTuplizer.class ); return map; } }
protected synchronized Properties getProps() { if (properties == null) { properties = new Properties(); Map<String, String[]> backup = new ConcurrentHashMap<String, String[]>(updatingResource); loadResources(properties, resources, quietmode); if (overlay != null) { properties.putAll(overlay); for (Entry<Object,Object> item: overlay.entrySet()) { String key = (String)item.getKey(); String[] source = backup.get(key); if(source != null) { updatingResource.put(key, source); } } } } return properties; }
/** * Sets parameter. * * @param key the key * @param value the value */ public MethodConfig setParameter(String key, String value) { if (parameters == null) { parameters = new ConcurrentHashMap<String, String>(); } parameters.put(key, value); return this; }
@Override public V put(Iterable<K> key, V value) { if (value == null) throw new IllegalArgumentException("Value cannot be null"); TrieMap<K, V> curTrie = this; // go through each element for(K element:key){ if (curTrie.children == null) { curTrie.children = new ConcurrentHashMap<>();//Generics.newConcurrentHashMap(); } TrieMap<K, V> parent = curTrie; curTrie = curTrie.children.get(element); if(curTrie == null){ parent.children.put(element, curTrie = new TrieMap<>()); } } V oldValue = curTrie.value; curTrie.value = value; return oldValue; }
/** * Sets parameter. * * @param key the key * @param value the value */ public MethodConfig setParameter(String key, String value) { if (parameters == null) { parameters = new ConcurrentHashMap<String, String>(); } parameters.put(key, value); return this; }