Class MultithreadEventExecutorGroup
java.lang.Object
io.netty.util.concurrent.AbstractEventExecutorGroup
io.netty.util.concurrent.MultithreadEventExecutorGroup
- All Implemented Interfaces:
EventExecutorGroup, Iterable<EventExecutor>, Executor, ExecutorService, ScheduledExecutorService
- Direct Known Subclasses:
DefaultEventExecutorGroup, MultithreadEventLoopGroup
Abstract base class for
EventExecutorGroup implementations that handles their tasks with multiple threads at
the same time.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMultithreadEventExecutorGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory, Object... args) Create a new instance.protectedMultithreadEventExecutorGroup(int nThreads, Executor executor, Object... args) Create a new instance.protectedMultithreadEventExecutorGroup(int nThreads, ThreadFactory threadFactory, Object... args) Create a new instance. -
Method Summary
Modifier 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()protected abstract EventExecutorCreate a new EventExecutor which will later then accessible via thenext()method.protected ThreadFactorynext()Returns one of theEventExecutors managed by thisEventExecutorGroup.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, submitMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EventExecutorGroup
tickerMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
MultithreadEventExecutorGroup
Create a new instance.- Parameters:
nThreads- the number of threads that will be used by this instance.threadFactory- the ThreadFactory to use, ornullif the default should be used.args- arguments which will passed to eachnewChild(Executor, Object...)call
-
MultithreadEventExecutorGroup
Create a new instance.- Parameters:
nThreads- the number of threads that will be used by this instance.executor- the Executor to use, ornullif the default should be used.args- arguments which will passed to eachnewChild(Executor, Object...)call
-
MultithreadEventExecutorGroup
protected MultithreadEventExecutorGroup(int nThreads, Executor executor, EventExecutorChooserFactory chooserFactory, Object... args) Create a new instance.- Parameters:
nThreads- the number of threads that will be used by this instance.executor- the Executor to use, ornullif the default should be used.chooserFactory- theEventExecutorChooserFactoryto use.args- arguments which will passed to eachnewChild(Executor, Object...)call
-
-
Method Details
-
newDefaultThreadFactory
-
next
Description copied from interface:EventExecutorGroupReturns one of theEventExecutors managed by thisEventExecutorGroup. -
iterator
-
executorCount
public final int executorCount()Return the number ofEventExecutorthis implementation uses. This number is the maps 1:1 to the threads it use. -
activeExecutorCount
public int activeExecutorCount()Returns the number of currently active threads if the group is using anEventExecutorChooserFactory.ObservableEventExecutorChooser. Otherwise, for a non-scaling group, this method returns the total number of threads, as all are considered active.- Returns:
- the count of active threads.
-
executorUtilizations
public List<AutoScalingEventExecutorChooserFactory.AutoScalingUtilizationMetric> executorUtilizations()Returns a list of real-time utilization metrics if the group was configured with a compatibleEventExecutorChooserFactory, otherwise an empty list.- Returns:
- A list of
AutoScalingEventExecutorChooserFactory.AutoScalingUtilizationMetricobjects.
-
newChild
Create a new EventExecutor which will later then accessible via thenext()method. This method will be called for each thread that will serve thisMultithreadEventExecutorGroup.- Throws:
Exception
-
shutdownGracefully
Description copied from interface:EventExecutorGroupSignals this executor that the caller wants the executor to be shut down. Once this method is called,EventExecutorGroup.isShuttingDown()starts to returntrue, and the executor prepares to shut itself down. UnlikeEventExecutorGroup.shutdown(), graceful shutdown ensures that no tasks are submitted for 'the quiet period' (usually a couple seconds) before it shuts itself down. If a task is submitted during the quiet period, it is guaranteed to be accepted and the quiet period will start over.- Parameters:
quietPeriod- the quiet period as described in the documentationtimeout- the maximum amount of time to wait until the executor is EventExecutorGroup.shutdown() regardless if a task was submitted during the quiet periodunit- the unit ofquietPeriodandtimeout- Returns:
- the
EventExecutorGroup.terminationFuture()
-
terminationFuture
Description copied from interface:EventExecutorGroupReturns theFuturewhich is notified when allEventExecutors managed by thisEventExecutorGrouphave been terminated. -
shutdown
Deprecated.- Specified by:
shutdownin interfaceEventExecutorGroup- Specified by:
shutdownin interfaceExecutorService- Specified by:
shutdownin classAbstractEventExecutorGroup
-
isShuttingDown
public boolean isShuttingDown()Description copied from interface:EventExecutorGroupReturnstrueif and only if allEventExecutors managed by thisEventExecutorGroupare being shut down gracefully or was shut down. -
isShutdown
public boolean isShutdown() -
isTerminated
public boolean isTerminated() -
awaitTermination
- Throws:
InterruptedException
-