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.apache.phoenix.query.ConnectionQueryServicesImpl.java

@Override
public void removeConnection(PhoenixConnection connection) throws SQLException {
    if (returnSequenceValues) {
        ConcurrentMap<SequenceKey, Sequence> formerSequenceMap = null;
        synchronized (connectionCountLock) {
            if (--connectionCount == 0) {
                if (!this.sequenceMap.isEmpty()) {
                    formerSequenceMap = this.sequenceMap;
                    this.sequenceMap = Maps.newConcurrentMap();
                }/*from   w w  w  .ja  va 2 s  . c  o m*/
            }
        }
        // Since we're using the former sequenceMap, we can do this outside
        // the lock.
        if (formerSequenceMap != null) {
            // When there are no more connections, attempt to return any sequences
            returnAllSequences(formerSequenceMap);
        }
    }
}

From source file:com.cinchapi.concourse.server.ConcourseServer.java

/**
 * Initialize this instance. This method MUST always be called after
 * constructing the instance./* w  w  w  .  j  a v  a  2  s . c  o  m*/
 * 
 * @param port - the port on which to listen for client connections
 * @param bufferStore - the location to store {@link Buffer} files
 * @param dbStore - the location to store {@link Database} files
 * @throws TTransportException
 */
private void init(int port, String bufferStore, String dbStore) throws TTransportException {
    Preconditions.checkState(!bufferStore.equalsIgnoreCase(dbStore),
            "Cannot store buffer and database files in the same directory. " + "Please check concourse.prefs.");
    Preconditions.checkState(!Strings.isNullOrEmpty(Environments.sanitize(DEFAULT_ENVIRONMENT)),
            "Cannot initialize " + "Concourse Server with a default environment of "
                    + "'%s'. Please use a default environment name that "
                    + "contains only alphanumeric characters.",
            DEFAULT_ENVIRONMENT);
    FileSystem.mkdirs(bufferStore);
    FileSystem.mkdirs(dbStore);
    FileSystem.lock(bufferStore);
    FileSystem.lock(dbStore);
    TServerSocket socket = new TServerSocket(port);
    ConcourseService.Processor<Iface> processor = new ConcourseService.Processor<Iface>(this);
    Args args = new TThreadPoolServer.Args(socket);
    args.processor(processor);
    args.maxWorkerThreads(NUM_WORKER_THREADS);
    args.executorService(Executors
            .newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("Client Worker" + " %d").build()));
    this.server = new TThreadPoolServer(args);
    this.bufferStore = bufferStore;
    this.dbStore = dbStore;
    this.engines = Maps.newConcurrentMap();
    this.accessManager = AccessManager.create(ACCESS_FILE);
    this.httpServer = GlobalState.HTTP_PORT > 0 ? HttpServer.create(this, GlobalState.HTTP_PORT)
            : HttpServer.disabled();
    getEngine(); // load the default engine
    this.plugins = new PluginManager(GlobalState.CONCOURSE_HOME + File.separator + "plugins");
}