|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.je.rep.elections.Elections
public class Elections
Represents the environment in which elections are run on behalf of a node. There is exactly one instance of an Elections for each node. Elections are initiated via this class. One of the primary goals of this interface is to keep Elections as free standing as possible, so that we can change how elections are held, or aspects of the election infrastructure with minimal impact on replication. For example, elections currently used tcp for communication of election messages but may want to switch over to udp. Such a change should be confined to just the Elections module. Other changes might include changes to the strategy used to suggest Values and the weight associated with a suggested Value. The following are the principal points of interaction between Elections and Replication: 1) The initiation of elections via the initiateElections() method. 2) The suggestion of nodes as masters and the ranking of the suggestion. This is done via the Acceptor.SuggestionGenerator interface. An instance of this interface is supplied when the Elections class is instantiated. Note that the implementation must also initiate a freeze of VLSNs to ensure that the ranking does not change as the election progresses. The VLSN can make progress when the node is informed via its Listener that an election with a higher Proposal number (than the one in the Propose request) has finished. 3) Obtaining the result of an election initiated in step 1. This is done via the Learner.Listener interface. An instance of this class is supplied when the Election class is first instantiated.
Nested Class Summary | |
---|---|
(package private) static class |
Elections.ElectionListener
Used to short-circuit Proposal retries is a new election has completed since the time this election was initiated. |
(package private) static class |
Elections.RetryPredicate
Implements the retry policy |
Constructor Summary | |
---|---|
Elections(RepNode repNode,
Learner.Listener listener,
Acceptor.SuggestionGenerator suggestionGenerator)
Creates an instance of Elections. |
Method Summary | |
---|---|
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. |
Learner |
getLearner()
Returns the Learner associated with this node |
(package private) 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. |
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 |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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 AcceptorMethod Detail |
---|
public ExecutorService getThreadPool()
public ServiceDispatcher getServiceDispatcher()
public RepNode getRepNode()
public RepImpl getRepImpl()
public void startLearner() throws IOException
IOException
public void participate() throws IOException
IOException
public Acceptor getAcceptor()
public Set<InetSocketAddress> getAcceptorSockets()
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 retried
InterruptedException
public void initiateElection(RepGroupImpl newGroup, QuorumPolicy quorumPolicy) throws InterruptedException
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 InterruptedException
InterruptedException
public void shutdownAcceptorsLearners(Set<InetSocketAddress> acceptorSockets, Set<InetSocketAddress> learnerSockets) throws InterruptedException
InterruptedException
public void shutdown() throws InterruptedException
InterruptedException
public void asyncInformMonitors(Proposer.Proposal proposal, Protocol.Value value)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |