Class ScalingNetworkTaskScheduler
java.lang.Object
eu.cloudnetservice.driver.impl.network.scheduler.ScalingNetworkTaskScheduler
- All Implemented Interfaces:
NetworkTaskScheduler, Executor
An implementation of a network task scheduler that slowly starts more threads depending on the count of tasks that
couldn't be scheduled into the core executor service. If more and more tasks are starting to come in and the core
thread pool is not able to keep up, the pace of starting new threads increases. Initially the time between thread
starts is 2.5 seconds, and it can go all the way down to 100ms if needed (starting at around 160 tasks waiting to be
scheduled).
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicBooleanprivate static final intprivate final ThreadPoolExecutorprivate final ThreadPoolExecutorprivate static final intprivate static final doubleprivate final TaskSchedulingAction -
Constructor Summary
ConstructorsConstructorDescriptionScalingNetworkTaskScheduler(@NonNull ThreadFactory threadFactory, int maximumCorePoolSize) Constructs a new scaling task executor. -
Method Summary
-
Field Details
-
BASE_QUEUE_TIMEOUT
private static final int BASE_QUEUE_TIMEOUT- See Also:
-
MINIMUM_QUEUE_TIMEOUT
private static final int MINIMUM_QUEUE_TIMEOUT- See Also:
-
QUEUE_TIMOUT_DECAY_FACTOR
private static final double QUEUE_TIMOUT_DECAY_FACTOR- See Also:
-
active
-
coreExecutor
-
fallbackExecutor
-
taskScheduler
-
-
Constructor Details
-
ScalingNetworkTaskScheduler
public ScalingNetworkTaskScheduler(@NonNull @NonNull ThreadFactory threadFactory, int maximumCorePoolSize) Constructs a new scaling task executor.- Parameters:
threadFactory- the thread factory to use when the underlying executors create new threads.maximumCorePoolSize- the maximum threads that the core executor can use.- Throws:
NullPointerException- if the given thread factory is null.IllegalArgumentException- if the given maximum pool size is smaller than 0.
-
-
Method Details
-
shutdown
public void shutdown()Triggers a shutdown operation on this scheduler, interrupting all currently running tasks and preventing new tasks from being scheduled.- Specified by:
shutdownin interfaceNetworkTaskScheduler
-
execute
-