Package io.aeron.cluster.service
Class ClusteredServiceContainer.Context
java.lang.Object
io.aeron.cluster.service.ClusteredServiceContainer.Context
- All Implemented Interfaces:
Cloneable
- Enclosing class:
- ClusteredServiceContainer
The context will be owned by
ClusteredServiceAgent after a successful
ClusteredServiceContainer.launch(Context) and closed via ClusteredServiceContainer.close().-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaeron()AnAeronclient for the container.Provide anAeronclient for the containerGet the top level Aeron directory used for communication between the Aeron client and Media Driver.aeronDirectoryName(String aeronDirectoryName) Set the top level Aeron directory used for communication between the Aeron client and Media Driver.intUser assigned application version which appended to the log as the appVersion in new leadership events.appVersion(int appVersion) User assigned application version which appended to the log as the appVersion in new leadership events.User assigned application version validator implementation used to check version compatibility.appVersionValidator(AppVersionValidator appVersionValidator) User assigned application version validator implementation used to check version compatibility.Get the context that should be used for communicating with the local Archive.archiveContext(AeronArchive.Context archiveContext) Set the context that should be used for communicating with the local Archive.clone()Perform a shallow copy of the object.voidclose()Close the context and free applicable resources.The directory used for the cluster directory.clusterDir(File clusterDir) Set the directory to use for the cluster directory.The directory name to use for the cluster directory.clusterDirectoryName(String clusterDirectoryName) Set the directory name to use for the consensus module directory.The service this container holds.clusteredService(ClusteredService clusteredService) Set the service this container is to hold.intGet the id for this cluster instance.clusterId(int clusterId) Set the id for this cluster instance.TheClusterMarkFilein use.clusterMarkFile(ClusterMarkFile markFile) Set theClusterMarkFilein use.voidconclude()Conclude configuration by setting up defaults when specifics are not provided.intGet the stream id for communications from the services to the consensus module.consensusModuleStreamId(int streamId) Set the stream id for communications from the services to the consensus module.Get the channel parameter for bidirectional communications between the consensus module and services.controlChannel(String channel) Set the channel parameter for bidirectional communications between the consensus module and services.TheerrorHandler()that will incrementerrorCounter()by default.countedErrorHandler(CountedErrorHandler countedErrorHandler) Non-default for context.longThreshold for the container work cycle time which when exceed it will increment the counter.cycleThresholdNs(long thresholdNs) Set a threshold for the container work cycle time which when exceed it will increment the counter.Get theDelegatingErrorHandlerto be used by theClusteredServiceContainerwhich will delegate toerrorHandler()as next in the chain.delegatingErrorHandler(DelegatingErrorHandler delegatingErrorHandler) Set theDelegatingErrorHandlerto be used by theClusteredServiceContainerwhich will delegate toerrorHandler()as next in the chain.voidDelete the cluster container directory.The duty cycle tracker used to track the container duty cycle.dutyCycleTracker(DutyCycleTracker dutyCycleTracker) Set a duty cycle tracker to be used for tracking the duty cycle time of the container.Get theEpochClockto used for tracking wall clock time within the container.epochClock(EpochClock clock) Set theEpochClockto be used for tracking wall clock time when interacting with the container.intThe error buffer length in bytes.errorBufferLength(int errorBufferLength) Set the error buffer length in bytes to use.Get the error counter that will record the number of errors the container has observed.errorCounter(AtomicCounter errorCounter) Set the error counter that will record the number of errors the cluster node has observed.Get theErrorHandlerto be used by theClusteredServiceContainer.errorHandler(ErrorHandler errorHandler) Set theErrorHandlerto be used by theClusteredServiceContainer.errorLog()TheDistinctErrorLogin use.errorLog(DistinctErrorLog errorLog) Set theDistinctErrorLogin use.Get a newIdleStrategybased on configured supplier.idleStrategySupplier(Supplier<IdleStrategy> idleStrategySupplier) Provides anIdleStrategysupplier for the idle strategy for the agent duty cycle.booleanHas the context had theconclude()method called.booleanIs this a service that responds to client requests?isRespondingService(boolean isRespondingService) Set if this a service that responds to client requests.intGet the fragment limit to be used when polling the logSubscription.logFragmentLimit(int logFragmentLimit) Set the fragment limit to be used when polling the logSubscription.Get the directory in which the ClusteredServiceContainer will store mark file (i.e.markFileDir(File markFileDir) Set the directory in which the ClusteredServiceContainer will store mark file (i.e.TheNanoClockas a source of time in nanoseconds for measuring duration.TheNanoClockas a source of time in nanoseconds for measuring duration.booleanDoes this context own theaeron()client and this takes responsibility for closing it?ownsAeronClient(boolean ownsAeronClient) Does this context own theaeron()client and this takes responsibility for closing it?Get the channel parameter for the cluster log and snapshot replay channel.replayChannel(String channel) Set the channel parameter for the cluster log and snapshot replay channel.intGet the stream id for the cluster log and snapshot replay channel.replayStreamId(int streamId) Set the stream id for the cluster log and snapshot replay channel.intGet the id for this clustered service.serviceId(int serviceId) Set the id for this clustered service.Get the name for a clustered service to be theAgent.roleName()for theAgent.serviceName(String serviceName) Set the name for a clustered service to be theAgent.roleName()for theAgent.intGet the stream id for communications from the consensus module and to the services.serviceStreamId(int streamId) Set the stream id for communications from the consensus module and to the services.Get the channel parameter for snapshot recordings.snapshotChannel(String channel) Set the channel parameter for snapshot recordings.longThreshold for snapshot duration which when exceeded will result in a counter increment.snapshotDurationThresholdNs(long thresholdNs) Set a threshold for snapshot duration which when exceeded will result in a counter increment.Get snapshot duration tracker used for monitoring snapshot duration.snapshotDurationTracker(SnapshotDurationTracker snapshotDurationTracker) Set snapshot duration tracker used for monitoring snapshot duration.intGet the stream id for snapshot recordings.snapshotStreamId(int streamId) Set the stream id for snapshot recordings.booleanIndicates if this node should take standby snapshots.standbySnapshotEnabled(boolean standbySnapshotEnabled) Indicates if this node should take standby snapshots.Get theRunnablethat is called when container is instructed to terminate.terminationHook(Runnable terminationHook) Set theRunnablethat is called when container is instructed to terminate.Get the thread factory used for creating threads.threadFactory(ThreadFactory threadFactory) Set the thread factory used for creating threads.toString()
-
Constructor Details
-
Context
public Context()
-
-
Method Details
-
clone
Perform a shallow copy of the object. -
conclude
public void conclude()Conclude configuration by setting up defaults when specifics are not provided. -
isConcluded
public boolean isConcluded()Has the context had theconclude()method called.- Returns:
- true of the
conclude()method has been called.
-
appVersion
User assigned application version which appended to the log as the appVersion in new leadership events.This can be validated using
SemanticVersionto ensure only application nodes of the same major version communicate with each other.- Parameters:
appVersion- for user application.- Returns:
- this for a fluent API.
-
appVersion
public int appVersion()User assigned application version which appended to the log as the appVersion in new leadership events.This can be validated using
SemanticVersionto ensure only application nodes of the same major version communicate with each other.- Returns:
- appVersion for user application.
-
appVersionValidator
public ClusteredServiceContainer.Context appVersionValidator(AppVersionValidator appVersionValidator) User assigned application version validator implementation used to check version compatibility.The default validator uses
SemanticVersionsemantics.- Parameters:
appVersionValidator- for user application.- Returns:
- this for fluent API.
-
appVersionValidator
User assigned application version validator implementation used to check version compatibility.The default is to use
SemanticVersionmajor version for checking compatibility.- Returns:
- AppVersionValidator in use.
-
clusterId
Set the id for this cluster instance. This must match with the Consensus Module.- Parameters:
clusterId- for this clustered instance.- Returns:
- this for a fluent API
- See Also:
-
clusterId
public int clusterId()Get the id for this cluster instance. This must match with the Consensus Module.- Returns:
- the id for this cluster instance.
- See Also:
-
serviceId
Set the id for this clustered service. Services should be numbered from 0 and be contiguous.- Parameters:
serviceId- for this clustered service.- Returns:
- this for a fluent API
- See Also:
-
serviceId
public int serviceId()Get the id for this clustered service. Services should be numbered from 0 and be contiguous.- Returns:
- the id for this clustered service.
- See Also:
-
serviceName
Set the name for a clustered service to be theAgent.roleName()for theAgent.- Parameters:
serviceName- for a clustered service to be the role for theAgent.- Returns:
- this for a fluent API.
- See Also:
-
serviceName
Get the name for a clustered service to be theAgent.roleName()for theAgent.- Returns:
- the name for a clustered service to be the role of the
Agent. - See Also:
-
replayChannel
Set the channel parameter for the cluster log and snapshot replay channel.- Parameters:
channel- parameter for the cluster log replay channel.- Returns:
- this for a fluent API.
- See Also:
-
replayChannel
Get the channel parameter for the cluster log and snapshot replay channel.- Returns:
- the channel parameter for the cluster replay channel.
- See Also:
-
replayStreamId
Set the stream id for the cluster log and snapshot replay channel.- Parameters:
streamId- for the cluster log replay channel.- Returns:
- this for a fluent API
- See Also:
-
replayStreamId
public int replayStreamId()Get the stream id for the cluster log and snapshot replay channel.- Returns:
- the stream id for the cluster log replay channel.
- See Also:
-
controlChannel
Set the channel parameter for bidirectional communications between the consensus module and services.- Parameters:
channel- parameter for sending messages to the Consensus Module.- Returns:
- this for a fluent API.
- See Also:
-
controlChannel
Get the channel parameter for bidirectional communications between the consensus module and services.- Returns:
- the channel parameter for sending messages to the Consensus Module.
- See Also:
-
serviceStreamId
Set the stream id for communications from the consensus module and to the services.- Parameters:
streamId- for communications from the consensus module and to the services.- Returns:
- this for a fluent API
- See Also:
-
serviceStreamId
public int serviceStreamId()Get the stream id for communications from the consensus module and to the services.- Returns:
- the stream id for communications from the consensus module and to the services.
- See Also:
-
consensusModuleStreamId
Set the stream id for communications from the services to the consensus module.- Parameters:
streamId- for communications from the services to the consensus module.- Returns:
- this for a fluent API
- See Also:
-
consensusModuleStreamId
public int consensusModuleStreamId()Get the stream id for communications from the services to the consensus module.- Returns:
- the stream id for communications from the services to the consensus module.
- See Also:
-
snapshotChannel
Set the channel parameter for snapshot recordings.- Parameters:
channel- parameter for snapshot recordings- Returns:
- this for a fluent API.
- See Also:
-
snapshotChannel
Get the channel parameter for snapshot recordings.- Returns:
- the channel parameter for snapshot recordings.
- See Also:
-
snapshotStreamId
Set the stream id for snapshot recordings.- Parameters:
streamId- for snapshot recordings.- Returns:
- this for a fluent API
- See Also:
-
snapshotStreamId
public int snapshotStreamId()Get the stream id for snapshot recordings.- Returns:
- the stream id for snapshot recordings.
- See Also:
-
isRespondingService
Set if this a service that responds to client requests.- Parameters:
isRespondingService- true if this service responds to client requests, otherwise false.- Returns:
- this for a fluent API.
- See Also:
-
logFragmentLimit
Set the fragment limit to be used when polling the logSubscription.- Parameters:
logFragmentLimit- for this clustered service.- Returns:
- this for a fluent API
- See Also:
-
logFragmentLimit
public int logFragmentLimit()Get the fragment limit to be used when polling the logSubscription.- Returns:
- the fragment limit to be used when polling the log
Subscription. - See Also:
-
isRespondingService
public boolean isRespondingService()Is this a service that responds to client requests?- Returns:
- true if this service responds to client requests, otherwise false.
- See Also:
-
threadFactory
Get the thread factory used for creating threads.- Returns:
- thread factory used for creating threads.
-
threadFactory
Set the thread factory used for creating threads.- Parameters:
threadFactory- used for creating threads- Returns:
- this for a fluent API.
-
idleStrategySupplier
public ClusteredServiceContainer.Context idleStrategySupplier(Supplier<IdleStrategy> idleStrategySupplier) Provides anIdleStrategysupplier for the idle strategy for the agent duty cycle.- Parameters:
idleStrategySupplier- supplier for the idle strategy for the agent duty cycle.- Returns:
- this for a fluent API.
-
idleStrategy
Get a newIdleStrategybased on configured supplier.- Returns:
- a new
IdleStrategybased on configured supplier.
-
epochClock
Set theEpochClockto be used for tracking wall clock time when interacting with the container.- Parameters:
clock-EpochClockto be used for tracking wall clock time when interacting with the container.- Returns:
- this for a fluent API.
-
epochClock
Get theEpochClockto used for tracking wall clock time within the container.- Returns:
- the
EpochClockto used for tracking wall clock time within the container.
-
errorHandler
Get theErrorHandlerto be used by theClusteredServiceContainer.- Returns:
- the
ErrorHandlerto be used by theClusteredServiceContainer.
-
errorHandler
Set theErrorHandlerto be used by theClusteredServiceContainer.- Parameters:
errorHandler- the error handler to be used by theClusteredServiceContainer.- Returns:
- this for a fluent API
-
delegatingErrorHandler
Get theDelegatingErrorHandlerto be used by theClusteredServiceContainerwhich will delegate toerrorHandler()as next in the chain.- Returns:
- the
DelegatingErrorHandlerto be used by theClusteredServiceContainer. - See Also:
-
delegatingErrorHandler
public ClusteredServiceContainer.Context delegatingErrorHandler(DelegatingErrorHandler delegatingErrorHandler) Set theDelegatingErrorHandlerto be used by theClusteredServiceContainerwhich will delegate toerrorHandler()as next in the chain.- Parameters:
delegatingErrorHandler- the error handler to be used by theClusteredServiceContainer.- Returns:
- this for a fluent API
- See Also:
-
errorCounter
Get the error counter that will record the number of errors the container has observed.- Returns:
- the error counter that will record the number of errors the container has observed.
-
errorCounter
Set the error counter that will record the number of errors the cluster node has observed.- Parameters:
errorCounter- the error counter that will record the number of errors the cluster node has observed.- Returns:
- this for a fluent API.
-
countedErrorHandler
public ClusteredServiceContainer.Context countedErrorHandler(CountedErrorHandler countedErrorHandler) Non-default for context.- Parameters:
countedErrorHandler- to override the default.- Returns:
- this for a fluent API.
-
countedErrorHandler
TheerrorHandler()that will incrementerrorCounter()by default.- Returns:
errorHandler()that will incrementerrorCounter()by default.
-
aeronDirectoryName
Set the top level Aeron directory used for communication between the Aeron client and Media Driver.- Parameters:
aeronDirectoryName- the top level Aeron directory.- Returns:
- this for a fluent API.
-
aeronDirectoryName
Get the top level Aeron directory used for communication between the Aeron client and Media Driver.- Returns:
- The top level Aeron directory.
-
aeron
AnAeronclient for the container.- Returns:
Aeronclient for the container
-
aeron
Provide anAeronclient for the containerIf not provided then one will be created.
- Parameters:
aeron- client for the container- Returns:
- this for a fluent API.
-
ownsAeronClient
Does this context own theaeron()client and this takes responsibility for closing it?- Parameters:
ownsAeronClient- does this context own theaeron()client.- Returns:
- this for a fluent API.
-
ownsAeronClient
public boolean ownsAeronClient()Does this context own theaeron()client and this takes responsibility for closing it?- Returns:
- does this context own the
aeron()client and this takes responsibility for closing it?
-
clusteredService
The service this container holds.- Returns:
- service this container holds.
-
clusteredService
Set the service this container is to hold.- Parameters:
clusteredService- this container is to hold.- Returns:
- this for fluent API.
-
archiveContext
Set the context that should be used for communicating with the local Archive.- Parameters:
archiveContext- that should be used for communicating with the local Archive.- Returns:
- this for a fluent API.
-
archiveContext
Get the context that should be used for communicating with the local Archive.- Returns:
- the context that should be used for communicating with the local Archive.
-
clusterDirectoryName
Set the directory name to use for the consensus module directory.- Parameters:
clusterDirectoryName- to use.- Returns:
- this for a fluent API.
- See Also:
-
clusterDirectoryName
The directory name to use for the cluster directory.- Returns:
- directory name for the cluster directory.
- See Also:
-
clusterDir
Set the directory to use for the cluster directory.- Parameters:
clusterDir- to use.- Returns:
- this for a fluent API.
- See Also:
-
clusterDir
The directory used for the cluster directory.- Returns:
- directory for the cluster directory.
- See Also:
-
markFileDir
Get the directory in which the ClusteredServiceContainer will store mark file (i.e.cluster-mark-service-0.dat). It defaults toclusterDir()if it is not set explicitly via theClusteredServiceContainer.Configuration.MARK_FILE_DIR_PROP_NAME.- Returns:
- the directory in which the ClusteredServiceContainer will store mark file (i.e.
cluster-mark-service-0.dat). - See Also:
-
markFileDir
Set the directory in which the ClusteredServiceContainer will store mark file (i.e.cluster-mark-service-0.dat).- Parameters:
markFileDir- the directory in which the ClusteredServiceContainer will store mark file (i.e.cluster-mark-service-0.dat).- Returns:
- this for a fluent API.
-
terminationHook
Set theRunnablethat is called when container is instructed to terminate.- Parameters:
terminationHook- that can be used to terminate a service container.- Returns:
- this for a fluent API.
-
terminationHook
Get theRunnablethat is called when container is instructed to terminate.- Returns:
- the
Runnablethat can be used to terminate a service container.
-
clusterMarkFile
Set theClusterMarkFilein use.- Parameters:
markFile- to use.- Returns:
- this for a fluent API.
-
clusterMarkFile
TheClusterMarkFilein use.- Returns:
ClusterMarkFilein use.
-
errorBufferLength
Set the error buffer length in bytes to use.- Parameters:
errorBufferLength- in bytes to use.- Returns:
- this for a fluent API.
-
errorBufferLength
public int errorBufferLength()The error buffer length in bytes.- Returns:
- error buffer length in bytes.
-
errorLog
Set theDistinctErrorLogin use.- Parameters:
errorLog- to use.- Returns:
- this for a fluent API.
-
errorLog
TheDistinctErrorLogin use.- Returns:
DistinctErrorLogin use.
-
nanoClock
TheNanoClockas a source of time in nanoseconds for measuring duration.- Returns:
- the
NanoClockas a source of time in nanoseconds for measuring duration.
-
nanoClock
TheNanoClockas a source of time in nanoseconds for measuring duration.- Parameters:
clock- to be used.- Returns:
- this for a fluent API.
-
cycleThresholdNs
Set a threshold for the container work cycle time which when exceed it will increment the counter.- Parameters:
thresholdNs- value in nanoseconds- Returns:
- this for fluent API.
- See Also:
-
cycleThresholdNs
public long cycleThresholdNs()Threshold for the container work cycle time which when exceed it will increment the counter.- Returns:
- threshold to track for the container work cycle time.
-
dutyCycleTracker
Set a duty cycle tracker to be used for tracking the duty cycle time of the container.- Parameters:
dutyCycleTracker- to use for tracking.- Returns:
- this for fluent API.
-
dutyCycleTracker
The duty cycle tracker used to track the container duty cycle.- Returns:
- the duty cycle tracker.
-
snapshotDurationThresholdNs
Set a threshold for snapshot duration which when exceeded will result in a counter increment.- Parameters:
thresholdNs- value in nanoseconds.- Returns:
- this for fluent API.
- Since:
- 1.44.0
- See Also:
-
snapshotDurationThresholdNs
public long snapshotDurationThresholdNs()Threshold for snapshot duration which when exceeded will result in a counter increment.- Returns:
- threshold value in nanoseconds.
- Since:
- 1.44.0
-
snapshotDurationTracker
public ClusteredServiceContainer.Context snapshotDurationTracker(SnapshotDurationTracker snapshotDurationTracker) Set snapshot duration tracker used for monitoring snapshot duration.- Parameters:
snapshotDurationTracker- snapshot duration tracker.- Returns:
- this for fluent API.
- Since:
- 1.44.0
-
snapshotDurationTracker
Get snapshot duration tracker used for monitoring snapshot duration.- Returns:
- snapshot duration tracker.
- Since:
- 1.44.0
-
deleteDirectory
public void deleteDirectory()Delete the cluster container directory. -
standbySnapshotEnabled
public boolean standbySnapshotEnabled()Indicates if this node should take standby snapshots.- Returns:
trueif this should take standby snapshots,falseotherwise.- See Also:
-
standbySnapshotEnabled
Indicates if this node should take standby snapshots.- Parameters:
standbySnapshotEnabled- if this node should take standby snapshots.- Returns:
- this for a fluent API.
- See Also:
-
close
public void close()Close the context and free applicable resources.If
ownsAeronClient()is true then theaeron()client will be closed. -
toString
-