Example usage for java.util.concurrent ConcurrentHashMap get

List of usage examples for java.util.concurrent ConcurrentHashMap get

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentHashMap get.

Prototype

public V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:ca.uhn.fhir.jaxrs.server.util.JaxRsMethodBindings.java

private void addMethodBinding(String key, BaseMethodBinding<?> binding) {
    ConcurrentHashMap<String, BaseMethodBinding<?>> mapByOperation = getMapForOperation(
            binding.getRestOperationType());
    if (mapByOperation.containsKey(key)) {
        throw new IllegalArgumentException("Multiple Search Method Bindings Found : " + mapByOperation.get(key)
                + " -- " + binding.getMethod());
    }/*  ww  w. java 2  s  .c  o  m*/
    mapByOperation.put(key, binding);
}

From source file:ca.uhn.fhir.jaxrs.server.util.JaxRsMethodBindings.java

/**
 * Get the binding /*from  ww w .ja v  a  2 s .c  om*/
 * 
 * @param operationType the type of operation
 * @param theBindingKey the binding key
 * @return the binding defined
 * @throws NotImplementedOperationException cannot be found
 */
public BaseMethodBinding<?> getBinding(RestOperationTypeEnum operationType, String theBindingKey) {
    String bindingKey = StringUtils.defaultIfBlank(theBindingKey, DEFAULT_METHOD_KEY);
    ConcurrentHashMap<String, BaseMethodBinding<?>> map = operationBindings.get(operationType);
    if (map == null || !map.containsKey(bindingKey)) {
        throw new NotImplementedOperationException("Operation not implemented");
    } else {
        return map.get(bindingKey);
    }
}

From source file:com.graphaware.importer.stats.LoggingStatisticsCollector.java

private AtomicInteger getCounter(String category, String name) {
    if (name == null) {
        name = "null";
    }//from w w  w .j av a  2s .c o  m

    ConcurrentHashMap<String, AtomicInteger> counter = counters.get(category);

    if (counter == null) {
        counters.putIfAbsent(category, new ConcurrentHashMap<String, AtomicInteger>());
        counter = counters.get(category);
    }

    AtomicInteger count = counter.get(name);

    if (count == null) {
        counter.putIfAbsent(name, new AtomicInteger(0));
        count = counter.get(name);
    }

    return count;
}

From source file:org.wso2.carbon.event.input.adapter.core.internal.CarbonInputEventAdapterService.java

@Override
public void start(String inputEventAdapterName) {
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    ConcurrentHashMap<String, InputAdapterRuntime> inputRuntimeMap = tenantSpecificEventAdapters.get(tenantId);
    if (inputRuntimeMap != null) {
        InputAdapterRuntime inputAdapterRuntime = inputRuntimeMap.get(inputEventAdapterName);
        if (inputAdapterRuntime != null) {
            inputAdapterRuntime.start();
        }/*from  w w  w . j ava 2 s.  co m*/
    }
}

From source file:org.wso2.carbon.event.input.adapter.core.internal.CarbonInputEventAdapterService.java

@Override
public boolean isEventDuplicatedInCluster(String inputEventAdapterName) throws InputEventAdapterException {
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    ConcurrentHashMap<String, InputAdapterRuntime> inputRuntimeMap = tenantSpecificEventAdapters.get(tenantId);
    if (inputRuntimeMap != null) {
        InputAdapterRuntime inputAdapterRuntime = inputRuntimeMap.get(inputEventAdapterName);
        if (inputAdapterRuntime != null) {
            return inputAdapterRuntime.isEventDuplicatedInCluster();
        }//  w  w w.j a v a 2s  . c  o  m
    }
    throw new InputEventAdapterException("Adapter with name '" + inputEventAdapterName + "' not found");
}

From source file:com.alibaba.wasp.meta.TableSchemaCacheReader.java

public List<Index> leftMatchIndexsByComposite(String tableName, String compositeName) {
    ConcurrentHashMap<String, List<Index>> tableIndexes = compositeIndex.get(tableName);
    for (String indexName : tableIndexes.keySet()) {
        if (indexName.startsWith(compositeName)) {
            return tableIndexes.get(indexName);
        }/*  w w w. j  a v a 2 s.  com*/
    }
    return null;
}

From source file:org.springframework.cloud.config.server.EncryptionController.java

public Environment decrypt(Environment environment) {
    Environment result = new Environment(environment.getName(), environment.getLabel());
    for (PropertySource source : environment.getPropertySources()) {
        ConcurrentHashMap<Object, Object> map = new ConcurrentHashMap<Object, Object>(source.getSource());
        for (Object key : map.keySet()) {
            String name = key.toString();
            String value = map.get(key).toString();
            if (value.startsWith("{cipher}")) {
                map.remove(key);//from  w w w.j  a  v  a 2s  .c om
                if (encryptor == null) {
                    map.put(name, value);
                } else {
                    try {
                        value = value == null ? null : encryptor.decrypt(value.substring("{cipher}".length()));
                    } catch (Exception e) {
                        value = "<n/a>";
                        name = "invalid." + name;
                        logger.warn("Cannot decrypt key: " + key + " (" + e.getClass() + ": " + e.getMessage()
                                + ")");
                    }
                    map.put(name, value);
                }
            }
        }
        result.add(new PropertySource(source.getName(), map));
    }
    return result;
}

From source file:org.apache.hadoop.yarn.server.resourcemanager.DistributedSchedulingService.java

private void addToMapping(ConcurrentHashMap<String, Set<NodeId>> mapping, String rackName, NodeId nodeId) {
    if (rackName != null) {
        mapping.putIfAbsent(rackName, new HashSet<NodeId>());
        Set<NodeId> nodeIds = mapping.get(rackName);
        synchronized (nodeIds) {
            nodeIds.add(nodeId);//w w  w  .j a va  2s  . c o  m
        }
    }
}

From source file:com.doctor.other.concurrent_hash_map_based_table.ConcurrentHashMapBasedTable.java

/**
 * ?/*from  w  w w .  ja v  a2  s  .c  om*/
 */
public void clear() {
    for (String rowKey : table.keySet()) {
        ConcurrentHashMap<String, ConcurrentSkipListMap<String, ConcurrentSet<T>>> rowMap = table.get(rowKey);
        for (String columnKey : rowMap.keySet()) {
            ConcurrentSkipListMap<String, ConcurrentSet<T>> columnMap = rowMap.get(columnKey);

            Iterator<String> iterator = columnMap.keySet().iterator();
            while (iterator.hasNext()) {
                String timesplices = iterator.next();
                columnMap.get(timesplices).clear();
                iterator.remove();
            }

        }
        rowMap.clear();
    }

    table.clear();
}

From source file:com.doctor.other.concurrent_hash_map_based_table.ConcurrentHashMapBasedTable.java

public List<T> get(final String rowKey, final String columnKey) {
    Preconditions.checkState(StringUtils.isNotBlank(rowKey), "rowKey is blank");
    Preconditions.checkState(StringUtils.isNotBlank(columnKey), "columnKey is blank");

    ConcurrentHashMap<String, ConcurrentSkipListMap<String, ConcurrentSet<T>>> row = table.get(rowKey);
    if (row == null) {
        return Arrays.asList();
    }//from  w ww  . j  a  va 2s.c  o  m

    ConcurrentSkipListMap<String, ConcurrentSet<T>> column = row.get(columnKey);
    if (column == null) {
        return Arrays.asList();
    }

    return column.values().parallelStream().flatMap(v -> v.parallelStream()).collect(Collectors.toList());
}