com.sleepycat.je.rep.elections
Class Proposer

java.lang.Object
  extended by com.sleepycat.je.rep.elections.Proposer
Direct Known Subclasses:
RankingProposer

public abstract class Proposer
extends Object

Plays the role of a Proposer in the consensus algorithm. Note that the Proposer also plays the role of a distinguished learner and informs all other listeners about the acceptance of a proposal.


Nested Class Summary
static class Proposer.MaxRetriesException
          Exception thrown when a Proposal issue fails because the retry limit has been exceeded.
static interface Proposer.Proposal
          The Interface defining a Proposal.
static interface Proposer.ProposalParser
           
static interface Proposer.RetryPredicate
          Interface to determine whether the Proposer should be retry with a new Proposal or abandon the effort.
static class Proposer.WinningProposal
          Summarizes the results of the election
 
Field Summary
protected  Elections elections
           
 
Constructor Summary
Proposer(Elections elections, NameIdPair nameIdPair)
          Initializes a proposer with the set of acceptors identified by the sockets on which they accept proposals.
 
Method Summary
protected abstract  Protocol.Value choosePhase2Value(Set<TextProtocol.MessageExchange> exchanges)
          Selects the value to be used during Phase2, which if it succeeds will become the "chosen value".
 StatGroup getProposerStats()
          Returns the current proposer statistics.
 Proposer.WinningProposal issueProposal(QuorumPolicy quorumPolicy, Proposer.RetryPredicate retryPredicate)
          Runs an election using the consensus algorithm.
protected abstract  Proposer.Proposal nextProposal()
          Creates the next unique Proposal to be used
 void shutDown()
          Shut down the proposer and reclaim its resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

elections

protected final Elections elections
Constructor Detail

Proposer

public Proposer(Elections elections,
                NameIdPair nameIdPair)
Initializes a proposer with the set of acceptors identified by the sockets on which they accept proposals.

Method Detail

shutDown

public void shutDown()
Shut down the proposer and reclaim its resources.


getProposerStats

public StatGroup getProposerStats()
Returns the current proposer statistics.


choosePhase2Value

protected abstract Protocol.Value choosePhase2Value(Set<TextProtocol.MessageExchange> exchanges)
Selects the value to be used during Phase2, which if it succeeds will become the "chosen value".

Parameters:
exchanges - the message exchanges from Phase 1
Returns:
the candidate value for Phase2 must not be null

nextProposal

protected abstract Proposer.Proposal nextProposal()
Creates the next unique Proposal to be used

Returns:
the Proposal

issueProposal

public Proposer.WinningProposal issueProposal(QuorumPolicy quorumPolicy,
                                              Proposer.RetryPredicate retryPredicate)
                                       throws Proposer.MaxRetriesException,
                                              InterruptedException
Runs an election using the consensus algorithm. An election can be used either to determine an existing consensus value, or to force an election if the current value is not suitable.

Parameters:
quorumPolicy - the policy used to determine whether we have a quorum.
retryPredicate - the interface which determines whether a retry should be attempted.
Returns:
the WinningProposal encapsulating the proposal and chosen value
Throws:
Proposer.MaxRetriesException - when a winning proposal could not be established.
InterruptedException


Copyright (c) 2004-2010 Oracle. All rights reserved.