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:gridool.dht.impl.DefaultLocalDirectory.java

public DefaultLocalDirectory(@CheckForNull LockManager lockManger) {
    super(lockManger);
    this.map = new ConcurrentHashMap<String, BIndexFile>(16);
}

From source file:ch.algotrader.service.AlgoOrderServiceImpl.java

public AlgoOrderServiceImpl(final OrderBook orderBook, final Engine serverEngine,
        final Map<Class<? extends AlgoOrder>, AlgoOrderExecService> algoExecServiceMap) {

    Validate.notNull(orderBook, "OpenOrderRegistry is null");
    Validate.notNull(serverEngine, "Engine is null");

    this.orderBook = orderBook;
    this.serverEngine = serverEngine;
    this.algoExecServiceMap = new ConcurrentHashMap<>(algoExecServiceMap);
}

From source file:io.siddhi.service.impl.SiddhiApiServiceImpl.java

@Override
public Response siddhiArtifactDeployPost(String siddhiApp) throws NotFoundException {

    log.info("SiddhiApp = " + siddhiApp);
    String jsonString = new Gson().toString();
    try {//www . j  av  a2s.c o m
        SiddhiApp parsedSiddhiApp = SiddhiCompiler.parse(siddhiApp);
        String siddhiAppName = AnnotationHelper.getAnnotationElement(
                SiddhiServiceConstants.ANNOTATION_NAME_NAME, null, parsedSiddhiApp.getAnnotations()).getValue();
        if (!siddhiAppRunTimeMap.containsKey(siddhiApp)) {
            SiddhiAppConfiguration siddhiAppConfiguration = new SiddhiAppConfiguration();
            siddhiAppConfiguration.setName(siddhiAppName);
            siddhiAppConfigurationMap.put(siddhiAppName, siddhiAppConfiguration);

            SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);

            if (siddhiAppRuntime != null) {
                Set<String> streamNames = siddhiAppRuntime.getStreamDefinitionMap().keySet();
                Map<String, InputHandler> inputHandlerMap = new ConcurrentHashMap<>(streamNames.size());

                for (String streamName : streamNames) {
                    inputHandlerMap.put(streamName, siddhiAppRuntime.getInputHandler(streamName));
                }

                siddhiAppSpecificInputHandlerMap.put(siddhiAppName, inputHandlerMap);

                siddhiAppRunTimeMap.put(siddhiAppName, siddhiAppRuntime);
                siddhiAppRuntime.start();

                jsonString = new Gson().toJson(new ApiResponseMessage(ApiResponseMessage.OK,
                        "Siddhi app is deployed " + "and runtime is created"));
            }
        } else {
            jsonString = new Gson().toJson(new ApiResponseMessage(ApiResponseMessage.ERROR,
                    "There is a Siddhi app already " + "exists with same name"));
        }

    } catch (Exception e) {
        jsonString = new Gson().toJson(new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage()));
    }

    return Response.ok().entity(jsonString).build();
}

From source file:io.engine.EngineIO.java

public EngineIO query(Map<String, String> query) {
    this.query = new ConcurrentHashMap<String, String>(query);
    return this;
}

From source file:com.twapime.app.util.AsyncImageLoader.java

/**
 * @param context/*from  www  .  j a v  a  2  s  .  c o  m*/
 */
private AsyncImageLoader(Context context) {
    this.context = context;
    //
    urlsBeingDownloaded = new Vector<String>();
    callbacks = new HashMap<String, List<ImageLoaderCallback>>();
    hardCache = new LinkedHashMap<String, Drawable>(HARD_CACHE_CAPACITY, 0.75f, true) {
        private static final long serialVersionUID = -4795168423098442895L;

        @Override
        protected boolean removeEldestEntry(LinkedHashMap.Entry<String, Drawable> eldest) {
            if (size() > HARD_CACHE_CAPACITY) {
                softCache.put(eldest.getKey(), new SoftReference<Drawable>(eldest.getValue()));
                //
                return true;
            } else
                return false;
        }
    };
    softCache = new ConcurrentHashMap<String, SoftReference<Drawable>>(HARD_CACHE_CAPACITY / 2);
    //
    loadCacheDir();
}

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

public BabuLSMTreeDirectory(LockManager lockManager) {
    super(lockManager);
    File colDir = GridUtils.getIndexDir(true);
    String baseDir = colDir.getAbsolutePath();
    File workDir = GridUtils.getWorkDir(true);
    String dbLogDir = new File(workDir, "babudb_log").getAbsolutePath();
    int numThreads = 4;
    long maxLogFileSize = 1024 * 1024 * 512; // 512mb
    int checkInterval = 5 * 60; // 5 min
    SyncMode syncMode = SyncMode.ASYNC;/*from w  w w  . j  a  va 2  s . c om*/
    int pseudoSyncWait = 0;
    int maxQ = 1000;
    boolean compression = true;
    int maxNumRecordsPerBlock = 0;
    int maxBlockFileSize = 0;
    BabuDBConfig conf = new BabuDBConfig(baseDir, dbLogDir, numThreads, maxLogFileSize, checkInterval, syncMode,
            pseudoSyncWait, maxQ, compression, maxNumRecordsPerBlock, maxBlockFileSize);
    final BabuDB databaseSystem;
    try {
        databaseSystem = BabuDBFactory.createBabuDB(conf);
    } catch (BabuDBException e) {
        throw new IllegalStateException(e);
    }
    this.databaseSystem = databaseSystem;
    this.dbm = databaseSystem.getDatabaseManager();
    this.map = new ConcurrentHashMap<String, Database>(16);
}

From source file:com.eharmony.services.swagger.persistence.FileDocumentationRepository.java

/**
 * Initializes documentation map by reading json file from file system.
 * @throws IOException Unable to load the file.
 *///  w w w. j  av  a 2 s. c  om
@PostConstruct
public void initializeDocumenationMap() throws IOException {
    if (StringUtils.isEmpty(this.fileLocation)) {
        this.fileLocation = DEFAULT_FILE_LOCATION;
    }
    documentationMap = new ConcurrentHashMap<>(readDocumentationFromFile());
}

From source file:com.github.horrorho.inflatabledonkey.KeyBagManager.java

public KeyBagManager(BiFunction<HttpClient, String, Optional<KeyBag>> keyBagClient,
        Map<String, KeyBag> keyBagMap) {
    this.keyBagClient = Objects.requireNonNull(keyBagClient, "keyBagClient");
    this.keyBagMap = new ConcurrentHashMap<>(keyBagMap);
}

From source file:com.netflix.config.ConcurrentMapConfiguration.java

public ConcurrentMapConfiguration(Map<String, Object> mapToCopy) {
    this();// w ww .java 2 s. c  o m
    map = new ConcurrentHashMap<String, Object>(mapToCopy);
}

From source file:ConcurrentHashSet.java

/**
 * Constructs a new, empty set; the backing <tt>HashMap</tt> instance has the specified initial
 * capacity and default load factor, which is <tt>0.75</tt>.
 * // w  w  w  .  j a v  a 2  s. c o  m
 * @param initialCapacity
 *            the initial capacity of the hash table.
 * @throws IllegalArgumentException
 *             if the initial capacity is less than zero.
 */
public ConcurrentHashSet(int initialCapacity) {
    map = new ConcurrentHashMap<E, Object>(initialCapacity);
}