Interface Config
- All Known Implementing Classes:
DefaultConfig
The Sodacan configuration contains settings for specifying factories, singleton objects, and static and dynamic settings.
Most configuration settings can be specified as functions. If the setting is "dynamic", the function will be called each time a value is requested. If the setting is "static", the function is called once, during initialization and the result is saved and returned as needed.
The configuration object is effectively read-only and is not thread-safe. Therefore, any of the functions should be free of side-effects. In cases where side effects are required, this configuration only returns a factory. In other words, the function returns a factory which is used to create the target object and the factory's thread safety must be secured by the framework
An exception to the thread safety rule is for global dynamic settings of which there are currently none.
-
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) Static.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 pairs
-
Method Details
-
getHostNumber
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.
- Returns:
- An integer containing the host number
-
getActorGroups
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.
- Returns:
- The number of actorGroups
-
getActorGroupReplicas
int getActorGroupReplicas() -
getBackpressureLimit
int getBackpressureLimit()The number of messages inFlight before backpressure is applied. This limit can change at any time.
- Returns:
-
getEviction
int getEviction() -
getActorGroupAssigner
ActorGroupAssigner getActorGroupAssigner() -
createMessageId
MessageId createMessageId() -
getActorGroupThreads
int getActorGroupThreads()Local static Return the current number of threads- Returns:
-
getCoordinator
Coordinator getCoordinator() -
getHost
Host getHost()Return the singleton host for this application instance
- Returns:
-
now
Instant now()Return the current instant of the configured clock.- Returns:
- an Instant
-
getClock
Clock getClock()Return the clock used throuhout the system. Usually the default is adequate except for testing.
- Returns:
- The Clock
-
getRandom
Random getRandom()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.- Returns:
- an instance of Random
-
getRootDirectory
String getRootDirectory()Get the root directory for this host. Local/Status- Returns:
-
createActorGroup
Create a actorGroup.- Returns:
-
createScheduler
Create a new scheduler. The function is a factor for creating schedulers.
- Returns:
- The new Scheduler subclass
-
createActorId
-
getBackpressureWaitMs
int getBackpressureWaitMs() -
getShutdownWaitMs
int getShutdownWaitMs() -
getProperty
-
getActorClass
Static. 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.- Parameters:
actorType
- string- Returns:
- Either null or the Actor class, suitable to use to instantiate that actor.
-
getActorMetadata
Static. We need to keep ActorMetadata along with the ActorClass. -
getSerializerFactory
SerializerFactory getSerializerFactory()The SerializerFactory is instantiated during configuration- Returns:
-
getPersisterFactory
PersisterFactory getPersisterFactory()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.- Returns:
- PersisterFactory implementation.
-
getActorTypes
Return all of the actorClasses that we know of- Returns:
- A list containing the names of all actor types
-
getHostBoundActorTypes
Return a list of host-bound actor types- Returns:
-
createActor
-
createMessage
Message createMessage() -
printConfig
Send a list of actorType names and actor class name pairs- Parameters:
out
-
-
listActors
Send a list of actorType names and actor class name pairs- Parameters:
out
-
-