Package io.micronaut.scheduling.executor
Class UserExecutorConfiguration
- java.lang.Object
-
- io.micronaut.scheduling.executor.UserExecutorConfiguration
-
- All Implemented Interfaces:
ExecutorConfiguration
@EachProperty("micronaut.executors") public class UserExecutorConfiguration extends java.lang.Object implements ExecutorConfigurationAllows configurationExecutorServiceinstances that are made available as beans.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static intAVAILABLE_PROCESSORSNumber of available processors.protected java.lang.Stringnameprotected java.lang.IntegernThreads-
Fields inherited from interface io.micronaut.scheduling.executor.ExecutorConfiguration
PREFIX, PREFIX_CONSUMER, PREFIX_IO, PREFIX_SCHEDULED
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedUserExecutorConfiguration(java.lang.String name, java.lang.Integer nThreads, ExecutorType type, java.lang.Integer parallelism, java.lang.Integer corePoolSize, java.lang.Class<? extends java.util.concurrent.ThreadFactory> threadFactoryClass)Default Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @Min(1L) java.lang.IntegergetCorePoolSize()java.lang.StringgetName()@Min(1L) java.lang.IntegergetNumberOfThreads()@Min(1L) java.lang.IntegergetParallelism()java.util.Optional<java.lang.Class<? extends java.util.concurrent.ThreadFactory>>getThreadFactoryClass()ExecutorTypegetType()static UserExecutorConfigurationof(ExecutorType type)Construct aUserExecutorConfigurationfor the givenExecutorType.static UserExecutorConfigurationof(ExecutorType type, int num)Construct aUserExecutorConfigurationfor the givenExecutorType.static UserExecutorConfigurationof(ExecutorType type, int num, java.lang.Class<? extends java.util.concurrent.ThreadFactory> threadFactoryClass)Construct aUserExecutorConfigurationfor the givenExecutorType.static UserExecutorConfigurationof(java.lang.String name, ExecutorType type)Construct aUserExecutorConfigurationfor the givenExecutorType.voidsetCorePoolSize(java.lang.Integer corePoolSize)Sets the core pool size forExecutorType.SCHEDULED.voidsetName(java.lang.String name)Sets the executor name.voidsetNumberOfThreads(java.lang.Integer nThreads)Sets the number of threads forExecutorType.FIXED.voidsetParallelism(java.lang.Integer parallelism)Sets the parallelism forExecutorType.WORK_STEALING.voidsetThreadFactoryClass(java.lang.Class<? extends java.util.concurrent.ThreadFactory> threadFactoryClass)Sets the thread factory class.voidsetType(ExecutorType type)Sets the executor type.
-
-
-
Constructor Detail
-
UserExecutorConfiguration
@ConfigurationInject protected UserExecutorConfiguration(@Nullable @Parameter java.lang.String name, @Nullable java.lang.Integer nThreads, @Nullable ExecutorType type, @Nullable java.lang.Integer parallelism, @Nullable java.lang.Integer corePoolSize, @Nullable java.lang.Class<? extends java.util.concurrent.ThreadFactory> threadFactoryClass)Default Constructor.- Parameters:
name- the namenThreads- number of threadstype- the typeparallelism- the parallelismcorePoolSize- the core pool sizethreadFactoryClass- the thread factory class
-
-
Method Detail
-
getName
@NonNull public java.lang.String getName()
- Specified by:
getNamein interfaceExecutorConfiguration- Returns:
- The name of the component
-
getType
public ExecutorType getType()
- Specified by:
getTypein interfaceExecutorConfiguration- Returns:
- The
ExecutorType
-
getParallelism
@Min(1L) public @Min(1L) java.lang.Integer getParallelism()
- Specified by:
getParallelismin interfaceExecutorConfiguration- Returns:
- The parallelism for
ExecutorType.WORK_STEALING
-
getNumberOfThreads
@Min(1L) public @Min(1L) java.lang.Integer getNumberOfThreads()
- Specified by:
getNumberOfThreadsin interfaceExecutorConfiguration- Returns:
- The number of threads for
ExecutorType.FIXED
-
getCorePoolSize
@Min(1L) public @Min(1L) java.lang.Integer getCorePoolSize()
- Specified by:
getCorePoolSizein interfaceExecutorConfiguration- Returns:
- The core pool size for
ExecutorType.SCHEDULED
-
getThreadFactoryClass
public java.util.Optional<java.lang.Class<? extends java.util.concurrent.ThreadFactory>> getThreadFactoryClass()
- Specified by:
getThreadFactoryClassin interfaceExecutorConfiguration- Returns:
- The class to use as the
ThreadFactory
-
setName
public void setName(java.lang.String name)
Sets the executor name.- Parameters:
name- The name
-
setType
public void setType(ExecutorType type)
Sets the executor type. Default value (ExecutorType.SCHEDULED).- Parameters:
type- The type
-
setParallelism
public void setParallelism(java.lang.Integer parallelism)
Sets the parallelism forExecutorType.WORK_STEALING. Default value (Number of processors available to the Java virtual machine).- Parameters:
parallelism- The parallelism
-
setNumberOfThreads
public void setNumberOfThreads(java.lang.Integer nThreads)
Sets the number of threads forExecutorType.FIXED. Default value (2 * Number of processors available to the Java virtual machine).- Parameters:
nThreads- The number of threads
-
setCorePoolSize
public void setCorePoolSize(java.lang.Integer corePoolSize)
Sets the core pool size forExecutorType.SCHEDULED. Default value (2 * Number of processors available to the Java virtual machine).- Parameters:
corePoolSize- The core pool size
-
setThreadFactoryClass
public void setThreadFactoryClass(java.lang.Class<? extends java.util.concurrent.ThreadFactory> threadFactoryClass)
Sets the thread factory class.- Parameters:
threadFactoryClass- The thread factory class.
-
of
public static UserExecutorConfiguration of(ExecutorType type)
Construct aUserExecutorConfigurationfor the givenExecutorType.- Parameters:
type- The type- Returns:
- The configuration
-
of
public static UserExecutorConfiguration of(java.lang.String name, ExecutorType type)
Construct aUserExecutorConfigurationfor the givenExecutorType.- Parameters:
name- The nametype- The type- Returns:
- The configuration
-
of
public static UserExecutorConfiguration of(ExecutorType type, int num)
Construct aUserExecutorConfigurationfor the givenExecutorType.- Parameters:
type- The typenum- The number of threads forExecutorType.FIXEDor the parallelism forExecutorType.WORK_STEALINGor the core pool size forExecutorType.SCHEDULED- Returns:
- The configuration
-
of
public static UserExecutorConfiguration of(ExecutorType type, int num, @Nullable java.lang.Class<? extends java.util.concurrent.ThreadFactory> threadFactoryClass)
Construct aUserExecutorConfigurationfor the givenExecutorType.- Parameters:
type- The typenum- The number of threads forExecutorType.FIXEDor the parallelism forExecutorType.WORK_STEALINGor the core pool size forExecutorType.SCHEDULEDthreadFactoryClass- The thread factory class- Returns:
- The configuration
-
-