Package io.netty.channel
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,io.netty.util.concurrent.EventExecutorGroup,Iterable<io.netty.util.concurrent.EventExecutor>,Executor,ExecutorService,ScheduledExecutorService
- Direct Known Subclasses:
LocalEventLoopGroup,NioEventLoopGroup
public class MultiThreadIoEventLoopGroup extends MultithreadEventLoopGroup implements IoEventLoopGroup
IoEventLoopGroupimplementation 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 ofAutoScalingEventExecutorChooserFactory.
-
-
Constructor Summary
Constructors Modifier Constructor Description MultiThreadIoEventLoopGroup(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, io.netty.util.concurrent.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, io.netty.util.concurrent.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, io.netty.util.concurrent.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IoEventLoopnewChild(Executor executor, IoHandlerFactory ioHandlerFactory, Object... args)protected EventLoopnewChild(Executor executor, Object... args)IoEventLoopnext()Return the nextEventLoopto usevoidsetIoRatio(int ioRatio)Sets theSingleThreadIoEventLoop.setIoRatio(int)for all theSingleThreadIoEventLoops managed by this group.-
Methods inherited from class io.netty.channel.MultithreadEventLoopGroup
newDefaultThreadFactory, register, register, register
-
Methods inherited from class io.netty.util.concurrent.MultithreadEventExecutorGroup
activeExecutorCount, awaitTermination, executorCount, executorUtilizations, isShutdown, isShuttingDown, isTerminated, iterator, shutdown, shutdownGracefully, terminationFuture
-
Methods inherited from class io.netty.util.concurrent.AbstractEventExecutorGroup
execute, invokeAll, invokeAll, invokeAny, invokeAny, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdownGracefully, shutdownNow, submit, submit, submit
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.util.concurrent.EventExecutorGroup
isShuttingDown, iterator, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdown, shutdownGracefully, shutdownGracefully, shutdownNow, submit, submit, submit, terminationFuture, ticker
-
Methods inherited from interface io.netty.channel.EventLoopGroup
register
-
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated
-
Methods inherited from interface io.netty.channel.IoEventLoopGroup
isCompatible, isIoType, register, register, register
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
MultiThreadIoEventLoopGroup
public MultiThreadIoEventLoopGroup(IoHandlerFactory ioHandlerFactory)
Creates a new instance of theMultiThreadIoEventLoopGroupusing the default number of threads and defaultThreadFactory.
-
MultiThreadIoEventLoopGroup
public MultiThreadIoEventLoopGroup(int nThreads, IoHandlerFactory ioHandlerFactory)/** 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
public MultiThreadIoEventLoopGroup(ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory)
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
public MultiThreadIoEventLoopGroup(Executor executor, IoHandlerFactory ioHandlerFactory)
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, io.netty.util.concurrent.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, io.netty.util.concurrent.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, io.netty.util.concurrent.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 Detail
-
newChild
protected EventLoop newChild(Executor executor, Object... args) throws Exception
- 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.
-
setIoRatio
public void setIoRatio(int ioRatio)
Sets theSingleThreadIoEventLoop.setIoRatio(int)for all theSingleThreadIoEventLoops managed by this group.
-
next
public IoEventLoop next()
Description copied from interface:EventLoopGroupReturn the nextEventLoopto use- Specified by:
nextin interfaceio.netty.util.concurrent.EventExecutorGroup- Specified by:
nextin interfaceEventLoopGroup- Specified by:
nextin interfaceIoEventLoopGroup- Overrides:
nextin classMultithreadEventLoopGroup
-
-