public class Elections extends Object
| Constructor and Description |
|---|
Elections(ElectionsConfig config,
Learner.Listener listener,
Acceptor.SuggestionGenerator suggestionGenerator)
Creates an instance of Elections.
|
| Modifier and Type | Method and Description |
|---|---|
void |
asyncInformMonitors(Proposer.Proposal proposal,
Protocol.Value value)
Used to propagate the results of an election to any monitors.
|
boolean |
electionInProgress()
Predicate to determine whether an election is currently in progress.
|
Acceptor |
getAcceptor()
Returns the Acceptor associated with this node.
|
Set<InetSocketAddress> |
getAcceptorSockets()
Returns a current set of acceptor sockets.
|
int |
getElectionCount()
The number of elections that have been held.
|
ElectionQuorum |
getElectionQuorum() |
Learner |
getLearner()
Returns the Learner associated with this node
|
Logger |
getLogger() |
Protocol |
getProtocol() |
RepImpl |
getRepImpl() |
RepNode |
getRepNode() |
ServiceDispatcher |
getServiceDispatcher() |
StatGroup |
getStats()
Statistics used during testing.
|
ExecutorService |
getThreadPool() |
void |
initiateElection(RepGroupImpl newGroup,
QuorumPolicy quorumPolicy)
The standard method for requesting and election, we normally want to run
elections until we hear of an election result.
|
void |
initiateElection(RepGroupImpl newGroup,
QuorumPolicy quorumPolicy,
int maxRetries)
Initiates an election.
|
boolean |
isShutdown() |
void |
participate()
Permits the Election agent to start participating in elections held
by the replication group, or initiate elections on behalf of this node.
|
void |
shutdown()
Shuts down just the election support at this node.
|
void |
shutdownAcceptorsLearners(Set<InetSocketAddress> acceptorSockets,
Set<InetSocketAddress> learnerSockets)
Shutdown all acceptor and learner agents by broadcasting a Shutdown
message.
|
void |
startAcceptor() |
void |
startLearner()
Starts a Learner agent.
|
void |
updateRepGroup(RepGroupImpl newRepGroup)
Updates elections notion of the rep group, so that acceptors are aware
of the current state of the group, even in the absence of an election
conducted by the node itself.
|
void |
updateRepGroupOnly(RepGroupImpl newRepGroup)
Updates elections notion of the rep group, so that acceptors are aware
of the current state of the group, even in the absence of an election
conducted by the node itself.
|
void |
waitForElection()
For INTERNAL TESTING ONLY.
|
public Elections(ElectionsConfig config, Learner.Listener listener, Acceptor.SuggestionGenerator suggestionGenerator)
config - elections configurationlistener - the Listener invoked when results are availablesuggestionGenerator - used by the Acceptorpublic ExecutorService getThreadPool()
public ServiceDispatcher getServiceDispatcher()
public ElectionQuorum getElectionQuorum()
public RepNode getRepNode()
public Logger getLogger()
public RepImpl getRepImpl()
public void startLearner()
public void participate()
public void startAcceptor()
public Acceptor getAcceptor()
public Set<InetSocketAddress> getAcceptorSockets()
public Protocol getProtocol()
public Learner getLearner()
public int getElectionCount()
public void initiateElection(RepGroupImpl newGroup, QuorumPolicy quorumPolicy, int maxRetries) throws InterruptedException
newGroup - the definition of the group to be used for this electionquorumPolicy - the policy to be used to reach a quorum.maxRetries - the max number of times a proposal may be retriedInterruptedExceptionpublic void initiateElection(RepGroupImpl newGroup, QuorumPolicy quorumPolicy) throws InterruptedException
public void updateRepGroup(RepGroupImpl newRepGroup)
newRepGroup - defines the new grouppublic void updateRepGroupOnly(RepGroupImpl newRepGroup)
newRepGroup - defines the new grouppublic boolean electionInProgress()
public StatGroup getStats()
public void waitForElection()
throws InterruptedException
InterruptedExceptionpublic void shutdownAcceptorsLearners(Set<InetSocketAddress> acceptorSockets, Set<InetSocketAddress> learnerSockets) throws InterruptedException
InterruptedExceptionpublic void shutdown()
throws InterruptedException
InterruptedExceptionpublic boolean isShutdown()
public void asyncInformMonitors(Proposer.Proposal proposal, Protocol.Value value)
Copyright © 2024. All rights reserved.