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:com.opengamma.financial.currency.AbstractCurrencyMatrix.java

@Override
public CurrencyMatrixValue getConversion(final Currency source, final Currency target) {
    if (source.equals(target)) {
        // This shouldn't happen in sensible code
        return CurrencyMatrixValue.of(1.0);
    }/*  ww  w .j  a va2s . c o m*/
    ConcurrentHashMap<Currency, CurrencyMatrixValue> conversions = _values.get(source);
    if (conversions == null) {
        return null;
    } else {
        CurrencyMatrixValue currMtxVal = conversions.get(target);
        return currMtxVal;
    }
}

From source file:com.willkara.zeteo.explorers.Explorer.java

public void namer(final File f, ConcurrentHashMap mapper) {

    String extension = FilenameUtils.getExtension(f.getName());
    BaseFileType bft = new BaseFileType(f);
    if (extension.equals("")) {
        extension = "N/A";
    }/*from   w  ww.  j  a  v a2 s.co  m*/
    List<BaseFileType> nameList = (List<BaseFileType>) mapper.get(extension);
    // if list does not exist create it
    if (nameList == null) {
        nameList = new ArrayList<>();
        nameList.add(bft);
        mapper.put(extension, nameList);
        //System.out.println("Added new one to map.");
    } else {
        // add if item is not already in list
        if (!nameList.contains(bft)) {
            nameList.add(bft);
        }
        //System.out.println("Added to map.");
    }
}

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

private List<Index> getIndexsByKeyField(String tableName, String column) {
    ConcurrentHashMap<String, List<Index>> col2indexs = key2Index.get(tableName);
    if (col2indexs == null) {
        return null;
    }//w w w  .j a  v  a2  s  . co  m
    return col2indexs.get(column);
}

From source file:org.wso2.carbon.websocket.transport.WebsocketConnectionFactory.java

public WebSocketClientHandler getChannelHandlerFromPool(String sourceIdentifier, String clientIdentifier) {
    ConcurrentHashMap<String, WebSocketClientHandler> handlerMap = channelHandlerPool.get(sourceIdentifier);
    if (handlerMap == null) {
        return null;
    } else {/*w  w w.  jav  a 2 s  .co  m*/
        return handlerMap.get(clientIdentifier);
    }
}

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

private List<Index> getIndexsByStoringField(String tableName, String column) {
    ConcurrentHashMap<String, List<Index>> col2indexs = storing2Index.get(tableName);
    if (col2indexs == null) {
        return null;
    }/*  www . ja va2 s . c o  m*/
    return col2indexs.get(column);
}

From source file:org.apache.hadoop.hbase.quotas.QuotaCache.java

/**
 * Returns the QuotaState requested.//ww w. j a  va  2 s  . c  o m
 * If the quota info is not in cache an empty one will be returned
 * and the quota request will be enqueued for the next cache refresh.
 */
private <K> QuotaState getQuotaState(final ConcurrentHashMap<K, QuotaState> quotasMap, final K key) {
    QuotaState quotaInfo = quotasMap.get(key);
    if (quotaInfo == null) {
        quotaInfo = new QuotaState();
        if (quotasMap.putIfAbsent(key, quotaInfo) == null) {
            triggerCacheRefresh();
        }
    }
    return quotaInfo;
}

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

public List<Index> getIndexsByComposite(String tableName, String compositeName) {
    ConcurrentHashMap<String, List<Index>> tableIndexes = compositeIndex.get(tableName);
    if (tableIndexes == null) {
        return null;
    }// w  w  w. ja  va  2s .  c o m
    return tableIndexes.get(compositeName);
}

From source file:org.getobjects.ofs.fs.OFSFileManager.java

public Object getCachedObject(final String _section, IOFSFileInfo _info) {
    if (_section == null || _info == null)
        return null;

    final ConcurrentHashMap<IOFSFileInfo, Object> sectionCache = this.objectCache.get(_section);
    if (sectionCache == null)
        return null;

    CacheNode entry = (CacheNode) sectionCache.get(_info);
    if (entry == null)
        return null;

    /* validate entry */

    Object newETag = this.etagFromFileInfo(_info);
    if (newETag == entry.etag)
        return entry.object; /* still valid */

    if (newETag == null || entry.etag == null || !(newETag.equals(entry.etag))) {
        /* expire entry if its still the same entry in the cache */
        sectionCache.remove(_info, entry);
        return null;
    }//from  ww  w.j a v a 2  s . co  m

    /* still valid */
    return entry.object;
}

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

private void removeFromMapping(ConcurrentHashMap<String, Set<NodeId>> mapping, String rackName, NodeId nodeId) {
    if (rackName != null) {
        Set<NodeId> nodeIds = mapping.get(rackName);
        synchronized (nodeIds) {
            nodeIds.remove(nodeId);/*from  w  ww  .  j  a va  2s.co  m*/
        }
    }
}

From source file:org.wso2.carbon.event.output.adapter.core.internal.CarbonOutputEventAdapterService.java

@Override
public boolean isPolled(String outputAdapterName) throws OutputEventAdapterException {
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    ConcurrentHashMap<String, OutputAdapterRuntime> inputRuntimeMap = tenantSpecificEventAdapters.get(tenantId);
    if (inputRuntimeMap != null) {
        OutputAdapterRuntime outputAdapterRuntime = inputRuntimeMap.get(outputAdapterName);
        if (outputAdapterRuntime != null) {
            return outputAdapterRuntime.isPolled();
        }/*  w  ww.  ja v a  2  s.  c om*/
    }
    throw new OutputEventAdapterException("Adopter with name'" + outputAdapterName + "' not found");
}