Search in sources :

Example 1 with ThreadNameDeterminer

use of org.jboss.netty.util.ThreadNameDeterminer in project tez by apache.

the class ShuffleHandler method serviceInit.

@Override
protected void serviceInit(Configuration conf) throws Exception {
    manageOsCache = conf.getBoolean(SHUFFLE_MANAGE_OS_CACHE, DEFAULT_SHUFFLE_MANAGE_OS_CACHE);
    readaheadLength = conf.getInt(SHUFFLE_READAHEAD_BYTES, DEFAULT_SHUFFLE_READAHEAD_BYTES);
    maxShuffleConnections = conf.getInt(MAX_SHUFFLE_CONNECTIONS, DEFAULT_MAX_SHUFFLE_CONNECTIONS);
    int maxShuffleThreads = conf.getInt(MAX_SHUFFLE_THREADS, DEFAULT_MAX_SHUFFLE_THREADS);
    if (maxShuffleThreads == 0) {
        maxShuffleThreads = 2 * Runtime.getRuntime().availableProcessors();
    }
    shuffleBufferSize = conf.getInt(SHUFFLE_BUFFER_SIZE, DEFAULT_SHUFFLE_BUFFER_SIZE);
    shuffleTransferToAllowed = conf.getBoolean(SHUFFLE_TRANSFERTO_ALLOWED, (Shell.WINDOWS) ? WINDOWS_DEFAULT_SHUFFLE_TRANSFERTO_ALLOWED : DEFAULT_SHUFFLE_TRANSFERTO_ALLOWED);
    maxSessionOpenFiles = conf.getInt(SHUFFLE_MAX_SESSION_OPEN_FILES, DEFAULT_SHUFFLE_MAX_SESSION_OPEN_FILES);
    final String BOSS_THREAD_NAME_PREFIX = "Tez Shuffle Handler Boss #";
    NioServerBossPool bossPool = new NioServerBossPool(Executors.newCachedThreadPool(), 1, new ThreadNameDeterminer() {

        @Override
        public String determineThreadName(String currentThreadName, String proposedThreadName) throws Exception {
            return BOSS_THREAD_NAME_PREFIX + currentThreadName.substring(currentThreadName.lastIndexOf('-') + 1);
        }
    });
    final String WORKER_THREAD_NAME_PREFIX = "Tez Shuffle Handler Worker #";
    NioWorkerPool workerPool = new NioWorkerPool(Executors.newCachedThreadPool(), maxShuffleThreads, new ThreadNameDeterminer() {

        @Override
        public String determineThreadName(String currentThreadName, String proposedThreadName) throws Exception {
            return WORKER_THREAD_NAME_PREFIX + currentThreadName.substring(currentThreadName.lastIndexOf('-') + 1);
        }
    });
    selector = new NioServerSocketChannelFactory(bossPool, workerPool);
    super.serviceInit(new YarnConfiguration(conf));
}
Also used : NioServerBossPool(org.jboss.netty.channel.socket.nio.NioServerBossPool) NioWorkerPool(org.jboss.netty.channel.socket.nio.NioWorkerPool) NioServerSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) JniDBFactory.asString(org.fusesource.leveldbjni.JniDBFactory.asString) ByteString(com.google.protobuf.ByteString) ThreadNameDeterminer(org.jboss.netty.util.ThreadNameDeterminer) ClosedChannelException(java.nio.channels.ClosedChannelException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TooLongFrameException(org.jboss.netty.handler.codec.frame.TooLongFrameException) FileNotFoundException(java.io.FileNotFoundException) DBException(org.iq80.leveldb.DBException)

Aggregations

ByteString (com.google.protobuf.ByteString)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ClosedChannelException (java.nio.channels.ClosedChannelException)1 ExecutionException (java.util.concurrent.ExecutionException)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 JniDBFactory.asString (org.fusesource.leveldbjni.JniDBFactory.asString)1 DBException (org.iq80.leveldb.DBException)1 NioServerBossPool (org.jboss.netty.channel.socket.nio.NioServerBossPool)1 NioServerSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory)1 NioWorkerPool (org.jboss.netty.channel.socket.nio.NioWorkerPool)1 TooLongFrameException (org.jboss.netty.handler.codec.frame.TooLongFrameException)1 ThreadNameDeterminer (org.jboss.netty.util.ThreadNameDeterminer)1