Example usage for java.util.concurrent ConcurrentHashMap put

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

Introduction

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

Prototype

public V put(K key, V value) 

Source Link

Document

Maps the specified key to the specified value in this table.

Usage

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

public void addChannelHandler(String sourceIdentifier, String clientIdentifier,
        WebSocketClientHandler clientHandler) {
    ConcurrentHashMap<String, WebSocketClientHandler> handlerMap = channelHandlerPool.get(sourceIdentifier);
    if (handlerMap == null) {
        handlerMap = new ConcurrentHashMap<String, WebSocketClientHandler>();
        handlerMap.put(clientIdentifier, clientHandler);
        channelHandlerPool.put(sourceIdentifier, handlerMap);
    } else {/*from   w  w w .ja  va 2s .  c  o m*/
        handlerMap.put(clientIdentifier, clientHandler);
    }
}

From source file:org.apache.oodt.cas.filemgr.catalog.solr.SolrClient.java

/**
 * Method to query the Solr index for a product with the specified id.
 * @param id/*from  w ww  .j  a v a  2  s  . c  o m*/
 * @return
 */
public String queryProductById(String id, String mimeType) throws CatalogException {

    ConcurrentHashMap<String, String[]> params = new ConcurrentHashMap<String, String[]>();
    params.put("q", new String[] { Parameters.PRODUCT_ID + ":" + id });
    return query(params, mimeType);

}

From source file:org.apache.oodt.cas.filemgr.catalog.solr.SolrClient.java

/**
 * Method to query the Solr index for a product with the specified name.
 * @param name/*www  . j  a v  a2s. c  o m*/
 * @param mimeType
 * @return
 */
public String queryProductByName(String name, String mimeType) throws CatalogException {

    ConcurrentHashMap<String, String[]> params = new ConcurrentHashMap<String, String[]>();
    params.put("q", new String[] { Parameters.PRODUCT_NAME + ":" + name });
    return query(params, mimeType);

}

From source file:org.apache.marmotta.ucuenca.wk.commons.function.SemanticDistance.java

private <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
    List<Map.Entry<K, V>> list = new LinkedList<>(map.entrySet());
    Collections.sort(list, new Comparator<Map.Entry<K, V>>() {
        @Override// ww w . j  a v  a  2  s  . c om
        public int compare(Map.Entry<K, V> o1, Map.Entry<K, V> o2) {
            return (o1.getValue()).compareTo(o2.getValue());
        }
    });

    ConcurrentHashMap<K, V> result = new ConcurrentHashMap<>();
    for (Map.Entry<K, V> entry : list) {
        result.put(entry.getKey(), entry.getValue());
    }
    return result;
}

From source file:org.apache.oodt.cas.filemgr.catalog.solr.SolrClient.java

/**
 * Method to query Solr for the most recent 'n' products.
 * @param n//from ww  w .  j  a v a  2  s  .  c o m
 * @return
 * @throws CatalogException
 */
public String queryProductsByDate(int n, String mimeType) throws CatalogException {

    ConcurrentHashMap<String, String[]> params = new ConcurrentHashMap<String, String[]>();
    params.put("q", new String[] { "*:*" });
    params.put("rows", new String[] { "" + n });
    params.put("sort", new String[] { Parameters.PRODUCT_RECEIVED_TIME + " desc" });
    return query(params, mimeType);

}

From source file:org.apache.oodt.cas.filemgr.catalog.solr.SolrClient.java

/**
 * Method to query Solr for the most recent 'n' products of a specified type.
 * @param n/*from  www .  j ava2 s  .  co  m*/
 * @return
 * @throws CatalogException
 */
public String queryProductsByDateAndType(int n, ProductType type, String mimeType) throws CatalogException {

    ConcurrentHashMap<String, String[]> params = new ConcurrentHashMap<String, String[]>();
    params.put("q", new String[] { Parameters.PRODUCT_TYPE_NAME + type.getName() });
    params.put("rows", new String[] { "" + n });
    params.put("sort", new String[] { Parameters.PRODUCT_RECEIVED_TIME + " desc" });
    return query(params, mimeType);

}

From source file:io.seldon.clustering.recommender.jdo.JdoClusterFromReferrer.java

