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 |
---|---|
static int |
ACKEPOCH
This message is used by the follow to ack a proposed epoch.
|
protected Set<Long> |
connectingFollowers |
protected Set<Long> |
electingFollowers |
protected boolean |
electionFinished |
static int |
LEADERINFO
This message is the first that a follower receives from the leader.
|
protected Leader.Proposal |
newLeaderProposal |
static int |
PROPOSAL
This message type is sent by a leader to propose a mutation.
|
protected boolean |
quorumFormed |
Modifier and Type | Method and Description |
---|---|
void |
commit(long zxid)
Create a commit packet and send it to all the members of the quorum
|
void |
commitAndActivate(long zxid,
long designatedLeader) |
LearnerSnapshotThrottler |
createLearnerSnapshotThrottler(int maxConcurrentSnapshots,
long maxConcurrentSnapshotTimeout) |
long |
getEpoch()
Returns the current epoch of the leader.
|
long |
getEpochToPropose(long sid,
long lastAcceptedEpoch) |
List<LearnerHandler> |
getForwardingFollowers()
Returns a copy of the current forwarding follower snapshot
|
List<LearnerHandler> |
getLearners()
Returns a copy of the current learner snapshot
|
LearnerSnapshotThrottler |
getLearnerSnapshotThrottler() |
int |
getNumPendingSyncs() |
List<LearnerHandler> |
getObservingLearners()
Returns a copy of the current observer snapshot
|
static String |
getPacketType(int packetType)
Get string representation of a given packet type
|
BufferStats |
getProposalStats() |
void |
inform(Leader.Proposal proposal)
Create an inform packet and send it to all observers.
|
void |
informAndActivate(Leader.Proposal proposal,
long designatedLeader)
Create an inform&activate packet and send it to all observers.
|
boolean |
isQuorumSynced(QuorumVerifier qv)
Returns true if a quorum in qv is connected and synced with the leader
and false otherwise
|
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
|
boolean |
tryToCommit(Leader.Proposal p,
long zxid,
SocketAddress followerAddr) |
void |
waitForEpochAck(long id,
StateSummary ss) |
void |
waitForNewLeaderAck(long sid,
long zxid)
Process NEWLEADER ack of a given sid and wait until the leader receives
sufficient acks.
|
protected boolean quorumFormed
public static final int LEADERINFO
public static final int ACKEPOCH
public static final int PROPOSAL
protected final Leader.Proposal newLeaderProposal
protected boolean electionFinished
public BufferStats getProposalStats()
public LearnerSnapshotThrottler createLearnerSnapshotThrottler(int maxConcurrentSnapshots, long maxConcurrentSnapshotTimeout)
public List<LearnerHandler> getLearners()
public List<LearnerHandler> getForwardingFollowers()
public List<LearnerHandler> getObservingLearners()
public int getNumPendingSyncs()
public boolean isQuorumSynced(QuorumVerifier qv)
qv,
- a QuorumVerifierpublic boolean tryToCommit(Leader.Proposal p, long zxid, SocketAddress followerAddr)
public void processAck(long sid, long zxid, SocketAddress followerAddr)
zxid,
- the zxid of the proposal sent outsid,
- the id of the server that sent the ackfollowerAddr
- public void commit(long zxid)
zxid
- public void commitAndActivate(long zxid, long designatedLeader)
public void inform(Leader.Proposal proposal)
public void informAndActivate(Leader.Proposal proposal, long designatedLeader)
public long getEpoch()
public Leader.Proposal propose(Request request) throws Leader.XidRolloverException
request
- Leader.XidRolloverException
public LearnerSnapshotThrottler getLearnerSnapshotThrottler()
public void processSync(LearnerSyncRequest r)
r
- the requestpublic void sendSync(LearnerSyncRequest r)
public long startForwarding(LearnerHandler handler, long lastSeenZxid)
handler
- handler of the followerInterruptedException
public long getEpochToPropose(long sid, long lastAcceptedEpoch) throws InterruptedException, IOException
InterruptedException
IOException
public void waitForEpochAck(long id, StateSummary ss) throws IOException, InterruptedException
IOException
InterruptedException
public void waitForNewLeaderAck(long sid, long zxid) throws InterruptedException
sid
- InterruptedException
public static String getPacketType(int packetType)
packetType
- Copyright © 2008–2019 The Apache Software Foundation. All rights reserved.