Class DefaultConfig
- All Implemented Interfaces:
Config
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateActor
(ActorId actorId) createActorGroup
(int actorGroupNumber) Create a actorGroup.createActorId
(String actorType) createScheduler
(ActorGroup actorGroup) Create a new scheduler.getActorClass
(String actorType) Get the class associated with an ActorType which is either a string assigned to the actor by the ActorType annotation or the full class name.int
int
The number of actorGroups in a network is more or less fixed.int
Local static Return the current number of threadsgetActorMetadata
(String actorType) Static.Return all of the actorClasses that we know ofint
The number of messages inFlight before backpressure is applied.int
getClock()
Return the clock used throuhout the system.int
getHost()
Return the singleton host for this application instanceReturn a list of host-bound actor typesint
Each host in the network has a unique number.The PersisterFactory provides access to persistent services for an Actor.getProperty
(String name) Get a Random Number Generator.Get the root directory for this host.The SerializerFactory is instantiated during configurationint
void
listActors
(PrintStream out) Send a list of actorType names and actor class name pairsnow()
Return the current instant of the configured clock.void
printConfig
(PrintStream out) Send a list of actorType names and actor class name pairsvoid
validate
(BaseBuilder builder)
-
Constructor Details
-
DefaultConfig
Construct a configuration object. Many of the settings can be specified as functions. This allows some behavior in configuring the system. For example, the message "eviction" setting could change depending on time of day.
In a clustered configuration, some of the configuration settings are shared among all hosts. In these cases, the parameter is described as "dynamic". On the other hand, some configuration settings are unique to a specific host. These settings are described as local. In a single host configuration, there is no difference between local and global settings.
- Parameters:
builder
- The builder object used to construct this configuration
-
-
Method Details
-
validate
-
getHostNumber
public int getHostNumber()Each host in the network has a unique number. This number is used to coordinate among multiple hosts in a network. The default is 1. Once assigned, a host number should be permanent. No duplicates.
- Specified by:
getHostNumber
in interfaceConfig
- Returns:
- An integer containing the host number
-
getActorGroups
public int getActorGroups()The number of actorGroups in a network is more or less fixed. Changing this number is difficult. The number must be consistent on all hosts in the cluster. As such, this setting is maintained by the coordinator.
- Specified by:
getActorGroups
in interfaceConfig
- Returns:
- The number of actorGroups
-
getActorGroupReplicas
public int getActorGroupReplicas()- Specified by:
getActorGroupReplicas
in interfaceConfig
-
getBackpressureLimit
public int getBackpressureLimit()The number of messages inFlight before backpressure is applied. This limit can change at any time.
- Specified by:
getBackpressureLimit
in interfaceConfig
- Returns:
-
getEviction
public int getEviction()- Specified by:
getEviction
in interfaceConfig
-
getActorGroupAssigner
- Specified by:
getActorGroupAssigner
in interfaceConfig
-
createMessageId
- Specified by:
createMessageId
in interfaceConfig
-
createMessage
- Specified by:
createMessage
in interfaceConfig
-
createActorId
- Specified by:
createActorId
in interfaceConfig
-
getActorGroupThreads
public int getActorGroupThreads()Local static Return the current number of threads- Specified by:
getActorGroupThreads
in interfaceConfig
- Returns:
-
getCoordinator
- Specified by:
getCoordinator
in interfaceConfig
-
getHost
Return the singleton host for this application instance
-
getClock
Description copied from interface:Config
Return the clock used throuhout the system. Usually the default is adequate except for testing.
-
now
Description copied from interface:Config
Return the current instant of the configured clock. -
getRandom
Description copied from interface:Config
Get a Random Number Generator. The default implementation uses ThreadLocalRandom which is bound to the local Thread. Therefore, it is best to only use the result of this call on the stack. Or, at least don't use the returned generator from more than one thread. -
createActorGroup
Create a actorGroup.- Specified by:
createActorGroup
in interfaceConfig
- Returns:
-
createScheduler
Create a new scheduler. The function is a factory for creating schedulers.
- Specified by:
createScheduler
in interfaceConfig
- Returns:
- The new Scheduler subclass
-
getBackpressureWaitMs
public int getBackpressureWaitMs()- Specified by:
getBackpressureWaitMs
in interfaceConfig
-
getShutdownWaitMs
public int getShutdownWaitMs()- Specified by:
getShutdownWaitMs
in interfaceConfig
-
getProperty
- Specified by:
getProperty
in interfaceConfig
-
getRootDirectory
Description copied from interface:Config
Get the root directory for this host. Local/Status- Specified by:
getRootDirectory
in interfaceConfig
- Returns:
-
getActorClass
Get the class associated with an ActorType which is either a string assigned to the actor by the ActorType annotation or the full class name.- Specified by:
getActorClass
in interfaceConfig
- Parameters:
actorType
- string- Returns:
- Either null or the Actor class, suitable to use to instantiate that actor.
-
getSerializerFactory
Description copied from interface:Config
The SerializerFactory is instantiated during configuration- Specified by:
getSerializerFactory
in interfaceConfig
- Returns:
-
getPersisterFactory
Description copied from interface:Config
The PersisterFactory provides access to persistent services for an Actor. The Factory is instantiated during configuration. The factory implementation can decide during construction how it will handle requests for multiple Actor threads.- Specified by:
getPersisterFactory
in interfaceConfig
- Returns:
- PersisterFactory implementation.
-
getActorMetadata
Description copied from interface:Config
Static. We need to keep ActorMetadata along with the ActorClass.- Specified by:
getActorMetadata
in interfaceConfig
-
getActorTypes
Return all of the actorClasses that we know of- Specified by:
getActorTypes
in interfaceConfig
- Returns:
-
getHostBoundActorTypes
Description copied from interface:Config
Return a list of host-bound actor types- Specified by:
getHostBoundActorTypes
in interfaceConfig
- Returns:
-
createActor
- Specified by:
createActor
in interfaceConfig
-
printConfig
Send a list of actorType names and actor class name pairs- Specified by:
printConfig
in interfaceConfig
- Parameters:
out
-
-
listActors
Send a list of actorType names and actor class name pairs- Specified by:
listActors
in interfaceConfig
- Parameters:
out
-
-