Package net.sf.eBus.config
Class ENetConfigure.SelectorInfoBuilder
- java.lang.Object
-
- net.sf.eBus.config.ENetConfigure.SelectorInfoBuilder
-
- Enclosing class:
- ENetConfigure
public static final class ENetConfigure.SelectorInfoBuilder extends Object
Constructs anENetConfigure.SelectorInfoinstance based on the parameters set via the builder's API. The minimally allowed configuration is based on the selector's thread type. In all cases a unique selector name and type must be provided. The selector parameters are:-
name: unique selector name.
Uniqueness is within the JVM.
Required: Yes.
-
type: selector
thread type.Required: Yes.
-
isDefault: if set to
true, then this is the default selector for all channels which do not specify a selector.Required: No.
Default Setting:
false. -
priority: the selector thread's
priority. Should be one of
Thread.MIN_PRIORITY,Thread.NORM_PRIORITY, orThread.MAX_PRIORITY.Required: No.
Default Setting:
ENetConfigure.DEFAULT_PRIORITY. -
spinLimit: number of times a selector
thread may spin before parking.
Required: No.
Default Setting:
ENetConfigure.DEFAULT_SPIN_LIMIT. -
parkTime: nanosecond duration for a
selector park.
Required: No.
Default Setting:
ENetConfigure.DEFAULT_PARK_TIME. -
threadAffinity:
ThreadAffinityConfigureused to associate selector thread with a core. Thread affinity should be considered when using a spinning thread type.Required: No.
Default Setting:
null.
Example building a
SelectorInfofinal ENetConfigure.SelectorInfoBuilder builder = ENetConfigure.selectorBuilder(); final ENetConfigure.SelectorInfo selectorInfo = builder.name("app_selector") .type(ThreadType.SPINPARK) .isDefault(true) .spinLimit(2_000_000L) .parkTime(500L) .build();
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ENetConfigure.SelectorInfobuild()Returns theENetConfigure.SelectorInfoinstance created from the configuration settings.ENetConfigure.SelectorInfoBuilderisDefault(boolean flag)Sets the selector flag marking whether this is the default selector or not.ENetConfigure.SelectorInfoBuildername(String name)Sets the selector name to the given value.ENetConfigure.SelectorInfoBuilderparkTime(Duration time)Sets a spin+park selector thread's park time.ENetConfigure.SelectorInfoBuilderpriority(int priority)Sets the selector thread priority to the given value.ENetConfigure.SelectorInfoBuilderspinLimit(long limit)Sets a spinning selector thread's spin limit.ENetConfigure.SelectorInfoBuilderthreadAffinity(ThreadAffinityConfigure affinity)Sets thread affinity configuration.ENetConfigure.SelectorInfoBuildertype(ThreadType type)Sets the selector thread type to the given value.
-
-
-
Method Detail
-
name
public ENetConfigure.SelectorInfoBuilder name(String name)
Sets the selector name to the given value.- Parameters:
name- selector name.- Returns:
this SelectorInfoBuilder.- Throws:
com.typesafe.config.ConfigException- ifnameis eithernullor an empty string.
-
type
public ENetConfigure.SelectorInfoBuilder type(ThreadType type)
Sets the selector thread type to the given value.- Parameters:
type- selector thread type.- Returns:
this SelectorInfoBuilder.- Throws:
com.typesafe.config.ConfigException- iftypeisnull.
-
isDefault
public ENetConfigure.SelectorInfoBuilder isDefault(boolean flag)
Sets the selector flag marking whether this is the default selector or not.- Parameters:
flag-trueif this is the default selector thread.- Returns:
this SelectorInfoBuilder.
-
priority
public ENetConfigure.SelectorInfoBuilder priority(int priority)
Sets the selector thread priority to the given value.- Parameters:
priority- thread priority.- Returns:
this SelectorInfoBuilder.- Throws:
com.typesafe.config.ConfigException- ifpriorityis <Thread.MIN_PRIORITYor >Thread.MAX_PRIORITY.
-
spinLimit
public ENetConfigure.SelectorInfoBuilder spinLimit(long limit)
Sets a spinning selector thread's spin limit.- Parameters:
limit- number of time the thread may spin on select before parking.- Returns:
this SelectorInfoBuilder.- Throws:
com.typesafe.config.ConfigException- iflimitis ≤ zero.
-
parkTime
public ENetConfigure.SelectorInfoBuilder parkTime(Duration time)
Sets a spin+park selector thread's park time.- Parameters:
time- nanosecond thread park time.- Returns:
this SelectorInfoBuilder.- Throws:
com.typesafe.config.ConfigException- iftimeisnullor ≤ zero.
-
threadAffinity
public ENetConfigure.SelectorInfoBuilder threadAffinity(ThreadAffinityConfigure affinity)
Sets thread affinity configuration.- Parameters:
affinity- thread affinity configuration. May benull.- Returns:
this SelectorInfoBuilder.
-
build
public ENetConfigure.SelectorInfo build()
Returns theENetConfigure.SelectorInfoinstance created from the configuration settings. Sets spin limit for spin/park and spin/yield thread types toENetConfigure.DEFAULT_SPIN_LIMITif spin limit is not set. Sets park time toENetConfigure.DEFAULT_PARK_TIMEif not configured for spin/park thread type.- Returns:
SelectorInfoinstance.- Throws:
com.typesafe.config.ConfigException- ifSelectorInfoconfiguration is invalid.
-
-