Package io.hekate.election
Class CandidateConfig
- java.lang.Object
-
- io.hekate.election.CandidateConfig
-
public class CandidateConfig extends Object
Configuration forCandidate
.Instances of this class can be
registered
within theElectionServiceFactory
.For more details about leader elections please see the documentation of the
ElectionService
interface.
-
-
Constructor Summary
Constructors Constructor Description CandidateConfig()
Default constructor.CandidateConfig(String group)
Constructs new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Candidate
getCandidate()
Returns the leader election candidate (seesetCandidate(Candidate)
).String
getGroup()
Returns the election group name (seesetGroup(String)
).void
setCandidate(Candidate candidate)
Sets the leader election candidate that should be notified upongroup
leader election results.void
setGroup(String group)
Sets the election group name.String
toString()
CandidateConfig
withCandidate(Candidate candidate)
Fluent-style version ofsetCandidate(Candidate)
.CandidateConfig
withGroup(String group)
Fluent-style version ofsetGroup(String)
.
-
-
-
Constructor Detail
-
CandidateConfig
public CandidateConfig()
Default constructor.
-
CandidateConfig
public CandidateConfig(String group)
Constructs new instance.- Parameters:
group
- Group name (seesetGroup(String)
).
-
-
Method Detail
-
getGroup
public String getGroup()
Returns the election group name (seesetGroup(String)
).- Returns:
- Election group name.
-
setGroup
public void setGroup(String group)
Sets the election group name. Can contain only alpha-numeric characters and non-repeatable dots/hyphens.Only one
candidate
among all candidates that are registered with the same group name will be elected as a leader and all other candidates will remain in the follower state. If candidates are registered with different group names then they will form completely independent groups with each group having its own leader.Value of this parameter is mandatory and must be unique across all configurations registered within the
ElectionServiceFactory
.- Parameters:
group
- Group name (can contain only alpha-numeric characters and non-repeatable dots/hyphens).
-
withGroup
public CandidateConfig withGroup(String group)
Fluent-style version ofsetGroup(String)
.- Parameters:
group
- Group name.- Returns:
- This instance.
-
getCandidate
public Candidate getCandidate()
Returns the leader election candidate (seesetCandidate(Candidate)
).- Returns:
- Leader election candidate.
-
setCandidate
public void setCandidate(Candidate candidate)
Sets the leader election candidate that should be notified upongroup
leader election results.- Parameters:
candidate
- Leader election candidate.
-
withCandidate
public CandidateConfig withCandidate(Candidate candidate)
Fluent-style version ofsetCandidate(Candidate)
.- Parameters:
candidate
- Leader election candidate.- Returns:
- This instance.
-
-