Class MultiThreadIoEventLoopGroup
java.lang.Object
io.netty.util.concurrent.AbstractEventExecutorGroup
io.netty.util.concurrent.MultithreadEventExecutorGroup
io.netty.channel.MultithreadEventLoopGroup
io.netty.channel.MultiThreadIoEventLoopGroup
- All Implemented Interfaces:
EventLoopGroup, IoEventLoopGroup, EventExecutorGroup, Iterable<EventExecutor>, Executor, ExecutorService, ScheduledExecutorService
- Direct Known Subclasses:
EpollEventLoopGroup, KQueueEventLoopGroup, LocalEventLoopGroup, NioEventLoopGroup
public class MultiThreadIoEventLoopGroup
extends MultithreadEventLoopGroup
implements IoEventLoopGroup
IoEventLoopGroup implementation that will handle its tasks with multiple threads.
This group supports advanced thread management strategies, such as dynamic auto-scaling,
by providing a custom EventExecutorChooserFactory. To enable utilization-based
auto-scaling, pass an instance of
AutoScalingEventExecutorChooserFactory.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionMultiThreadIoEventLoopGroup(int nThreads, IoHandlerFactory ioHandlerFactory) /** Creates a new instance of theMultiThreadIoEventLoopGroupusing the defaultThreadFactory.MultiThreadIoEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory) Creates a new instance of theMultiThreadIoEventLoopGroup.protectedMultiThreadIoEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory, EventExecutorChooserFactory chooserFactory, Object... args) Creates a new instance of theMultiThreadIoEventLoopGroup.protectedMultiThreadIoEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory, Object... args) Creates a new instance of theMultiThreadIoEventLoopGroup.MultiThreadIoEventLoopGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory, IoHandlerFactory ioHandlerFactory) Creates a new instance of theMultiThreadIoEventLoopGroup.MultiThreadIoEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory) Creates a new instance of theMultiThreadIoEventLoopGroup.protectedMultiThreadIoEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, EventExecutorChooserFactory chooserFactory, Object... args) Creates a new instance of theMultiThreadIoEventLoopGroup.protectedMultiThreadIoEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, Object... args) Creates a new instance of theMultiThreadIoEventLoopGroup.MultiThreadIoEventLoopGroup(IoHandlerFactory ioHandlerFactory) Creates a new instance of theMultiThreadIoEventLoopGroupusing the default number of threads and defaultThreadFactory.MultiThreadIoEventLoopGroup(Executor executor, IoHandlerFactory ioHandlerFactory) Creates a new instance of theMultiThreadIoEventLoopGroupusing the default number of threads.MultiThreadIoEventLoopGroup(ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory) Create a new instance using the default number of thread. -
Method Summary
Modifier and TypeMethodDescriptionprotected IoEventLoopnewChild(Executor executor, IoHandlerFactory ioHandlerFactory, Object... args) protected EventLoopCreate a new EventExecutor which will later then accessible via theMultithreadEventExecutorGroup.next()method.next()Returns one of theEventExecutors managed by thisEventExecutorGroup.Methods inherited from class MultithreadEventLoopGroup
newDefaultThreadFactory, register, register, registerModifier and TypeMethodDescriptionprotected ThreadFactoryregister(ChannelPromise promise) register(Channel channel, ChannelPromise promise) Deprecated.Methods inherited from class MultithreadEventExecutorGroup
activeExecutorCount, awaitTermination, executorCount, executorUtilizations, isShutdown, isShuttingDown, isTerminated, iterator, shutdown, shutdownGracefully, terminationFutureModifier and TypeMethodDescriptionintReturns the number of currently active threads if the group is using anEventExecutorChooserFactory.ObservableEventExecutorChooser.booleanawaitTermination(long timeout, TimeUnit unit) final intReturn the number ofEventExecutorthis implementation uses.Returns a list of real-time utilization metrics if the group was configured with a compatibleEventExecutorChooserFactory, otherwise an empty list.booleanbooleanReturnstrueif and only if allEventExecutors managed by thisEventExecutorGroupare being shut down gracefully or was shut down.booleaniterator()voidshutdown()Deprecated.Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) Signals this executor that the caller wants the executor to be shut down.Future<?> Returns theFuturewhich is notified when allEventExecutors managed by thisEventExecutorGrouphave been terminated.Methods inherited from class AbstractEventExecutorGroup
execute, invokeAll, invokeAll, invokeAny, invokeAny, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdownGracefully, shutdownNow, submit, submit, submitModifier and TypeMethodDescriptionvoidinvokeAll(Collection<? extends Callable<T>> tasks) invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) <T> TinvokeAny(Collection<? extends Callable<T>> tasks) <T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) <V> ScheduledFuture<V> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) Future<?> Shortcut method forEventExecutorGroup.shutdownGracefully(long, long, TimeUnit)with sensible default values.Deprecated.Future<?> <T> Future<T> <T> Future<T> Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EventExecutorGroup
tickerMethods inherited from interface IoEventLoopGroup
isCompatible, isIoType, register, register, registerModifier and TypeMethodDescriptiondefault booleanisCompatible(Class<? extends IoHandle> handleType) Returnstrueif the given type is compatible with thisIoEventLoopGroupand so can be registered to the containedIoEventLoops,falseotherwise.default booleandefault ChannelFutureDeprecated.default ChannelFutureregister(ChannelPromise promise) Deprecated.default Future<IoRegistration> Methods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
MultiThreadIoEventLoopGroup
Creates a new instance of theMultiThreadIoEventLoopGroupusing the default number of threads and defaultThreadFactory. -
MultiThreadIoEventLoopGroup
/** Creates a new instance of theMultiThreadIoEventLoopGroupusing the defaultThreadFactory.- Parameters:
nThreads- the number of threads and soEventLoops that are created.ioHandlerFactory- theIoHandlerFactorythat will be used to createIoHandlerfor handling IO.
-
MultiThreadIoEventLoopGroup
Create a new instance using the default number of thread.- Parameters:
threadFactory- theThreadFactorythat is used.ioHandlerFactory- theIoHandlerFactorythat will be used to createIoHandlerfor handling IO.
-
MultiThreadIoEventLoopGroup
Creates a new instance of theMultiThreadIoEventLoopGroupusing the default number of threads.- Parameters:
executor- theExecutorthat is used.ioHandlerFactory- theIoHandlerFactorythat will be used to createIoHandlerfor handling IO.
-
MultiThreadIoEventLoopGroup
public MultiThreadIoEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory) Creates a new instance of theMultiThreadIoEventLoopGroup.- Parameters:
nThreads- the number of threads and soEventLoops that are created.executor- theExecutorthat is used.ioHandlerFactory- theIoHandlerFactorythat will be used to createIoHandlerfor handling IO.
-
MultiThreadIoEventLoopGroup
public MultiThreadIoEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory) Creates a new instance of theMultiThreadIoEventLoopGroup.- Parameters:
nThreads- the number of threads and soEventLoops that are created.threadFactory- theThreadFactorythat is used.ioHandlerFactory- theIoHandlerFactorythat will be used to createIoHandlerfor handling IO.
-
MultiThreadIoEventLoopGroup
public MultiThreadIoEventLoopGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory, IoHandlerFactory ioHandlerFactory) Creates a new instance of theMultiThreadIoEventLoopGroup.- Parameters:
nThreads- the number of threads and soEventLoops that are created.executor- theExecutorthat is used.chooserFactory- theEventExecutorChooserFactorythat is used to choose theIoEventLoopwhennext()is called.ioHandlerFactory- theIoHandlerFactorythat will be used to createIoHandlerfor handling IO.
-
MultiThreadIoEventLoopGroup
protected MultiThreadIoEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory, Object... args) Creates a new instance of theMultiThreadIoEventLoopGroup.- Parameters:
nThreads- the number of threads and soEventLoops that are created.executor- theExecutorthat is used.ioHandlerFactory- theIoHandlerFactorythat will be used to createIoHandlerfor handling IO.args- extra args that are passed tonewChild(Executor, Object...)method.
-
MultiThreadIoEventLoopGroup
protected MultiThreadIoEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, Object... args) Creates a new instance of theMultiThreadIoEventLoopGroup.- Parameters:
nThreads- the number of threads and soEventLoops that are created.threadFactory- theThreadFactorythat is used.ioHandlerFactory- theIoHandlerFactorythat will be used to createIoHandlerfor handling IO.args- extra args that are passed tonewChild(Executor, Object...)method.
-
MultiThreadIoEventLoopGroup
protected MultiThreadIoEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, EventExecutorChooserFactory chooserFactory, Object... args) Creates a new instance of theMultiThreadIoEventLoopGroup.- Parameters:
nThreads- the number of threads and soEventLoops that are created.threadFactory- theThreadFactorythat is used.ioHandlerFactory- theIoHandlerFactorythat will be used to createIoHandlerfor handling IO.chooserFactory- theEventExecutorChooserFactorythat is used to choose theargs- extra args that are passed tonewChild(Executor, Object...)method.
-
MultiThreadIoEventLoopGroup
protected MultiThreadIoEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory, EventExecutorChooserFactory chooserFactory, Object... args) Creates a new instance of theMultiThreadIoEventLoopGroup.- Parameters:
nThreads- the number of threads and soEventLoops that are created.executor- theExecutorthat is used.ioHandlerFactory- theIoHandlerFactorythat will be used to createIoHandlerfor handling IO.chooserFactory- theEventExecutorChooserFactorythat is used to choose theargs- extra args that are passed tonewChild(Executor, Object...)method.
-
-
Method Details
-
newChild
Description copied from class:MultithreadEventExecutorGroupCreate a new EventExecutor which will later then accessible via theMultithreadEventExecutorGroup.next()method. This method will be called for each thread that will serve thisMultithreadEventExecutorGroup.- Specified by:
newChildin classMultithreadEventLoopGroup- Throws:
Exception
-
newChild
protected IoEventLoop newChild(Executor executor, IoHandlerFactory ioHandlerFactory, Object... args) - Parameters:
executor- theExecutorthat should be used to handle execution of tasks and IO.ioHandlerFactory- theIoHandlerFactorythat should be used to obtainIoHandlerto handle IO.args- extra arguments that are based by the constructor.- Returns:
- the created
IoEventLoop.
-
next
Description copied from interface:EventExecutorGroupReturns one of theEventExecutors managed by thisEventExecutorGroup.- Specified by:
nextin interfaceEventExecutorGroup- Specified by:
nextin interfaceEventLoopGroup- Specified by:
nextin interfaceIoEventLoopGroup- Overrides:
nextin classMultithreadEventLoopGroup
-
EventExecutorGroup.shutdownGracefully(long, long, TimeUnit)orAbstractEventExecutorGroup.shutdownGracefully()instead.