public abstract class SchedulerThreadPools extends Object
Schedulers provided by this implementation of SchedulerService use a shared single-threaded
ScheduledExecutorService for scheduling work. When a scheduled tasks is fired, they are executed using the
Scheduler's own executor.| Modifier and Type | Class and Description |
|---|---|
static class |
SchedulerThreadPools.Builder |
| Modifier and Type | Field and Description |
|---|---|
protected List<org.mule.runtime.api.scheduler.Scheduler> |
activeCustomSchedulers |
protected Lock |
activeSchedulersReadLock |
protected Lock |
activeSchedulersWriteLock |
protected Function<String,RejectedExecutionHandler> |
byCallerThreadGroupPolicy |
protected ThreadGroup |
customCallerRunsAnsWaitGroup |
protected ThreadGroup |
customCallerRunsGroup |
protected ThreadGroup |
customGroup |
protected Set<ThreadPoolExecutor> |
customSchedulersExecutors |
protected ThreadGroup |
customWaitGroup |
protected String |
name |
protected ThreadGroup |
parentGroup |
protected org.quartz.Scheduler |
quartzScheduler |
protected ScheduledThreadPoolExecutor |
scheduledExecutor |
protected org.mule.runtime.api.scheduler.SchedulerPoolsConfig |
threadPoolsConfig |
protected ThreadGroup |
timerGroup |
protected org.slf4j.Logger |
traceLogger |
| Modifier | Constructor and Description |
|---|---|
protected |
SchedulerThreadPools(String name,
org.mule.runtime.api.scheduler.SchedulerPoolsConfig threadPoolsConfig,
boolean preStartThreads,
Consumer<AbstractExecutorService> preStartCallback,
org.slf4j.Logger traceLogger) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
addScheduler(List<org.mule.runtime.api.scheduler.Scheduler> activeSchedulers,
org.mule.runtime.api.scheduler.Scheduler scheduler) |
static SchedulerThreadPools.Builder |
builder(String name,
org.mule.runtime.api.scheduler.SchedulerPoolsConfig config) |
abstract String |
buildReportString() |
org.mule.runtime.api.scheduler.Scheduler |
createCpuIntensiveScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout) |
abstract org.mule.runtime.api.scheduler.Scheduler |
createCpuIntensiveScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout,
org.mule.runtime.api.profiling.ProfilingService profilingService) |
org.mule.runtime.api.scheduler.Scheduler |
createCpuLightScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int parallelTasksEstimate,
Supplier<Long> stopTimeout) |
abstract org.mule.runtime.api.scheduler.Scheduler |
createCpuLightScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int parallelTasksEstimate,
Supplier<Long> stopTimeout,
org.mule.runtime.api.profiling.ProfilingService profilingService) |
org.mule.runtime.api.scheduler.Scheduler |
createCustomScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout) |
org.mule.runtime.api.scheduler.Scheduler |
createCustomScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout,
int queueSize) |
org.mule.runtime.api.scheduler.Scheduler |
createCustomScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout,
int queueSize,
org.mule.runtime.api.profiling.ProfilingService profilingService) |
org.mule.runtime.api.scheduler.Scheduler |
createCustomScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout,
org.mule.runtime.api.profiling.ProfilingService profilingService) |
protected abstract void |
createCustomThreadGroups() |
org.mule.runtime.api.scheduler.Scheduler |
createIoScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout) |
abstract org.mule.runtime.api.scheduler.Scheduler |
createIoScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout,
org.mule.runtime.api.profiling.ProfilingService profilingService) |
protected BlockingQueue<Runnable> |
createQueue(int size)
Create queue using a
SynchronousQueue if size is 0 or a LinkedBlockingQueue if size > 0. |
protected abstract ByCallerThreadGroupPolicy |
createThreadGroupPolicy(String schedulerName) |
protected abstract void |
doStart(boolean preStartThreads) |
protected abstract ThreadPoolExecutor |
getCustomSchedulerDestroyerExecutor() |
protected abstract List<org.mule.runtime.api.scheduler.Scheduler> |
getOwnSchedulers() |
List<org.mule.runtime.api.scheduler.Scheduler> |
getSchedulers() |
abstract boolean |
isCurrentThreadForCpuWork() |
protected abstract void |
onStopCompleted() |
protected void |
prestartCoreThreads(AbstractExecutorService executor,
int corePoolSize)
Workaround to avoid a race condition when a
SynchronousQueue is combined with a call to
ThreadPoolExecutor.prestartAllCoreThreads(). |
protected String |
resolveSchedulerName(org.mule.runtime.api.scheduler.SchedulerConfig config,
String prefix) |
protected boolean |
shouldThrottle(org.mule.runtime.api.scheduler.SchedulerConfig config,
OptionalInt backingPoolMaxSize) |
protected Consumer<org.mule.runtime.api.scheduler.Scheduler> |
shutdownCallback(List<org.mule.runtime.api.scheduler.Scheduler> activeSchedulers) |
protected abstract void |
shutdownPools() |
void |
start() |
void |
stop() |
protected void |
validateCustomSchedulerOnlyConfigNotChanged(org.mule.runtime.api.scheduler.SchedulerConfig config) |
protected abstract void |
waitForExecutorTermination(long shutdownStartMillis) |
protected void |
waitForExecutorTermination(long startMillis,
ExecutorService executor,
String executorLabel) |
protected final String name
protected final ThreadGroup parentGroup
protected final org.mule.runtime.api.scheduler.SchedulerPoolsConfig threadPoolsConfig
protected final ThreadGroup timerGroup
protected final ThreadGroup customGroup
protected final ThreadGroup customWaitGroup
protected final ThreadGroup customCallerRunsGroup
protected final ThreadGroup customCallerRunsAnsWaitGroup
protected final Set<ThreadPoolExecutor> customSchedulersExecutors
protected final Function<String,RejectedExecutionHandler> byCallerThreadGroupPolicy
protected final Lock activeSchedulersReadLock
protected final List<org.mule.runtime.api.scheduler.Scheduler> activeCustomSchedulers
protected final Lock activeSchedulersWriteLock
protected final org.slf4j.Logger traceLogger
protected ScheduledThreadPoolExecutor scheduledExecutor
protected org.quartz.Scheduler quartzScheduler
protected SchedulerThreadPools(String name, org.mule.runtime.api.scheduler.SchedulerPoolsConfig threadPoolsConfig, boolean preStartThreads, Consumer<AbstractExecutorService> preStartCallback, org.slf4j.Logger traceLogger)
public static SchedulerThreadPools.Builder builder(String name, org.mule.runtime.api.scheduler.SchedulerPoolsConfig config)
protected abstract ByCallerThreadGroupPolicy createThreadGroupPolicy(String schedulerName)
protected abstract void createCustomThreadGroups()
public final void start()
throws org.mule.runtime.api.exception.MuleException
org.mule.runtime.api.exception.MuleExceptionprotected abstract void doStart(boolean preStartThreads)
throws org.mule.runtime.api.exception.MuleException
org.mule.runtime.api.exception.MuleExceptionprotected BlockingQueue<Runnable> createQueue(int size)
SynchronousQueue if size is 0 or a LinkedBlockingQueue if size > 0.size - queue sizeprotected abstract void shutdownPools()
throws org.mule.runtime.api.exception.MuleException,
InterruptedException
org.mule.runtime.api.exception.MuleExceptionInterruptedExceptionpublic final void stop()
throws org.mule.runtime.api.exception.MuleException,
InterruptedException
org.mule.runtime.api.exception.MuleExceptionInterruptedExceptionprotected abstract void waitForExecutorTermination(long shutdownStartMillis)
throws InterruptedException
InterruptedExceptionprotected abstract void onStopCompleted()
protected void waitForExecutorTermination(long startMillis,
ExecutorService executor,
String executorLabel)
throws InterruptedException
InterruptedExceptionpublic org.mule.runtime.api.scheduler.Scheduler createCpuLightScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int parallelTasksEstimate,
Supplier<Long> stopTimeout)
public abstract org.mule.runtime.api.scheduler.Scheduler createCpuLightScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int parallelTasksEstimate,
Supplier<Long> stopTimeout,
org.mule.runtime.api.profiling.ProfilingService profilingService)
public org.mule.runtime.api.scheduler.Scheduler createIoScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout)
public abstract org.mule.runtime.api.scheduler.Scheduler createIoScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout,
org.mule.runtime.api.profiling.ProfilingService profilingService)
protected boolean addScheduler(List<org.mule.runtime.api.scheduler.Scheduler> activeSchedulers, org.mule.runtime.api.scheduler.Scheduler scheduler)
public org.mule.runtime.api.scheduler.Scheduler createCpuIntensiveScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout)
public abstract org.mule.runtime.api.scheduler.Scheduler createCpuIntensiveScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout,
org.mule.runtime.api.profiling.ProfilingService profilingService)
protected Consumer<org.mule.runtime.api.scheduler.Scheduler> shutdownCallback(List<org.mule.runtime.api.scheduler.Scheduler> activeSchedulers)
protected void validateCustomSchedulerOnlyConfigNotChanged(org.mule.runtime.api.scheduler.SchedulerConfig config)
protected boolean shouldThrottle(org.mule.runtime.api.scheduler.SchedulerConfig config,
OptionalInt backingPoolMaxSize)
public org.mule.runtime.api.scheduler.Scheduler createCustomScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout)
public org.mule.runtime.api.scheduler.Scheduler createCustomScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout,
org.mule.runtime.api.profiling.ProfilingService profilingService)
public org.mule.runtime.api.scheduler.Scheduler createCustomScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout,
int queueSize)
public org.mule.runtime.api.scheduler.Scheduler createCustomScheduler(org.mule.runtime.api.scheduler.SchedulerConfig config,
int workers,
Supplier<Long> stopTimeout,
int queueSize,
org.mule.runtime.api.profiling.ProfilingService profilingService)
protected abstract ThreadPoolExecutor getCustomSchedulerDestroyerExecutor()
protected void prestartCoreThreads(AbstractExecutorService executor, int corePoolSize)
SynchronousQueue is combined with a call to
ThreadPoolExecutor.prestartAllCoreThreads().
When using a SynchronousQueue on an Executor, even if calling prestartAllCoreThreads(), a race condition may occur where the worker threads are started but before it starts to take elements from the queue, the user of the Executor dispatches some task to it.
In that case, the threads are prestarted by dispatching work to the executor as a workaround, which avoids the issue.
executor - the executor to prestart the threads forcorePoolSize - the number of threads to start in e=the executorprotected String resolveSchedulerName(org.mule.runtime.api.scheduler.SchedulerConfig config, String prefix)
public abstract boolean isCurrentThreadForCpuWork()
public List<org.mule.runtime.api.scheduler.Scheduler> getSchedulers()
protected abstract List<org.mule.runtime.api.scheduler.Scheduler> getOwnSchedulers()
public abstract String buildReportString()
Copyright © 2003–2022 MuleSoft, Inc.. All rights reserved.