com.sleepycat.je.rep.elections
Class TimebasedProposalGenerator

java.lang.Object
  extended by com.sleepycat.je.rep.elections.TimebasedProposalGenerator

public class TimebasedProposalGenerator
extends Object

Generates a unique sequence of ascending proposal numbers that is unique across all machines. Each proposal number is built as the catenation of the following components: ms time (8 bytes) | IP address (16 bytes) | locally unique Id (4 bytes) The ms time supplies the increasing number and the IP address a number unique across machines.


Field Summary
(package private) static int ADDRESS_WIDTH
           
(package private) static int TIME_WIDTH
           
(package private) static int UID_WIDTH
           
(package private) static int uniqueIdGenerator
           
 
Constructor Summary
TimebasedProposalGenerator()
          Constructor defaulting the unique id so it's merely unique within the process.
TimebasedProposalGenerator(int locallyUniqueId)
          Creates an instance with an application-specified locally (machine wide) unique id, e.g.
 
Method Summary
static Proposer.ProposalParser getParser()
          Returns the parser used to convert wire representations into Proposal instances.
 Proposer.Proposal nextProposal()
          Returns the next Proposal greater than all previous proposals returned on this machine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uniqueIdGenerator

static int uniqueIdGenerator

TIME_WIDTH

static final int TIME_WIDTH
See Also:
Constant Field Values

ADDRESS_WIDTH

static final int ADDRESS_WIDTH
See Also:
Constant Field Values

UID_WIDTH

static final int UID_WIDTH
See Also:
Constant Field Values
Constructor Detail

TimebasedProposalGenerator

TimebasedProposalGenerator(int locallyUniqueId)
Creates an instance with an application-specified locally (machine wide) unique id, e.g. a port number, or a combination of a pid and some other number.

Parameters:
locallyUniqueId - the machine wide unique id

TimebasedProposalGenerator

public TimebasedProposalGenerator()
Constructor defaulting the unique id so it's merely unique within the process.

Method Detail

nextProposal

public Proposer.Proposal nextProposal()
Returns the next Proposal greater than all previous proposals returned on this machine.

Returns:
the next unique proposal

getParser

public static Proposer.ProposalParser getParser()
Returns the parser used to convert wire representations into Proposal instances.

Returns:
a ProposalParser


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