Refine search
private static final int NUM_CORES = Runtime.getRuntime().availableProcessors(); private static final ExecutorService forPool = Executors.newFixedThreadPool(NUM_CORES * 2, new NamedThreadFactory("Parallel.For"));
@Deprecated public static NamedThreadFactory daemon( String threadNamePrefix ) { return daemon( threadNamePrefix, NO_OP_MONITOR ); }
public AsyncRequestLog( FileSystemAbstraction fs, ZoneId logTimeZone, String logFile, long rotationSize, int rotationKeepNumber ) throws IOException { NamedThreadFactory threadFactory = new NamedThreadFactory( "HTTP-Log-Rotator", true ); ExecutorService rotationExecutor = Executors.newCachedThreadPool( threadFactory ); outputSupplier = new RotatingFileOutputStreamSupplier( fs, new File( logFile ), rotationSize, 0, rotationKeepNumber, rotationExecutor ); FormattedLogProvider logProvider = FormattedLogProvider.withZoneId( logTimeZone ) .toOutputStream( outputSupplier ); asyncLogProcessingExecutor = Executors.newSingleThreadExecutor( new NamedThreadFactory( "HTTP-Log-Writer" ) ); asyncEventProcessor = new AsyncEvents<>( this, this ); AsyncLogProvider asyncLogProvider = new AsyncLogProvider( asyncEventProcessor, logProvider ); log = asyncLogProvider.getLog( "REQUEST" ); }
@Override public void init() { chunkSize = config.getChunkSize(); assertChunkSizeIsWithinFrameSize( chunkSize, frameLength ); String className = getClass().getSimpleName(); targetCallExecutor = newCachedThreadPool( named( className + ":" + config.getServerAddress().getPort() ) ); unfinishedTransactionExecutor = newScheduledThreadPool( 2, named( "Unfinished transactions" ) ); silentChannelExecutor = newSingleThreadScheduledExecutor( named( "Silent channel reaper" ) ); silentChannelExecutor.scheduleWithFixedDelay( connectedSlaveChannels, 5, 5, TimeUnit.SECONDS ); }
ExecutorService executor = cleanup.add( Executors.newFixedThreadPool( 2, named( "Test-executor-thread" ) ) );
@Test void notifyWithExecutorAndNotification() throws Exception { String message = "foo"; String threadNamePrefix = "test-thread"; Listener listener1 = new Listener(); Listener listener2 = new Listener(); Listeners<Listener> listeners = newListeners( listener1, listener2 ); ExecutorService executor = newSingleThreadExecutor( named( threadNamePrefix ) ); listeners.notify( executor, listener -> listener.process( message ) ); executor.shutdown(); executor.awaitTermination( 1, TimeUnit.MINUTES ); assertEquals( message, listener1.message ); assertThat( listener1.threadName, startsWith( threadNamePrefix ) ); assertEquals( message, listener2.message ); assertThat( listener2.threadName, startsWith( threadNamePrefix ) ); }
@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 ); } }
serverBootstrap = new ServerBootstrap( new NioServerSocketChannelFactory(Executors .newCachedThreadPool(new NamedThreadFactory( "TCP-Server-Boss")), Executors .newCachedThreadPool(new NamedThreadFactory( "TCP-Server-Worker"))));
@Deprecated public static NamedThreadFactory daemon( String threadNamePrefix, Monitor monitor ) { return new NamedThreadFactory( threadNamePrefix, DEFAULT_THREAD_PRIORITY, monitor, true ); } }
public AsyncRequestLog( FileSystemAbstraction fs, ZoneId logTimeZone, String logFile, long rotationSize, int rotationKeepNumber ) throws IOException { NamedThreadFactory threadFactory = new NamedThreadFactory( "HTTP-Log-Rotator", true ); ExecutorService rotationExecutor = Executors.newCachedThreadPool( threadFactory ); outputSupplier = new RotatingFileOutputStreamSupplier( fs, new File( logFile ), rotationSize, 0, rotationKeepNumber, rotationExecutor ); FormattedLogProvider logProvider = FormattedLogProvider.withZoneId( logTimeZone ) .toOutputStream( outputSupplier ); asyncLogProcessingExecutor = Executors.newSingleThreadExecutor( new NamedThreadFactory( "HTTP-Log-Writer" ) ); asyncEventProcessor = new AsyncEvents<>( this, this ); AsyncLogProvider asyncLogProvider = new AsyncLogProvider( asyncEventProcessor, logProvider ); log = asyncLogProvider.getLog( "REQUEST" ); }
newCachedThreadPool( daemon( getClass().getSimpleName() + "-boss@" + destination ) ), newCachedThreadPool( daemon( getClass().getSimpleName() + "-worker@" + destination ) ) ) ); bootstrap.setPipelineFactory( this );
@Deprecated public static NamedThreadFactory named( String threadNamePrefix ) { return new NamedThreadFactory( threadNamePrefix ); }
ExecutorService pool = Executors.newFixedThreadPool( numRunners, new NamedThreadFactory( title + "Importer" ) ); IoMonitor writeMonitor = new IoMonitor( stores.getIoTracer() ); ControllableStep step = new ControllableStep( title, roughEntityCountProgress, Configuration.DEFAULT,
@Deprecated public static NamedThreadFactory named( String threadNamePrefix, int priority ) { return new NamedThreadFactory( threadNamePrefix, priority ); }
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 ); }
ExecutorService pool = Executors.newFixedThreadPool( numRunners, new NamedThreadFactory( title + "Importer" ) ); IoMonitor writeMonitor = new IoMonitor( stores.getIoTracer() ); ControllableStep step = new ControllableStep( title, roughEntityCountProgress, Configuration.DEFAULT,
@Test public void shouldGivePortConflictErrorWithPortNumberInIt() throws Throwable { // Given an occupied port int port = 16000; try ( ServerSocketChannel ignore = ServerSocketChannel.open().bind( new InetSocketAddress( "localhost", port ) ) ) { final ListenSocketAddress address = new ListenSocketAddress( "localhost", port ); // Expect exception.expect( PortBindException.class ); // When Map<BoltConnector,NettyServer.ProtocolInitializer> initializersMap = genericMap( new BoltConnector( "test" ), protocolOnAddress( address ) ); new NettyServer( new NamedThreadFactory( "mythreads" ), initializersMap, new ConnectorPortRegister(), NullLog.getInstance() ).start(); } }
@Deprecated public static NamedThreadFactory daemon( String threadNamePrefix ) { return daemon( threadNamePrefix, NO_OP_MONITOR ); }
@Override public void start() { eventLoopGroup = new NioEventLoopGroup( 0, new NamedThreadFactory( "catch-up-client" ) ); }
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 ); }