Class CommonExecutorService
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- java.util.concurrent.ThreadPoolExecutor
-
- jetbrains.buildServer.util.executors.TeamCityThreadPoolExecutor
-
- jetbrains.buildServer.util.executors.ScalingThreadPoolExecutor
-
- jetbrains.buildServer.serverSide.impl.executors.CommonExecutorService
-
- All Implemented Interfaces:
Executor,ExecutorService,ScheduledExecutorService,ExecutorServiceEx
public class CommonExecutorService extends ScalingThreadPoolExecutor implements ScheduledExecutorService
This is the common executor service each TeamCity service or plugin should use unless it requires a separate ExecutorService for some specific purpose.The idea behind is to use a single executor service for both scheduled and non-scheduled tasks.
Since the standard ScheduledExecutorService implementation - ScheduledThreadPoolExecutor (which can run immediate tasks also) is actually based on a fixed-sized thread pool, it's not very convenient for us because we want the number of threads running to vary depending on the workload.
That's why this implementation is based on the two JDK executor services - ScheduledThreadPoolExecutor and ThreadPoolExecutor.
The first one is used only for scheduled tasks while the other one is used for the tasks requiring immediate execution.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
-
-
Constructor Summary
Constructors Constructor Description CommonExecutorService(int corePoolSize, int maximumPoolSize, int maximumQueueCapacity, long keepAliveTime, TimeUnit timeUnit, NamedThreadFactory threadFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanawaitTermination(long timeout, TimeUnit unit)booleanisShutdown()booleanisTerminated()ScheduledFuture<?>schedule(Runnable command, long delay, TimeUnit unit)<V> ScheduledFuture<V>schedule(Callable<V> callable, long delay, TimeUnit unit)ScheduledFuture<?>scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)ScheduledFuture<?>scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)voidshutdown()List<Runnable>shutdownNow()-
Methods inherited from class jetbrains.buildServer.util.executors.ScalingThreadPoolExecutor
getMaxQueueCapacity, getQueue, getRejectsCount
-
Methods inherited from class jetbrains.buildServer.util.executors.TeamCityThreadPoolExecutor
afterExecute, beforeExecute, getName, getQueuedTasksCount, isPaused, newTaskFor, newTaskFor, pause, resume, setPoolSize
-
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, terminated, toString
-
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submit
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.concurrent.ExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submit
-
Methods inherited from interface jetbrains.buildServer.util.executors.ExecutorServiceEx
getActiveCount
-
-
-
-
Constructor Detail
-
CommonExecutorService
public CommonExecutorService(int corePoolSize, int maximumPoolSize, int maximumQueueCapacity, long keepAliveTime, TimeUnit timeUnit, NamedThreadFactory threadFactory)
-
-
Method Detail
-
schedule
@NotNull public ScheduledFuture<?> schedule(@NotNull Runnable command, long delay, @NotNull TimeUnit unit)
- Specified by:
schedulein interfaceScheduledExecutorService
-
schedule
@NotNull public <V> ScheduledFuture<V> schedule(@NotNull Callable<V> callable, long delay, @NotNull TimeUnit unit)
- Specified by:
schedulein interfaceScheduledExecutorService
-
scheduleAtFixedRate
@NotNull public ScheduledFuture<?> scheduleAtFixedRate(@NotNull Runnable command, long initialDelay, long period, @NotNull TimeUnit unit)
- Specified by:
scheduleAtFixedRatein interfaceScheduledExecutorService
-
scheduleWithFixedDelay
@NotNull public ScheduledFuture<?> scheduleWithFixedDelay(@NotNull Runnable command, long initialDelay, long delay, @NotNull TimeUnit unit)
- Specified by:
scheduleWithFixedDelayin interfaceScheduledExecutorService
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfaceExecutorService- Overrides:
shutdownin classTeamCityThreadPoolExecutor
-
shutdownNow
public List<Runnable> shutdownNow()
- Specified by:
shutdownNowin interfaceExecutorService- Overrides:
shutdownNowin classThreadPoolExecutor
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdownin interfaceExecutorService- Overrides:
isShutdownin classThreadPoolExecutor
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminatedin interfaceExecutorService- Overrides:
isTerminatedin classThreadPoolExecutor
-
awaitTermination
public boolean awaitTermination(long timeout, @NotNull TimeUnit unit) throws InterruptedException- Specified by:
awaitTerminationin interfaceExecutorService- Overrides:
awaitTerminationin classThreadPoolExecutor- Throws:
InterruptedException
-
-