Search in sources :

Example 16 with ThreadFactoryBuilder

use of org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder in project hbase by apache.

the class CompactSplit method createCompactionExecutors.

private void createCompactionExecutors() {
    this.regionSplitLimit = conf.getInt(REGION_SERVER_REGION_SPLIT_LIMIT, DEFAULT_REGION_SERVER_REGION_SPLIT_LIMIT);
    int largeThreads = Math.max(1, conf.getInt(LARGE_COMPACTION_THREADS, LARGE_COMPACTION_THREADS_DEFAULT));
    int smallThreads = conf.getInt(SMALL_COMPACTION_THREADS, SMALL_COMPACTION_THREADS_DEFAULT);
    // if we have throttle threads, make sure the user also specified size
    Preconditions.checkArgument(largeThreads > 0 && smallThreads > 0);
    final String n = Thread.currentThread().getName();
    StealJobQueue<Runnable> stealJobQueue = new StealJobQueue<Runnable>(COMPARATOR);
    this.longCompactions = new ThreadPoolExecutor(largeThreads, largeThreads, 60, TimeUnit.SECONDS, stealJobQueue, new ThreadFactoryBuilder().setNameFormat(n + "-longCompactions-%d").setDaemon(true).build());
    this.longCompactions.setRejectedExecutionHandler(new Rejection());
    this.longCompactions.prestartAllCoreThreads();
    this.shortCompactions = new ThreadPoolExecutor(smallThreads, smallThreads, 60, TimeUnit.SECONDS, stealJobQueue.getStealFromQueue(), new ThreadFactoryBuilder().setNameFormat(n + "-shortCompactions-%d").setDaemon(true).build());
    this.shortCompactions.setRejectedExecutionHandler(new Rejection());
}
Also used : ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder) StealJobQueue(org.apache.hadoop.hbase.util.StealJobQueue) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 17 with ThreadFactoryBuilder

use of org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder in project hbase by apache.

the class RegionReplicationFlushRequester method getTimer.

private static HashedWheelTimer getTimer() {
    HashedWheelTimer timer = TIMER;
    if (timer != null) {
        return timer;
    }
    synchronized (RegionReplicationFlushRequester.class) {
        timer = TIMER;
        if (timer != null) {
            return timer;
        }
        timer = new HashedWheelTimer(new ThreadFactoryBuilder().setNameFormat("RegionReplicationFlushRequester-Timer-pool-%d").setDaemon(true).setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build(), 500, TimeUnit.MILLISECONDS);
        TIMER = timer;
    }
    return timer;
}
Also used : ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder) HashedWheelTimer(org.apache.hbase.thirdparty.io.netty.util.HashedWheelTimer)

Example 18 with ThreadFactoryBuilder

use of org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder in project hbase by apache.

the class FifoRpcScheduler method start.

@Override
public void start() {
    LOG.info("Using {} as user call queue; handlerCount={}; maxQueueLength={}", this.getClass().getSimpleName(), handlerCount, maxQueueLength);
    this.executor = new ThreadPoolExecutor(handlerCount, handlerCount, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(maxQueueLength), new ThreadFactoryBuilder().setNameFormat("FifoRpcScheduler.handler-pool-%d").setDaemon(true).setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build(), new ThreadPoolExecutor.CallerRunsPolicy());
}
Also used : ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 19 with ThreadFactoryBuilder

use of org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder in project hbase by apache.

the class MasterFifoRpcScheduler method start.

@Override
public void start() {
    LOG.info("Using {} as call queue; handlerCount={}; maxQueueLength={}; rsReportHandlerCount={}; " + "rsReportMaxQueueLength={}", this.getClass().getSimpleName(), handlerCount, maxQueueLength, rsReportHandlerCount, rsRsreportMaxQueueLength);
    this.executor = new ThreadPoolExecutor(handlerCount, handlerCount, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(maxQueueLength), new ThreadFactoryBuilder().setNameFormat("MasterFifoRpcScheduler.call.handler-pool-%d").setDaemon(true).setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build(), new ThreadPoolExecutor.CallerRunsPolicy());
    this.rsReportExecutor = new ThreadPoolExecutor(rsReportHandlerCount, rsReportHandlerCount, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<>(rsRsreportMaxQueueLength), new ThreadFactoryBuilder().setNameFormat("MasterFifoRpcScheduler.RSReport.handler-pool-%d").setDaemon(true).setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build(), new ThreadPoolExecutor.CallerRunsPolicy());
}
Also used : ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 20 with ThreadFactoryBuilder

use of org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder in project hbase by apache.

the class HFileContentValidator method createThreadPool.

private ExecutorService createThreadPool(Configuration conf) {
    int availableProcessors = Runtime.getRuntime().availableProcessors();
    int numThreads = conf.getInt("hfilevalidator.numthreads", availableProcessors);
    return Executors.newFixedThreadPool(numThreads, new ThreadFactoryBuilder().setNameFormat("hfile-validator-pool-%d").setDaemon(true).setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build());
}
Also used : ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder)

Aggregations

ThreadFactoryBuilder (org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder)25 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)9 ExecutorService (java.util.concurrent.ExecutorService)7 IOException (java.io.IOException)6 Configuration (org.apache.hadoop.conf.Configuration)6 Future (java.util.concurrent.Future)5 TableName (org.apache.hadoop.hbase.TableName)5 BeforeClass (org.junit.BeforeClass)5 ExecutionException (java.util.concurrent.ExecutionException)4 Executors (java.util.concurrent.Executors)4 TimeUnit (java.util.concurrent.TimeUnit)4 InterruptedIOException (java.io.InterruptedIOException)3 Arrays (java.util.Arrays)3 Path (org.apache.hadoop.fs.Path)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 NavigableMap (java.util.NavigableMap)2 Random (java.util.Random)2 Set (java.util.Set)2 SortedSet (java.util.SortedSet)2