Example usage for com.google.common.collect Maps newConcurrentMap

List of usage examples for com.google.common.collect Maps newConcurrentMap

Introduction

In this page you can find the example usage for com.google.common.collect Maps newConcurrentMap.

Prototype

public static <K, V> ConcurrentMap<K, V> newConcurrentMap() 

Source Link

Document

Returns a general-purpose instance of ConcurrentMap , which supports all optional operations of the ConcurrentMap interface.

Usage

From source file:nl.knaw.huygens.timbuctoo.storage.file.VREAuthorizationFileCollection.java

public VREAuthorizationFileCollection(List<VREAuthorization> authorizations) {
    idAuthorizationMap = Maps.newConcurrentMap();
    vreIdUserIdIdMap = Maps.newConcurrentMap();
    initialize(authorizations);
}

From source file:com.davidbracewell.scripting.ScriptEnvironmentManager.java

private ScriptEnvironmentManager() {
    environments = Maps.newConcurrentMap();
    engineManager = new ScriptEngineManager();
}

From source file:org.apache.tez.runtime.InputReadyTracker.java

public InputReadyTracker() {
    readyInputs = Maps.newConcurrentMap();
}

From source file:org.ros.internal.node.topic.TopicManager.java

public TopicManager() {
    publishers = Maps.newConcurrentMap();
    subscribers = Maps.newConcurrentMap();
}

From source file:com.github.hilcode.versionator.maven.impl.DefaultPomFinder.java

@Override
public ImmutableList<Pom> findAllPoms(final File rootDir) {
    final Map<GroupArtifact, Pom> map = Maps.newConcurrentMap();
    final File rootPomFile = new File(rootDir, "pom.xml");
    findPoms(map, rootPomFile);/* www  . ja v  a  2  s . co  m*/
    final List<Pom> allPoms = Lists.newArrayList(map.values());
    Collections.sort(allPoms);
    return ImmutableList.copyOf(allPoms);
}

From source file:org.apache.kylin.cube.cuboid.CuboidManager.java

public Cuboid findById(CuboidScheduler cuboidScheduler, long cuboidID) {
    Map<Long, Cuboid> cubeCache = schedulerCuboidCache.get(cuboidScheduler.getCuboidCacheKey());
    if (cubeCache == null) {
        cubeCache = Maps.newConcurrentMap();
        schedulerCuboidCache.put(cuboidScheduler.getCuboidCacheKey(), cubeCache);
    }/*from   w w w .j a  v  a  2  s  . co  m*/
    Cuboid cuboid = cubeCache.get(cuboidID);
    if (cuboid == null) {
        long validCuboidID = cuboidScheduler.findBestMatchCuboid(cuboidID);
        cuboid = new Cuboid(cuboidScheduler.getCubeDesc(), cuboidID, validCuboidID);
        cubeCache.put(cuboidID, cuboid);
    }
    return cuboid;
}

From source file:com.pinterest.terrapin.server.ResourcePartitionMap.java

public ResourcePartitionMap() {
    // We use concurrent maps since we require the ability to issue lock free reads. Writes
    // are still synchronized so that we can update both maps together.
    this.readerMap = Maps.newConcurrentMap();
    this.partitionCountMap = Maps.newConcurrentMap();
}

From source file:alluxio.job.util.JobUtils.java

/**
 * Returns whichever specified worker stores the most blocks from the block info list.
 *
 * @param workers a list of workers to consider
 * @param fileBlockInfos a list of file block information
 * @return a worker address storing the most blocks from the list
 *///from ww w.j  a v  a 2s  . c o  m
public static BlockWorkerInfo getWorkerWithMostBlocks(List<BlockWorkerInfo> workers,
        List<FileBlockInfo> fileBlockInfos) {
    // Index workers by their addresses.
    IndexedSet<BlockWorkerInfo> addressIndexedWorkers = new IndexedSet<>(WORKER_ADDRESS_INDEX);
    addressIndexedWorkers.addAll(workers);

    // Use ConcurrentMap for putIfAbsent. A regular Map works in Java 8.
    ConcurrentMap<BlockWorkerInfo, Integer> blocksPerWorker = Maps.newConcurrentMap();
    int maxBlocks = 0;
    BlockWorkerInfo mostBlocksWorker = null;
    for (FileBlockInfo fileBlockInfo : fileBlockInfos) {
        for (BlockLocation location : fileBlockInfo.getBlockInfo().getLocations()) {
            BlockWorkerInfo worker = addressIndexedWorkers.getFirstByField(WORKER_ADDRESS_INDEX,
                    location.getWorkerAddress());
            if (worker == null) {
                // We can only choose workers in the workers list.
                continue;
            }
            blocksPerWorker.putIfAbsent(worker, 0);
            int newBlockCount = blocksPerWorker.get(worker) + 1;
            blocksPerWorker.put(worker, newBlockCount);
            if (newBlockCount > maxBlocks) {
                maxBlocks = newBlockCount;
                mostBlocksWorker = worker;
            }
        }
    }
    return mostBlocksWorker;
}

From source file:org.apache.bookkeeper.clients.impl.container.StorageContainerChannelManager.java

@VisibleForTesting
StorageContainerChannelManager(StorageContainerChannelFactory factory) {
    this.factory = factory;
    this.scChannels = Maps.newConcurrentMap();
}

From source file:org.codetrack.database.file.FileProject.java

public FileProject() {

    itemsMap = Maps.newConcurrentMap();
}