Java 8 ConcurrentHashMap - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ConcurrentHashMap class.

This code example shows how to use the following methods:
package com.taobao.oceanbase.network; 
 
import java.net.SocketAddress; 
import java.util.concurrent.ConcurrentHashMap; 
import java.util.concurrent.ConcurrentMap; 
import java.util.concurrent.TimeUnit; 
import java.util.concurrent.locks.ReentrantLock; 
 
public abstract class SessionFactory { 
 
	private ConcurrentMap<SocketAddress, Session> cache = new ConcurrentHashMap<SocketAddress, Session>();
 
	private ReentrantLock lock = new ReentrantLock();
 
	public Session getSession(Server server, SocketAddress address,
			int timeout, TimeUnit unit) {
		Session session = cache.get(address);
		if (session != null)
			return session;
		lock.lock();

10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
    public static <K, V> ConcurrentMap<K, V> newConcurrentMapWithAggressiveConcurrency() {
        return new ConcurrentHashMap<>(16, 0.75f, aggressiveConcurrencyLevel);
    } 
 
    public static <K, V> ConcurrentMap<K, V> newConcurrentMap() {
        return new ConcurrentHashMap<>();
    } 
 
    /** 
     * Creates a new CHM with an aggressive concurrency level, aimed at highly updateable long living maps. 
     */ 
    public static <V> ConcurrentMapLong<V> newConcurrentMapLongWithAggressiveConcurrency() { 
        return new ConcurrentHashMapLong<>(ConcurrentCollections.<Long, V>newConcurrentMapWithAggressiveConcurrency());
    } 
 
    public static <V> ConcurrentMapLong<V> newConcurrentMapLong() { 
        return new ConcurrentHashMapLong<>(ConcurrentCollections.<Long, V>newConcurrentMap());
    } 
 
    public static <V> Set<V> newConcurrentSet() {
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: get, putIfAbsent
 
    public void subscribe(final String topic, final String group, final int maxSize,
            final MessageListener messageListener, final ConsumerMessageFilter consumerMessageFilter)
                    throws MetaClientException { 
        final ConcurrentHashMap<String, SubscriberInfo> topicSubsriberRegistry = this.getTopicSubscriberRegistry(group);
        SubscriberInfo info = topicSubsriberRegistry.get(topic);
        if (info == null) {
            info = new SubscriberInfo(messageListener, consumerMessageFilter, maxSize);
            final SubscriberInfo oldInfo = topicSubsriberRegistry.putIfAbsent(topic, info);
            if (oldInfo != null) {
                throw new MetaClientException("Topic=" + topic + " has been subscribered by group " + group);
            } 
        } 
        else { 
            throw new MetaClientException("Topic=" + topic + " has been subscribered by group " + group);
        } 
    } 
 
 
    private ConcurrentHashMap<String, SubscriberInfo> getTopicSubscriberRegistry(final String group)

9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
 
public final class MockInternalEngine extends InternalEngine implements Engine { 
    public static final ConcurrentMap<AssertingSearcher, RuntimeException> INFLIGHT_ENGINE_SEARCHERS = new ConcurrentHashMap<>();
    public static final String WRAP_READER_RATIO = "index.engine.mock.random.wrap_reader_ratio";
    public static final String READER_WRAPPER_TYPE = "index.engine.mock.random.wrapper";
 
    private final Random random;
    private final boolean wrapReader;
    private final Class<? extends FilterDirectoryReader> wrapper;
 
    @Inject 
    public MockInternalEngine(ShardId shardId, @IndexSettings Settings indexSettings, ThreadPool threadPool,
                              IndexSettingsService indexSettingsService, ShardIndexingService indexingService, @Nullable IndicesWarmer warmer, Store store,
                              SnapshotDeletionPolicy deletionPolicy, Translog translog, MergePolicyProvider mergePolicyProvider,
                              MergeSchedulerProvider mergeScheduler, AnalysisService analysisService, SimilarityService similarityService,
                              CodecService codecService) throws EngineException {
        super(shardId, indexSettings, threadPool, indexSettingsService, indexingService, warmer, store,
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
    private boolean diskCacheEnabled = false;
    private ExecutorService writeThread;
 
    public WebImageCache(Context context) {
        // Set up in-memory cache store 
        memoryCache = new ConcurrentHashMap<String, SoftReference<Bitmap>>();
 
        // Set up disk cache store 
        Context appContext = context.getApplicationContext();
        diskCachePath = appContext.getCacheDir().getAbsolutePath() + DISK_CACHE_PATH;
 
        File outFile = new File(diskCachePath);
        outFile.mkdirs();
 
        diskCacheEnabled = outFile.exists();
 
        // Set up threadpool for image fetching tasks 
        writeThread = Executors.newSingleThreadExecutor();
    } 
 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Java 8 ConcurrentHashMap Methods: