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:org.ros.internal.node.server.master.MasterRegistrationManagerImpl.java

public MasterRegistrationManagerImpl(MasterRegistrationListener listener) {
    this.listener = listener;
    nodes = Maps.newHashMap();
    services = Maps.newConcurrentMap();
    topics = Maps.newHashMap();
}

From source file:org.onosproject.incubator.store.virtual.impl.DistributedVirtualFlowObjectiveStore.java

@Override
protected ConcurrentMap<Integer, byte[]> getNextGroups(NetworkId networkId) {
    nextGroupsMap.computeIfAbsent(networkId, n -> {
        log.debug("getNextGroups - creating new ConcurrentMap");
        return Maps.newConcurrentMap();
    });/* w  w w.  j  a v  a  2  s . c om*/

    return nextGroupsMap.get(networkId).value();
}

From source file:com.cloudera.branchreduce.impl.distributed.TaskMaster.java

public TaskMaster(int vassalCount, List<T> initialTasks, G globalState, ExecutorService executor) {
    this.vassalCount = vassalCount;
    this.workers = Lists.newArrayList();
    this.hasWork = Maps.newConcurrentMap();
    this.tasks = new LinkedBlockingQueue<T>(initialTasks);
    this.globalState = globalState;
    if (!initialTasks.isEmpty()) {
        this.taskClass = (Class<T>) initialTasks.get(0).getClass();
    } else {// w  w w  . j a  v a  2 s .  com
        this.taskClass = null;
    }
    this.executor = executor;
}

From source file:com.metamx.druid.client.ClientSideServerView.java

public ClientSideServerView(QueryToolChestWarehouse warehose, ObjectMapper smileMapper, HttpClient httpClient) {
    this.warehose = warehose;
    this.smileMapper = smileMapper;
    this.httpClient = httpClient;

    this.clients = Maps.newConcurrentMap();
    this.selectors = Maps.newHashMap();
    this.timelines = Maps.newHashMap();
    this.serverCallbacks = Maps.newConcurrentMap();
    this.segmentCallbacks = Maps.newConcurrentMap();
}

From source file:org.axonframework.ext.hazelcast.distributed.commandbus.queue.HzCommandBusAgent.java

/**
 * c-tor/*from  w ww. j a va 2s  . c  o  m*/
 *
 * @param hzInstance   the Hazelcast instance
 * @param clusterName  the cluster name
 * @param nodeName     the node name
 */
public HzCommandBusAgent(HazelcastInstance hzInstance, String clusterName, String nodeName) {
    m_hzInstance = hzInstance;
    m_clusterName = clusterName;
    m_nodeName = nodeName + "@" + m_clusterName;
    m_queue = m_hzInstance.getQueue(m_nodeName);
    m_scheduler = Executors.newScheduledThreadPool(1);
    m_registry = m_hzInstance.getMap(HzCommandConstants.REG_CMD_NODES);
    m_callbacks = Maps.newConcurrentMap();

    m_registry.addEntryListener(new NodeListener(), true);
}

From source file:de.felix_klauke.pegasus.server.handler.PacketHandler.java

/**
 * The basic Constructor fot his class. The logger will be assigned to the local var
 * and the map for the Listeners will be created using the google Collections Library.
 *
 * @param logger the Logger to log all important information
 *///from  w  w w. ja v a2 s .  c om
public PacketHandler(Logger logger) {
    this.logger = logger;
    this.listeners = Maps.newConcurrentMap();
    this.userManager = new UserManager();

    //Register Listeners here
    registerListener(new PacketMessageListener(userManager), PacketMessage.class);
}

From source file:org.gradle.api.internal.artifacts.ivyservice.modulecache.ResolvedArtifactCaches.java

private Map<ComponentArtifactIdentifier, ResolvableArtifact> getResolvedArtifactCache(
        ModuleComponentRepository input) {
    Map<ComponentArtifactIdentifier, ResolvableArtifact> resolvedArtifactCache = cachePerRepo
            .get(input.getId());/*from  w w  w.j a v  a 2 s.  c o  m*/
    if (resolvedArtifactCache == null) {
        LOG.debug("Creating new in-memory cache for repo '{}' [{}].", input.getName(), input.getId());
        resolvedArtifactCache = Maps.newConcurrentMap();
        cachePerRepo.put(input.getId(), resolvedArtifactCache);
    } else {
        LOG.debug("Reusing in-memory cache for repo '{}' [{}].", input.getName(), input.getId());
    }
    return resolvedArtifactCache;
}

From source file:org.onosproject.incubator.store.virtual.impl.SimpleVirtualPacketStore.java

@Override
public void requestPackets(NetworkId networkId, PacketRequest request) {
    requests.computeIfAbsent(networkId, k -> Maps.newConcurrentMap());

    requests.get(networkId).compute(request.selector(), (s, existingRequests) -> {
        if (existingRequests == null) {
            if (hasDelegate(networkId)) {
                delegateMap.get(networkId).requestPackets(request);
            }/* ww  w .  j  a v  a  2 s  . co m*/
            return ImmutableSet.of(request);
        } else if (!existingRequests.contains(request)) {
            if (hasDelegate(networkId)) {
                delegateMap.get(networkId).requestPackets(request);
            }
            return ImmutableSet.<PacketRequest>builder().addAll(existingRequests).add(request).build();
        } else {
            return existingRequests;
        }
    });
}

From source file:org.locationtech.geogig.storage.memory.HeapObjectDatabse.java

/**
 * Opens the database for use by GeoGig.
 *///from   ww w.  j  a v a2s .c o m
@Override
public void open() {
    if (isOpen()) {
        return;
    }
    objects = Maps.newConcurrentMap();
    conflicts = new HeapConflictsDatabase();
}

From source file:org.sosy_lab.cpachecker.core.algorithm.termination.lasso_analysis.toolchain.LassoRankerToolchainStorage.java

public LassoRankerToolchainStorage(LogManager pLogger, ShutdownNotifier pShutdownNotifier) {
    logger = Preconditions.checkNotNull(pLogger);
    shutdownNotifier = Preconditions.checkNotNull(pShutdownNotifier);
    lassoRankerLoggingService = new LassoRankerLoggingService(pLogger);
    toolchainStorage = Maps.newConcurrentMap();
}