Class ConsensusModule.Context
- All Implemented Interfaces:
Cloneable
- Enclosing class:
- ConsensusModule
ConsensusModule in a cluster.
The context will be owned by ConsensusModuleAgent after a successful
ConsensusModule.launch(Context) and closed via ConsensusModule.close().
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicate whether this node should accept snapshots from standby nodes.acceptStandbySnapshots(boolean acceptStandbySnapshots) Indicate whether this node should accept snapshots from standby nodes.aeron()Aeronclient for communicating with the local Media Driver.Aeronclient for communicating with the local Media Driver.Get 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.Get theAgent.roleName()to be used for the consensus module agent.agentRoleName(String agentRoleName) Set theAgent.roleName()to be used for the consensus module agent.intThe cluster member id of the appointed cluster leader.appointedLeaderId(int appointedLeaderId) The cluster member id of the appointed cluster leader.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 theAeronArchive.Contextthat should be used for communicating with the local Archive.archiveContext(AeronArchive.Context archiveContext) Set theAeronArchive.Contextthat should be used for communicating with the local Archive.Get theAuthenticatorSupplierthat should be used for the consensus module.authenticatorSupplier(AuthenticatorSupplier authenticatorSupplier) Set theAuthenticatorSupplierthat will be used for the consensus module.Get theAuthorisationServiceSupplierthat should be used for the consensus module.authorisationServiceSupplier(AuthorisationServiceSupplier authorisationServiceSupplier) Set theAuthorisationServiceSupplierthat will be used for the consensus module.clone()Perform a shallow copy of the object.voidclose()Close the context and free applicable resources.Get theClusterClockto used for timestamping messages and timers.clusterClock(ClusterClock clock) Set theClusterClockto be used for timestamping messages and timers.The directory used for the consensus module directory.clusterDir(File clusterDir) Set the directory to use for the consensus module directory.The directory name to use for the consensus module directory.clusterDirectoryName(String clusterDirectoryName) Set the directory name to use for the consensus module directory.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.intThis cluster member identity.clusterMemberId(int clusterMemberId) This cluster member identity.The endpoints representing members of the cluster which are all candidates to be leader.clusterMembers(String clusterMembers) String representing the cluster members.Get the counter for representing the currentCluster.Roleof the consensus module node.clusterNodeRoleCounter(Counter nodeRole) Set the counter for representing the currentCluster.Roleof the cluster node.The directory used by the clustered service containers.clusterServicesDirectoryName(String clusterServicesDirectoryName) Set the directory used by clustered service containers.Get the supplier of a consumer of timestamps which can be used for testing time progress in a cluster.clusterTimeConsumerSupplier(Function<ConsensusModule.Context, LongConsumer> clusterTimeConsumerSupplier) Set the supplier of a consumer of timestamps which can be used for testing time progress in a cluster.Get the counter for the commit position the cluster has reached for consensus.commitPositionCounter(Counter commitPosition) Set the counter for the commit position the cluster has reached for consensus.voidconclude()Conclude configuration by setting up defaults when specifics are not provided.Get the channel parameter for the consensus communication channel.consensusChannel(String channel) Set the channel parameter for the consensus communication channel.Registered consensus module extension.consensusModuleExtension(ConsensusModuleExtension consensusModuleExtension) Register a ConsensusModuleExtension to extend the behaviour of the consensus module instead of using ClusteredServices.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.intGet the stream id for the consensus channel.consensusStreamId(int streamId) Set the stream id for the consensus channel.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.Get the counter for the control toggle for triggering actions for the cluster.controlToggleCounter(Counter controlToggle) Set the counter for the control toggle for triggering actions for the cluster.TheerrorHandler()that will incrementerrorCounter()by default.countedErrorHandler(CountedErrorHandler countedErrorHandler) TheerrorHandler()that will incrementerrorCounter()by default.longThreshold for the consensus module agent work cycle time which when exceed it will increment the counter.cycleThresholdNs(long thresholdNs) Set a threshold for the consensus module agent work cycle time which when exceed it will increment the counter.voidDelete the cluster directory.booleanWill the consensus module attempt to immediately deleteclusterDir()on startup.deleteDirOnStart(boolean deleteDirOnStart) Should the consensus module attempt to immediately deleteclusterDir()on startup.The duty cycle tracker used to track the consensus module agent duty cycle.dutyCycleTracker(DutyCycleTracker dutyCycleTracker) Set a duty cycle tracker to be used for tracking the duty cycle time of the consensus module agent.Get the template channel that is used to refine the response channels for a Cluster, i.e.egressChannel(String channel) Set the template channel that is used to refine the response channels for a Cluster, i.e.Get the counter used to track the number of elections on this node.electionCounter(Counter electionCounter) Set the counter used to track the number of elections on this node.Get the counter for the current state of an election.electionStateCounter(Counter electionStateCounter) Set the counter for the current state of an election.longInterval at which a member will send out status messages during the election phases.electionStatusIntervalNs(long electionStatusIntervalNs) Interval at which a member will send out status messages during the election phases.longTimeout to wait for votes in an election before declaring the election void and starting over.electionTimeoutNs(long timeoutNs) Timeout to wait for votes in an election before declaring the election void and starting over.booleanIf the ConsensusModule should set the control endpoint for the Consensus publication.enableControlOnConsensusChannel(boolean enableControlOnConsensusChannel) If the ConsensusModule should bind the control endpoint for the Consensus publication.booleanIf the ConsensusModule should set the control endpoint for the Consensus publication.enableControlOnLogControl(boolean setControlOnLogChannel) If the LogModule should set the control endpoint for the Log publication.Get theEpochClockto used for tracking wall clock time.epochClock(EpochClock clock) Set theEpochClockto be used for tracking wall clock time.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 observed.errorCounter(AtomicCounter errorCounter) Set the error counter that will record the number of errors observed.Get theErrorHandlerto be used by the Consensus Module.errorHandler(ErrorHandler errorHandler) Set theErrorHandlerto be used by the Consensus Module.errorLog()TheDistinctErrorLogin use.errorLog(DistinctErrorLog errorLog) Set theDistinctErrorLogin use.intGet level at which files should be sync'ed to disk.fileSyncLevel(int syncLevel) Set level at which files should be sync'ed to disk.Gets the channel template used for replaying logs to a follower using theClusterMember.catchupEndpoint().followerCatchupChannel(String channel) Set a channel template used for replaying logs to a follower using theClusterMember.catchupEndpoint().Get a newIdleStrategybased on configured supplier.idleStrategySupplier(Supplier<IdleStrategy> idleStrategySupplier) Provides anIdleStrategysupplier for the idle strategy for the agent duty cycle.Get the channel parameter for the ingress channel.ingressChannel(String channel) Set the channel parameter for the ingress channel.intThe limit for fragments to be consumed on each poll of ingress.ingressFragmentLimit(int ingressFragmentLimit) Set limit for fragments to be consumed on each poll of ingress.intGet the stream id for the ingress channel.ingressStreamId(int streamId) Set the stream id for the ingress channel.booleanHas the context had theconclude()method called.booleanGet whether IPC ingress is allowed or not.isIpcIngressAllowed(boolean isIpcIngressAllowed) Set whether IPC ingress is allowed or not.Gets the channel template used to build the control request channel for the leader Archive using theClusterMember.archiveEndpoint().leaderArchiveControlChannel(String channel) Set a channel template used to build the control request channel for the leader Archive using theClusterMember.archiveEndpoint().longInterval at which a leader will send heartbeats if the log is not progressing.leaderHeartbeatIntervalNs(long heartbeatIntervalNs) Interval at which a leader will send heartbeats if the log is not progressing.longTimeout for a leader if no heartbeat is received by another member.leaderHeartbeatTimeoutNs(long heartbeatTimeoutNs) Timeout for a leader if no heartbeat is received by another member.Get the counter used to track the leadership term id.leadershipTermIdCounter(Counter leadershipTermId) Set the counter used to track the number of elections on this node.Get the channel parameter for the cluster log channel.logChannel(String channel) Set the channel parameter for the cluster log channel.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.intGet the stream id for the cluster log channel.logStreamId(int streamId) Set the stream id for the cluster log channel.Get the directory in which the ConsensusModule will store mark file (i.e.markFileDir(File markFileDir) Set the directory in which the ConsensusModule will store mark file (i.e.intGet the limit for the maximum number of concurrent cluster sessions.maxConcurrentSessions(int maxSessions) Set the limit for the maximum number of concurrent cluster sessions.Get the endpoints for this cluster node.memberEndpoints(String endpoints) Set the endpoints for this cluster node.Get the counter for the current state of the consensus module.moduleStateCounter(Counter moduleState) Set the counter for the current state of the consensus module.Deprecated.nameResolver(NameResolver ignore) Deprecated.Get the counter for the control toggle for triggering actions on the cluster node.nodeControlToggleCounter(Counter nodeControlToggle) Set the counter for the control toggle for triggering actions on the cluster node.TheNodeStateFilethat is used by the consensus module.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?random()The source of random values for timeouts used in elections.The source of random values for timeouts used in elections.TheRecordingLogfor the log terms and snapshots.recordingLog(RecordingLog recordingLog) Set theRecordingLogfor the log terms and snapshots.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.Get the replication channel for logs and snapshots.replicationChannel(String channel) Set the channel parameter for the replication communication channel.intGet the number of clustered services in this cluster instance.serviceCount(int serviceCount) Set the number of clustered services in this cluster instance.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.longTimeout for a session if no activity is observed.sessionTimeoutNs(long sessionTimeoutNs) Timeout for a session if no activity is observed.Get the channel parameter for snapshot recordings.snapshotChannel(String channel) Set the channel parameter for snapshot recordings.Get the counter for the count of snapshots taken.snapshotCounter(Counter snapshotCounter) Set the counter for the count of snapshots taken.intGet the stream id for snapshot recordings.snapshotStreamId(int streamId) Set the stream id for snapshot recordings.Get the counter used to track standby snapshots accepted by this node.standbySnapshotCounter(Counter standbySnapshotCounter) Set the counter used to track standby snapshots accepted by this node.longTimeout to wait for hearing the status of all cluster members on startup after recovery before commencing an election if a majority of members has been heard from.startupCanvassTimeoutNs(long timeoutNs) Timeout to wait for hearing the status of all cluster members on startup after recovery before commencing an election if a majority of members has been heard from.Get theRunnablethat is called when theConsensusModuleprocesses a termination action.terminationHook(Runnable terminationHook) Set theRunnablethat is called when theConsensusModuleprocesses a termination action.longTimeout to wait for follower termination by leader.terminationTimeoutNs(long terminationTimeoutNs) Timeout to wait for follower termination by leader.Get the thread factory used for creating threads.threadFactory(ThreadFactory threadFactory) Set the thread factory used for creating threads.intNumber of ticks, or spokes, on the timer wheel.ticksPerWheel(int ticksPerWheel) Number of ticks, or spokes, on the timer wheel.Get the counter for the count of clients that have been timed out and disconnected.timedOutClientCounter(Counter timedOutClientCounter) Set the counter for the count of clients that have been timed out and disconnected.Supplier of theTimerServiceinstances.timerServiceSupplier(TimerServiceSupplier timerServiceSupplier) Provides anTimerServicesupplier for the idle strategy for the agent duty cycle.toString()longThreshold for total snapshot duration which when exceeded it will increment the counter.totalSnapshotDurationThresholdNs(long thresholdNs) Set a threshold for total snapshot duration which when exceeded will result in a counter increment.Get snapshot duration tracker used for monitoring total snapshot duration.totalSnapshotDurationTracker(SnapshotDurationTracker snapshotDurationTracker) Set snapshot duration tracker used for monitoring total snapshot duration.booleanShould anAgentInvokerbe used for running theConsensusModulerather than run it on a thread with aAgentRunner.useAgentInvoker(boolean useAgentInvoker) Should anAgentInvokerbe used for running theConsensusModulerather than run it on a thread with aAgentRunner.longResolution in nanoseconds for each tick of the timer wheel for scheduling deadlines.wheelTickResolutionNs(long wheelTickResolutionNs) Resolution in nanoseconds for each tick of the timer wheel for scheduling deadlines.
-
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.
-
deleteDirOnStart
Should the consensus module attempt to immediately deleteclusterDir()on startup.- Parameters:
deleteDirOnStart- Attempt deletion.- Returns:
- this for a fluent API.
-
deleteDirOnStart
public boolean deleteDirOnStart()Will the consensus module attempt to immediately deleteclusterDir()on startup.- Returns:
- true when directory will be deleted, otherwise false.
-
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 consensus module directory.- Returns:
- directory name for the consensus module directory.
- See Also:
-
clusterServicesDirectoryName
Set the directory used by clustered service containers. By default, the cluster services will share a directory with the consensus module. However, sometimes it will be useful for these values to be different. Setting this value allows that location to be tracked in the ClusterMarkFile to allow for the ClusterTool to resolve their location when using action likedescribeorerrors. There is an expectation that all clustered service containers will use the same directory.- Parameters:
clusterServicesDirectoryName- to use.- Returns:
- this for a fluent API.
- See Also:
-
clusterServicesDirectoryName
The directory used by the clustered service containers.- Returns:
- directory used by the clustered service containers.
- See Also:
-
clusterDir
Set the directory to use for the consensus module directory.- Parameters:
clusterDir- to use.- Returns:
- this for a fluent API.
- See Also:
-
clusterDir
The directory used for the consensus module directory.- Returns:
- directory for the consensus module directory.
- See Also:
-
markFileDir
Get the directory in which the ConsensusModule will store mark file (i.e.cluster-mark.dat). It defaults toclusterDir()if it is not set explicitly via theClusteredServiceContainer.Configuration.MARK_FILE_DIR_PROP_NAME.- Returns:
- the directory in which the ConsensusModule will store mark file (i.e.
cluster-mark.dat). - See Also:
-
markFileDir
Set the directory in which the ConsensusModule will store mark file (i.e.cluster-mark.dat).- Parameters:
markFileDir- the directory in which the Archive will store mark file (i.e.cluster-mark.dat).- Returns:
- this for a fluent API.
-
recordingLog
Set theRecordingLogfor the log terms and snapshots.- Parameters:
recordingLog- to use.- Returns:
- this for a fluent API.
-
recordingLog
TheRecordingLogfor the log terms and snapshots.- Returns:
RecordingLogfor the log terms and snapshots.
-
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
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.
-
fileSyncLevel
public int fileSyncLevel()Get level at which files should be sync'ed to disk.- 0 - normal writes.
- 1 - sync file data.
- 2 - sync file data + metadata.
- Returns:
- the level to be applied for file write.
- See Also:
-
fileSyncLevel
Set level at which files should be sync'ed to disk.- 0 - normal writes.
- 1 - sync file data.
- 2 - sync file data + metadata.
- Parameters:
syncLevel- to be applied for file writes.- Returns:
- this for a fluent API.
- See Also:
-
clusterId
Set the id for this cluster instance. This must match with the service containers.- 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 service containers.- Returns:
- the id for this cluster instance.
- See Also:
-
clusterMemberId
This cluster member identity.- Parameters:
clusterMemberId- for this member.- Returns:
- this for a fluent API.
- See Also:
-
clusterMemberId
public int clusterMemberId()This cluster member identity.- Returns:
- this cluster member identity.
- See Also:
-
appointedLeaderId
The cluster member id of the appointed cluster leader.-1 means no leader has been appointed and an automated leader election should occur.
This feature is for testing and not recommended for production usage.
- Parameters:
appointedLeaderId- for the cluster.- Returns:
- this for a fluent API.
- See Also:
-
appointedLeaderId
public int appointedLeaderId()The cluster member id of the appointed cluster leader.-1 means no leader has been appointed and an automated leader election should occur.
- Returns:
- cluster member id of the appointed cluster leader.
- See Also:
-
clusterMembers
String representing the cluster members.0,ingress:port,consensus:port,log:port,catchup:port,archive:port| \ 1,ingress:port,consensus:port,log:port,catchup:port,archive:port| ...The ingress endpoints will be used as the endpoint substituted into the
ingressChannel()if the endpoint is not provided unless it is multicast.- Parameters:
clusterMembers- which are all candidates to be leader.- Returns:
- this for a fluent API.
- See Also:
-
clusterMembers
The endpoints representing members of the cluster which are all candidates to be leader.The ingress endpoints will be used as the endpoint in
ingressChannel()if the endpoint is not provided in that when it is not multicast.- Returns:
- members of the cluster which are all candidates to be leader.
- See Also:
-
ingressChannel
Set the channel parameter for the ingress channel.- Parameters:
channel- parameter for the ingress channel.- Returns:
- this for a fluent API.
- See Also:
-
ingressChannel
Get the channel parameter for the ingress channel.- Returns:
- the channel parameter for the ingress channel.
- See Also:
-
ingressStreamId
Set the stream id for the ingress channel.- Parameters:
streamId- for the ingress channel.- Returns:
- this for a fluent API
- See Also:
-
ingressStreamId
public int ingressStreamId()Get the stream id for the ingress channel.- Returns:
- the stream id for the ingress channel.
- See Also:
-
ingressFragmentLimit
Set limit for fragments to be consumed on each poll of ingress.- Parameters:
ingressFragmentLimit- for the ingress channel.- Returns:
- this for a fluent API
- See Also:
-
ingressFragmentLimit
public int ingressFragmentLimit()The limit for fragments to be consumed on each poll of ingress.- Returns:
- the limit for fragments to be consumed on each poll of ingress.
- See Also:
-
egressChannel
Set the template channel that is used to refine the response channels for a Cluster, i.e. egress channel, backup query response channel, heartbeat response channel etc. Defaults tonullin which case the provided response channel will be used. The main use-case is the ability to define the `interface` parameter to steer the response traffic via a specific network interface.Note: each URI parameter that is defined on this channel template will override the corresponding URI parameter in the provided response channel!
- Parameters:
channel- the channel template for response channels.- Returns:
- this for a fluent API.
- See Also:
-
egressChannel
Get the template channel that is used to refine the response channels for a Cluster, i.e. egress channel, backup query response channel, heartbeat response channel etc. Defaults tonullin which case the provided response channel will be used. The main use-case is the ability to define the `interface` parameter to steer the response traffic via a specific network interface.Note: each URI parameter that is defined on this channel template will override the corresponding URI parameter in the provided response channel!
- Returns:
- the channel template for response channels.
- See Also:
-
isIpcIngressAllowed
Set whether IPC ingress is allowed or not.- Parameters:
isIpcIngressAllowed- or not.- Returns:
- this for a fluent API
- See Also:
-
isIpcIngressAllowed
public boolean isIpcIngressAllowed()Get whether IPC ingress is allowed or not.- Returns:
- whether IPC ingress is allowed or not.
- See Also:
-
logChannel
Set the channel parameter for the cluster log channel.- Parameters:
channel- parameter for the cluster log channel.- Returns:
- this for a fluent API.
- See Also:
-
logChannel
Get the channel parameter for the cluster log channel.- Returns:
- the channel parameter for the cluster channel.
- See Also:
-
logStreamId
Set the stream id for the cluster log channel.- Parameters:
streamId- for the cluster log channel.- Returns:
- this for a fluent API
- See Also:
-
logStreamId
public int logStreamId()Get the stream id for the cluster log channel.- Returns:
- the stream id for the cluster log channel.
- See Also:
-
memberEndpoints
Set the endpoints for this cluster node.- Parameters:
endpoints- for the cluster node.- Returns:
- this for a fluent API.
- See Also:
-
memberEndpoints
Get the endpoints for this cluster node.- Returns:
- the endpoints for the cluster node.
- 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 bidirectional communications between the consensus module and services.- 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 bidirectional communications between the consensus module and services.
- 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:
-
consensusChannel
Set the channel parameter for the consensus communication channel.- Parameters:
channel- parameter for the consensus communication channel.- Returns:
- this for a fluent API.
- See Also:
-
consensusChannel
Get the channel parameter for the consensus communication channel.- Returns:
- the channel parameter for the consensus communication channel.
- See Also:
-
consensusStreamId
Set the stream id for the consensus channel.- Parameters:
streamId- for the consensus channel.- Returns:
- this for a fluent API
- See Also:
-
consensusStreamId
public int consensusStreamId()Get the stream id for the consensus channel.- Returns:
- the stream id for the consensus channel.
- See Also:
-
replicationChannel
Set the channel parameter for the replication communication channel. This is channel that the local will send to src archives to replay their recordings back to. It should contain an endpoint that other members in the cluster will be able to reach. Using port 0 for the endpoint is valid for this channel to simplify port allocation.- Parameters:
channel- replication communication channel to be used by the consensus module.- Returns:
- this for a fluent API
- See Also:
-
replicationChannel
Get the replication channel for logs and snapshots.- Returns:
- channel to receive replication responses from other node's archives when using log and snapshot replication to catch up.
- See Also:
-
followerCatchupChannel
Set a channel template used for replaying logs to a follower using theClusterMember.catchupEndpoint().- Parameters:
channel- to do a catch replay to a follower.- Returns:
- this for a fluent API
- See Also:
-
followerCatchupChannel
Gets the channel template used for replaying logs to a follower using theClusterMember.catchupEndpoint().- Returns:
- channel used for replaying older data during a catchup phase.
- See Also:
-
leaderArchiveControlChannel
Set a channel template used to build the control request channel for the leader Archive using theClusterMember.archiveEndpoint().- Parameters:
channel- for the Archive control requests.- Returns:
- this for a fluent API
- See Also:
-
leaderArchiveControlChannel
Gets the channel template used to build the control request channel for the leader Archive using theClusterMember.archiveEndpoint().- Returns:
- channel used for replaying older data during a catchup phase.
- 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:
-
wheelTickResolutionNs
Resolution in nanoseconds for each tick of the timer wheel for scheduling deadlines.- Parameters:
wheelTickResolutionNs- the resolution in nanoseconds of each tick on the timer wheel.- Returns:
- this for a fluent API
- See Also:
-
wheelTickResolutionNs
public long wheelTickResolutionNs()Resolution in nanoseconds for each tick of the timer wheel for scheduling deadlines.- Returns:
- the resolution in nanoseconds for each tick on the timer wheel.
- See Also:
-
ticksPerWheel
Number of ticks, or spokes, on the timer wheel. Higher number of ticks reduces potential conflicts traded off against memory usage.- Parameters:
ticksPerWheel- the number of ticks on the timer wheel.- Returns:
- this for a fluent API
- See Also:
-
ticksPerWheel
public int ticksPerWheel()Number of ticks, or spokes, on the timer wheel. Higher number of ticks reduces potential conflicts traded off against memory usage.- Returns:
- the number of ticks on the timer wheel.
- See Also:
-
serviceCount
Set the number of clustered services in this cluster instance.- Parameters:
serviceCount- the number of clustered services in this cluster instance.- Returns:
- this for a fluent API
- See Also:
-
serviceCount
public int serviceCount()Get the number of clustered services in this cluster instance.- Returns:
- the number of clustered services in this cluster instance.
- See Also:
-
maxConcurrentSessions
Set the limit for the maximum number of concurrent cluster sessions.- Parameters:
maxSessions- after which new sessions will be rejected.- Returns:
- this for a fluent API
- See Also:
-
maxConcurrentSessions
public int maxConcurrentSessions()Get the limit for the maximum number of concurrent cluster sessions.- Returns:
- the limit for the maximum number of concurrent cluster sessions.
- See Also:
-
sessionTimeoutNs
Timeout for a session if no activity is observed.- Parameters:
sessionTimeoutNs- to wait for activity on a session.- Returns:
- this for a fluent API.
- See Also:
-
sessionTimeoutNs
public long sessionTimeoutNs()Timeout for a session if no activity is observed.- Returns:
- the timeout for a session if no activity is observed.
- See Also:
-
leaderHeartbeatTimeoutNs
Timeout for a leader if no heartbeat is received by another member.- Parameters:
heartbeatTimeoutNs- to wait for heartbeat from a leader.- Returns:
- this for a fluent API.
- See Also:
-
leaderHeartbeatTimeoutNs
public long leaderHeartbeatTimeoutNs()Timeout for a leader if no heartbeat is received by another member.- Returns:
- the timeout for a leader if no heartbeat is received by another member.
- See Also:
-
leaderHeartbeatIntervalNs
Interval at which a leader will send heartbeats if the log is not progressing.- Parameters:
heartbeatIntervalNs- between leader heartbeats.- Returns:
- this for a fluent API.
- See Also:
-
leaderHeartbeatIntervalNs
public long leaderHeartbeatIntervalNs()Interval at which a leader will send heartbeats if the log is not progressing.- Returns:
- the interval at which a leader will send heartbeats if the log is not progressing.
- See Also:
-
startupCanvassTimeoutNs
Timeout to wait for hearing the status of all cluster members on startup after recovery before commencing an election if a majority of members has been heard from.- Parameters:
timeoutNs- to wait on startup after recovery before commencing an election.- Returns:
- this for a fluent API.
- See Also:
-
startupCanvassTimeoutNs
public long startupCanvassTimeoutNs()Timeout to wait for hearing the status of all cluster members on startup after recovery before commencing an election if a majority of members has been heard from.- Returns:
- the timeout to wait on startup after recovery before commencing an election.
- See Also:
-
electionTimeoutNs
Timeout to wait for votes in an election before declaring the election void and starting over.- Parameters:
timeoutNs- to wait for votes in an elections.- Returns:
- this for a fluent API.
- See Also:
-
electionTimeoutNs
public long electionTimeoutNs()Timeout to wait for votes in an election before declaring the election void and starting over.- Returns:
- the timeout to wait for votes in an elections.
- See Also:
-
electionStatusIntervalNs
Interval at which a member will send out status messages during the election phases.- Parameters:
electionStatusIntervalNs- between status message updates.- Returns:
- this for a fluent API.
- See Also:
-
electionStatusIntervalNs
public long electionStatusIntervalNs()Interval at which a member will send out status messages during the election phases.- Returns:
- the interval at which a member will send out status messages during the election phases.
- See Also:
-
terminationTimeoutNs
Timeout to wait for follower termination by leader.- Parameters:
terminationTimeoutNs- to wait for follower termination.- Returns:
- this for a fluent API.
- See Also:
-
terminationTimeoutNs
public long terminationTimeoutNs()Timeout to wait for follower termination by leader.- Returns:
- timeout to wait for follower termination by leader.
- See Also:
-
cycleThresholdNs
Set a threshold for the consensus module agent 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 consensus module agent work cycle time which when exceed it will increment the counter.- Returns:
- threshold to track for the consensus module agent work cycle time.
-
dutyCycleTracker
Set a duty cycle tracker to be used for tracking the duty cycle time of the consensus module agent.- Parameters:
dutyCycleTracker- to use for tracking.- Returns:
- this for fluent API.
-
dutyCycleTracker
The duty cycle tracker used to track the consensus module agent duty cycle.- Returns:
- the duty cycle tracker.
-
totalSnapshotDurationThresholdNs
Set a threshold for total snapshot duration which when exceeded will result in a counter increment.- Parameters:
thresholdNs- value in nanoseconds- Returns:
- this for fluent API.
- See Also:
-
totalSnapshotDurationThresholdNs
public long totalSnapshotDurationThresholdNs()Threshold for total snapshot duration which when exceeded it will increment the counter.- Returns:
- threshold value in nanoseconds.
-
totalSnapshotDurationTracker
public ConsensusModule.Context totalSnapshotDurationTracker(SnapshotDurationTracker snapshotDurationTracker) Set snapshot duration tracker used for monitoring total snapshot duration.- Parameters:
snapshotDurationTracker- snapshot duration tracker.- Returns:
- this for fluent API.
-
totalSnapshotDurationTracker
Get snapshot duration tracker used for monitoring total snapshot duration.- Returns:
- snapshot duration tracker
-
agentRoleName
Get theAgent.roleName()to be used for the consensus module agent. Ifnullthen one will be generated.- Returns:
- the
Agent.roleName()to be used for the consensus module agent.
-
agentRoleName
Set theAgent.roleName()to be used for the consensus module agent.- Parameters:
agentRoleName- to be used for the consensus module agent.- Returns:
- this for a fluent API.
-
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
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.
-
clusterClock
Set theClusterClockto be used for timestamping messages and timers.- Parameters:
clock-ClusterClockto be used for timestamping messages and timers.- Returns:
- this for a fluent API.
-
clusterClock
Get theClusterClockto used for timestamping messages and timers.- Returns:
- the
ClusterClockto used for timestamping messages and timers.
-
epochClock
Set theEpochClockto be used for tracking wall clock time.- Parameters:
clock-EpochClockto be used for tracking wall clock time.- Returns:
- this for a fluent API.
-
epochClock
Get theEpochClockto used for tracking wall clock time.- Returns:
- the
EpochClockto used for tracking wall clock time.
-
clusterTimeConsumerSupplier
public ConsensusModule.Context clusterTimeConsumerSupplier(Function<ConsensusModule.Context, LongConsumer> clusterTimeConsumerSupplier) Set the supplier of a consumer of timestamps which can be used for testing time progress in a cluster. The timestamp passed to the consumer is the timestamp of the last completedAgent.doWork()cycle by the consensus moduleAgent. The supplier will be called after the context is concluded and can be referenced during the construction of the consumer.- Parameters:
clusterTimeConsumerSupplier- to which the latest timestamp will be passed.- Returns:
- this for a fluent API
-
clusterTimeConsumerSupplier
Get the supplier of a consumer of timestamps which can be used for testing time progress in a cluster. The timestamp passed to the consumer is the timestamp of the last completedAgent.doWork()cycle by the consensus moduleAgent.- Returns:
- the consumer of timestamps for completed work cycles.
-
errorHandler
Get theErrorHandlerto be used by the Consensus Module.- Returns:
- the
ErrorHandlerto be used by the Consensus Module.
-
errorHandler
Set theErrorHandlerto be used by the Consensus Module.- Parameters:
errorHandler- the error handler to be used by the Consensus Module.- Returns:
- this for a fluent API
-
countedErrorHandler
TheerrorHandler()that will incrementerrorCounter()by default.- 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.
-
errorCounter
Get the error counter that will record the number of errors observed.- Returns:
- the error counter that will record the number of errors observed.
-
errorCounter
Set the error counter that will record the number of errors observed.- Parameters:
errorCounter- the error counter that will record the number of errors observed.- Returns:
- this for a fluent API.
-
moduleStateCounter
Get the counter for the current state of the consensus module.- Returns:
- the counter for the current state of the consensus module.
- See Also:
-
moduleStateCounter
Set the counter for the current state of the consensus module.- Parameters:
moduleState- the counter for the current state of the consensus module.- Returns:
- this for a fluent API.
- See Also:
-
electionStateCounter
Get the counter for the current state of an election.- Returns:
- the counter for the current state of an election.
- See Also:
-
electionStateCounter
Set the counter for the current state of an election.- Parameters:
electionStateCounter- for the current state of an election.- Returns:
- this for a fluent API.
- See Also:
-
commitPositionCounter
Get the counter for the commit position the cluster has reached for consensus.- Returns:
- the counter for the commit position the cluster has reached for consensus.
-
commitPositionCounter
Set the counter for the commit position the cluster has reached for consensus.- Parameters:
commitPosition- counter for the commit position the cluster has reached for consensus.- Returns:
- this for a fluent API.
-
clusterNodeRoleCounter
Get the counter for representing the currentCluster.Roleof the consensus module node.- Returns:
- the counter for representing the current
Cluster.Roleof the cluster node. - See Also:
-
clusterNodeRoleCounter
Set the counter for representing the currentCluster.Roleof the cluster node.- Parameters:
nodeRole- the counter for representing the currentCluster.Roleof the cluster node.- Returns:
- this for a fluent API.
- See Also:
-
controlToggleCounter
Get the counter for the control toggle for triggering actions for the cluster.- Returns:
- the counter for triggering cluster node actions.
- See Also:
-
controlToggleCounter
Set the counter for the control toggle for triggering actions for the cluster.- Parameters:
controlToggle- the counter for triggering cluster node actions.- Returns:
- this for a fluent API.
- See Also:
-
nodeControlToggleCounter
Get the counter for the control toggle for triggering actions on the cluster node.- Returns:
- the counter for triggering cluster node actions.
- See Also:
-
nodeControlToggleCounter
Set the counter for the control toggle for triggering actions on the cluster node.- Parameters:
nodeControlToggle- the counter for triggering cluster node actions.- Returns:
- this for a fluent API.
- See Also:
-
snapshotCounter
Get the counter for the count of snapshots taken.- Returns:
- the counter for the count of snapshots taken.
-
snapshotCounter
Set the counter for the count of snapshots taken.- Parameters:
snapshotCounter- the count of snapshots taken.- Returns:
- this for a fluent API.
-
timedOutClientCounter
Get the counter for the count of clients that have been timed out and disconnected.- Returns:
- the counter for the count of clients that have been timed out and disconnected.
-
timedOutClientCounter
Set the counter for the count of clients that have been timed out and disconnected.- Parameters:
timedOutClientCounter- the count of clients that have been timed out and disconnected.- Returns:
- this for a fluent API.
-
aeron
Aeronclient for communicating with the local Media Driver.This client will be closed when the
ConsensusModule.close()orclose()methods are called ifownsAeronClient()is true.The method is mostly here in order to test with a custom Aeron instance. The recommended approach is to set the aeronDirectoryName and allow the ConsensusModule to construct the Aeron client. The supplied Aeron client must be set to
Aeron.Context.useConductorInvoker(true)to work correctly with the ConsensusModule.- Parameters:
aeron- client for communicating with the local Media Driver.- Returns:
- this for a fluent API.
- See Also:
-
aeron
Aeronclient for communicating with the local Media Driver.If not provided then a default will be established during
conclude()by callingAeron.connect().- Returns:
- client for communicating with the local Media Driver.
-
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.
-
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?
-
archiveContext
Set theAeronArchive.Contextthat 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 theAeronArchive.Contextthat should be used for communicating with the local Archive.- Returns:
- the
AeronArchive.Contextthat should be used for communicating with the local Archive.
-
authenticatorSupplier
Get theAuthenticatorSupplierthat should be used for the consensus module.- Returns:
- the
AuthenticatorSupplierto be used for the consensus module.
-
authenticatorSupplier
Set theAuthenticatorSupplierthat will be used for the consensus module.- Parameters:
authenticatorSupplier-AuthenticatorSupplierto use for the consensus module.- Returns:
- this for a fluent API.
-
authorisationServiceSupplier
Get theAuthorisationServiceSupplierthat should be used for the consensus module.- Returns:
- the
AuthorisationServiceSupplierto be used for the consensus module.
-
authorisationServiceSupplier
public ConsensusModule.Context authorisationServiceSupplier(AuthorisationServiceSupplier authorisationServiceSupplier) Set the
AuthorisationServiceSupplierthat will be used for the consensus module.When using an authorisation service for the ConsensusModule, then the following values for protocolId, actionId, and type should be considered.
Parameters for authorisation service queries from the Consensus Module Description protocolId actionId type(s) Admin requests made through the client API MessageHeaderDecoder.SCHEMA_IDAdminRequestDecoder.TEMPLATE_IDAdminRequestType.SNAPSHOTBackup queries from Cluster Backup & Standby BackupQueryDecoder.TEMPLATE_ID(null)Heartbeat requests from Cluster Standby HeartbeatRequestDecoder.TEMPLATE_ID(null)Standby snapshot notifications from Cluster Standby StandbySnapshotDecoder.TEMPLATE_ID(null)- Parameters:
authorisationServiceSupplier-AuthorisationServiceSupplierto use for the consensus module.- Returns:
- this for a fluent API.
-
useAgentInvoker
Should anAgentInvokerbe used for running theConsensusModulerather than run it on a thread with aAgentRunner.- Parameters:
useAgentInvoker- useAgentInvokerbe used for running theConsensusModule?- Returns:
- this for a fluent API.
-
useAgentInvoker
public boolean useAgentInvoker()Should anAgentInvokerbe used for running theConsensusModulerather than run it on a thread with aAgentRunner.- Returns:
- true if the
ConsensusModulewill be run with anAgentInvokerotherwise false.
-
terminationHook
Set theRunnablethat is called when theConsensusModuleprocesses a termination action.- Parameters:
terminationHook- that can be used to terminate a consensus module.- Returns:
- this for a fluent API.
-
terminationHook
Get theRunnablethat is called when theConsensusModuleprocesses a termination action.- Returns:
- the
Runnablethat can be used to terminate a consensus module.
-
clusterMarkFile
Set theClusterMarkFilein use.- Parameters:
markFile- to use.- Returns:
- this for a fluent API.
-
clusterMarkFile
TheClusterMarkFilein use.- Returns:
ClusterMarkFilein use.
-
nodeStateFile
TheNodeStateFilethat is used by the consensus module.- Returns:
- node state file.
-
errorBufferLength
Set the error buffer length in bytes to use.- Parameters:
errorBufferLength- in bytes to use.- Returns:
- this for a fluent API.
- See Also:
-
errorBufferLength
public int errorBufferLength()The error buffer length in bytes.- Returns:
- error buffer length in bytes.
- See Also:
-
errorLog
Set theDistinctErrorLogin use.- Parameters:
errorLog- to use.- Returns:
- this for a fluent API.
-
errorLog
TheDistinctErrorLogin use.- Returns:
DistinctErrorLogin use.
-
random
The source of random values for timeouts used in elections.- Parameters:
random- source of random values for timeouts used in elections.- Returns:
- this for a fluent API.
-
random
The source of random values for timeouts used in elections.- Returns:
- source of random values for timeouts used in elections.
-
timerServiceSupplier
Provides anTimerServicesupplier for the idle strategy for the agent duty cycle.- Parameters:
timerServiceSupplier- supplier for the idle strategy for the agent duty cycle.- Returns:
- this for a fluent API.
-
timerServiceSupplier
Supplier of theTimerServiceinstances.- Returns:
- supplier of dynamically created
TimerServiceinstances.
-
consensusModuleExtension
public ConsensusModule.Context consensusModuleExtension(ConsensusModuleExtension consensusModuleExtension) Register a ConsensusModuleExtension to extend the behaviour of the consensus module instead of using ClusteredServices.- Parameters:
consensusModuleExtension- supplier for consensus module extension- Returns:
- this for a fluent API.
-
consensusModuleExtension
Registered consensus module extension.- Returns:
- Registered consensus module extension or null.
-
nameResolver
Deprecated.Deprecated for removal.- Returns:
null.
-
nameResolver
Deprecated.Deprecated for removal.- Parameters:
ignore- as deprecated.- Returns:
- this for fluent API.
-
acceptStandbySnapshots
public boolean acceptStandbySnapshots()Indicate whether this node should accept snapshots from standby nodes.- Returns:
trueif this node should accept snapshots from standby nodes,falseotherwise.- See Also:
-
acceptStandbySnapshots
Indicate whether this node should accept snapshots from standby nodes.- Parameters:
acceptStandbySnapshots-trueif this node should accept snapshots from standby nodes,falseotherwise.- Returns:
- this for a fluent API.
- See Also:
-
standbySnapshotCounter
Get the counter used to track standby snapshots accepted by this node.- Returns:
- the counter for standby snapshots.
-
standbySnapshotCounter
Set the counter used to track standby snapshots accepted by this node.- Parameters:
standbySnapshotCounter- the counter for standby snapshots.- Returns:
- this for a fluentAPI.
-
electionCounter
Get the counter used to track the number of elections on this node.- Returns:
- the counter for elections.
- Since:
- 1.44.0
-
electionCounter
Set the counter used to track the number of elections on this node.- Parameters:
electionCounter- the counter for elections.- Returns:
- this for a fluentAPI.
- Since:
- 1.44.0
-
leadershipTermIdCounter
Get the counter used to track the leadership term id.- Returns:
- the counter containing the leadership term id.
- Since:
- 1.44.0
-
leadershipTermIdCounter
Set the counter used to track the number of elections on this node.- Parameters:
leadershipTermId- the counter for elections.- Returns:
- this for a fluentAPI.
- Since:
- 1.44.0
-
enableControlOnConsensusChannel
public boolean enableControlOnConsensusChannel()If the ConsensusModule should set the control endpoint for the Consensus publication.- Returns:
trueif the control endpoint should be set,falseotherwise.
-
enableControlOnConsensusChannel
public ConsensusModule.Context enableControlOnConsensusChannel(boolean enableControlOnConsensusChannel) If the ConsensusModule should bind the control endpoint for the Consensus publication.- Parameters:
enableControlOnConsensusChannel-trueif the control endpoint should be set,falseotherwise.- Returns:
- this for fluent API.
-
enableControlOnLogControl
public boolean enableControlOnLogControl()If the ConsensusModule should set the control endpoint for the Consensus publication.- Returns:
trueif the control endpoint should be bound,falseotherwise.
-
enableControlOnLogControl
If the LogModule should set the control endpoint for the Log publication.- Parameters:
setControlOnLogChannel-trueif the control endpoint should be set,falseotherwise.- Returns:
- this for fluent API.
-
deleteDirectory
public void deleteDirectory()Delete the cluster directory. -
close
public void close()Close the context and free applicable resources.If
ownsAeronClient()is true then theaeron()client will be closed. -
toString
-