private void updateClusterMap() {
    PersistenceManager pm = JDOFactory.get().getPersistenceManager(client);
    if (pm != null) {
        Query query = pm.newQuery("javax.jdo.query.SQL", "select referrer,cluster from cluster_referrer");
        query.setResultClass(ClusterReferrer.class);
        List<ClusterReferrer> res = (List<ClusterReferrer>) query.execute();
        logger.info("Getting READ lock");
        lock.writeLock().lock();//from   w w  w .j ava  2s . co  m
        try {
            ConcurrentHashMap<String, Integer> clusterMapNew = new ConcurrentHashMap<>();
            for (ClusterReferrer r : res) {
                logger.info("Updating cluster map for " + client + " with referrer:" + r.getReferrer()
                        + " cluster:" + r.getCluster());
                clusterMapNew.put(r.getReferrer(), r.getCluster());
            }

            clusterMap = clusterMapNew;
        } finally {
            lock.writeLock().unlock();
            logger.info("Released WRITE lock");
        }

    } else
        logger.error("Failed to get persistence manager for client " + client);
}

From source file:cc.osint.graphd.server.GraphServerHandler.java

@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
    String clientId = "" + e.getChannel().getId();
    if (null == clientStateMap.get(clientId)) {
        ConcurrentHashMap<String, String> clientState = new ConcurrentHashMap<String, String>();
        clientState.put(ST_NAMECON, DEFAULT_CONNECTION_NAME + "-" + clientId);
        clientStateMap.put(clientId, clientState);
        clientIdChannelMap.put(clientId, e.getChannel());

        /*//from w w  w  .j  a va  2  s .co  m
         * start "client fiber & channel" & connect them
        */
        Fiber fiber = fiberFactory.create();
        fiber.start();
        org.jetlang.channels.Channel<JSONObject> inboundChannel = new MemoryChannel<JSONObject>();
        InboundChannelProcess inboundChannelProcess = new InboundChannelProcess(clientId, fiber, inboundChannel, // jetlang channel
                e.getChannel()); // netty channel
        inboundChannelMap.put(clientId, new WeakReference<InboundChannelProcess>(inboundChannelProcess));

        log.info(clientId + ": " + inboundChannelMap.get(clientId));

        inboundChannel.subscribe(fiber, inboundChannelProcess);
    }
    e.getChannel().write("-graphd " + InetAddress.getLocalHost().getHostName() + GraphServerProtocol.SPACE
            + clientId + GraphServerProtocol.NL);
}

From source file:de.ks.flatadocdb.index.GlobalIndex.java

@Override
public void addEntry(SessionEntry sessionEntry) {
    IndexElement element = new IndexElement(repository, sessionEntry.getCompletePath(), sessionEntry.getId(),
            sessionEntry.getNaturalId(), sessionEntry.getObject().getClass());
    idToElement.put(element.getId(), element);
    if (element.hasNaturalId()) {
        naturalIdToElement.put(element.getNaturalId(), element);
    }/*ww  w. java2  s  .  co  m*/
    @SuppressWarnings("unchecked")
    Set<Query<Object, Object>> queries = (Set) sessionEntry.getEntityDescriptor().getQueries();
    for (Query<Object, Object> query : queries) {
        Object value = query.getValue(sessionEntry.getObject());
        ConcurrentHashMap<IndexElement, Optional<Object>> map = queryElements.computeIfAbsent(query,
                q -> new ConcurrentHashMap<>());
        map.put(element, Optional.ofNullable(value));
    }
}

From source file:gov.nih.nci.integration.caaers.CaAERSParticipantServiceWSClient.java

private void initClient(String serviceUrl) {
    // Manual WSS4JOutInterceptor interceptor process - start
    final ConcurrentHashMap<String, Object> outProps = new ConcurrentHashMap<String, Object>();
    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    outProps.put(WSHandlerConstants.USER, userName);
    outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
    outProps.put(WSHandlerConstants.PW_CALLBACK_REF, clientPasswordCallback);

    final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);

    final JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

    factory.getOutInterceptors().add(wssOut);
    factory.setServiceClass(ParticipantServiceInterface.class);
    factory.setAddress(serviceUrl);/*  w  w w . ja v a2s.co m*/

    client = (ParticipantServiceInterface) factory.create();

    final Client clientProxy = ClientProxy.getClient(client);

    final HTTPConduit http = (HTTPConduit) clientProxy.getConduit();
    final TLSClientParameters tlsClientParams = new TLSClientParameters();
    tlsClientParams.setDisableCNCheck(true);
    http.setTlsClientParameters(tlsClientParams);
}