org.apache.zookeeper.server.quorum
public class Leader extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Leader.Proposal |
static class |
Leader.XidRolloverException |
Modifier and Type | Field and Description |
---|---|
HashSet<LearnerHandler> |
forwardingFollowers |
HashSet<LearnerHandler> |
learners |
protected HashSet<LearnerHandler> |
observingLearners |
HashMap<Long,List<LearnerSyncRequest>> |
pendingSyncs |
static int |
PROPOSAL
This message type is sent by a leader to propose a mutation.
|
Modifier and Type | Method and Description |
---|---|
void |
commit(long zxid)
Create a commit packet and send it to all the members of the quorum
|
long |
getEpoch()
Returns the current epoch of the leader.
|
void |
inform(Leader.Proposal proposal)
Create an inform packet and send it to all observers.
|
void |
processAck(long sid,
long zxid,
SocketAddress followerAddr)
Keep a count of acks that are received by the leader for a particular
proposal
|
void |
processSync(LearnerSyncRequest r)
Process sync requests
|
Leader.Proposal |
propose(Request request)
create a proposal and send it out to all the members
|
void |
sendSync(LearnerSyncRequest r)
Sends a sync message to the appropriate server
|
long |
startForwarding(LearnerHandler handler,
long lastSeenZxid)
lets the leader know that a follower is capable of following and is done
syncing
|
public final HashSet<LearnerHandler> learners
public final HashSet<LearnerHandler> forwardingFollowers
protected final HashSet<LearnerHandler> observingLearners
public final HashMap<Long,List<LearnerSyncRequest>> pendingSyncs
public static final int PROPOSAL
public void processAck(long sid, long zxid, SocketAddress followerAddr)
zxid
- the zxid of the proposal sent outfollowerAddr
- public void commit(long zxid)
zxid
- public void inform(Leader.Proposal proposal)
zxid
- proposal
- public long getEpoch()
public Leader.Proposal propose(Request request) throws Leader.XidRolloverException
request
- Leader.XidRolloverException
public void processSync(LearnerSyncRequest r)
r
- the requestpublic void sendSync(LearnerSyncRequest r)
f
- r
- public long startForwarding(LearnerHandler handler, long lastSeenZxid)
handler
- handler of the followerCopyright © 2014 The Apache Software Foundation