Example usage for java.util.concurrent ConcurrentHashMap ConcurrentHashMap

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

Introduction

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

Prototype

public ConcurrentHashMap(Map<? extends K, ? extends V> m) 

Source Link

Document

Creates a new map with the same mappings as the given map.

Usage

From source file:com.alibaba.zonda.logger.server.writer.OutputStreamManager.java

private OutputStreamManager(String baseDir) {
    this.lock = new ReentrantReadWriteLock();
    this.baseDir = baseDir;
    this.osMap = new ConcurrentHashMap<String, LogOutputStream>(5);
}

From source file:com.sm.store.server.InvokerServerHandler.java

public InvokerServerHandler(Serializer serializer, List<String> classList) {
    this.serializer = serializer;
    if (serializer == null)
        serializer = new HessianSerializer();
    this.classList = classList;
    if (classList == null || classList.size() == 0)
        throw new RuntimeException("classList is null or freq 0");
    this.serviceMap = new ConcurrentHashMap<String, Service>(19);
    init();//from w  ww  . ja  va  2  s.co  m

}

From source file:com.google.api.auth.DefaultKeyUriSupplier.java

/**
 * Constructor./*  w ww  .java 2s  .com*/
 *
 * @param httpRequestFactory is the factory used to make HTTP requests.
 * @param issuerKeyUrls is the configurations that map an issuer to the verification key URL.
 */
public DefaultKeyUriSupplier(HttpRequestFactory httpRequestFactory,
        Map<String, IssuerKeyUrlConfig> issuerKeyUrls) {
    Preconditions.checkNotNull(httpRequestFactory);
    Preconditions.checkNotNull(issuerKeyUrls);

    this.httpRequestFactory = httpRequestFactory;
    this.issuerKeyUrls = new ConcurrentHashMap<>(issuerKeyUrls);
}

From source file:org.spring.cache.impl.MyMapCache.java

/**
 * Create a new ConcurrentMapCache with the specified name.
 * @param name the name of the cache/*from   w ww  .  j  a  va  2s .co m*/
 * @param allowNullValues whether to accept and convert {@code null}
 * values for this cache
 */
public MyMapCache(String name, boolean allowNullValues) {
    this(name, new ConcurrentHashMap<Object, Object>(256), allowNullValues);
}

From source file:com.mike.aframe.http.KJFileParams.java

private void init(int i) {
    urlParams = new ConcurrentHashMap<String, String>(8);
    fileParams = new ArrayList<InputStream>(i);
    fileWraps = new ConcurrentHashMap<String, FileWrapper>(i);
}

From source file:org.honeysoft.akka.actor.BusinessActorTest.java

@Test
public void shouldBeValidWhenNoOneIsNull() throws Exception {
    //GIVEN/*from   ww  w  .  j  a v a2s  .co  m*/
    final ConcurrentMap<String, Object> threadSafeMap = new ConcurrentHashMap<String, Object>(1);
    field("logger").ofType(Logger.class).in(businessService).postDecorateWith(new TestLogger(threadSafeMap));

    //WHEN
    String testString = "test-string";
    businessActorRef.tell(testString);

    //THEN
    Awaitility.waitAtMost(Duration.FIVE_SECONDS).until(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            return !threadSafeMap.isEmpty();
        }
    });

    Assertions.assertThat(threadSafeMap).hasSize(1);
    Assertions.assertThat(threadSafeMap.values().iterator().next()).isEqualTo(testString);
}

From source file:com.comphenix.xp.extra.ServiceProvider.java

/**
 * Copy everything from the given provider.
 * @param other - the given provider./*from  w  ww  .ja  va2  s.  co  m*/
 */
public ServiceProvider(ServiceProvider<TService> other) {
    this.defaultName = other.defaultName;
    this.nameLookup = new ConcurrentHashMap<String, TService>(other.nameLookup);
    this.disabledLookup = Sets.newSetFromMap(new ConcurrentHashMap<String, Boolean>());

    // Insert all disabled elements
    for (String disabled : other.disabledLookup) {
        this.disabledLookup.add(disabled);
    }
}

From source file:ch.algotrader.config.spring.DefaultConfigProvider.java

public DefaultConfigProvider(final Map<String, ?> paramMap, final ConversionService conversionService,
        final ConfigProvider fallbackProvider) {
    Assert.notNull(paramMap, "ParamMap is null");
    Assert.notNull(conversionService, "ConversionService is null");
    this.paramMap = new ConcurrentHashMap<>(paramMap);
    this.conversionService = conversionService;
    this.fallbackProvider = fallbackProvider;
}

From source file:ConcurrentHashSet.java

/**
 * Constructs a new set containing the elements in the specified collection. The
 * <tt>ConcurrentHashMap</tt> is created with default load factor (0.75) and an initial capacity
 * sufficient to contain the elements in the specified collection.
 * //from   w w w .  ja  va2s  . com
 * @param c
 *            the collection whose elements are to be placed into this set.
 * @throws NullPointerException
 *             if the specified collection is null.
 */
public ConcurrentHashSet(Collection<? extends E> c) {
    map = new ConcurrentHashMap<E, Object>(Math.max((int) (c.size() / .75f) + 1, 16));
    addAll(c);
}

From source file:gridool.dht.impl.TcBtreeLocalDirectory.java

public TcBtreeLocalDirectory(LockManager lockManger) {
    super(lockManger);
    this.map = new ConcurrentHashMap<String, BDB>(16);
}