@Deprecated public static NamedThreadFactory daemon( String threadNamePrefix ) { return daemon( threadNamePrefix, NO_OP_MONITOR ); }
private ExecutorService createThreadPool() { int threads = getNumberOfPopulationWorkers(); BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>( TASK_QUEUE_SIZE ); ThreadFactory threadFactory = daemon( FLUSH_THREAD_NAME_PREFIX ); RejectedExecutionHandler rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy(); return new ThreadPoolExecutor( threads, threads, 0L, TimeUnit.MILLISECONDS, workQueue, threadFactory, rejectedExecutionHandler ); }
@Deprecated public static NamedThreadFactory daemon( String threadNamePrefix ) { return daemon( threadNamePrefix, NO_OP_MONITOR ); }
private ExecutorService createThreadPool() { int threads = getNumberOfPopulationWorkers(); BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>( TASK_QUEUE_SIZE ); ThreadFactory threadFactory = daemon( FLUSH_THREAD_NAME_PREFIX ); RejectedExecutionHandler rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy(); return new ThreadPoolExecutor( threads, threads, 0L, TimeUnit.MILLISECONDS, workQueue, threadFactory, rejectedExecutionHandler ); }
public static ExecutorService createDefaultPool() { return new ThreadPoolExecutor( DEFAULT_CONCURRENCY, DEFAULT_CONCURRENCY * 2, 30L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(DEFAULT_QUEUE_SIZE), NamedThreadFactory.daemon("algo"), new CallerBlocksPolicy()); }
public static ExecutorService createDefaultPool() { return new ThreadPoolExecutor( DEFAULT_CONCURRENCY, DEFAULT_CONCURRENCY * 2, 30L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(DEFAULT_QUEUE_SIZE), NamedThreadFactory.daemon("algo"), new CallerBlocksPolicy()); }
@Override public void start() throws Throwable { String className = getClass().getSimpleName(); ExecutorService bossExecutor = newCachedThreadPool( daemon( "Boss-" + className ) ); ExecutorService workerExecutor = newCachedThreadPool( daemon( "Worker-" + className ) ); bootstrap = new ServerBootstrap( new NioServerSocketChannelFactory( bossExecutor, workerExecutor, config.getMaxConcurrentTransactions() ) ); bootstrap.setPipelineFactory( this ); PortRangeSocketBinder portRangeSocketBinder = new PortRangeSocketBinder( bootstrap ); try { Connection connection = portRangeSocketBinder.bindToFirstAvailablePortInRange( config.getServerAddress() ); Channel channel = connection.getChannel(); socketAddress = connection.getSocketAddress(); channelGroup = new DefaultChannelGroup(); channelGroup.add( channel ); msgLog.info( className + " communication server started and bound to " + socketAddress ); } catch ( Exception ex ) { msgLog.error( "Failed to bind server to " + socketAddress, ex ); bootstrap.releaseExternalResources(); targetCallExecutor.shutdownNow(); unfinishedTransactionExecutor.shutdownNow(); silentChannelExecutor.shutdownNow(); throw new IOException( ex ); } }