public class Elections
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
Elections.ElectionListener
Used to short-circuit Proposal retries if a new election has completed
since the time this election was initiated.
|
(package private) static class |
Elections.RetryPredicate
Implements the retry policy
|
Constructor and Description |
---|
Elections(RepNode repNode,
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.
|
java.util.Set<java.net.InetSocketAddress> |
getAcceptorSockets()
Returns a current set of acceptor sockets.
|
int |
getElectionCount()
The number of elections that have been held.
|
Learner |
getLearner()
Returns the Learner associated with this node
|
java.util.logging.Logger |
getLogger() |
Protocol |
getProtocol() |
RepImpl |
getRepImpl() |
RepNode |
getRepNode() |
ServiceDispatcher |
getServiceDispatcher() |
StatGroup |
getStats()
Statistics used during testing.
|
java.util.concurrent.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.
|
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(java.util.Set<java.net.InetSocketAddress> acceptorSockets,
java.util.Set<java.net.InetSocketAddress> learnerSockets)
Shutdown all acceptor and learner agents by broadcasting a Shutdown
message.
|
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 |
waitForElection()
For INTERNAL TESTING ONLY.
|
public Elections(RepNode repNode, Learner.Listener listener, Acceptor.SuggestionGenerator suggestionGenerator)
listener
- the Listener invoked when results are availablerepNode
- is the owning replicated node, the associated repImpl
may be null, if it's being run in a test environment.suggestionGenerator
- used by the Acceptorpublic java.util.concurrent.ExecutorService getThreadPool()
public ServiceDispatcher getServiceDispatcher()
public RepNode getRepNode()
public java.util.logging.Logger getLogger()
public RepImpl getRepImpl()
public void startLearner() throws java.io.IOException
java.io.IOException
public void participate() throws java.io.IOException
java.io.IOException
public Acceptor getAcceptor()
public java.util.Set<java.net.InetSocketAddress> getAcceptorSockets()
public Protocol getProtocol()
public Learner getLearner()
public int getElectionCount()
public void initiateElection(RepGroupImpl newGroup, QuorumPolicy quorumPolicy, int maxRetries) throws java.lang.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 retriedjava.lang.InterruptedException
public void initiateElection(RepGroupImpl newGroup, QuorumPolicy quorumPolicy) throws java.lang.InterruptedException
java.lang.InterruptedException
initiateElection(com.sleepycat.je.rep.impl.RepGroupImpl, com.sleepycat.je.rep.QuorumPolicy, int)
public void updateRepGroup(RepGroupImpl newRepGroup)
newRepGroup
- defines the new grouppublic boolean electionInProgress()
public StatGroup getStats()
public void waitForElection() throws java.lang.InterruptedException
java.lang.InterruptedException
public void shutdownAcceptorsLearners(java.util.Set<java.net.InetSocketAddress> acceptorSockets, java.util.Set<java.net.InetSocketAddress> learnerSockets) throws java.lang.InterruptedException
java.lang.InterruptedException
public void shutdown() throws java.lang.InterruptedException
java.lang.InterruptedException
public void asyncInformMonitors(Proposer.Proposal proposal, Protocol.Value value)
Copyright (c) 2004-2012 Oracle. All rights reserved.